|
1 | | -import js from '@eslint/js' |
2 | | -import globals from 'globals' |
3 | | -import reactHooks from 'eslint-plugin-react-hooks' |
4 | | -import reactRefresh from 'eslint-plugin-react-refresh' |
| 1 | +// import js from '@eslint/js' |
| 2 | +import globals from "globals"; |
| 3 | +import reactHooks from "eslint-plugin-react-hooks"; |
| 4 | +import reactRefresh from "eslint-plugin-react-refresh"; |
| 5 | +import tseslint from "typescript-eslint"; |
| 6 | +import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"; |
5 | 7 |
|
6 | 8 | export default [ |
| 9 | + ...tseslint.configs.recommended, |
| 10 | + eslintPluginPrettierRecommended, |
7 | 11 | { |
8 | | - ignores: ['dist'], |
9 | | - }, |
10 | | - js.configs.recommended, |
11 | | - { |
12 | | - files: ['**/*.{js,jsx}'], |
| 12 | + files: ["**/*.{js,jsx,ts,tsx}"], |
13 | 13 | plugins: { |
14 | | - 'react-hooks': reactHooks, |
15 | | - 'react-refresh': reactRefresh, |
16 | | - }, |
17 | | - languageOptions: { |
18 | | - ecmaVersion: 2020, |
19 | | - globals: globals.browser, |
20 | | - parserOptions: { |
21 | | - ecmaVersion: 'latest', |
22 | | - ecmaFeatures: { jsx: true }, |
23 | | - sourceType: 'module', |
24 | | - }, |
| 14 | + "react-hooks": reactHooks, |
| 15 | + "react-refresh": reactRefresh, |
25 | 16 | }, |
26 | 17 | rules: { |
27 | 18 | ...reactHooks.configs.recommended.rules, |
28 | | - 'react-refresh/only-export-components': [ |
29 | | - 'warn', |
| 19 | + "react-refresh/only-export-components": [ |
| 20 | + "warn", |
30 | 21 | { allowConstantExport: true }, |
31 | 22 | ], |
32 | | - 'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }], |
| 23 | + // 允许在 effect 中调用异步函数,只要状态更新在异步回调中 |
| 24 | + "react-hooks/set-state-in-effect": "off", |
| 25 | + }, |
| 26 | + languageOptions: { |
| 27 | + globals: globals.browser, |
33 | 28 | }, |
34 | 29 | }, |
35 | | -] |
| 30 | +]; |
0 commit comments