editorconfig-checker / editorconfig-checker.javascript

A tool to verify that your files are in harmony with your .editorconfig
https://editorconfig-checker.github.io/
MIT License
71 stars 10 forks source link

Works incorrectly with paths #387

Closed Alecto closed 2 years ago

Alecto commented 2 years ago

Hello! Please help me figure out how to exclude several folders from the scan.

documentation says to use valid regular expressions image

with one folder - exception works image

but if I use a valid regular expression - the plugin doesn't work image path not found as the result image

please explain where I went wrong and how to set an exception for a group of certain files or folders.

mstruebing commented 2 years ago

Can you try:

    "editorconfig": "editorconfig-checker -exclude 'libs|styles\\.css'"

I think it has to do with how npm/node interprets the script command.

Alecto commented 2 years ago

@mstruebing doesnt work image ...path not found

and if I leave only the folder - it doesn't work either image

the impression is that the regular expression is not perceived at all, only the simplest string.

mstruebing commented 2 years ago

For me it works:

https://user-images.githubusercontent.com/12071529/183366955-cb34e0f3-d405-4fa8-98e1-da1b9e9e13ae.mov

mstruebing commented 2 years ago

Uhhh, sorry, I just realized: it looks like you are on windows by the path your terminal shows? I don't really have a clue about windows development and don't have a machine to test.

Could you may run the command with --verbose --debug to may see additional information?

Alecto commented 2 years ago

that's how it works image

but if you put '...' - it stops working image

even if you specify one folder, but in quotes - it no longer works image path not found

image

look like ' - is a part of path

image image

jerone commented 2 years ago

It looks like any paths are incorrectly being mapped. Also the paths in .editorconfig file itself.

With the following (part of) .editorconfig:

[tests/**.ts]
trim_trailing_whitespace = false

It should not give the following errors: image

rasa commented 2 years ago

I don't know it is required in this context, but the regex

libs|styles\\.css

may need parentheses:

(libs|styles\\.css)

Also, I don't know if it applies here, but Windows' CMD.EXE needs the double quote character (instead of the apostrophe) to surround strings. So can you try:

"editorconfig-checker -exclude \"(libs|styles\\.css)\""
Alecto commented 2 years ago

@rasa Thanks a lot, it looks like your solution works! I'll check with a fresh mind, but so far I've managed to ignore files and folders! thanks again.

rasa commented 2 years ago

@Alecto Great news! If it's solved your issue, please close this ticket if you don't mind. Thanks.

jerone commented 2 years ago

This is still an issue when using the .editorconfig paths, instead of CLI command. Creating some custom altered version for the CLI command, specifically for one OS, will not work for an .editorconfig file.

See reply above; https://github.com/editorconfig-checker/editorconfig-checker.javascript/issues/387#issuecomment-1213539658

rasa commented 1 year ago

@jerone Your fix changes \\ to / in the .editorconfig file. Is this the issue you are raising? That editorconfig-checker handles /s properly, but fails on treating \\ as a valid directory separator on Windows?

If that is the case, note that https://spec.editorconfig.org/#file-format says: "Backslashes (\) are not allowed as path separators (even on Windows)."

jerone commented 1 year ago

@jerone Your fix changes \\ to / in the .editorconfig file. Is this the issue you are raising? That editorconfig-checker handles /s properly, but fails on treating \\ as a valid directory separator on Windows?

Aldo this was an half year ago, I think that "fix" was an test to see editorconfig-checker in action. The issue at that time, was that it would not handle any path separators. See https://github.com/editorconfig-checker/editorconfig-checker.javascript/issues/387#issuecomment-1237329381 If that is still an issue, I have no idea.