-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
jsx-indent and indent require the same indentation amount #915
Comments
Rules can't access other rules' config. If you want 2 spaces, you have to configure both rules. |
This raises the question as to why there are two rules. Could it not work similar how the eslint
By default, it could use the same value. |
@tswaters there are two rules because JSX isn't part of JS, so eslint core doesn't tend to have rules that can work with it. |
My mistake, I misread the original post. I was talking about |
That does seem reasonable - however, people indent their props in far crazier ways then they indent their object literal keys, so it might get unwieldy. The first step would be enhancing @yannickcr, thoughts? |
I've encountered the same issue where after the ESLint 4 upgrade, the JSX and ESLint indent levels have to match up otherwise there are conflicts. |
After also doing the upgrade from
... to
The |
@HHogg you can instead configure |
@ljharb Any chance you have an example of how to setup the I have the same situation as @HHogg. Looking at the docs for |
https://eslint.org/docs/rules/indent#ignorednodes, with a selector of "JSX*" should do it. |
Thank very much for the quick reply @ljharb - using your suggestion I was able to get something working. Using the wildcard character on the syntax tree node name didn't work for me, but by using the rule below, I seem to have about the equivalent of how our linting used to work:
I believe that this will just turn off the A side note for anyone else exploring this - I found this site very useful for finding out what the AST node names actually are (https://astexplorer.net/). |
@Wilfred does this solve your issue? |
I ended up configuring both plugins to just use the same indent, so I'm happy. In a perfect world the plugins would detect the conflicting settings, but I don't see how that's possible. It's just a small papercut. I'm happy to close this if you don't think there's anything else we can do here? |
Unless eslint core agrees to make a global "indent" setting that the core indent rule reads (and then that jsx-indent could read), there's nothing we can do. |
Related to #898, but I think it's sufficiently different to warrant a separate issue.
Given the JS:
and following eslint configuration:
Then I get a warning
Expected indentation of 12 space characters but found 10.
for the<span>
.I suspect this is because the default indent for
jsx-indent
is 4 spaces, whereas I've configuredindent
to use 2 spaces.I think that jsx-indent should either be able to handle different indent values to
indent
, or perhaps it should just reuse the existing indent value?The text was updated successfully, but these errors were encountered: