|
| 1 | +import path from 'node:path'; |
| 2 | +import { fileURLToPath } from 'node:url'; |
| 3 | + |
| 4 | +const __filename = fileURLToPath(import.meta.url); |
| 5 | +const __dirname = path.dirname(__filename); |
| 6 | + |
| 7 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 8 | +import js from '@eslint/js'; |
| 9 | +import mochaPlugin from 'eslint-plugin-mocha'; |
| 10 | +import noOnlyTestsPlugin from 'eslint-plugin-no-only-tests'; |
| 11 | +import reactPlugin from 'eslint-plugin-react'; |
| 12 | +import globals from 'globals'; |
| 13 | + |
| 14 | +const compat = new FlatCompat({ |
| 15 | + baseDirectory: __dirname, |
| 16 | + recommendedConfig: js.configs.recommended, |
| 17 | + allConfig: js.configs.all |
| 18 | +}); |
| 19 | + |
| 20 | +export default [ |
| 21 | + ...compat.extends( |
| 22 | + 'eslint:recommended', |
| 23 | + 'plugin:mocha/recommended', |
| 24 | + 'plugin:react/recommended' |
| 25 | + ), |
| 26 | + { |
| 27 | + settings: { |
| 28 | + react: { |
| 29 | + version: 'detect' |
| 30 | + } |
| 31 | + } |
| 32 | + }, |
| 33 | + { |
| 34 | + ignores: [ |
| 35 | + 'built/*', |
| 36 | + 'public/*' |
| 37 | + ] |
| 38 | + }, |
| 39 | + { |
| 40 | + languageOptions: { |
| 41 | + globals: { |
| 42 | + ...globals.node |
| 43 | + }, |
| 44 | + ecmaVersion: 2020, |
| 45 | + sourceType: 'module' |
| 46 | + }, |
| 47 | + rules: { |
| 48 | + 'comma-dangle': 2, |
| 49 | + eqeqeq: 2, |
| 50 | + 'guard-for-in': 2, |
| 51 | + 'new-cap': 0, |
| 52 | + 'no-caller': 2, |
| 53 | + 'no-console': 2, |
| 54 | + 'no-extend-native': 2, |
| 55 | + 'no-irregular-whitespace': 2, |
| 56 | + 'no-loop-func': 2, |
| 57 | + 'no-multi-spaces': 2, |
| 58 | + 'no-multiple-empty-lines': [2, { max: 1 }], |
| 59 | + 'no-undef': 2, |
| 60 | + 'no-underscore-dangle': 0, |
| 61 | + 'no-unused-vars': 2, |
| 62 | + 'no-var': 2, |
| 63 | + 'one-var': [2, 'never'], |
| 64 | + quotes: [2, 'single'], |
| 65 | + semi: 2, |
| 66 | + 'space-before-function-paren': 2, |
| 67 | + 'spaced-comment': 2, |
| 68 | + strict: [2, 'global'], |
| 69 | + 'wrap-iife': 2 |
| 70 | + } |
| 71 | + }, |
| 72 | + { |
| 73 | + files: [ |
| 74 | + '**/*.jsx' |
| 75 | + ], |
| 76 | + languageOptions: { |
| 77 | + globals: { |
| 78 | + ...globals.browser |
| 79 | + }, |
| 80 | + parserOptions: { |
| 81 | + ecmaFeatures: { |
| 82 | + jsx: true |
| 83 | + } |
| 84 | + } |
| 85 | + }, |
| 86 | + plugins: { |
| 87 | + react: reactPlugin |
| 88 | + }, |
| 89 | + rules: { |
| 90 | + 'react/react-in-jsx-scope': 0 |
| 91 | + } |
| 92 | + }, |
| 93 | + { |
| 94 | + files: [ |
| 95 | + 'test/**/*.test.js' |
| 96 | + ], |
| 97 | + languageOptions: { |
| 98 | + globals: { |
| 99 | + ...globals.mocha |
| 100 | + } |
| 101 | + }, |
| 102 | + plugins: { |
| 103 | + mocha: mochaPlugin, |
| 104 | + 'no-only-tests': noOnlyTestsPlugin |
| 105 | + }, |
| 106 | + rules: { |
| 107 | + 'mocha/no-mocha-arrows': 0, |
| 108 | + 'no-only-tests/no-only-tests': 2 |
| 109 | + } |
| 110 | + } |
| 111 | +]; |
0 commit comments