2021-07-20 14:50:37 +00:00
|
|
|
/** @type {import("eslint").Linter.Config } */
|
|
|
|
module.exports = {
|
|
|
|
root: true,
|
2021-08-18 09:29:42 +00:00
|
|
|
parserOptions: {
|
2021-09-01 05:55:53 +00:00
|
|
|
project: "./tsconfig.json",
|
2021-08-18 09:29:42 +00:00
|
|
|
},
|
2021-07-20 14:50:37 +00:00
|
|
|
env: {
|
|
|
|
node: true,
|
|
|
|
},
|
|
|
|
extends: [
|
|
|
|
"eslint:recommended",
|
|
|
|
"plugin:react/recommended",
|
|
|
|
"plugin:@typescript-eslint/base",
|
|
|
|
"plugin:@typescript-eslint/eslint-recommended",
|
|
|
|
"plugin:prettier/recommended",
|
|
|
|
],
|
|
|
|
settings: {
|
|
|
|
react: {
|
|
|
|
version: "detect",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
rules: {
|
2021-08-18 09:29:42 +00:00
|
|
|
// Prefer using `includes()` to check if values exist over `indexOf() === -1`, as it's a more appropriate API for this.
|
|
|
|
"@typescript-eslint/prefer-includes": "error",
|
|
|
|
// Prefer using an optional chain expression, as it's more concise and easier to read.
|
2021-08-12 11:15:47 +00:00
|
|
|
"@typescript-eslint/prefer-optional-chain": "error",
|
2021-07-20 14:50:37 +00:00
|
|
|
"no-unused-vars": "off",
|
2021-07-27 20:56:16 +00:00
|
|
|
"@typescript-eslint/no-unused-vars": "error",
|
|
|
|
"@typescript-eslint/no-empty-function": "error",
|
2021-08-10 11:14:16 +00:00
|
|
|
// react/prop-types cannot handle generic props, so we need to disable it.
|
|
|
|
// https://github.com/yannickcr/eslint-plugin-react/issues/2777#issuecomment-814968432
|
|
|
|
"react/prop-types": "off",
|
2021-08-26 12:15:28 +00:00
|
|
|
// Prevent fragments from being added that have only a single child.
|
2021-09-01 05:55:53 +00:00
|
|
|
"react/jsx-no-useless-fragment": "error",
|
|
|
|
"prettier/prettier": [
|
|
|
|
"error",
|
|
|
|
{
|
|
|
|
endOfLine: "auto",
|
|
|
|
},
|
|
|
|
],
|
2021-07-20 14:50:37 +00:00
|
|
|
},
|
2021-07-27 20:56:16 +00:00
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
files: ["*.test.*"],
|
|
|
|
rules: {
|
|
|
|
// For tests it can make sense to pass empty functions as mocks.
|
|
|
|
"@typescript-eslint/no-empty-function": "off",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2021-07-20 14:50:37 +00:00
|
|
|
};
|