New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Considering .eslintignore
#584
Comments
.eslintignore
.eslintignore
No, it should not affect how eslint works. 🚫💩 Lint-staged only calls eslint with arguments that are staged files so I don’t think this is a valid solution. Are you sure it’s not considering it? If so that must be some isssue with eslint since I’ve been using eslint with ignores like this before. |
Closing of inactivity |
@okonet So strange, I'm also having the same error as @hepiyellow. I run Is there a way to pass the |
That's weird indeed. I never had such issues with it before. If that's an issue with lint-staged, when we'd need a reproducible case. |
@okonet Of course! Hopefully it's just something in my configuration. Let me give some background: DescriptionWhen running Steps to reproduceThis is my configuration:
I tried this as well:
Folder structure
Debug LogsEnvironmentNode v10.13.0 Thanks for your help! 😄 |
Please investigate the root cause of this and submit a fix. |
I also have this is issue. I have added *d.ts files to ignore and it works well with my eslint but fails with lint-staged |
Please post debug logs, otherwise there is nothing we can do to debug this issue. |
I have the same problem. Even if I explictly pass I defined the ignore patterns in
|
@okonet I'm having a similar issue: I have an
Here's the command I'm running:
Here it is in
Here is the warning log when run from
|
same error +1 |
@1o1w1 - I solved it by adding a |
For those traveling through the issues in future (like me for last couple hours): @kunalnagar answer above was very helpful, but I had to adjust it to consider 2 .eslintrc configs I had (root and for cypress): const { ESLint } = require('eslint')
const filterAsync = require('node-filter-async').default
// All of this below is caused by eslint dropping warnings (File ignored because of a matching ignore pattern.) on ignored files
// solution taken from: https://github.com/okonet/lint-staged#eslint--7
// two eslint initializations because we have two .eslintrc, one in root, another one in cypress/.eslintrc
const rootEslintCli = new ESLint()
const cypressEslintCli = new ESLint({ overrideConfigFile: './cypress/.eslintrc'})
const removeIgnoredFiles = async (files, eslintCli) => {
const filteredFiles = await filterAsync(files, async (file) => {
const isIgnored = await eslintCli.isPathIgnored(file)
return !isIgnored
})
return filteredFiles.join(' ')
}
module.exports = {
'src/**/*.{ts,tsx,js,jsx}': async (files) => {
const filesToLint = await removeIgnoredFiles(files, rootEslintCli)
return ['tsc', `eslint --fix --max-warnings=0 ${filesToLint}`]
},
'cypress/**/*.{ts,tsx,js,jsx}': async (files) => {
const filesToLint = await removeIgnoredFiles(files, cypressEslintCli)
return ['tsc --project cypress', `eslint --config cypress/.eslintrc --fix --max-warnings=0 ${filesToLint}`]
},
} |
Hi everyone, To address this, I've published a tool called This CLI tool enhances It's straightforward to use, first install: pnpm add @skarab/eslint-staged --save-dev And add the following to your {
"*": [
"pnpm eslint-staged --fix --max-warnings=0",
"pnpm prettier --write --ignore-unknown"
]
} I believe this could be a helpful solution for those experiencing similar issues. The package is open for contributions, and I'd love to hear your feedback! You can find it here: https://github.com/skarab42/eslint-staged Happy coding! |
ESLint now has a command line flag
https://eslint.org/docs/latest/use/command-line-interface This also documented in our readme: https://github.com/lint-staged/lint-staged#how-can-i-ignore-files-from-eslintignore |
Description
It sems that with this configuration:
eslint does NOT consider any
.eslintignore
, thus I get errors for files which are in folders that have an.eslintignore
.I have corrected this by doing this:
Is this the correct way to configure this?
Should this be a default behaviour?
Maybe worth adding this to the example configs?
Thanks.
Steps to reproduce
Debug Logs
Environment
The text was updated successfully, but these errors were encountered: