I’m trying to make an ErrorBoundary using a class component like this
class ErrorBoundary extends Component<ErrorBoundaryProps,ErrorBoundaryState>
But every time I format it with prettier, the part <ErrorBoundaryProps,ErrorBoundaryState> disappears, I’m not sure if it’s prettier or eslint.
Here’s my .eslintrc.json
{
"extends": [
"next/core-web-vitals",
"plugin:storybook/recommended"
],
"plugins": ["simple-import-sort"],
"rules": {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error"
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": "latest"
}
}
2
Answers
Install Necessary Plugins:
Make sure you have the required ESLint and Prettier plugins installed:
Disable ESLint Formatting:
You can configure ESLint to not format certain aspects. Add the following rule to your
.eslintrc.json
to prevent ESLint from interfering with TypeScript generics:Use the Correct Parser:
Ensure you’re using the TypeScript parser for ESLint. Your
.eslintrc.json
should include:Configure Prettier and ESLint to Work Together:
Add the following to your
.eslintrc.json
to integrate Prettier with ESLint:Upgrading to the latest version(
version 3.3.3
) solved my issue.