question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update indent rule with sane defaults for JSX

See original GitHub issue

As 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:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:46 (42 by maintainers)

github_iconTop GitHub Comments

4reactions
kaicataldocommented, Apr 7, 2017

Defaulting to line-aligned seems like the best course of action to me, then!

3reactions
not-an-aardvarkcommented, Apr 7, 2017

@soda0289 That would be determined by the VariableDeclarator option. Both of the examples would be allowed depending on whether the VariableDeclarator 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found