|
| 1 | +import js from '@eslint/js'; |
| 2 | +import globals from 'globals'; |
| 3 | +import babelParser from '@babel/eslint-parser'; |
| 4 | +import tsParser from '@typescript-eslint/parser'; |
| 5 | +import tsPlugin from '@typescript-eslint/eslint-plugin'; |
| 6 | +import reactPlugin from 'eslint-plugin-react'; |
| 7 | +import jestPlugin from 'eslint-plugin-jest'; |
| 8 | + |
| 9 | +const sharedRules = { |
| 10 | + 'array-callback-return': ['warn'], |
| 11 | + 'eqeqeq': ['off', 'always', { null: 'ignore' }], |
| 12 | + 'new-parens': ['warn'], |
| 13 | + 'no-array-constructor': ['warn'], |
| 14 | + 'no-caller': ['warn'], |
| 15 | + 'no-cond-assign': ['warn', 'always'], |
| 16 | + 'no-eval': ['warn'], |
| 17 | + 'no-extend-native': ['warn'], |
| 18 | + 'no-extra-bind': ['warn'], |
| 19 | + 'no-implied-eval': ['warn'], |
| 20 | + 'no-iterator': ['warn'], |
| 21 | + 'no-lone-blocks': ['warn'], |
| 22 | + 'no-loop-func': ['warn'], |
| 23 | + 'no-multi-str': ['warn'], |
| 24 | + 'no-global-assign': ['warn'], |
| 25 | + 'no-new-wrappers': ['warn'], |
| 26 | + 'no-script-url': ['warn'], |
| 27 | + 'no-self-compare': ['warn'], |
| 28 | + 'no-shadow-restricted-names': ['warn'], |
| 29 | + 'no-template-curly-in-string': ['warn'], |
| 30 | + 'no-throw-literal': ['warn'], |
| 31 | + 'no-useless-computed-key': ['warn'], |
| 32 | + 'no-useless-concat': ['warn'], |
| 33 | + 'no-useless-rename': ['warn'], |
| 34 | + 'no-whitespace-before-property': ['warn'], |
| 35 | +}; |
| 36 | + |
| 37 | +export default [ |
| 38 | + // Global ignores (replaces .eslintignore) |
| 39 | + { |
| 40 | + ignores: [ |
| 41 | + '**/node_modules/**', |
| 42 | + '**/lib/**', |
| 43 | + '**/output/**', |
| 44 | + '**/dist/**', |
| 45 | + '**/docs/**', |
| 46 | + '**/tmp/**', |
| 47 | + 'packages/styleguide/Sandbox.tsx', |
| 48 | + ], |
| 49 | + }, |
| 50 | + |
| 51 | + // Base recommended rules for all files |
| 52 | + js.configs.recommended, |
| 53 | + |
| 54 | + // JS/JSX files |
| 55 | + { |
| 56 | + files: ['**/*.{js,jsx}'], |
| 57 | + plugins: { |
| 58 | + react: reactPlugin, |
| 59 | + }, |
| 60 | + languageOptions: { |
| 61 | + parser: babelParser, |
| 62 | + parserOptions: { |
| 63 | + sourceType: 'module', |
| 64 | + requireConfigFile: false, |
| 65 | + }, |
| 66 | + globals: { |
| 67 | + ...globals.browser, |
| 68 | + ...globals.es2021, |
| 69 | + ...globals.node, |
| 70 | + ...globals.jest, |
| 71 | + }, |
| 72 | + }, |
| 73 | + settings: { |
| 74 | + react: { |
| 75 | + version: 'detect', |
| 76 | + }, |
| 77 | + }, |
| 78 | + rules: { |
| 79 | + ...sharedRules, |
| 80 | + 'no-console': ['warn', { allow: ['warn', 'error', 'reportException', 'info'] }], |
| 81 | + 'no-unused-vars': ['warn', { args: 'none', ignoreRestSiblings: true }], |
| 82 | + 'no-use-before-define': ['warn'], |
| 83 | + 'no-useless-constructor': ['warn'], |
| 84 | + 'no-unreachable': ['warn'], |
| 85 | + 'no-constant-condition': ['warn'], |
| 86 | + 'no-case-declarations': ['off'], |
| 87 | + |
| 88 | + // React |
| 89 | + ...reactPlugin.configs.flat.recommended.rules, |
| 90 | + 'react/prop-types': ['off'], |
| 91 | + 'react/no-unescaped-entities': ['off'], |
| 92 | + 'react/style-prop-object': ['warn'], |
| 93 | + 'react/no-children-props': ['off'], |
| 94 | + }, |
| 95 | + }, |
| 96 | + |
| 97 | + // TS/TSX files |
| 98 | + { |
| 99 | + files: ['**/*.{ts,tsx}'], |
| 100 | + plugins: { |
| 101 | + '@typescript-eslint': tsPlugin, |
| 102 | + react: reactPlugin, |
| 103 | + jest: jestPlugin, |
| 104 | + }, |
| 105 | + languageOptions: { |
| 106 | + parser: tsParser, |
| 107 | + parserOptions: { |
| 108 | + sourceType: 'module', |
| 109 | + project: [ |
| 110 | + 'packages/react-drylus/tsconfig.json', |
| 111 | + 'packages/styleguide/tsconfig.json', |
| 112 | + 'packages/drylus-style-vars/tsconfig.json', |
| 113 | + ], |
| 114 | + }, |
| 115 | + globals: { |
| 116 | + ...globals.browser, |
| 117 | + ...globals.es2021, |
| 118 | + ...globals.node, |
| 119 | + ...globals.commonjs, |
| 120 | + }, |
| 121 | + }, |
| 122 | + settings: { |
| 123 | + react: { |
| 124 | + version: 'detect', |
| 125 | + }, |
| 126 | + }, |
| 127 | + rules: { |
| 128 | + ...sharedRules, |
| 129 | + ...jestPlugin.configs['flat/recommended'].rules, |
| 130 | + 'no-console': ['warn', { allow: ['warn', 'error', 'reportException'] }], |
| 131 | + |
| 132 | + // TypeScript overrides |
| 133 | + 'no-undef': ['off'], |
| 134 | + 'no-unused-vars': ['off'], |
| 135 | + '@typescript-eslint/no-unused-vars': ['warn', { ignoreRestSiblings: true }], |
| 136 | + 'no-useless-constructor': ['off'], |
| 137 | + '@typescript-eslint/no-useless-constructor': ['warn'], |
| 138 | + 'no-use-before-define': ['off'], |
| 139 | + '@typescript-eslint/no-use-before-define': ['warn', { functions: false, variables: false }], |
| 140 | + |
| 141 | + // React |
| 142 | + ...reactPlugin.configs.flat.recommended.rules, |
| 143 | + 'react/prop-types': ['off'], |
| 144 | + 'react/no-unescaped-entities': ['off'], |
| 145 | + 'react/style-prop-object': ['warn'], |
| 146 | + 'react/display-name': ['off'], |
| 147 | + 'react/no-children-props': ['off'], |
| 148 | + 'react/no-unknown-property': ['error', { ignore: ['mask-type'] }], |
| 149 | + }, |
| 150 | + }, |
| 151 | + |
| 152 | + // Icon build scripts — allow console |
| 153 | + { |
| 154 | + files: ['packages/icons/scripts/**/*.js'], |
| 155 | + rules: { |
| 156 | + 'no-console': 'off', |
| 157 | + }, |
| 158 | + }, |
| 159 | +]; |
0 commit comments