I use Prettier in JavaScript project with React. All my component props is formated in 1 line :
<Icon icon="arrow-left" width={15} height={18} />
And i would like this :
<Icon
icon="arrow-left"
width={15}
height={18}
/>
I've add "react/jsx-max-props-per-line": [1, { "when": "multiline" }]
to my .prettierrc, but no result.
I've an ESLint config too, with this rules :
{
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:prettier/recommended"
],
"plugins": ["react", "prettier", "standard"],
"rules": {
"indent": [2, 2, { "SwitchCase": 1 }],
"quotes": [2, "single"],
"linebreak-style": [2, "unix"],
"semi": [2, "always"],
"no-console": [0],
"no-loop-func": [0],
"new-cap": [0],
"no-trailing-spaces": [0],
"no-param-reassign": [0],
"func-names": [0],
"comma-dangle": [0],
"no-unused-expressions": [0],
"block-scoped-var": [0],
"react/prop-types": [0],
"prettier/prettier": "error"
}
}
My .prettier file config :
"bracketSpacing": true,
"jsxBracketSameLine": true,
"printWidth": 80,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"useTabs": false,
"react/jsx-max-props-per-line": [1, { "when": "always" }]
Maybe a conflict ? I've try to move the react/jsx-max-props-per-line
to ESLint rules, but no result too. No change.
Anyone can help me ?
module.exports = {
'extends': [
'eslint:recommended',
],
'env': {
'es6': true
},
'plugins': ['react'],
'parser': 'babel-eslint',
'rules': {
// you rules....
'react/jsx-first-prop-new-line': [1, 'multiline'],
'react/jsx-max-props-per-line': [1,
{
'maximum': 1
}
]
},
};
yarn add --dev prettier-eslint-cli
VS code userConfig
"prettier.eslintIntegration": true,