Answer the question
In order to leave comments, you need to log in
Prettier - how to set each jsx attribute to be on a new line?
Actually, I set up a bunch of eslint + prettier for myself, everything works with one exception, in JSX all attributes of a tag are written on one line, but I would like each one on a new line:
How prettier formats now:
<li className={classNames} onMouseLeave={() => setMouseLeave(true)} onMouseEnter={() => setMouseLeave(false)}>
<li className={classNames}
onMouseLeave={() => setMouseLeave(true)}
onMouseEnter={() => setMouseLeave(false)}>
{
"singleQuote": true,
"printWidth": 120,
"tabWidth": 4,
"semi": true,
"trailingComma": "none",
"jsxBracketSameLine": true,
"arrowParens": "always",
"bracketSpacing": true
}
Answer the question
In order to leave comments, you need to log in
There is a jsx-max-props-per-line rule in eslint with eslint-plugin-react . Set it up and use eslint's own autofix, or integrate eslint with prettier https://github.com/prettier/eslint-plugin-prettier https://github.com/prettier/prettier-eslint
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question