|
1 | 1 | {
|
2 |
| - "env": { |
3 |
| - "browser": true, |
4 |
| - "es2021": true, |
5 |
| - "node": true, |
6 |
| - "cypress/globals": true, |
7 |
| - "jest": true |
8 |
| - }, |
9 |
| - "plugins": [ |
10 |
| - "@typescript-eslint", |
11 |
| - "react", |
12 |
| - "react-hooks", |
13 |
| - "eslint-plugin-tsdoc", |
14 |
| - "cypress", |
15 |
| - "prettier", |
16 |
| - "patternfly-react" |
17 |
| - ], |
| 2 | + "plugins": ["eslint-comments", "promise", "unicorn"], |
18 | 3 | "extends": [
|
19 |
| - "plugin:cypress/recommended", |
20 |
| - "eslint:recommended", |
21 |
| - "plugin:@typescript-eslint/recommended", |
22 |
| - "plugin:react/recommended", |
| 4 | + "airbnb", |
| 5 | + "airbnb/hooks", |
| 6 | + "plugin:eslint-comments/recommended", |
| 7 | + "plugin:promise/recommended", |
| 8 | + "plugin:unicorn/recommended", |
| 9 | + "prettier", |
23 | 10 | "next"
|
24 | 11 | ],
|
25 |
| - "parserOptions": { |
26 |
| - "project": "./tsconfig.json", |
27 |
| - "sourceType": "module", |
28 |
| - "ecmaFeatures": { |
29 |
| - "jsx": true |
30 |
| - } |
| 12 | + "env": { |
| 13 | + "browser": true, |
| 14 | + "node": true |
31 | 15 | },
|
32 | 16 | "settings": {
|
33 | 17 | "react": {
|
34 | 18 | "version": "detect"
|
35 | 19 | }
|
36 | 20 | },
|
37 |
| - "globals": { |
38 |
| - "describe": "readonly", |
39 |
| - "test": "readonly", |
40 |
| - "jest": "readonly", |
41 |
| - "expect": "readonly", |
42 |
| - "require": "readonly", |
43 |
| - "global": "writable", |
44 |
| - "it": "readonly", |
45 |
| - "afterEach": "readonly", |
46 |
| - "beforeEach": "readonly" |
| 21 | + "parserOptions": { |
| 22 | + "project": "./tsconfig.json", |
| 23 | + "ecmaVersion": 13, |
| 24 | + "sourceType": "module", |
| 25 | + "ecmaFeatures": { |
| 26 | + "jsx": true |
| 27 | + } |
47 | 28 | },
|
48 | 29 | "rules": {
|
| 30 | + // React is already in-scope for all files compiled with Next.js |
| 31 | + "react/react-in-jsx-scope": "off", |
| 32 | + // SSR does not support useLayoutEffect |
49 | 33 | "no-restricted-imports": [
|
50 | 34 | "error",
|
51 | 35 | {
|
|
54 | 38 | "message": "`useLayoutEffect` causes a warning in SSR. Use `useEffect`"
|
55 | 39 | }
|
56 | 40 | ],
|
57 |
| - "tsdoc/syntax": "warn", |
58 |
| - "cypress/no-assigning-return-values": "error", |
59 |
| - "cypress/no-unnecessary-waiting": "error", |
60 |
| - "cypress/assertion-before-screenshot": "warn", |
61 |
| - "cypress/no-force": "warn", |
62 |
| - "cypress/no-async-tests": "error", |
63 |
| - "@typescript-eslint/no-unsafe-member-access": [0], |
64 |
| - "@typescript-eslint/no-non-null-assertion": "off", |
65 |
| - "react/react-in-jsx-scope": "off", |
66 |
| - "@typescript-eslint/adjacent-overload-signatures": "error", |
67 |
| - "@typescript-eslint/array-type": "error", |
68 |
| - "@typescript-eslint/ban-types": "error", |
69 |
| - "@typescript-eslint/consistent-type-assertions": "error", |
70 |
| - "@typescript-eslint/consistent-type-definitions": "error", |
71 |
| - "@typescript-eslint/explicit-member-accessibility": "error", |
72 |
| - "@typescript-eslint/explicit-module-boundary-types": "error", |
73 |
| - "@typescript-eslint/indent": "off", |
74 |
| - "@typescript-eslint/no-empty-function": "error", |
75 |
| - "@typescript-eslint/no-empty-interface": "error", |
76 |
| - "@typescript-eslint/no-explicit-any": "error", |
77 |
| - "@typescript-eslint/no-inferrable-types": "error", |
78 |
| - "@typescript-eslint/no-misused-new": "error", |
79 |
| - "@typescript-eslint/no-namespace": "error", |
80 |
| - "@typescript-eslint/no-unused-vars": [ |
81 |
| - "error", |
82 |
| - { |
83 |
| - "argsIgnorePattern": "^_" |
84 |
| - } |
85 |
| - ], |
86 |
| - "@typescript-eslint/no-use-before-define": "off", |
87 |
| - "@typescript-eslint/no-var-requires": "error", |
88 |
| - "@typescript-eslint/prefer-for-of": "error", |
89 |
| - "@typescript-eslint/prefer-function-type": "error", |
90 |
| - "@typescript-eslint/prefer-namespace-keyword": "error", |
91 |
| - "@typescript-eslint/unified-signatures": "error", |
92 |
| - "@typescript-eslint/explicit-function-return-type": "error", |
93 |
| - "quotes": ["error", "single"], |
94 |
| - "arrow-body-style": "error", |
| 41 | + // Enables for of and for in loops since airbnb does not allow them |
| 42 | + "no-restricted-syntax": "off", |
| 43 | + // Enforces camelcase |
95 | 44 | "camelcase": [
|
96 | 45 | "error",
|
97 | 46 | {
|
98 | 47 | "ignoreDestructuring": true
|
99 | 48 | }
|
100 | 49 | ],
|
101 |
| - "constructor-super": "error", |
102 |
| - "curly": "error", |
103 |
| - "dot-notation": "error", |
104 |
| - "eqeqeq": ["error", "smart"], |
105 |
| - "guard-for-in": "error", |
106 |
| - "max-classes-per-file": ["error", 1], |
107 |
| - "max-len": "off", |
108 |
| - "no-nested-ternary": "error", |
109 |
| - "no-bitwise": "error", |
110 |
| - "no-caller": "error", |
111 |
| - "no-cond-assign": "error", |
112 |
| - "no-console": "error", |
113 |
| - "no-debugger": "error", |
114 |
| - "no-empty": "error", |
115 |
| - "no-eval": "error", |
116 |
| - "no-new-wrappers": "error", |
117 |
| - "no-prototype-builtins": "error", |
118 |
| - "no-shadow": "off", |
119 |
| - "no-throw-literal": "error", |
120 |
| - "no-trailing-spaces": "off", |
121 |
| - "no-undef-init": "error", |
122 |
| - "no-unsafe-finally": "error", |
123 |
| - "no-unused-expressions": [ |
124 |
| - "error", |
125 |
| - { |
126 |
| - "allowTernary": true, |
127 |
| - "allowShortCircuit": true |
| 50 | + // Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins |
| 51 | + "no-prototype-builtins": "off", |
| 52 | + // Does not allow unreachable loops unless its a for of loop |
| 53 | + "no-unreachable-loop": ["error", { "ignore": ["ForInStatement", "ForOfStatement"] }], |
| 54 | + // The default case may not be necessary when explicitly knowing return types |
| 55 | + "default-case": "warn", |
| 56 | + // Can make ugly code |
| 57 | + "consistent-return": "off", |
| 58 | + // Can make ugly code |
| 59 | + "no-case-declarations": "off", |
| 60 | + // Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md |
| 61 | + "react/destructuring-assignment": "off", |
| 62 | + // No jsx extension: https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904 |
| 63 | + "react/jsx-filename-extension": "off", |
| 64 | + // Allow only arrow function based components |
| 65 | + "react/function-component-definition": [2, { "namedComponents": "arrow-function" }], |
| 66 | + // Common practice in React |
| 67 | + "react/jsx-props-no-spreading": "off", |
| 68 | + // Warn when the index is used as a key instead of a unique value |
| 69 | + "react/no-array-index-key": "warn", |
| 70 | + // Sometimes its useful to return a useless fragment instead of adding a null as a union type |
| 71 | + "react/jsx-no-useless-fragment": "warn", |
| 72 | + // Common abbreviations are known and readable |
| 73 | + "unicorn/prevent-abbreviations": "off", |
| 74 | + // Airbnb prefers forEach |
| 75 | + "unicorn/no-array-for-each": "off", |
| 76 | + // React prefers capitalized file names for components |
| 77 | + "unicorn/filename-case": "off", |
| 78 | + // Enables Array.reduce() |
| 79 | + "unicorn/no-array-reduce": "off", |
| 80 | + // https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html |
| 81 | + "import/prefer-default-export": "off", |
| 82 | + // It's not accurate in the monorepo style |
| 83 | + "import/no-extraneous-dependencies": "off", |
| 84 | + // Import for import of components |
| 85 | + "import/no-cycle": "off" |
| 86 | + }, |
| 87 | + "overrides": [ |
| 88 | + { |
| 89 | + "files": ["**/*.js"], |
| 90 | + "rules": { |
| 91 | + // Allow CJS until ESM support improves |
| 92 | + "unicorn/prefer-module": "off" |
128 | 93 | }
|
129 |
| - ], |
130 |
| - "no-unused-labels": "error", |
131 |
| - "no-var": "error", |
132 |
| - "object-shorthand": "error", |
133 |
| - "one-var": ["error", "never"], |
134 |
| - "patternfly-react/import-tokens-icons": "error", |
135 |
| - "patternfly-react/no-anonymous-functions": "error", |
136 |
| - "prefer-const": "error", |
137 |
| - "prettier/prettier": "error", |
138 |
| - "radix": ["error", "as-needed"], |
139 |
| - "react/prop-types": 0, |
140 |
| - "react/display-name": 0, |
141 |
| - "react/no-unescaped-entities": ["error", { "forbid": [">", "}"] }], |
142 |
| - "spaced-comment": "error", |
143 |
| - "use-isnan": "error" |
144 |
| - } |
| 94 | + }, |
| 95 | + { |
| 96 | + "files": ["**/*.ts", "**/*.tsx"], |
| 97 | + "plugins": ["@typescript-eslint"], |
| 98 | + "extends": [ |
| 99 | + "airbnb-typescript", |
| 100 | + "plugin:@typescript-eslint/recommended", |
| 101 | + "plugin:@typescript-eslint/recommended-requiring-type-checking" |
| 102 | + ], |
| 103 | + "parser": "@typescript-eslint/parser", |
| 104 | + "rules": { |
| 105 | + // It's not accurate in the monorepo style |
| 106 | + "import/no-extraneous-dependencies": "off", |
| 107 | + // Requires return type |
| 108 | + "@typescript-eslint/explicit-function-return-type": "error", |
| 109 | + // Allows the use of functions before definition |
| 110 | + "@typescript-eslint/no-use-before-define": ["off"], |
| 111 | + // Allows variables starting with _ to be ignored if not used |
| 112 | + "@typescript-eslint/no-unused-vars": [ |
| 113 | + "error", |
| 114 | + { |
| 115 | + "argsIgnorePattern": "^_" |
| 116 | + } |
| 117 | + ], |
| 118 | + // Disallows function overloading |
| 119 | + "@typescript-eslint/unified-signatures": "error", |
| 120 | + // Requires function return types |
| 121 | + "@typescript-eslint/prefer-function-type": "error", |
| 122 | + // Requires classes to make member access explicit |
| 123 | + "@typescript-eslint/explicit-member-accessibility": "error", |
| 124 | + // Requires the use of interface over type when possible |
| 125 | + "@typescript-eslint/consistent-type-definitions": "error", |
| 126 | + // Requires consistent type casting |
| 127 | + "@typescript-eslint/consistent-type-assertions": "error", |
| 128 | + // Requires the T[] type syntax for an array |
| 129 | + "@typescript-eslint/array-type": "error", |
| 130 | + // Next.js does not require all anchor tags to have an href |
| 131 | + "jsx-a11y/anchor-is-valid": "off" |
| 132 | + } |
| 133 | + } |
| 134 | + ] |
145 | 135 | }
|
0 commit comments