996a290afd
To allow us to incrementally adopt more comprehensive linting rules, this pull request disables the previous behaviour of failing CI when any warnings were discovered. Instead, this modifies the previous warnings to be errors which will preserve the previous linting behaviour. As we enable new lint rules, they can be added as warnings which will gently nudge us towards fixing in related pull requests.
357 lines
11 KiB
JSON
357 lines
11 KiB
JSON
{
|
|
"root": true,
|
|
"parser": "@babel/eslint-parser",
|
|
"plugins": ["react", "react-hooks", "jest", "import", "jsdoc"],
|
|
"env": {
|
|
"browser": true,
|
|
"commonjs": true,
|
|
"es6": true,
|
|
"node": true,
|
|
"jest": true
|
|
},
|
|
"parserOptions": {
|
|
"requireConfigFile": false,
|
|
"sourceType": "module",
|
|
"ecmaFeatures": {
|
|
"jsx": true
|
|
},
|
|
"babelOptions": {
|
|
"presets": ["next/babel"],
|
|
"caller": {
|
|
// Eslint supports top level await when a parser for it is included. We enable the parser by default for Babel.
|
|
"supportsTopLevelAwait": true
|
|
}
|
|
}
|
|
},
|
|
"settings": {
|
|
"react": {
|
|
"version": "detect"
|
|
},
|
|
"import/internal-regex": "^next/"
|
|
},
|
|
"overrides": [
|
|
{
|
|
"files": ["test/**/*.js", "test/**/*.ts", "**/*.test.ts"],
|
|
"extends": ["plugin:jest/recommended"],
|
|
"rules": {
|
|
"jest/expect-expect": "off",
|
|
"jest/no-disabled-tests": "off",
|
|
"jest/no-conditional-expect": "off",
|
|
"jest/valid-title": "off",
|
|
"jest/no-interpolation-in-snapshots": "off",
|
|
"jest/no-export": "off"
|
|
}
|
|
},
|
|
{ "files": ["**/__tests__/**"], "env": { "jest": true } },
|
|
{
|
|
"extends": [
|
|
"plugin:@typescript-eslint/recommended",
|
|
"plugin:@typescript-eslint/stylistic"
|
|
],
|
|
"files": ["**/*.ts", "**/*.tsx"],
|
|
"parser": "@typescript-eslint/parser",
|
|
"parserOptions": {
|
|
"sourceType": "module",
|
|
"warnOnUnsupportedTypeScriptVersion": false
|
|
},
|
|
"plugins": ["@typescript-eslint"],
|
|
"rules": {
|
|
// Todo: investigate, for each of these rules, whether we want them.
|
|
"@typescript-eslint/array-type": "off",
|
|
"@typescript-eslint/ban-ts-comment": "off",
|
|
"@typescript-eslint/ban-tslint-comment": "off",
|
|
"@typescript-eslint/ban-types": "off",
|
|
"@typescript-eslint/class-literal-property-style": "off",
|
|
"@typescript-eslint/consistent-generic-constructors": "off",
|
|
"@typescript-eslint/consistent-indexed-object-style": "off",
|
|
"@typescript-eslint/consistent-type-definitions": "off",
|
|
"@typescript-eslint/no-empty-function": "off",
|
|
"@typescript-eslint/no-namespace": "off",
|
|
"@typescript-eslint/no-shadow": "off",
|
|
"@typescript-eslint/no-empty-interface": "off",
|
|
"@typescript-eslint/no-explicit-any": "off",
|
|
"@typescript-eslint/no-inferrable-types": "off",
|
|
"@typescript-eslint/no-var-requires": "off",
|
|
"@typescript-eslint/prefer-for-of": "off",
|
|
"@typescript-eslint/prefer-function-type": "off",
|
|
"@typescript-eslint/no-this-alias": "off",
|
|
"@typescript-eslint/triple-slash-reference": "off",
|
|
"no-var": "off",
|
|
"prefer-const": "off",
|
|
"prefer-rest-params": "off",
|
|
"prefer-spread": "off",
|
|
|
|
// These off- or differently-configured rules work well for us.
|
|
"no-unused-expressions": "off",
|
|
"@typescript-eslint/no-unused-expressions": [
|
|
"error",
|
|
{
|
|
"allowShortCircuit": true,
|
|
"allowTernary": true,
|
|
"allowTaggedTemplates": true
|
|
}
|
|
],
|
|
"no-unused-vars": "off",
|
|
"@typescript-eslint/no-unused-vars": [
|
|
"error",
|
|
{
|
|
"args": "none",
|
|
"ignoreRestSiblings": true
|
|
}
|
|
],
|
|
"no-use-before-define": "off",
|
|
"no-useless-constructor": "off",
|
|
"@typescript-eslint/no-use-before-define": "off",
|
|
"@typescript-eslint/no-useless-constructor": "error",
|
|
"@typescript-eslint/prefer-literal-enum-member": "error"
|
|
}
|
|
},
|
|
{
|
|
"files": ["packages/**/*.tsx?"],
|
|
"rules": {
|
|
"jsdoc/no-types": "error",
|
|
"jsdoc/no-undefined-types": "error"
|
|
}
|
|
},
|
|
{
|
|
"files": ["examples/**/*"],
|
|
"rules": {
|
|
"@typescript-eslint/no-use-before-define": [
|
|
"error",
|
|
{
|
|
"functions": true,
|
|
"classes": true,
|
|
"variables": true,
|
|
"enums": true,
|
|
"typedefs": true
|
|
}
|
|
],
|
|
"import/no-anonymous-default-export": [
|
|
"error",
|
|
{
|
|
// React components:
|
|
"allowArrowFunction": false,
|
|
"allowAnonymousClass": false,
|
|
"allowAnonymousFunction": false,
|
|
|
|
// Non-React stuff:
|
|
"allowArray": true,
|
|
"allowCallExpression": true,
|
|
"allowLiteral": true,
|
|
"allowObject": true
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"files": ["packages/**"],
|
|
"excludedFiles": [
|
|
"packages/next/taskfile*.js",
|
|
"packages/next/webpack.config.js"
|
|
],
|
|
"rules": {
|
|
"no-shadow": ["error", { "builtinGlobals": false }],
|
|
"import/no-extraneous-dependencies": [
|
|
"error",
|
|
{ "devDependencies": false }
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"files": ["packages/**/*.tsx", "packages/**/*.ts"],
|
|
"rules": {
|
|
// Note: you must disable the base rule as it can report incorrect errors
|
|
"no-shadow": "off",
|
|
"@typescript-eslint/no-shadow": ["error", { "builtinGlobals": false }],
|
|
"@typescript-eslint/no-unused-vars": [
|
|
"error",
|
|
{
|
|
"args": "all",
|
|
"argsIgnorePattern": "^_",
|
|
"ignoreRestSiblings": true
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"files": [
|
|
"packages/eslint-plugin-next/**/*.js",
|
|
"test/unit/eslint-plugin-next/**/*.test.ts"
|
|
],
|
|
"extends": ["plugin:eslint-plugin/recommended"],
|
|
"parserOptions": {
|
|
"sourceType": "script"
|
|
},
|
|
"rules": {
|
|
"eslint-plugin/prefer-replace-text": "error",
|
|
"eslint-plugin/report-message-format": [
|
|
"error",
|
|
".+\\. See: https://nextjs.org/docs/messages/[a-z\\-]+$"
|
|
],
|
|
"eslint-plugin/require-meta-docs-description": [
|
|
"error",
|
|
{
|
|
"pattern": ".+"
|
|
}
|
|
],
|
|
"eslint-plugin/require-meta-docs-url": "error"
|
|
}
|
|
},
|
|
{
|
|
"files": ["packages/**/*.tsx", "packages/**/*.ts"],
|
|
"rules": {
|
|
"@typescript-eslint/consistent-type-imports": [
|
|
"error",
|
|
{
|
|
"disallowTypeAnnotations": false
|
|
}
|
|
],
|
|
"@typescript-eslint/no-import-type-side-effects": "error"
|
|
}
|
|
}
|
|
],
|
|
"rules": {
|
|
"array-callback-return": "error",
|
|
"default-case": ["error", { "commentPattern": "^no default$" }],
|
|
"dot-location": ["error", "property"],
|
|
"eqeqeq": ["error", "smart"],
|
|
"new-parens": "error",
|
|
"no-array-constructor": "error",
|
|
"no-caller": "error",
|
|
"no-cond-assign": ["error", "except-parens"],
|
|
"no-const-assign": "error",
|
|
"no-control-regex": "error",
|
|
"no-delete-var": "error",
|
|
"no-dupe-args": "error",
|
|
"no-dupe-class-members": "error",
|
|
"no-dupe-keys": "error",
|
|
"no-duplicate-case": "error",
|
|
"no-empty-character-class": "error",
|
|
"no-empty-pattern": "error",
|
|
"no-eval": "error",
|
|
"no-ex-assign": "error",
|
|
"no-extend-native": "error",
|
|
"no-extra-bind": "error",
|
|
"no-extra-label": "error",
|
|
"no-fallthrough": "error",
|
|
"no-func-assign": "error",
|
|
"no-implied-eval": "error",
|
|
"no-invalid-regexp": "error",
|
|
"no-iterator": "error",
|
|
"no-label-var": "error",
|
|
"no-labels": ["error", { "allowLoop": true, "allowSwitch": false }],
|
|
"no-lone-blocks": "error",
|
|
"no-loop-func": "error",
|
|
"no-mixed-operators": [
|
|
"error",
|
|
{
|
|
"groups": [
|
|
["&", "|", "^", "~", "<<", ">>", ">>>"],
|
|
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
|
|
["&&", "||"],
|
|
["in", "instanceof"]
|
|
],
|
|
"allowSamePrecedence": false
|
|
}
|
|
],
|
|
"no-multi-str": "error",
|
|
"no-native-reassign": "error",
|
|
"no-negated-in-lhs": "error",
|
|
"no-new-func": "error",
|
|
"no-new-object": "error",
|
|
"no-new-symbol": "error",
|
|
"no-new-wrappers": "error",
|
|
"no-obj-calls": "error",
|
|
"no-octal": "error",
|
|
"no-octal-escape": "error",
|
|
"no-regex-spaces": "error",
|
|
"no-restricted-syntax": [
|
|
"error",
|
|
"WithStatement",
|
|
{
|
|
"message": "substr() is deprecated, use slice() or substring() instead",
|
|
"selector": "MemberExpression > Identifier[name='substr']"
|
|
}
|
|
],
|
|
"no-script-url": "error",
|
|
"no-self-assign": "error",
|
|
"no-self-compare": "error",
|
|
"no-sequences": "error",
|
|
"no-shadow-restricted-names": "error",
|
|
"no-sparse-arrays": "error",
|
|
"no-template-curly-in-string": "error",
|
|
"no-this-before-super": "error",
|
|
"no-throw-literal": "error",
|
|
"no-undef": "error",
|
|
"no-unexpected-multiline": "error",
|
|
"no-unreachable": "error",
|
|
"no-unused-expressions": [
|
|
"error",
|
|
{
|
|
"allowShortCircuit": true,
|
|
"allowTernary": true,
|
|
"allowTaggedTemplates": true
|
|
}
|
|
],
|
|
"no-unused-labels": "error",
|
|
"no-unused-vars": [
|
|
"error",
|
|
{
|
|
"args": "none",
|
|
"ignoreRestSiblings": true
|
|
}
|
|
],
|
|
"no-use-before-define": "off",
|
|
"no-useless-computed-key": "error",
|
|
"no-useless-concat": "error",
|
|
"no-useless-constructor": "error",
|
|
"no-useless-escape": "error",
|
|
"no-useless-rename": [
|
|
"error",
|
|
{
|
|
"ignoreDestructuring": false,
|
|
"ignoreImport": false,
|
|
"ignoreExport": false
|
|
}
|
|
],
|
|
"no-with": "error",
|
|
"no-whitespace-before-property": "error",
|
|
"react-hooks/exhaustive-deps": "error",
|
|
"require-yield": "error",
|
|
"rest-spread-spacing": ["error", "never"],
|
|
"strict": ["error", "never"],
|
|
"unicode-bom": ["error", "never"],
|
|
"use-isnan": "error",
|
|
"valid-typeof": "error",
|
|
"getter-return": "error",
|
|
"react/forbid-foreign-prop-types": ["error", { "allowInPropTypes": true }],
|
|
"react/jsx-no-comment-textnodes": "error",
|
|
"react/jsx-no-duplicate-props": "error",
|
|
"react/jsx-no-target-blank": "error",
|
|
"react/jsx-no-undef": "error",
|
|
"react/jsx-pascal-case": [
|
|
"error",
|
|
{
|
|
"allowAllCaps": true,
|
|
"ignore": []
|
|
}
|
|
],
|
|
"react/jsx-uses-react": "error",
|
|
"react/jsx-uses-vars": "error",
|
|
"react/no-danger-with-children": "error",
|
|
"react/no-deprecated": "error",
|
|
"react/no-direct-mutation-state": "error",
|
|
"react/no-is-mounted": "error",
|
|
"react/no-typos": "error",
|
|
"react/react-in-jsx-scope": "off",
|
|
"react/require-render-return": "error",
|
|
"react/style-prop-object": "error",
|
|
"react-hooks/rules-of-hooks": "error",
|
|
// "@typescript-eslint/non-nullable-type-assertion-style": "error",
|
|
"@typescript-eslint/prefer-as-const": "error",
|
|
"@typescript-eslint/no-redeclare": [
|
|
"error",
|
|
{ "builtinGlobals": false, "ignoreDeclarationMerge": true }
|
|
]
|
|
}
|
|
}
|