|
19 | 19 | "version": "detect"
|
20 | 20 | }
|
21 | 21 | },
|
22 |
| - "plugins": ["react", "react-hooks"], |
23 |
| - "extends": [ |
24 |
| - "eslint:recommended", |
25 |
| - "plugin:react-hooks/recommended", |
26 |
| - "prettier", |
27 |
| - "plugin:react/recommended", |
28 |
| - "plugin:@typescript-eslint/recommended", |
29 |
| - "plugin:import/typescript", |
30 |
| - "airbnb", |
31 |
| - "airbnb-typescript", |
32 |
| - "plugin:prettier/recommended" |
33 |
| - ], |
34 |
| - "rules": { |
35 |
| - "react-hooks/rules-of-hooks": "error", |
36 |
| - "react-hooks/exhaustive-deps": "warn", |
37 |
| - "react/prop-types": "off", |
38 |
| - "react/jsx-uses-react": "error", |
39 |
| - "react/jsx-uses-vars": "error", |
40 |
| - "no-console": ["error", { "allow": ["warn", "error"] }], |
41 |
| - "react/react-in-jsx-scope": "off", |
42 |
| - "react/display-name": 0, |
43 |
| - "import/no-extraneous-dependencies": 0, |
44 |
| - "import/prefer-default-export": 0, |
45 |
| - "import/no-cycle": 0, |
46 |
| - "@typescript-eslint/no-explicit-any": 0, |
47 |
| - "@typescript-eslint/lines-between-class-members": "off", |
48 |
| - "prettier/prettier": ["error"], |
49 |
| - "consistent-return": 0, |
50 |
| - "@typescript-eslint/no-throw-literal": 0, |
51 |
| - "no-underscore-dangle": 0, |
52 |
| - "react/function-component-definition": 0, |
53 |
| - "react/no-unused-prop-types": 0, |
54 |
| - "react/no-array-index-key": 0, |
55 |
| - "react/jsx-no-useless-fragment": 0, |
56 |
| - "react/jsx-props-no-spreading": 0, |
57 |
| - "react/require-default-props": 0, |
58 |
| - "react/no-unknown-property": 0, |
59 |
| - "testing-library/render-result-naming-convention": "off", |
60 |
| - "import/order": [ |
61 |
| - "error", |
62 |
| - { |
63 |
| - "groups": [ |
64 |
| - ["builtin", "external"], |
65 |
| - ["internal", "parent", "sibling", "index"] |
| 22 | + |
| 23 | + "overrides": [ |
| 24 | + { |
| 25 | + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], |
| 26 | + "plugins": ["react", "react-hooks", "eslint-plugin-prettier", "tree-shaking"], |
| 27 | + "extends": [ |
| 28 | + "eslint:recommended", |
| 29 | + "plugin:react-hooks/recommended", |
| 30 | + "prettier", |
| 31 | + "plugin:react/recommended", |
| 32 | + "plugin:@typescript-eslint/recommended", |
| 33 | + "plugin:import/typescript", |
| 34 | + "airbnb", |
| 35 | + "airbnb-typescript", |
| 36 | + "plugin:prettier/recommended" |
| 37 | + ], |
| 38 | + "rules": { |
| 39 | + "react-hooks/rules-of-hooks": "error", |
| 40 | + "react-hooks/exhaustive-deps": "warn", |
| 41 | + "react/prop-types": "off", |
| 42 | + "react/jsx-uses-react": "error", |
| 43 | + "react/jsx-uses-vars": "error", |
| 44 | + "no-console": ["error", { "allow": ["warn", "error"] }], |
| 45 | + "react/react-in-jsx-scope": "off", |
| 46 | + "no-continue": "off", |
| 47 | + "react/display-name": 0, |
| 48 | + "import/no-extraneous-dependencies": 0, |
| 49 | + "import/prefer-default-export": 0, |
| 50 | + "import/no-cycle": 0, |
| 51 | + "import/no-default-export": ["error"], |
| 52 | + "max-lines": ["error", 400], |
| 53 | + "@typescript-eslint/no-explicit-any": "error", |
| 54 | + "@typescript-eslint/lines-between-class-members": "off", |
| 55 | + "prettier/prettier": ["error"], |
| 56 | + "consistent-return": 0, |
| 57 | + "@typescript-eslint/no-throw-literal": 0, |
| 58 | + "no-underscore-dangle": 0, |
| 59 | + "react/jsx-props-no-spreading": 0, |
| 60 | + "react/function-component-definition": 0, |
| 61 | + "react/require-default-props": 0, |
| 62 | + "testing-library/render-result-naming-convention": "off", |
| 63 | + "max-params": ["error", 3], |
| 64 | + "no-param-reassign": [ |
| 65 | + "error", |
| 66 | + { |
| 67 | + "props": true, |
| 68 | + "ignorePropertyModificationsFor": ["draft", "acc"] |
| 69 | + } |
66 | 70 | ],
|
67 |
| - "pathGroups": [ |
68 |
| - { "pattern": "assets/**", "group": "sibling", "position": "after" }, |
| 71 | + "tree-shaking/no-side-effects-in-initialization": [ |
| 72 | + 2, |
69 | 73 | {
|
70 |
| - "pattern": "@external/**/*.css", |
71 |
| - "group": "sibling", |
72 |
| - "position": "after" |
73 |
| - }, |
| 74 | + "noSideEffectsWhenCalled": [ |
| 75 | + { "function": "Object.freeze" }, |
| 76 | + { |
| 77 | + "module": "react", |
| 78 | + "functions": ["createContext", "createRef", "forwardRef", "memo"] |
| 79 | + } |
| 80 | + ] |
| 81 | + } |
| 82 | + ], |
| 83 | + "import/order": [ |
| 84 | + "error", |
74 | 85 | {
|
75 |
| - "pattern": "*.css", |
76 |
| - "group": "index", |
77 |
| - "patternOptions": { "matchBase": true }, |
78 |
| - "position": "after" |
| 86 | + "groups": [ |
| 87 | + ["builtin", "external"], |
| 88 | + ["internal", "parent", "sibling", "index"] |
| 89 | + ], |
| 90 | + "pathGroups": [ |
| 91 | + { "pattern": "assets/**", "group": "sibling", "position": "after" }, |
| 92 | + { |
| 93 | + "pattern": "*.style{s,x}", |
| 94 | + "group": "sibling", |
| 95 | + "patternOptions": { "matchBase": true }, |
| 96 | + "position": "after" |
| 97 | + } |
| 98 | + ], |
| 99 | + "warnOnUnassignedImports": true, |
| 100 | + "pathGroupsExcludedImportTypes": ["css"], |
| 101 | + "newlines-between": "always" |
79 | 102 | }
|
80 | 103 | ],
|
81 |
| - "warnOnUnassignedImports": true, |
82 |
| - "pathGroupsExcludedImportTypes": ["css"], |
83 |
| - "newlines-between": "always" |
| 104 | + "@typescript-eslint/naming-convention": [ |
| 105 | + "error", |
| 106 | + // destructured variables come from other places so no format is enforced |
| 107 | + { |
| 108 | + "selector": "variable", |
| 109 | + "modifiers": ["destructured"], |
| 110 | + "format": null |
| 111 | + }, |
| 112 | + // functions defined as constants must be constants (not var/let) |
| 113 | + { |
| 114 | + "selector": "variable", |
| 115 | + "types": ["function"], |
| 116 | + "modifiers": ["const"], |
| 117 | + "format": ["camelCase", "PascalCase"] |
| 118 | + }, |
| 119 | + // Constants can also be camelCase apart from UPPER_CASE |
| 120 | + // - functional components (PascalCase) |
| 121 | + { |
| 122 | + "selector": "variable", |
| 123 | + "modifiers": ["const"], |
| 124 | + "format": ["UPPER_CASE", "camelCase", "PascalCase"] |
| 125 | + }, |
| 126 | + // functions can be: |
| 127 | + // - regular functions (camelCase) |
| 128 | + { |
| 129 | + "selector": "function", |
| 130 | + "format": ["camelCase"] |
| 131 | + }, |
| 132 | + // forbid lower case |
| 133 | + { |
| 134 | + "selector": "typeLike", |
| 135 | + "format": ["PascalCase"] |
| 136 | + }, |
| 137 | + // forbid lower case |
| 138 | + { |
| 139 | + "selector": "typeParameter", |
| 140 | + "format": ["PascalCase"] |
| 141 | + }, |
| 142 | + // Uppercase enums |
| 143 | + { |
| 144 | + "selector": "enumMember", |
| 145 | + "format": ["UPPER_CASE"] |
| 146 | + } |
| 147 | + ] |
84 | 148 | }
|
85 |
| - ] |
86 |
| - }, |
87 |
| - "overrides": [ |
| 149 | + }, |
88 | 150 | {
|
89 |
| - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], |
| 151 | + "files": ["*.mdx"], |
| 152 | + "rules": { |
| 153 | + "react/jsx-filename-extension": "off" |
| 154 | + } |
| 155 | + }, |
| 156 | + { |
| 157 | + "files": ["**/__tests__/**/*"], |
90 | 158 | "rules": {
|
91 |
| - "testing-library/render-result-naming-convention": "off" |
| 159 | + "max-lines": "off", |
| 160 | + "tree-shaking/no-side-effects-in-initialization": 0 |
92 | 161 | }
|
| 162 | + }, |
| 163 | + { |
| 164 | + // IMPORTANT: DO NOT ADD `*styles.{ts,tsx}` or `contexts.{ts,tsx}` here, we should keep all styles in stylex files! |
| 165 | + // File naming must be consistent across the whole project |
| 166 | + "files": [ |
| 167 | + "*theme.ts", |
| 168 | + "*context.ts", |
| 169 | + "**/__stories__/**/*", |
| 170 | + "**/__docs__/**/*", |
| 171 | + "*.stylex.{ts,tsx}", |
| 172 | + "**/jest.setup.ts" |
| 173 | + ], |
| 174 | + "rules": { |
| 175 | + "tree-shaking/no-side-effects-in-initialization": 0 |
| 176 | + } |
| 177 | + }, |
| 178 | + { |
| 179 | + "files": ["*.md", "*.mdx"], |
| 180 | + "extends": "plugin:mdx/recommended" |
93 | 181 | }
|
94 | 182 | ]
|
95 | 183 | }
|
0 commit comments