I'm having trouble with conflicting rules between Eslint and Prettier on React project with TS and Styled Components. VSCode shows the following problem message:
"Insert
··
eslint(prettier/prettier)"
in a .ts
file used for styling. Everytime I save the file with the intended indentation, the linter removes the ··
.
How linter is identing
background-color: ${(props) => {
if (props.isSideOpen || props.isOverviewOpen)
return `rgba(${colors.white.rgba}, 1)`;
return `rgba(${colors.white.rgba}, 0.6)`;
}};
How it should be is identing
background-color: ${(props) => {
if (props.isSideOpen || props.isOverviewOpen)
return `rgba(${colors.white.rgba}, 1)`;
return `rgba(${colors.white.rgba}, 0.6)`;
}};
I tried going through the Eslint and Prettier rules but I couldn't find anything that made sense to my current issue.
Any tips?
.eslintrc
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"extends": ["eslint:recommended", "plugin:react/recommended", "prettier"],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
"ecmaFeatures": {
"classes": true,
"jsx": true
}
},
"plugins": ["prettier", "react", "import"],
"rules": {
"arrow-body-style": "off",
"no-console": 2,
"no-empty": "off",
"no-empty-function": "off",
"prefer-arrow-callback": 2,
"prefer-const": 2,
"prefer-promise-reject-errors": 2,
"strict": [2, "global"],
"import/first": "error",
"import/named": "warn",
"import/newline-after-import": 1,
"prettier/prettier": ["error", { "endOfLine": "auto" }],
"react/prop-types": 0,
"react/react-in-jsx-scope": 0
},
"settings": {
"react": {
"version": "16.12.0"
},
"import/resolver": {
"alias": {
"map": [["@", "./src"]],
"extensions": [".ts", ".tsx", ".js", ".jsx", ".json"]
}
}
},
"overrides": [
{
"files": ["*.tsx"],
"rules": {
"no-undef": "off"
}
}
]
}