From ce437dccf180c89dfe6a7e75857353a67a3112cf Mon Sep 17 00:00:00 2001 From: Aron Date: Tue, 10 Dec 2024 10:37:36 +0800 Subject: [PATCH] Add(ESLint Config): `eslint-plugin-react-hooks` plugin --- packages/eslint-config/configs/react.js | 18 ++++++++++-------- packages/eslint-config/configs/stylistic.js | 5 +---- packages/eslint-config/package.json | 3 ++- pnpm-lock.yaml | 12 ++++++++++++ vue-project/.vscode/settings.json | 11 +++++++++++ 5 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 vue-project/.vscode/settings.json diff --git a/packages/eslint-config/configs/react.js b/packages/eslint-config/configs/react.js index 0b4030d..c5d300e 100644 --- a/packages/eslint-config/configs/react.js +++ b/packages/eslint-config/configs/react.js @@ -1,17 +1,19 @@ -const reactPlugin = require('eslint-plugin-react') -const reactHooksPlugin = require('eslint-plugin-react-hooks') +const react = require('eslint-plugin-react') +const reactHooks = require('eslint-plugin-react-hooks') +const reactRefresh = require('eslint-plugin-react-refresh') /** @type {import('eslint').Linter.Config} */ module.exports = { - ...reactPlugin.configs.flat.recommended, + ...react.configs.flat.recommended, rules: { - ...reactPlugin.configs['jsx-runtime'].rules, - ...reactHooksPlugin.configs.recommended.rules, + ...react.configs['jsx-runtime'].rules, + ...reactHooks.configs.recommended.rules, 'react/display-name': 'off' }, plugins: { - 'react': reactPlugin, - 'react-hooks': reactHooksPlugin, + 'react': react, + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, }, - files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'], + files: ['**/*.{js,mjs,cjs,ts,cts,mts,jsx,mjsx,tsx,mtsx}'], } diff --git a/packages/eslint-config/configs/stylistic.js b/packages/eslint-config/configs/stylistic.js index bba0de8..23b81b2 100644 --- a/packages/eslint-config/configs/stylistic.js +++ b/packages/eslint-config/configs/stylistic.js @@ -7,8 +7,5 @@ module.exports = { 'quotes': ['error', 'single', { 'allowTemplateLiterals': true }], 'semi': ['error', 'never'] }, - files: [ - '**/*.js', '**/*.jsx', '**/*.mjs', '**/*.cjs', - '**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts' - ], + files: ['**/*.{js,mjs,cjs,ts,cts,mts,jsx,mjsx,tsx,mtsx}'], } \ No newline at end of file diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 2d26fce..9de0591 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -48,6 +48,7 @@ "eslint": "*", "typescript": "*", "eslint-plugin-react": "*", - "eslint-plugin-react-hooks": "*" + "eslint-plugin-react-hooks": "*", + "eslint-plugin-react-refresh": "*" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8000fad..22d64e2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -163,6 +163,9 @@ importers: eslint-plugin-react-hooks: specifier: '*' version: 5.0.0(eslint@9.15.0(jiti@1.21.0)) + eslint-plugin-react-refresh: + specifier: '*' + version: 0.4.16(eslint@9.15.0(jiti@1.21.0)) typescript: specifier: '*' version: 5.7.2 @@ -2366,6 +2369,11 @@ packages: peerDependencies: eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 + eslint-plugin-react-refresh@0.4.16: + resolution: {integrity: sha512-slterMlxAhov/DZO8NScf6mEeMBBXodFUolijDvrtTxyezyLoTQaa73FyYus/VbTdftd8wBgBxPMRk3poleXNQ==} + peerDependencies: + eslint: '>=8.40' + eslint-plugin-react@7.37.2: resolution: {integrity: sha512-EsTAnj9fLVr/GZleBLFbj/sSuXeWmp1eXIN60ceYnZveqEaUCyW4X+Vh4WTdUhCkW4xutXYqTXCUSyqD4rB75w==} engines: {node: '>=4'} @@ -7094,6 +7102,10 @@ snapshots: dependencies: eslint: 9.15.0(jiti@1.21.0) + eslint-plugin-react-refresh@0.4.16(eslint@9.15.0(jiti@1.21.0)): + dependencies: + eslint: 9.15.0(jiti@1.21.0) + eslint-plugin-react@7.37.2(eslint@9.15.0(jiti@1.21.0)): dependencies: array-includes: 3.1.8 diff --git a/vue-project/.vscode/settings.json b/vue-project/.vscode/settings.json new file mode 100644 index 0000000..72d9f19 --- /dev/null +++ b/vue-project/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.patterns": { + "tsconfig.json": "tsconfig.*.json, env.d.ts", + "vite.config.*": "jsconfig*, vitest.config.*, cypress.config.*, playwright.config.*", + "package.json": "package-lock.json, pnpm*, .yarnrc*, yarn*, .eslint*, eslint*, .prettier*, prettier*, .editorconfig" + }, + "editor.codeActionsOnSave": { + "source.fixAll": "explicit" + } +}