|
| 1 | +const reactPlugin = require('eslint-plugin-react'); |
| 2 | +const reactHooksPlugin = require('eslint-plugin-react-hooks'); |
| 3 | +const jsxA11yPlugin = require('eslint-plugin-jsx-a11y'); |
| 4 | +const importPlugin = require('eslint-plugin-import'); |
| 5 | +const filenamesPlugin = require('eslint-plugin-filenames'); |
| 6 | + |
| 7 | +const browserGlobals = { |
| 8 | + window: 'readonly', |
| 9 | + document: 'readonly', |
| 10 | + navigator: 'readonly', |
| 11 | + location: 'readonly', |
| 12 | + history: 'readonly', |
| 13 | + self: 'readonly', |
| 14 | + globalThis: 'readonly', |
| 15 | + console: 'readonly', |
| 16 | + alert: 'readonly', |
| 17 | + confirm: 'readonly', |
| 18 | + prompt: 'readonly', |
| 19 | + setTimeout: 'readonly', |
| 20 | + setInterval: 'readonly', |
| 21 | + clearTimeout: 'readonly', |
| 22 | + clearInterval: 'readonly', |
| 23 | + requestAnimationFrame: 'readonly', |
| 24 | + cancelAnimationFrame: 'readonly', |
| 25 | + fetch: 'readonly', |
| 26 | + XMLHttpRequest: 'readonly', |
| 27 | + localStorage: 'readonly', |
| 28 | + sessionStorage: 'readonly', |
| 29 | + URL: 'readonly', |
| 30 | + URLSearchParams: 'readonly', |
| 31 | + Blob: 'readonly', |
| 32 | + File: 'readonly', |
| 33 | + FileReader: 'readonly', |
| 34 | + FormData: 'readonly', |
| 35 | + event: 'readonly', |
| 36 | + Event: 'readonly', |
| 37 | + EventTarget: 'readonly', |
| 38 | + CustomEvent: 'readonly', |
| 39 | + MouseEvent: 'readonly', |
| 40 | + KeyboardEvent: 'readonly', |
| 41 | + HTMLElement: 'readonly', |
| 42 | + HTMLInputElement: 'readonly', |
| 43 | + HTMLSelectElement: 'readonly', |
| 44 | + Element: 'readonly', |
| 45 | + Node: 'readonly', |
| 46 | + MutationObserver: 'readonly', |
| 47 | + IntersectionObserver: 'readonly', |
| 48 | + ResizeObserver: 'readonly', |
| 49 | + Worker: 'readonly', |
| 50 | + CSS: 'readonly', |
| 51 | + performance: 'readonly', |
| 52 | + crypto: 'readonly', |
| 53 | + atob: 'readonly', |
| 54 | + btoa: 'readonly', |
| 55 | + getComputedStyle: 'readonly', |
| 56 | +}; |
| 57 | + |
| 58 | +const nodeGlobals = { |
| 59 | + process: 'readonly', |
| 60 | + require: 'readonly', |
| 61 | + module: 'writable', |
| 62 | + exports: 'writable', |
| 63 | + __dirname: 'readonly', |
| 64 | + __filename: 'readonly', |
| 65 | + global: 'readonly', |
| 66 | + Buffer: 'readonly', |
| 67 | + setImmediate: 'readonly', |
| 68 | + clearImmediate: 'readonly', |
| 69 | + queueMicrotask: 'readonly', |
| 70 | +}; |
| 71 | + |
| 72 | +const es6Globals = { |
| 73 | + Promise: 'readonly', |
| 74 | + Symbol: 'readonly', |
| 75 | + Map: 'readonly', |
| 76 | + Set: 'readonly', |
| 77 | + WeakMap: 'readonly', |
| 78 | + WeakSet: 'readonly', |
| 79 | + WeakRef: 'readonly', |
| 80 | + Proxy: 'readonly', |
| 81 | + Reflect: 'readonly', |
| 82 | + ArrayBuffer: 'readonly', |
| 83 | + DataView: 'readonly', |
| 84 | + SharedArrayBuffer: 'readonly', |
| 85 | + Atomics: 'readonly', |
| 86 | + BigInt: 'readonly', |
| 87 | + Int8Array: 'readonly', |
| 88 | + Uint8Array: 'readonly', |
| 89 | + Uint8ClampedArray: 'readonly', |
| 90 | + Int16Array: 'readonly', |
| 91 | + Uint16Array: 'readonly', |
| 92 | + Int32Array: 'readonly', |
| 93 | + Uint32Array: 'readonly', |
| 94 | + Float32Array: 'readonly', |
| 95 | + Float64Array: 'readonly', |
| 96 | + BigInt64Array: 'readonly', |
| 97 | + BigUint64Array: 'readonly', |
| 98 | +}; |
| 99 | + |
| 100 | +const mochaGlobals = { |
| 101 | + describe: 'readonly', |
| 102 | + it: 'readonly', |
| 103 | + before: 'readonly', |
| 104 | + after: 'readonly', |
| 105 | + beforeEach: 'readonly', |
| 106 | + afterEach: 'readonly', |
| 107 | + context: 'readonly', |
| 108 | + specify: 'readonly', |
| 109 | + suite: 'readonly', |
| 110 | + test: 'readonly', |
| 111 | + suiteSetup: 'readonly', |
| 112 | + suiteTeardown: 'readonly', |
| 113 | + setup: 'readonly', |
| 114 | + teardown: 'readonly', |
| 115 | + run: 'readonly', |
| 116 | + mocha: 'readonly', |
| 117 | +}; |
| 118 | + |
| 119 | +module.exports = [ |
| 120 | + { |
| 121 | + files: ['**/*.js', '**/*.jsx'], |
| 122 | + plugins: { |
| 123 | + react: reactPlugin, |
| 124 | + 'react-hooks': reactHooksPlugin, |
| 125 | + 'jsx-a11y': jsxA11yPlugin, |
| 126 | + import: importPlugin, |
| 127 | + filenames: filenamesPlugin, |
| 128 | + }, |
| 129 | + languageOptions: { |
| 130 | + ecmaVersion: 2022, |
| 131 | + sourceType: 'module', |
| 132 | + parserOptions: { |
| 133 | + allowImportExportEverywhere: true, |
| 134 | + ecmaFeatures: { |
| 135 | + jsx: true, |
| 136 | + }, |
| 137 | + }, |
| 138 | + globals: { |
| 139 | + ...browserGlobals, |
| 140 | + ...nodeGlobals, |
| 141 | + ...es6Globals, |
| 142 | + ...mochaGlobals, |
| 143 | + }, |
| 144 | + }, |
| 145 | + settings: { |
| 146 | + react: { |
| 147 | + version: 'detect', |
| 148 | + }, |
| 149 | + 'import/extensions': ['.js'], |
| 150 | + 'import/resolver': { |
| 151 | + node: { |
| 152 | + extensions: ['.js'], |
| 153 | + }, |
| 154 | + webpack: { |
| 155 | + config: 'webpack.config.js', |
| 156 | + }, |
| 157 | + }, |
| 158 | + }, |
| 159 | + rules: { |
| 160 | + ...jsxA11yPlugin.flatConfigs.recommended.rules, |
| 161 | + 'jsx-a11y/no-autofocus': [2, { ignoreNonDOM: true }], |
| 162 | + 'no-console': 'off', |
| 163 | + semi: 2, |
| 164 | + 'no-undef': 2, |
| 165 | + 'no-undef-init': 2, |
| 166 | + 'no-tabs': 2, |
| 167 | + 'react/self-closing-comp': 2, |
| 168 | + 'react/jsx-no-duplicate-props': 'warn', |
| 169 | + 'react-hooks/rules-of-hooks': 'error', |
| 170 | + 'react-hooks/exhaustive-deps': 'warn', |
| 171 | + }, |
| 172 | + }, |
| 173 | +]; |
0 commit comments