-
-
Notifications
You must be signed in to change notification settings - Fork 416
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
lint-staged is not taking .eslintrc.js configuration. #677
Comments
In your eslint config you have specified this rule I think your issue is the other way around: your plain eslint command is not picking up the configuration. |
Eslint errors show it wants 4 spaces instead of 2. This rule says I want 2 spaces: Eslint error says "Expected indentation of 4 spaces but found 2". So eslint is using this rule: Anyway, I have solved this problem with:
Anyway x2, solved. |
I'm currently having the same problem, where the cli output from |
@husseinbob Please post your debug logs, otherwise nothing can be done. |
I think I found the issue. my changes to .eslintrc.js also needed to be staged, by the looks of it? either way, |
@husseinbob yeah, lint-staged will hide unstaged changes before running tasks, so at that point eslint would see the old version of your config. |
I confirm that it's not working when I run lint-staged whereas running
.eslintrc.js config
package.json
UPDATE: I found out that running
So it isn't due to not loading the config, at least not on initial pass. It's something with the way eslint is parsing it during the --fix flag. |
I started running into this issue too and running the |
Moreover, I would like to say that with --fix or --quiet eslint part taking too much time and sometims even fails with heap error, my assumption is that with addtional parameters it's ignoring the fact that only single file should be processed. |
Did ESLint change the way they handle arguments maybe? |
I work with a monorepo structure, I ran into the same error. I tried the following configuration into the It used to be: {
"*.{js,jsx}": ["prettier --write", "eslint --fix --quiet", "git add"],
"*.{ts,tsx}": ["prettier --write", "eslint --fix --quiet", "git add"],
"*.{scss,scss,css,md,html}": ["prettier --write", "git add"]
} Now it looks like this: {
"*.{js,jsx}": ["prettier --write", "eslint --fix --quiet --config .eslintrc.json --resolve-plugins-relative-to .", "git add"],
"*.{ts,tsx}": ["prettier --write", "eslint --fix --quiet --config .eslintrc.json --resolve-plugins-relative-to .", "git add"],
"*.{scss,scss,css,md,html}": ["prettier --write", "git add"]
} No issues after that, you should give it a try. The following config |
Same problem here with a monorepo. What @MDOR proposed doesn't work for me. My problem is a path with alias not being resolved. |
I was also having difficulties with a monorepo and was not able to get @MDOR 's solution to work for me. I believe the reason for this is that in The way I was able to get around this was to add a .lintstagedrc to each workspace and change directory to the workspace so that the "*.{js,jsx,ts,tsx}": "cd path/to/workspace && eslint --resolve-plugins-relative-to . --fix" Obviously, this is not ideal, but it did let me get around it for now. Of note, I do something similar for running eslint through yarn berry: "g:eslint": "cd $INIT_CWD && eslint --resolve-plugins-relative-to . --ext .js,.jsx,.ts,.tsx .", where $INIT_CWD is a yarn berry env var for getting the CWD of the workspace that used the script. |
Using |
Not everyone use yarn worspaces, some use Nx, other lerna or bit. |
Of course not, but I hope it is still helpful to know that you need to change directories somehow (and then back afterwards) to make use of |
I am having the same issue with a pnpm monorepo. If i run |
I would have a |
I tried a few solutions in this thread and found that upgrading lint-staged from 9.2.5 to 12.5.0 worked for me. (I can't use 13 because this project is on Node 12 still) To really test this, put garbage text in your .eslintrc file and run eslint to see if it fails on parsing that |
I was able to solve it by adding the following settings to the
|
apply suggestion from lint-staged/lint-staged#677 (comment) closes #3518
apply suggestion from lint-staged/lint-staged#677 (comment) closes #3518
[BUG]
Description
I have created 2 package.json npm scripts:
My configuration for lint-staged looks like;
By running
![image](https://user-images.githubusercontent.com/7398214/62238104-95d85e80-b3d2-11e9-946d-ff9881441d00.png)
yarn eslint:test
ornpm run eslint:test
I've got no errors.Like on the image attached:
But by running second command ("lint-staged:test") I've got some errors related with the file that was checked with the first command. Image shows it:
![image](https://user-images.githubusercontent.com/7398214/62238079-86f1ac00-b3d2-11e9-815a-14ccf0fd48fd.png)
Those are my rules for eslint (.eslinrc.js file):
which are applied for the first command but are not applied for lint-staged.
Some possible solutions?
Environment
lint-staged
: 9.2.1,eslint
: 5.3.0",The text was updated successfully, but these errors were encountered: