Giter VIP home page Giter VIP logo

editorconfig-checker / editorconfig-checker Goto Github PK

View Code? Open in Web Editor NEW
378.0 8.0 46.0 1.08 MB

A tool to verify that your files are in harmony with your .editorconfig

Home Page: https://editorconfig-checker.github.io/

License: MIT License

Go 86.91% Makefile 7.13% Dockerfile 0.61% Nix 4.94% JavaScript 0.15% C 0.26%
editorconfig editorconfig-checker clean-code cleancode codequality code-quality linter lint linting lintcode

editorconfig-checker's Issues

Introduce config file

There should be a config file i.e. .ecrc which contains all configuration options and you do not have to use command line flags.

autofix flag

introduce an autofix flag which should fix all issues which can be fixed.

Bug: Default excludes ignored?

According to the first output line

Exclude Regexp: yarn\.lock$|package-lock\.json|composer\.lock$|\.snap$|\.otf$|\.woff$|\.woff2$|\.eot$|\.ttf$|\.gif$|\.png$|\.jpg$|\.jpeg$|\.mp4$|\.wmv$|\.svg$|\.ico$|\.bak$|\.bin$|\.pdf$|\.zip$|\.gz$|\.tar$|\.7z$|\.bz2$|\.log$|\.css\.map$|\.js\.map$|min\.css$|min\.js$

I would expect that the given regex would be applied but that does not happen (at lest in the docker container):

$ docker run --rm -v=$PWD:/check mstruebing/editorconfig-checker ec -v | grep yarn.lock
Add yarn.lock to be checked
Validate yarn.lock
$ docker run --rm -v=$PWD:/check mstruebing/editorconfig-checker ec -v -exclude 'yarn\.lock$|package-lock\.json|composer\.lock$|\.snap$|\.otf$|\.woff$|\.woff2$|\.eot$|\.ttf$|\.gif$|\.png$|\.jpg$|\.jpeg$|\.mp4$|\.wmv$|\.svg$|\.ico$|\.bak$|\.bin$|\.pdf$|\.zip$|\.gz$|\.tar$|\.7z$|\.bz2$|\.log$|\.css\.map$|\.js\.map$|min\.css$|min\.js$' | grep yarn.lock
Don't add yarn.lock to be checked

Ignores non-wildcard rules

Create a .editorconfig like this

root = true

[*]
insert_final_newline = false
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4

[file.toml]
indent_style = space
indent_size = 2

and with a file.toml containing

[foo]
  bar = "buz"

The tool will wrongly say it expected to see tabs

.\file.toml:
        2: Wrong indentation type(spaces instead of tabs)

1 errors found

Changing the rule to be a wildcard (*.toml) works, but is undesirable when fine-grained control is required.

Support "tabs for indentation, spaces for alignment" style

This is a continuation of discussion of the issue in editorconfig-checker.javascript project.

"Tabs for indentation, spaces for alignment" is a common coding style. It allows the code viewers to adjust any tab space they want without breaking alignments. Addition information is presented in these articles: https://dmitryfrank.com/articles/indent_with_tabs_align_with_spaces, https://vim.fandom.com/wiki/Indent_with_tabs,_align_with_spaces. This style is called "Smart tabs" in some IDEs (e. g. in JetBrains IDEs).

For now for projects using this style, editorconfig-checker shows the following error for each line with alignment:

136: Wrong indentation type(spaces instead of tabs)

I see several ways to deal with it it.

I think, the most natural way is automatically detect the alignment with spaces. If we are in a block, nested with N tabs, and then if we see spaces after N tabs, we should consider it an alignment with spaces.

Another approach would be to introduce additional command line key to enable this style or additional custom parameter to .editorconfig (if this is possible).

Support checking all files' text encodings, if declared to be UTF-8

Enforcing a specified text encoding in a monorepo rife with all kinds of textual resources is hard for crossplatform development teams. This feature would be of great value, and simple to implement. Especially if only a BOM-check is done. Alternatively, every text file that is covered by the EditorConfig settings can be decoded as UTF-8 on the fly.

Option to only disable indent_size check

It would be great to be able to just disable indent_size check but not indent_style check.

Currently it is only possible to -disable-indentation which means disabling indent_size and indent_style check.

Unfortunately there are many use cases where indent_size is not correct in complex files because every language handles some special cases differently. Also if you have blank lines with just the correct number of spaces the check fails at the moment with "Wrong amount of left-padding spaces(want multiple of x)"

At the moment it is not possible in our workspace to fix all indent_size problems, but we would like to check the indent_style only but not the indent_size.

max_line_length should support non ASCII characters

Currently it seems like ä, ö and ü are counted as two characters which makes the max_line_length rule not usable for not plain ASCII files (like UTF-8 so everything with emojis which maybe should also count as one character ;))

Get git versioned files

instead of checking each file if it is versioned by git it would be a HUGE performance gain if I would get a list of every versioned file and then doing stuff with them.

git ls-tree -r --name-only HEAD

extend default excludes

It would be cool to have some default excludes which can be extended and/or discarded for own excludes.

Create Chocolatey Package

It would be very useful for Winfows users if you could create a Chocolatey package to keep an always-up-to-date binary release of editorconfig-checker locally.

Ideally, the binary file should be renamed something like editorconfig-checker.exe (which is more intuitive than ec-windows-amd64.exe, etc.), regarldess of the app bitness (Chocolatey will always try to install the app with the same bitness of the OS), and make the binary available on the system PATH (Chocolatey can handle this via shims).

Chocolatey is a useful tool to keep updated many applications under Windows via a unified interface, especially via Chocolatey GUI. It can update both standalone apps as well as software that requires full setup.

As officials maintainers of the editorconfig-checker project, you could automate on GitHub the process of updating the Chocolatey package on every new release. So, after some initial setup effort, maintaining the Choco package updated should be an effortless task.

Thanks for all the great work!

Make default excludes configurable

The defaultExcludes are currently hardcoded into the main.go but they should be configurable either via .ecrc/.editorconfigrc or via cli parameter.

Don't run exclude regexp on absolute path

Currently the regular expression of the default excludes are run on the whole absolute path but it should rather run on the relative path of the project root somehow.

For example for this repository, git would match (read exclude) all of this and much more (because of the github.com):

git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/Makefile
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/README.md
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/bin/ec
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/cmd/editorconfig-checker/main.go
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/cmd/editorconfig-checker/main_test.go
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/coverage.txt
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/docs/logo.png
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/pkg/types/types.go
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/pkg/utils/utils.go
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/pkg/utils/utils_test.go
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/pkg/validators/validators.go
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/pkg/validators/validators_test.go
git /home/maex/go/src/github.com/editorconfig-checker/editorconfig-checker.go/tags

Problems excluding files via .ecrc on Windows

I upgraded from 1.4.0 release to 2.0.1 of https://github.com/editorconfig-checker/editorconfig-checker.javascript.

Using the old version I used a bunch of --exclude-pattern parameters. These exclusions I moved to a .ecrc file:

\.js$
\.jsx$
\.css$
\.scss$
\.less$
^dir1\/
^dir2\/
^dir3\/subdir1\/
^dir3\/subdir2\/

This works on Mac but on Windows it seems that the config file is completely ignored. I also tried to test for / or \, with optional prepending ./ and without ^. But everything I tried without success.

cache already checked results

We could save the results to specific checks maybe somewhere in ~/.editorconfig-checker/ or ~/.ec/
and so make recurring checks way faster.

Also keep in mind to add clear-cache and no-cache flags.

RFC: Caching the different versions of the binary in wrapper tools

In every wrapper tool the release is currently downloaded to the directory where the wrapper tool is located and extracted to the bin directory right there.

We should consider caching the already downloaded binary, especially since maybe you have many projects which depend on it what would be a massive waste of space.

My suggestion would be (inspired and adopted from @vbrandl):

  1. Download the release in a writable temporary directory
  2. Extract the binary in the temporary directory
  3. Verify the correctness of the binary via some hashing function (maybe sha512?), maybe the right hash should be hard-coded into the wrapper itself?
  4. Move the binary either to $XDG_DATA_HOME/[ec|editorconfig-checker]/x.x.x/ec $XDG_CACHE_HOME/[ec|editorconfig-checker]/x.x.x/ec- I'm not really sure what would be more sufficient.
  5. Check the correctness of the binary on every execution of the wrapper, if hash doesn't match start with point 1.

Is there something I'm missing? Are there any other good ideas?
Feel free to tell me :)

Disable line

There should be an inline option to disable single lines from checking.

// editorconfig-checker disable-line or something

review error handling

Maybe it would be a better approach to hand the errors up to the main/calling function and decide there if something and what should happen. Currently there are mostly just panics

The panics are bubbled up into main.go now.

dry run command

There should be a dry-run command which should output all files which are checked.

editorconfig-checker ignores multiple files with brace expansion notation

Also opening an issue here because the python repo might not be monitored.

See editorconfig-checker/editorconfig-checker.python#1


This is my .editorconfig:

root = true

[*]
insert_final_newline = true
indent_style = space
tab_width = 4
trim_trailing_whitespace = true

[*.yml]
tab_width = 2

[{Makefile, Makefile.am, Makefile.in}]
indent_style = tab

[*.{diff, patch}]
trim_trailing_whitespace = false

When running editorconfig-checker, it warns about trailing whitespaces in patches.

It works fine if I change

[*.{diff, patch}]
trim_trailing_whitespace = false

to

[*.diff]
trim_trailing_whitespace = false
[*.patch]
trim_trailing_whitespace = false

But this shouldn't be necessary as the original syntax is supported by the editorconfig standard. It is used in the example.

editorconfig-checker -version
2.0.3

python --version
Python 3.8.1

`insert_final_newline` should ensure that the file doesn't have a final newline at the end.

As pointed out in this issue: editorconfig-checker/editorconfig-checker.javascript#59
The behaviour of insert_final_newline is handled wrongly.

Current behavour: right now it checks only if insert_final_newline is set to true and does nothing otherwise.
Expected behaviour: it should be checked that these files don't have a final newline if insert_final_newline is set to false. If it is left blank it shouldn't matter at all.

Thanks to @ericcornelissen for pointing out.

Disable file

There should be an inline option to disable single files from checking.

// editorconfig-checker disable-file or something

use golangs power for checking of files

Golang is very good at making things concurrent/run in parallel.
This should be taken into account when searching for files to check and also when running the validators over these files.

Performance measures would be nice :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.