My eslint setup is as follows:
{
"env": {
"es2020": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"settings": {
"import/resolver": {
"typescript": true,
"node": true
}
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"parserOptions": {
"project": ["./tsconfig.json"]
},
"rules": {
"@typescript-eslint/consistent-type-imports": [
"error",
{
"fixStyle": "inline-type-imports"
}
],
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/prefer-ts-expect-error": "error",
"@typescript-eslint/consistent-generic-constructors": ["error", "constructor"],
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
}
}
],
"rules": {
"indent": "off",
"max-len": [
"error",
{
"code": 88,
"ignoreRegExpLiterals": true
}
],
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"semi": ["error", "always"],
"arrow-parens": ["error", "as-needed"],
"prefer-const": ["error"],
"react/require-default-props": "off",
"import/order": [
"error",
{
"newlines-between": "always",
"groups": ["builtin", "external", "parent", "sibling", "index", "type"]
}
]
}
}
This is my prettier configuration:
{
"semi": true,
"tabWidth": 2,
"printWidth": 88,
"singleQuote": true,
"trailingComma": "none",
"jsxBracketSameLine": true,
"endOfLine": "auto",
"arrowParens": "avoid"
}
I have a typescript file with the following code snippet:
import { createRoot } from 'react-dom/client';
export const mount = (el: HTMLElement) => {
const root = createRoot(el);
};
An eslint error occurs:
Delete ".." eslint(prettier/prettier)
. Deleting 2 spaces resolves it temporarily, but reformatting adds the spaces back and triggers the same error.
The conflicting eslint rules are puzzling, especially considering I've set the tabWidth
to 2. What could be causing this issue? Thank you!