indent conflicts with react/jsx-closing-bracket-location
See original GitHub issueTell us about your environment
- ESLint Version: 5.16
- Node Version: 11.4.0
- yarn Version: 1.9.4
What parser (default, Babel-ESLint, etc.) are you using? @tylescript-eslint/parser
Please show your full configuration:
.eslintrc:
module.exports = {
env: {
'jest/globals': true
},
extends: [
'airbnb',
'plugin:@typescript-eslint/recommended',
],
globals: {
'document': true,
'window': true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
project: './tsconfig.json',
},
plugins: ['@typescript-eslint', 'jest'],
rules: {
'indent': 'off',
'@typescript-eslint/indent': [
'error',
2,
{
'ignoredNodes': ['JSXElement *'],
'SwitchCase': 1,
},
],
},
settings: {
'import/extensions': [
'.js',
'.jsx'
],
'import/resolver': {
webpack: {
config: 'webpack.common.js',
}
}
},
};
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
- Clone this repo.
- run
yarn
- run
yarn build:dev
What did you expect to happen?
No errors. Aligning the closing bracket should not cause an indent error. I am stating that the indent rule should be ignored for JSX Elements. Note that indenting the closing bracket will conflict with the react/jsx-closing-bracket-location rule.
sampleComponent.jsx:
import React from 'react';
const SampleComponent = () => (
<h
custom-attr-one="1"
custom-attr-two="2"
custom-attr-three="3"
> // <- causes failure
custom header
</h>
);
export default SampleComponent;
error:
ERROR in ./src/sampleComponent.jsx
Module build failed (from ./node_modules/eslint-loader/index.js):
Module failed because of a eslint error.
/Users/jemery/dev/typescript-eslint-debug/src/sampleComponent.jsx
8:1 error Expected indentation of 4 spaces but found 2 @typescript-eslint/indent
✖ 1 problem (1 error, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
@ ./src/index.jsx 4:0-48 5:27-42
@ multi babel-polyfill ./src/index.jsx
error Command failed with exit code 2.
Are you willing to submit a pull request to fix this bug? Yes
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to fix "react/jsx-closing-bracket-location" in WebStorm
The closing bracket must be aligned with the opening tag (expected column 13) react/jsx-closing-bracket-location.
Read more >eslint-plugin-react/README.md - UNPKG
The CDN for eslint-plugin-react. ... /jsx-closing-bracket-location.md) | Validate closing bracket location in JSX | ... Validate props indentation in JSX |.
Read more >Airbnb React/JSX Style Guide
A mostly reasonable approach to React and JSX ... Follow these alignment styles for JSX syntax. eslint: react/jsx-closing-bracket-location ...
Read more >eslint-plugin-react - npm
Start using eslint-plugin-react in your project by running `npm i ... jsx-closing-bracket-location, Enforce closing bracket location in JSX ...
Read more >eslint/eslint - Gitter
... "react/jsx-closing-bracket-location": 0, "react/jsx-curly-spacing": 1, "react/jsx-indent-props": 0, "react/jsx-key": 1, "react/jsx-max-props-per-line": ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What happens if you configure your ignored nodes to include JSXElement as well (not just
JSXElement *
)?As suggested by OliverSieweke, the following
"indent"
configuration is working for me: