|
| 1 | +module.exports = { |
| 2 | + root: true, |
| 3 | + plugins: [ |
| 4 | + "@typescript-eslint", |
| 5 | + "react", |
| 6 | + "react-native", |
| 7 | + "jest", |
| 8 | + "import", |
| 9 | + "react-compiler", |
| 10 | + "eslint-comments", |
| 11 | + "prettier", |
| 12 | + "react-perf", |
| 13 | + "jsdoc", |
| 14 | + ], |
| 15 | + extends: [ |
| 16 | + "@react-native", |
| 17 | + "prettier", |
| 18 | + "eslint:recommended", |
| 19 | + "plugin:@typescript-eslint/recommended", |
| 20 | + "plugin:jest/recommended", |
| 21 | + "plugin:import/typescript", |
| 22 | + "plugin:eslint-comments/recommended", |
| 23 | + "plugin:react-perf/recommended", |
| 24 | + ], |
| 25 | + settings: { |
| 26 | + "import/parsers": { |
| 27 | + "@typescript-eslint/parser": [".ts", ".tsx"], |
| 28 | + }, |
| 29 | + "import/resolver": { |
| 30 | + typescript: { |
| 31 | + alwaysTryTypes: true, |
| 32 | + project: "<root>/tsconfig.json", |
| 33 | + }, |
| 34 | + }, |
| 35 | + }, |
| 36 | + rules: { |
| 37 | + "prettier/prettier": [ |
| 38 | + "error", |
| 39 | + { |
| 40 | + quoteProps: "consistent", |
| 41 | + trailingComma: "all", |
| 42 | + }, |
| 43 | + ], |
| 44 | + // react-hooks |
| 45 | + "react-hooks/exhaustive-deps": "warn", |
| 46 | + // react |
| 47 | + "react/jsx-sort-props": [ |
| 48 | + "error", |
| 49 | + { |
| 50 | + callbacksLast: true, |
| 51 | + shorthandFirst: true, |
| 52 | + shorthandLast: false, |
| 53 | + ignoreCase: true, |
| 54 | + noSortAlphabetically: false, |
| 55 | + reservedFirst: ["ref", "key"], |
| 56 | + }, |
| 57 | + ], |
| 58 | + "react/jsx-no-bind": [ |
| 59 | + "warn", |
| 60 | + { |
| 61 | + // should be an error, but we need to fix a lot of places |
| 62 | + ignoreDOMComponents: false, |
| 63 | + ignoreRefs: false, |
| 64 | + allowArrowFunctions: false, |
| 65 | + allowFunctions: false, |
| 66 | + allowBind: false, |
| 67 | + }, |
| 68 | + ], |
| 69 | + // react-perf |
| 70 | + "react-perf/jsx-no-new-function-as-prop": "off", // because we have jsx-no-bind |
| 71 | + "react-perf/jsx-no-jsx-as-prop": "warn", |
| 72 | + "react-perf/jsx-no-new-array-as-prop": "warn", |
| 73 | + "react-perf/jsx-no-new-object-as-prop": "warn", |
| 74 | + // typescript |
| 75 | + "@typescript-eslint/consistent-type-imports": [ |
| 76 | + "error", |
| 77 | + { prefer: "type-imports" }, |
| 78 | + ], |
| 79 | + "@typescript-eslint/no-import-type-side-effects": "error", |
| 80 | + "@typescript-eslint/no-var-requires": "warn", |
| 81 | + // import |
| 82 | + "sort-imports": [ |
| 83 | + "error", |
| 84 | + { |
| 85 | + // sort destructure imports |
| 86 | + ignoreCase: false, |
| 87 | + ignoreDeclarationSort: true, |
| 88 | + ignoreMemberSort: false, |
| 89 | + memberSyntaxSortOrder: ["none", "all", "single", "multiple"], |
| 90 | + allowSeparatedGroups: true, |
| 91 | + }, |
| 92 | + ], |
| 93 | + "import/order": [ |
| 94 | + "error", |
| 95 | + { |
| 96 | + "groups": [ |
| 97 | + "builtin", |
| 98 | + "external", |
| 99 | + "internal", |
| 100 | + "parent", |
| 101 | + "sibling", |
| 102 | + "index", |
| 103 | + "type", |
| 104 | + ], |
| 105 | + "alphabetize": { |
| 106 | + order: "asc", |
| 107 | + caseInsensitive: true, |
| 108 | + }, |
| 109 | + "newlines-between": "always", |
| 110 | + }, |
| 111 | + ], |
| 112 | + "import/no-cycle": ["error", { maxDepth: "∞" }], |
| 113 | + // jest |
| 114 | + "jest/expect-expect": [ |
| 115 | + "warn", |
| 116 | + { |
| 117 | + assertFunctionNames: [ |
| 118 | + "expect", |
| 119 | + "expectBitmapsToBeEqual", |
| 120 | + "expectElementBitmapsToBeEqual", |
| 121 | + ], |
| 122 | + additionalTestBlockFunctions: [], |
| 123 | + }, |
| 124 | + ], |
| 125 | + // react-compiler |
| 126 | + "react-compiler/react-compiler": "error", |
| 127 | + // eslint-comments |
| 128 | + "eslint-comments/no-unused-disable": "error", |
| 129 | + // eslint |
| 130 | + "curly": "error", |
| 131 | + "eqeqeq": ["error", "always"], // check “===” |
| 132 | + "no-nested-ternary": "error", |
| 133 | + "padding-line-between-statements": [ |
| 134 | + "error", |
| 135 | + { |
| 136 | + blankLine: "always", |
| 137 | + prev: "*", |
| 138 | + next: ["return", "try", "throw", "function", "for", "while", "do"], |
| 139 | + }, |
| 140 | + { blankLine: "always", prev: ["const", "let", "var"], next: "*" }, |
| 141 | + { |
| 142 | + blankLine: "any", |
| 143 | + prev: ["const", "let", "var"], |
| 144 | + next: ["const", "let", "var"], |
| 145 | + }, |
| 146 | + { blankLine: "always", prev: "*", next: "if" }, |
| 147 | + { blankLine: "any", prev: "if", next: "if" }, |
| 148 | + ], |
| 149 | + "no-param-reassign": "error", |
| 150 | + "max-lines": ["warn", { max: 300 }], |
| 151 | + }, |
| 152 | + overrides: [ |
| 153 | + { |
| 154 | + files: ["src/specs/**"], |
| 155 | + rules: { |
| 156 | + "@typescript-eslint/ban-types": [ |
| 157 | + "error", |
| 158 | + { |
| 159 | + extendDefaults: true, |
| 160 | + types: { |
| 161 | + "{}": false, |
| 162 | + }, |
| 163 | + }, |
| 164 | + ], |
| 165 | + }, |
| 166 | + }, |
| 167 | + { |
| 168 | + files: ["src/**"], |
| 169 | + excludedFiles: ["src/specs/**"], |
| 170 | + rules: { |
| 171 | + "jsdoc/check-access": "error", |
| 172 | + "jsdoc/check-alignment": "error", |
| 173 | + "jsdoc/check-indentation": 1, |
| 174 | + "jsdoc/check-line-alignment": 1, |
| 175 | + "jsdoc/check-param-names": "error", |
| 176 | + "jsdoc/check-template-names": 1, |
| 177 | + "jsdoc/check-property-names": "error", |
| 178 | + "jsdoc/check-syntax": 1, |
| 179 | + "jsdoc/check-tag-names": ["error", { definedTags: ["platform"] }], |
| 180 | + "jsdoc/check-types": "error", |
| 181 | + "jsdoc/check-values": "error", |
| 182 | + "jsdoc/empty-tags": "error", |
| 183 | + "jsdoc/implements-on-classes": "error", |
| 184 | + "jsdoc/informative-docs": 1, |
| 185 | + "jsdoc/match-description": 1, |
| 186 | + "jsdoc/multiline-blocks": "error", |
| 187 | + "jsdoc/no-bad-blocks": 1, |
| 188 | + "jsdoc/no-blank-block-descriptions": 1, |
| 189 | + "jsdoc/no-defaults": 1, |
| 190 | + "jsdoc/no-multi-asterisks": "error", |
| 191 | + "jsdoc/no-types": 1, |
| 192 | + "jsdoc/require-asterisk-prefix": 1, |
| 193 | + "jsdoc/require-description": 1, |
| 194 | + "jsdoc/require-description-complete-sentence": 1, |
| 195 | + "jsdoc/require-example": 1, |
| 196 | + "jsdoc/require-hyphen-before-param-description": 1, |
| 197 | + "jsdoc/require-jsdoc": "error", |
| 198 | + "jsdoc/require-param": "error", |
| 199 | + "jsdoc/require-param-description": "error", |
| 200 | + "jsdoc/require-param-name": "error", |
| 201 | + "jsdoc/require-property": "error", |
| 202 | + "jsdoc/require-property-description": "error", |
| 203 | + "jsdoc/require-property-name": "error", |
| 204 | + "jsdoc/require-returns": "error", |
| 205 | + "jsdoc/require-returns-check": "error", |
| 206 | + "jsdoc/require-returns-description": "error", |
| 207 | + "jsdoc/require-template": 1, |
| 208 | + "jsdoc/require-throws": 1, |
| 209 | + "jsdoc/require-yields": "error", |
| 210 | + "jsdoc/require-yields-check": "error", |
| 211 | + "jsdoc/sort-tags": 1, |
| 212 | + "jsdoc/tag-lines": ["error", "never", { startLines: 1 }], |
| 213 | + "jsdoc/valid-types": "error", |
| 214 | + "jsdoc/no-restricted-syntax": "off", |
| 215 | + "jsdoc/require-file-overview": "off", |
| 216 | + "jsdoc/no-missing-syntax": "off", |
| 217 | + "jsdoc/check-examples": "off", |
| 218 | + "jsdoc/no-undefined-types": "off", |
| 219 | + "jsdoc/require-param-type": "off", |
| 220 | + "jsdoc/require-property-type": "off", |
| 221 | + "jsdoc/require-returns-type": "off", |
| 222 | + }, |
| 223 | + }, |
| 224 | + ], |
| 225 | + env: { |
| 226 | + "react-native/react-native": true, |
| 227 | + "jest/globals": true, |
| 228 | + }, |
| 229 | + ignorePatterns: ["node_modules/**", "lib/**", "scripts/**", "docs/build/**"], |
| 230 | +}; |
0 commit comments