|
| 1 | +module.exports = { |
| 2 | + root: true, |
| 3 | + reportUnusedDisableDirectives: true, |
| 4 | + overrides: [ |
| 5 | + // Docusaurus, Storybook |
| 6 | + { |
| 7 | + files: [ |
| 8 | + 'apps/*-docs/**/*', |
| 9 | + 'apps/*-storybook/**/*', |
| 10 | + 'examples/docusaurus/**/*', |
| 11 | + 'examples/storybook/**/*', |
| 12 | + ], |
| 13 | + rules: { |
| 14 | + 'import/no-extraneous-dependencies': 'off', |
| 15 | + }, |
| 16 | + }, |
| 17 | + ], |
| 18 | + parserOptions: { |
| 19 | + parser: "@typescript-eslint/parser", |
| 20 | + project: "./tsconfig.json", |
| 21 | + }, |
| 22 | + plugins: ['react-perf', 'relay', '@typescript-eslint'], |
| 23 | + extends: [ |
| 24 | + 'airbnb-typescript/base', |
| 25 | + 'airbnb/rules/react', |
| 26 | + 'airbnb/rules/react-a11y', |
| 27 | + 'plugin:relay/strict', |
| 28 | + ], |
| 29 | + rules: { |
| 30 | + 'react/destructuring-assignment': 'off', |
| 31 | + 'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx', '.mdx'] }], |
| 32 | + |
| 33 | + // We utilize prop spreading |
| 34 | + 'react/jsx-props-no-spreading': 'off', |
| 35 | + |
| 36 | + // We utilize class properties |
| 37 | + 'react/state-in-constructor': 'off', |
| 38 | + |
| 39 | + // Dont use prop types since were using TypeScript |
| 40 | + 'react/default-props-match-prop-types': 'off', |
| 41 | + 'react/forbid-foreign-prop-types': 'off', |
| 42 | + 'react/forbid-prop-types': 'off', |
| 43 | + 'react/no-unused-prop-types': 'off', |
| 44 | + 'react/prefer-read-only-props': 'off', |
| 45 | + 'react/prop-types': 'off', |
| 46 | + 'react/require-default-props': 'off', |
| 47 | + 'react/sort-prop-types': 'off', |
| 48 | + |
| 49 | + // Performance: Avoid unnecessary renders |
| 50 | + 'react-perf/jsx-no-new-array-as-prop': 'warn', |
| 51 | + 'react-perf/jsx-no-new-function-as-prop': 'warn', |
| 52 | + 'react-perf/jsx-no-new-object-as-prop': ['warn', { nativeAllowList: ['style'] }], |
| 53 | + |
| 54 | + // We prefer function declarations |
| 55 | + 'react/function-component-definition': [ |
| 56 | + 'error', |
| 57 | + { namedComponents: 'function-declaration', unnamedComponents: 'function-expression' }, |
| 58 | + ], |
| 59 | + |
| 60 | + // We prefer on/handle named events |
| 61 | + 'react/jsx-handler-names': 'error', |
| 62 | + |
| 63 | + // We require named functions for inferred `displayName` |
| 64 | + // This is required for memo() and forwardRef() usage |
| 65 | + 'prefer-arrow-callback': ['error', { allowNamedFunctions: true }], |
| 66 | + |
| 67 | + 'react/jsx-one-expression-per-line': 'off', |
| 68 | + |
| 69 | + // We dont use flow |
| 70 | + 'relay/generated-flow-types': 'off', |
| 71 | + |
| 72 | + // Shorthand types |
| 73 | + '@typescript-eslint/array-type': ['error', { default: 'array' }], |
| 74 | + '@typescript-eslint/consistent-indexed-object-style': ['error', 'record'], |
| 75 | + '@typescript-eslint/consistent-type-definitions': ['error', 'type'], |
| 76 | + '@typescript-eslint/method-signature-style': ['error', 'property'], |
| 77 | + '@typescript-eslint/no-inferrable-types': 'error', |
| 78 | + |
| 79 | + // Forbid types |
| 80 | + '@typescript-eslint/ban-types': 'error', |
| 81 | + '@typescript-eslint/no-explicit-any': ['error', { fixToUnknown: true }], |
| 82 | + '@typescript-eslint/no-invalid-void-type': 'error', |
| 83 | + '@typescript-eslint/no-unsafe-argument': 'error', |
| 84 | + '@typescript-eslint/no-unsafe-assignment': 'error', |
| 85 | + '@typescript-eslint/no-unsafe-call': 'error', |
| 86 | + '@typescript-eslint/no-unsafe-return': 'error', |
| 87 | + |
| 88 | + // Readability |
| 89 | + '@typescript-eslint/adjacent-overload-signatures': 'error', |
| 90 | + '@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: false }], |
| 91 | + '@typescript-eslint/no-parameter-properties': 'error', |
| 92 | + '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error', |
| 93 | + |
| 94 | + // Correctness |
| 95 | + '@typescript-eslint/switch-exhaustiveness-check': 'error', |
| 96 | + '@typescript-eslint/no-for-in-array': 'error', |
| 97 | + '@typescript-eslint/no-misused-new': 'error', |
| 98 | + '@typescript-eslint/no-this-alias': 'error', |
| 99 | + '@typescript-eslint/no-unnecessary-qualifier': 'error', |
| 100 | + '@typescript-eslint/no-unnecessary-type-assertion': 'error', |
| 101 | + '@typescript-eslint/no-unnecessary-type-constraint': 'error', |
| 102 | + '@typescript-eslint/prefer-for-of': 'error', |
| 103 | + '@typescript-eslint/prefer-literal-enum-member': 'error', |
| 104 | + '@typescript-eslint/restrict-plus-operands': ['error', { checkCompoundAssignments: true }], |
| 105 | + '@typescript-eslint/unified-signatures': 'error', |
| 106 | + |
| 107 | + // Assertions |
| 108 | + '@typescript-eslint/consistent-type-assertions': 'error', |
| 109 | + '@typescript-eslint/no-confusing-non-null-assertion': 'error', |
| 110 | + '@typescript-eslint/no-extra-non-null-assertion': 'error', |
| 111 | + '@typescript-eslint/no-non-null-assertion': 'error', |
| 112 | + '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', |
| 113 | + '@typescript-eslint/prefer-as-const': 'error', |
| 114 | + |
| 115 | + // Comments |
| 116 | + '@typescript-eslint/ban-ts-comment': ['error', { 'ts-expect-error': 'allow-with-description' }], |
| 117 | + '@typescript-eslint/prefer-ts-expect-error': 'error', |
| 118 | + '@typescript-eslint/triple-slash-reference': [ |
| 119 | + 'error', |
| 120 | + { path: 'never', types: 'never', lib: 'never' }, |
| 121 | + ], |
| 122 | + |
| 123 | + // Async |
| 124 | + 'no-void': 'off', |
| 125 | + '@typescript-eslint/await-thenable': 'error', |
| 126 | + '@typescript-eslint/no-floating-promises': 'error', |
| 127 | + '@typescript-eslint/no-misused-promises': 'error', |
| 128 | + '@typescript-eslint/promise-function-async': 'error', |
| 129 | + |
| 130 | + // APIs |
| 131 | + '@typescript-eslint/prefer-includes': 'error', |
| 132 | + '@typescript-eslint/prefer-nullish-coalescing': 'error', |
| 133 | + '@typescript-eslint/prefer-optional-chain': 'error', |
| 134 | + '@typescript-eslint/prefer-string-starts-ends-with': 'error', |
| 135 | + |
| 136 | + // Hard to migrate |
| 137 | + // Errors for all try/catch blocks and any types from third-parties |
| 138 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 139 | + |
| 140 | + } |
| 141 | +} |
0 commit comments