|
| 1 | +import cypress from 'eslint-plugin-cypress'; |
| 2 | +import reactHooks from 'eslint-plugin-react-hooks'; |
| 3 | +import { fixupPluginRules } from '@eslint/compat'; |
| 4 | +import globals from 'globals'; |
| 5 | +import babelParser from '@babel/eslint-parser'; |
| 6 | +import path from 'node:path'; |
| 7 | +import { fileURLToPath } from 'node:url'; |
| 8 | +import js from '@eslint/js'; |
| 9 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 10 | + |
| 11 | +const __filename = fileURLToPath(import.meta.url); |
| 12 | +const __dirname = path.dirname(__filename); |
| 13 | +const compat = new FlatCompat({ |
| 14 | + baseDirectory: __dirname, |
| 15 | + recommendedConfig: js.configs.recommended, |
| 16 | + allConfig: js.configs.all, |
| 17 | +}); |
| 18 | + |
| 19 | +export default [ |
| 20 | + { |
| 21 | + ignores: [ |
| 22 | + '**/dist/', |
| 23 | + '**/examples/', |
| 24 | + 'src/content/loaders/_*.mdx', |
| 25 | + 'src/content/plugins/_*.mdx', |
| 26 | + '.github/**/*.md', |
| 27 | + '**/README.md', |
| 28 | + ], |
| 29 | + }, |
| 30 | + ...compat.extends( |
| 31 | + 'eslint:recommended', |
| 32 | + 'plugin:react/recommended', |
| 33 | + 'prettier' |
| 34 | + ), |
| 35 | + { |
| 36 | + plugins: { |
| 37 | + cypress, |
| 38 | + 'react-hooks': fixupPluginRules(reactHooks), |
| 39 | + }, |
| 40 | + |
| 41 | + languageOptions: { |
| 42 | + globals: { |
| 43 | + ...globals.browser, |
| 44 | + ...globals.node, |
| 45 | + ...globals.jest, |
| 46 | + ...cypress.environments.globals.globals, |
| 47 | + }, |
| 48 | + |
| 49 | + parser: babelParser, |
| 50 | + }, |
| 51 | + |
| 52 | + settings: { |
| 53 | + react: { |
| 54 | + version: 'detect', |
| 55 | + }, |
| 56 | + }, |
| 57 | + |
| 58 | + rules: { |
| 59 | + 'no-console': 'off', |
| 60 | + semi: ['error', 'always'], |
| 61 | + quotes: ['error', 'single'], |
| 62 | + 'no-duplicate-imports': 'error', |
| 63 | + 'react/jsx-uses-react': 'off', |
| 64 | + 'react/react-in-jsx-scope': 'off', |
| 65 | + 'react-hooks/rules-of-hooks': 'error', |
| 66 | + 'react-hooks/exhaustive-deps': 'warn', |
| 67 | + |
| 68 | + 'react/no-unknown-property': [ |
| 69 | + 'error', |
| 70 | + { |
| 71 | + ignore: ['watch', 'align'], |
| 72 | + }, |
| 73 | + ], |
| 74 | + }, |
| 75 | + }, |
| 76 | + { |
| 77 | + files: ['src/**/*.jsx'], |
| 78 | + }, |
| 79 | + ...compat.extends('plugin:mdx/recommended').map((config) => ({ |
| 80 | + ...config, |
| 81 | + files: ['**/*.mdx'], |
| 82 | + })), |
| 83 | + { |
| 84 | + files: ['**/*.mdx'], |
| 85 | + |
| 86 | + languageOptions: { |
| 87 | + globals: { |
| 88 | + Badge: true, |
| 89 | + StackBlitzPreview: true, |
| 90 | + }, |
| 91 | + }, |
| 92 | + |
| 93 | + settings: { |
| 94 | + 'mdx/code-blocks': true, |
| 95 | + }, |
| 96 | + |
| 97 | + rules: { |
| 98 | + semi: ['off'], |
| 99 | + }, |
| 100 | + }, |
| 101 | + { |
| 102 | + files: ['**/*.mdx/*.{js,javascript}'], |
| 103 | + |
| 104 | + rules: { |
| 105 | + indent: ['error', 2], |
| 106 | + |
| 107 | + quotes: [ |
| 108 | + 'error', |
| 109 | + 'single', |
| 110 | + { |
| 111 | + allowTemplateLiterals: true, |
| 112 | + }, |
| 113 | + ], |
| 114 | + |
| 115 | + 'no-undef': 'off', |
| 116 | + 'no-unused-vars': 'off', |
| 117 | + 'no-constant-condition': 'off', |
| 118 | + 'no-useless-escape': 'off', |
| 119 | + 'no-dupe-keys': 'off', |
| 120 | + 'no-duplicate-imports': 'off', |
| 121 | + }, |
| 122 | + }, |
| 123 | +]; |
0 commit comments