Update indent rule with sane defaults for JSX
See original GitHub issueAs discussed in https://github.com/eslint/eslint/pull/7618, now that the indent rewrite has landed, we should enhance it with sane defaults for JSX, allowing for users who prefer to use a custom rule like eslint-plugin-react to do so with an ignoreJSX
option.
Note: It already currently checks JSX. The proposal here is to update the rule to make it allow for common JSX styles and fix any bugs we see. Ideally, people won’t have to use the ignoreJSX
option. Actually, maybe we should hold off on that option and wait and see if anyone asks for it? It would be nice if everyone could just use the indent rule, since we support JSX out of the box!
So far, the following enhancements have been discussed:
- Allow for props to be inline or multiline indented one level
- Closing tags should be inline or indented at same level as opening tag
- The first level of indentation for JS expressions inside JSXExpressionContainer nodes needs to be calculated correctly
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:46 (42 by maintainers)
Top Results From Across the Web
indent - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >How to auto indent jsx in VSCode - reactjs - Stack Overflow
Try changing the language mode to JavaScript React. Open the commands palette. Type change language mode; Press Enter; Type javascript react; Press Enter....
Read more >JavaScript Standard Style
Note: by default standard will look for all files matching the patterns: **/*.js ... If you really want to configure hundreds of ESLint...
Read more >eslint-plugin-react - npm
React specific linting rules for ESLint. ... You should also specify settings that will be shared across all the plugin rules.
Read more >indent.js - pure code indenter - GitHub Pages
Fast, minimalistic, pure code indentation. Indents JavaScript, JSON, JSX, Typescript, TSX, CSS, LESS, SCSS, and HTML. Unlike JSBeautify, which adds new lines ...
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
Defaulting to
line-aligned
seems like the best course of action to me, then!@soda0289 That would be determined by the
VariableDeclarator
option. Both of the examples would be allowed depending on whether theVariableDeclarator
config was 1 or 0, respectively.Basically, if you squint a bit and pretend that the JSXElement is an object literal and the attributes are properties, the same thing will be allowed for the element as for the corresponding object literal.