|
| 1 | +module.exports = { |
| 2 | + "parser": "@typescript-eslint/parser", |
| 3 | + "env": { |
| 4 | + "browser": true, |
| 5 | + "node": true |
| 6 | + }, |
| 7 | + // tell the TypeScript parser that we want to use JSX syntax |
| 8 | + "parserOptions": { |
| 9 | + "tsx": true, |
| 10 | + "jsx": true, |
| 11 | + "js": true, |
| 12 | + "useJSXTextNode": true, |
| 13 | + "project": "./tsconfig.json", |
| 14 | + "tsconfigRootDir": __dirname |
| 15 | + }, |
| 16 | + // includes the typescript specific rules found here: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules |
| 17 | + "plugins": [ |
| 18 | + "@typescript-eslint", |
| 19 | + "react-hooks", |
| 20 | + "eslint-plugin-react-hooks", |
| 21 | + "import", |
| 22 | + "no-only-tests", |
| 23 | + "no-relative-import-paths", |
| 24 | + "prettier" |
| 25 | + ], |
| 26 | + "extends": [ |
| 27 | + "eslint:recommended", |
| 28 | + "plugin:jsx-a11y/recommended", |
| 29 | + "plugin:react/recommended", |
| 30 | + "plugin:@typescript-eslint/recommended", |
| 31 | + "plugin:prettier/recommended", |
| 32 | + "prettier" |
| 33 | + ], |
| 34 | + "globals": { |
| 35 | + "window": "readonly", |
| 36 | + "describe": "readonly", |
| 37 | + "test": "readonly", |
| 38 | + "expect": "readonly", |
| 39 | + "it": "readonly", |
| 40 | + "process": "readonly", |
| 41 | + "document": "readonly" |
| 42 | + }, |
| 43 | + "settings": { |
| 44 | + "react": { |
| 45 | + "version": "detect" |
| 46 | + }, |
| 47 | + "import/parsers": { |
| 48 | + "@typescript-eslint/parser": [".ts", ".tsx"] |
| 49 | + }, |
| 50 | + "import/resolver": { |
| 51 | + "typescript": { |
| 52 | + "project": "." |
| 53 | + } |
| 54 | + } |
| 55 | + }, |
| 56 | + "rules": { |
| 57 | + "jsx-a11y/no-autofocus": ["error", { "ignoreNonDOM": true }], |
| 58 | + "jsx-a11y/anchor-is-valid": [ |
| 59 | + "error", |
| 60 | + { |
| 61 | + "components": ["Link"], |
| 62 | + "specialLink": ["to"], |
| 63 | + "aspects": ["noHref", "invalidHref", "preferButton"] |
| 64 | + } |
| 65 | + ], |
| 66 | + "react/jsx-boolean-value": "error", |
| 67 | + "react/jsx-fragments": "error", |
| 68 | + "react/jsx-no-constructed-context-values": "error", |
| 69 | + "react/no-unused-prop-types": "error", |
| 70 | + "arrow-body-style": "error", |
| 71 | + "curly": "error", |
| 72 | + "no-only-tests/no-only-tests": "error", |
| 73 | + "@typescript-eslint/default-param-last": "error", |
| 74 | + "@typescript-eslint/dot-notation": ["error", { "allowKeywords": true }], |
| 75 | + "@typescript-eslint/method-signature-style": "error", |
| 76 | + "@typescript-eslint/naming-convention": [ |
| 77 | + "error", |
| 78 | + { |
| 79 | + "selector": "variable", |
| 80 | + "format": ["camelCase", "PascalCase", "UPPER_CASE"] |
| 81 | + }, |
| 82 | + { |
| 83 | + "selector": "function", |
| 84 | + "format": ["camelCase", "PascalCase"] |
| 85 | + }, |
| 86 | + { |
| 87 | + "selector": "typeLike", |
| 88 | + "format": ["PascalCase"] |
| 89 | + } |
| 90 | + ], |
| 91 | + "@typescript-eslint/no-unused-expressions": [ |
| 92 | + "error", |
| 93 | + { |
| 94 | + "allowShortCircuit": false, |
| 95 | + "allowTernary": false, |
| 96 | + "allowTaggedTemplates": false |
| 97 | + } |
| 98 | + ], |
| 99 | + "@typescript-eslint/no-redeclare": "error", |
| 100 | + "@typescript-eslint/no-shadow": "error", |
| 101 | + "@typescript-eslint/return-await": ["error", "in-try-catch"], |
| 102 | + "camelcase": "warn", |
| 103 | + "no-else-return": ["error", { "allowElseIf": false }], |
| 104 | + "eqeqeq": ["error", "always", { "null": "ignore" }], |
| 105 | + "react/jsx-curly-brace-presence": [2, { "props": "never", "children": "never" }], |
| 106 | + "object-shorthand": ["error", "always"], |
| 107 | + "no-console": "error", |
| 108 | + "no-param-reassign": [ |
| 109 | + "error", |
| 110 | + { |
| 111 | + "props": true, |
| 112 | + "ignorePropertyModificationsFor": ["acc", "e"], |
| 113 | + "ignorePropertyModificationsForRegex": ["^assignable[A-Z]"] |
| 114 | + } |
| 115 | + ], |
| 116 | + "@typescript-eslint/no-base-to-string": "error", |
| 117 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 118 | + "@typescript-eslint/interface-name-prefix": "off", |
| 119 | + "@typescript-eslint/no-var-requires": "off", |
| 120 | + "@typescript-eslint/no-empty-function": "error", |
| 121 | + "@typescript-eslint/no-inferrable-types": "error", |
| 122 | + "@typescript-eslint/no-unused-vars": "error", |
| 123 | + "@typescript-eslint/explicit-module-boundary-types": "error", |
| 124 | + "react/self-closing-comp": "error", |
| 125 | + "@typescript-eslint/no-unnecessary-condition": "error", |
| 126 | + "react-hooks/exhaustive-deps": "error", |
| 127 | + "prefer-destructuring": [ |
| 128 | + "error", |
| 129 | + { |
| 130 | + "VariableDeclarator": { |
| 131 | + "array": false, |
| 132 | + "object": true |
| 133 | + }, |
| 134 | + "AssignmentExpression": { |
| 135 | + "array": true, |
| 136 | + "object": false |
| 137 | + } |
| 138 | + }, |
| 139 | + { |
| 140 | + "enforceForRenamedProperties": false |
| 141 | + } |
| 142 | + ], |
| 143 | + "react-hooks/rules-of-hooks": "error", |
| 144 | + "import/extensions": "off", |
| 145 | + "import/no-unresolved": "off", |
| 146 | + "import/order": [ |
| 147 | + "error", |
| 148 | + { |
| 149 | + "pathGroups": [ |
| 150 | + { |
| 151 | + "pattern": "~/**", |
| 152 | + "group": "external", |
| 153 | + "position": "after" |
| 154 | + } |
| 155 | + ], |
| 156 | + "pathGroupsExcludedImportTypes": ["builtin"], |
| 157 | + "groups": [ |
| 158 | + "builtin", |
| 159 | + "external", |
| 160 | + "internal", |
| 161 | + "index", |
| 162 | + "sibling", |
| 163 | + "parent", |
| 164 | + "object", |
| 165 | + "unknown" |
| 166 | + ] |
| 167 | + } |
| 168 | + ], |
| 169 | + "no-restricted-properties": [ |
| 170 | + "error", |
| 171 | + { |
| 172 | + "property": "sort", |
| 173 | + "message": "Avoid using .sort, use .toSorted instead." |
| 174 | + } |
| 175 | + ], |
| 176 | + "import/newline-after-import": "error", |
| 177 | + "import/no-duplicates": "error", |
| 178 | + "import/no-named-as-default": "error", |
| 179 | + "import/no-extraneous-dependencies": [ |
| 180 | + "error", |
| 181 | + { |
| 182 | + "devDependencies": true, |
| 183 | + "optionalDependencies": true |
| 184 | + } |
| 185 | + ], |
| 186 | + "no-relative-import-paths/no-relative-import-paths": [ |
| 187 | + "warn", |
| 188 | + { |
| 189 | + "allowSameFolder": true, |
| 190 | + "rootDir": "src", |
| 191 | + "prefix": "~" |
| 192 | + } |
| 193 | + ], |
| 194 | + "prettier/prettier": [ |
| 195 | + "error", |
| 196 | + { |
| 197 | + "arrowParens": "always", |
| 198 | + "singleQuote": true, |
| 199 | + "trailingComma": "all", |
| 200 | + "printWidth": 100 |
| 201 | + } |
| 202 | + ], |
| 203 | + "react/prop-types": "off", |
| 204 | + "array-callback-return": ["error", { "allowImplicit": true }], |
| 205 | + "prefer-template": "error", |
| 206 | + "no-lone-blocks": "error", |
| 207 | + "no-lonely-if": "error", |
| 208 | + "no-promise-executor-return": "error", |
| 209 | + "no-restricted-globals": [ |
| 210 | + "error", |
| 211 | + { |
| 212 | + "name": "isFinite", |
| 213 | + "message": "Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite" |
| 214 | + }, |
| 215 | + { |
| 216 | + "name": "isNaN", |
| 217 | + "message": "Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan" |
| 218 | + } |
| 219 | + ], |
| 220 | + "no-sequences": "error", |
| 221 | + "no-undef-init": "error", |
| 222 | + "no-unneeded-ternary": ["error", { "defaultAssignment": false }], |
| 223 | + "no-useless-computed-key": "error", |
| 224 | + "no-useless-return": "error", |
| 225 | + "symbol-description": "error", |
| 226 | + "yoda": "error", |
| 227 | + "func-names": "warn" |
| 228 | + }, |
| 229 | + "overrides": [ |
| 230 | + { |
| 231 | + "files": ["./src/api/**"], |
| 232 | + "rules": { |
| 233 | + "no-restricted-imports": [ |
| 234 | + "off", |
| 235 | + { |
| 236 | + "patterns": ["~/api/**"] |
| 237 | + } |
| 238 | + ] |
| 239 | + } |
| 240 | + }, |
| 241 | + { |
| 242 | + "files": ["./src/__tests__/cypress/**/*.ts"], |
| 243 | + "parserOptions": { |
| 244 | + "project": ["./src/__tests__/cypress/tsconfig.json"] |
| 245 | + }, |
| 246 | + "extends": [ |
| 247 | + "eslint:recommended", |
| 248 | + "plugin:react/recommended", |
| 249 | + "plugin:@typescript-eslint/recommended", |
| 250 | + "plugin:prettier/recommended", |
| 251 | + "prettier", |
| 252 | + "plugin:cypress/recommended" |
| 253 | + ] |
| 254 | + }, |
| 255 | + { |
| 256 | + "files": ["*.ts", "*.tsx"], |
| 257 | + "excludedFiles": ["**/__mocks__/**", "**/__tests__/**"], |
| 258 | + "rules": { |
| 259 | + "@typescript-eslint/consistent-type-assertions": [ |
| 260 | + "error", |
| 261 | + { |
| 262 | + "assertionStyle": "never" |
| 263 | + } |
| 264 | + ] |
| 265 | + } |
| 266 | + }, |
| 267 | + { |
| 268 | + "files": ["src/__tests__/cypress/**"], |
| 269 | + "rules": { |
| 270 | + "@typescript-eslint/consistent-type-imports": "error", |
| 271 | + "no-restricted-imports": [ |
| 272 | + "error", |
| 273 | + { |
| 274 | + "patterns": [ |
| 275 | + { |
| 276 | + "group": [ |
| 277 | + "@patternfly/**" |
| 278 | + ], |
| 279 | + "message": "Cypress tests should only import mocks and types from outside the Cypress test directory." |
| 280 | + } |
| 281 | + ] |
| 282 | + } |
| 283 | + ] |
| 284 | + } |
| 285 | + } |
| 286 | + ] |
| 287 | +} |
0 commit comments