|
| 1 | +'use strict' |
| 2 | + |
| 3 | +module.exports = { |
| 4 | + parser: '@typescript-eslint/parser', |
| 5 | + parserOptions: { |
| 6 | + ecmaFeatures: { |
| 7 | + jsx: true, |
| 8 | + }, |
| 9 | + }, |
| 10 | + extends: [ |
| 11 | + 'plugin:react/recommended', |
| 12 | + 'plugin:jsx-a11y/recommended', |
| 13 | + 'plugin:react-hooks/recommended', |
| 14 | + 'plugin:prettier/recommended', |
| 15 | + 'plugin:github/recommended', |
| 16 | + 'plugin:github/browser', |
| 17 | + 'plugin:primer-react/recommended', |
| 18 | + 'plugin:import/typescript', |
| 19 | + ], |
| 20 | + settings: { |
| 21 | + react: { |
| 22 | + version: 'detect', |
| 23 | + }, |
| 24 | + 'import/parsers': { |
| 25 | + '@typescript-eslint/parser': ['.js', '.jsx', '.ts', '.tsx'], |
| 26 | + 'eslint-mdx': ['.mdx'], |
| 27 | + }, |
| 28 | + 'import/resolver': { |
| 29 | + node: true, |
| 30 | + typescript: true, |
| 31 | + }, |
| 32 | + }, |
| 33 | + ignorePatterns: [ |
| 34 | + 'node_modules', |
| 35 | + '.cache', |
| 36 | + 'coverage/**/*', |
| 37 | + 'docs/public/**/*', |
| 38 | + 'dist/**/*', |
| 39 | + 'lib/**/*', |
| 40 | + 'lib-*/**/*', |
| 41 | + 'types/**/*', |
| 42 | + 'consumer-test/**/*', |
| 43 | + 'contributor-docs/adrs/*', |
| 44 | + 'examples/nextjs/**', |
| 45 | + // Note: this file is inlined from an external dependency |
| 46 | + 'src/utils/polymorphic.ts', |
| 47 | + 'storybook-static', |
| 48 | + 'CHANGELOG.md', |
| 49 | + ], |
| 50 | + globals: { |
| 51 | + __DEV__: 'readonly', |
| 52 | + }, |
| 53 | + env: { |
| 54 | + browser: true, |
| 55 | + commonjs: true, |
| 56 | + es6: true, |
| 57 | + jest: true, |
| 58 | + node: true, |
| 59 | + }, |
| 60 | + // rules which apply to JS, TS, etc. |
| 61 | + rules: { |
| 62 | + 'no-shadow': 'off', |
| 63 | + 'react/prop-types': 'off', |
| 64 | + 'react/display-name': 'off', |
| 65 | + 'react-hooks/exhaustive-deps': 'error', |
| 66 | + 'jsx-a11y/label-has-for': [ |
| 67 | + 2, |
| 68 | + { |
| 69 | + components: [], |
| 70 | + }, |
| 71 | + ], |
| 72 | + camelcase: [ |
| 73 | + 'error', |
| 74 | + { |
| 75 | + allow: ['dark_dimmed'], |
| 76 | + }, |
| 77 | + ], |
| 78 | + 'primer-react/no-deprecated-colors': ['warn', {checkAllStrings: true}], |
| 79 | + |
| 80 | + // Overrides from updating plugin:github |
| 81 | + 'filenames/match-regex': 'off', |
| 82 | + 'import/extensions': 'off', |
| 83 | + 'import/namespace': 'off', |
| 84 | + 'import/no-commonjs': 'off', |
| 85 | + 'import/no-nodejs-modules': 'off', |
| 86 | + 'import/no-dynamic-require': 'off', |
| 87 | + 'import/no-unresolved': 'off', |
| 88 | + 'i18n-text/no-en': 'off', |
| 89 | + 'github/no-inner-html': 'off', |
| 90 | + 'github/role-supports-aria-props': 'off', |
| 91 | + 'no-restricted-syntax': 'off', |
| 92 | + }, |
| 93 | + overrides: [ |
| 94 | + // rules which apply only to JS |
| 95 | + { |
| 96 | + files: ['**/*.{js,jsx}'], |
| 97 | + rules: { |
| 98 | + 'eslint-comments/no-use': 'off', |
| 99 | + 'import/no-namespace': 'off', |
| 100 | + 'import/no-named-as-default': 'off', |
| 101 | + 'import/no-named-as-default-member': 'off', |
| 102 | + 'no-unused-vars': [ |
| 103 | + 'error', |
| 104 | + { |
| 105 | + ignoreRestSiblings: true, |
| 106 | + }, |
| 107 | + ], |
| 108 | + }, |
| 109 | + }, |
| 110 | + |
| 111 | + // rules which apply only to TS |
| 112 | + { |
| 113 | + parserOptions: { |
| 114 | + project: 'tsconfig.json', |
| 115 | + }, |
| 116 | + files: ['**/*.{ts,tsx}'], |
| 117 | + extends: ['plugin:@typescript-eslint/recommended'], |
| 118 | + rules: { |
| 119 | + '@typescript-eslint/no-explicit-any': 2, |
| 120 | + '@typescript-eslint/no-unnecessary-condition': 2, |
| 121 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 122 | + '@typescript-eslint/no-unused-vars': [ |
| 123 | + 'error', |
| 124 | + { |
| 125 | + argsIgnorePattern: '^_', |
| 126 | + }, |
| 127 | + ], |
| 128 | + '@typscript-eslint/no-shadow': 'off', |
| 129 | + '@typescript-eslint/no-empty-function': 'off', |
| 130 | + '@typescript-eslint/ban-ts-comment': [ |
| 131 | + 'error', |
| 132 | + { |
| 133 | + 'ts-ignore': 'allow-with-description', |
| 134 | + }, |
| 135 | + ], |
| 136 | + 'import/default': 'off', |
| 137 | + 'import/no-deprecated': 'off', |
| 138 | + 'import/no-named-as-default': 'off', |
| 139 | + 'import/no-named-as-default-member': 'off', |
| 140 | + 'no-restricted-imports': [ |
| 141 | + 'error', |
| 142 | + { |
| 143 | + paths: [ |
| 144 | + { |
| 145 | + name: '@react-aria/ssr', |
| 146 | + importNames: ['useSSRSafeId'], |
| 147 | + message: 'Please use the `useId` hook from `src/hooks/useId.ts` instead', |
| 148 | + }, |
| 149 | + ], |
| 150 | + patterns: [], |
| 151 | + }, |
| 152 | + ], |
| 153 | + }, |
| 154 | + }, |
| 155 | + |
| 156 | + // Tests |
| 157 | + { |
| 158 | + files: ['src/**/*.test.{ts,tsx}'], |
| 159 | + extends: ['plugin:jest/recommended'], |
| 160 | + rules: { |
| 161 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 162 | + 'jest/expect-expect': 'off', |
| 163 | + 'jest/no-conditional-expect': 'off', |
| 164 | + 'jest/no-disabled-tests': 'off', |
| 165 | + }, |
| 166 | + }, |
| 167 | + |
| 168 | + // Stories |
| 169 | + { |
| 170 | + files: ['**/*.stories.{ts,tsx}'], |
| 171 | + extends: ['plugin:storybook/recommended'], |
| 172 | + rules: {}, |
| 173 | + }, |
| 174 | + |
| 175 | + // e2e tests |
| 176 | + { |
| 177 | + files: ['playwright.config.ts', 'e2e/**/*.{ts,tsx}'], |
| 178 | + parserOptions: { |
| 179 | + project: 'tsconfig.json', |
| 180 | + }, |
| 181 | + rules: { |
| 182 | + 'github/array-foreach': 'off', |
| 183 | + }, |
| 184 | + }, |
| 185 | + |
| 186 | + // rules which apply only to Markdown |
| 187 | + { |
| 188 | + files: ['**/*.{md,mdx}'], |
| 189 | + extends: ['plugin:mdx/recommended'], |
| 190 | + settings: { |
| 191 | + 'mdx/code-blocks': true, |
| 192 | + }, |
| 193 | + rules: { |
| 194 | + 'no-unused-vars': 'off', |
| 195 | + 'prettier/prettier': 'off', |
| 196 | + 'react/jsx-no-undef': 'off', |
| 197 | + }, |
| 198 | + }, |
| 199 | + |
| 200 | + // rules which apply only to Markdown code blocks |
| 201 | + { |
| 202 | + files: ['**/*.{md,mdx}/**'], |
| 203 | + parserOptions: { |
| 204 | + project: false, |
| 205 | + }, |
| 206 | + rules: { |
| 207 | + camelcase: 'off', |
| 208 | + 'no-constant-condition': 'off', |
| 209 | + 'no-console': 'off', |
| 210 | + 'no-empty-pattern': 'off', |
| 211 | + 'no-unused-vars': 'off', |
| 212 | + 'no-undef': 'off', |
| 213 | + 'react/no-unescaped-entities': 'off', |
| 214 | + 'react/react-in-jsx-scope': 'off', |
| 215 | + 'react/jsx-no-undef': 'off', |
| 216 | + 'react/jsx-key': 'off', |
| 217 | + 'react/jsx-no-comment-textnodes': 'off', |
| 218 | + 'import/no-anonymous-default-export': 'off', |
| 219 | + 'prettier/prettier': 'off', |
| 220 | + // These a11y rules should eventually be re-enabled |
| 221 | + 'jsx-a11y/anchor-is-valid': 'off', |
| 222 | + 'jsx-a11y/accessible-emoji': 'off', |
| 223 | + 'jsx-a11y/label-has-for': 'off', |
| 224 | + '@typescript-eslint/no-unnecessary-condition': 'off', |
| 225 | + '@typescript-eslint/no-unused-vars': 'off', |
| 226 | + 'primer-react/no-deprecated-colors': ['error', {skipImportCheck: true}], |
| 227 | + 'no-redeclare': 'off', |
| 228 | + }, |
| 229 | + }, |
| 230 | + ], |
| 231 | +} |
0 commit comments