editorconfig-checker / editorconfig-checker Goto Github PK
View Code? Open in Web Editor NEWA tool to verify that your files are in harmony with your .editorconfig
Home Page: https://editorconfig-checker.github.io/
License: MIT License
A tool to verify that your files are in harmony with your .editorconfig
Home Page: https://editorconfig-checker.github.io/
License: MIT License
While working on the rust wrapper I've noticed that the verbose setting from the configuration file doesn't get passed correctly as it seems. Exclude
seems to work.
Also it seems that it doesn't really work when not used with --verbose
-flag.
There should be a config file i.e. .ecrc
which contains all configuration options and you do not have to use command line flags.
introduce an autofix flag which should fix all issues which can be fixed.
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
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.
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).
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.
Especially before doing performance optimizations :)
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
.
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 ;))
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
It would be cool to have some default excludes which can be extended and/or discarded for own excludes.
I'd say by default.
this would also apply to other encrypted files.
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!
The defaultExcludes
are currently hardcoded into the main.go
but they should be configurable either via .ecrc
/.editorconfigrc
or via cli parameter.
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
Currently we use git ls-tree -r --name-only HEAD
to find files which should be checked.
It seems it would be better to read the .gitignore
file, see: editorconfig-checker/editorconfig-checker.javascript#111 (comment)
by checking only for text/plain
, it will ignore any text/xml
file.
Currently the verbose output is not very clear and structured. This can be done way better.
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.
Use the verbose flag and give some output
Currently the only allowed contenttype is text/*
, this should be made configurable in the .ecrc
file or via arguments.
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.
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):
$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.Is there something I'm missing? Are there any other good ideas?
Feel free to tell me :)
There should be an inline option to disable single lines from checking.
// editorconfig-checker disable-line
or something
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.
There should be a dry-run
command which should output all files which are checked.
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
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.
Have a look how it is implemented here: https://github.com/jedmao/eclint
There should be an inline option to disable single files from checking.
// editorconfig-checker disable-file
or something
When releasing it should be ensured that the master branch is checked out and it has no untracked or modified files.
E.g., it currently cannot be determined from the documentation whether editorconfig-checker
supports validating text encodings.
The logger is a perfect, single purpose library which can be extracted into a library.
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 :)
The error output should be colourized to be better readable.
See:
https://raw.githubusercontent.com/editorconfig-checker/editorconfig-checker.javascript/master/Docs/sample.png
https://raw.githubusercontent.com/editorconfig-checker/editorconfig-checker.php/master/Docs/sample.png
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.