Open techfg opened 5 months ago
I might be running into this too.
I expected that .eslintignore
would be respected, but setting up eslint via codeActionsOnSave
doesn't seem to work correctly with .eslintignore
. I can't find any good way to ignore certain folder or file patterns.
@bashmish .eslintignore
should be full respected. Do you see any errors in the file?
Can you please provide me with a GitHub repository I can clone with a minimal repro setup to demo what you are seeing.
@dbaeumer here it is https://github.com/bashmish/bug-eslint-fixall-ignore
.vscode/settings.json
with most important ones to simplify the reproductiontest/
folder in .eslintignore
on the screenshot you can see the file inside test
contains an error, but I don't want to lint the files in test
on save inside my-test.js
the eslint will auto-fix and add a JSDoc to the function, which is also not expected for test
folder
npm test
will run eslint with just the src
folder, which I have to explicitly specify in the CLI arg (try running npx eslint **/*.js
without src
arg, it will lint test
folder too)
basically .eslintignore
is not working for me in any of the scenarios, and it looks to be not just an issue with vscode-eslint
, but also the the eslint
CLI
shall I open a separate issue for this? in this repo or in the eslint core?
@bashmish you are using the new flat config which doesn't honor .eslintignore
files. You need to add an ignore section to the flat config. See https://eslint.org/docs/latest/use/configure/configuration-files-new#globally-ignoring-files-with-ignores
@dbaeumer the problem with the latter is that it gets overridden by one of my other configs. I can't easily repro it as I have a closed-sourced company wide config and already spent an hour trying to find out which part of it overrides mine... I tried putting { ignores: ['test/'] }
to both start and end of the config, no luck. In the repo https://github.com/bashmish/bug-eslint-fixall-ignore it does work, but doesn't help me.
This is how I ended up here, hoping that some other way to exclude certain file pattern globally can override whatever I have in my eslint config.
With CLI I can just do eslint src
and then it's only linting the src
folder. With the vscode-eslint
I don't know how to achieve the same.
Would be even better if I can explicitly set file patterns I wanna lint similarly to the CLI, instead of trying to ignore all the rest.
Would like to see a way to be able to control which files are fixed during onCodeActionsSave. Currently, the only method to differentiate what is done on lint vs fix is
eslint.onCodeActionsSave.rules
which can be cumbersome to manage, especially with complicated configurations.Potential Approaches:
eslint.onCodeActionsSave.ignorePatterns
which could be passed to eslint directlyeslint.onCodeActionsSave.ignorePath
which could be passed to eslint directly and would allow a different ignore file to be used during fixUse Case: When linting certain file types (e.g.,
*.{md,mdx}
), fixing a file could conflict with prettier formatting (e.g., remark stringifies the result resulting in characters being escaped while prettier removes the unnecessary escapes). For this reason, we ignore these files during fixing from cli but there is no way to replicate this behavior (at least not that I can see from the available options) when using the extension.Thank you for your consideration!