From 1149044308fb204fd499869d2f5f449396dfefc4 Mon Sep 17 00:00:00 2001 From: 1ncounter <1ncounter.100@gmail.com> Date: Wed, 3 Apr 2024 14:23:23 +0800 Subject: [PATCH] ci: change eslint settings --- .eslintignore | 18 --------------- eslint.config.js | 60 ++++++++++++++++++++++-------------------------- package.json | 9 +++++--- 3 files changed, 33 insertions(+), 54 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index ad6cd2ec2..000000000 --- a/.eslintignore +++ /dev/null @@ -1,18 +0,0 @@ -# 忽略目录 -node_modules -test-cases -test -output -build -dist -demo -es -lib -tests -.* -~* - -# 忽略文件 -**/*.min.js -**/*-min.js -**/*.bundle.js diff --git a/eslint.config.js b/eslint.config.js index e19c03400..3bda22ccb 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,40 +1,34 @@ import stylistic from '@stylistic/eslint-plugin'; -import tsParser from '@typescript-eslint/parser'; +import tseslint from 'typescript-eslint' import js from '@eslint/js'; import reactHooks from 'eslint-plugin-react-hooks'; import reactRefresh from 'eslint-plugin-react-refresh'; -export default [ - js.configs.recommended, - { - files: ['**/src/**/*.{ts?(x),js?(x)}'], - plugins: { - '@stylistic': stylistic, - 'react-hooks': reactHooks, - }, - languageOptions: { - parser: tsParser, - }, - rules: { - '@stylistic/indent': ['error', 2], - "@stylistic/indent-binary-ops": ["error", 2], - '@stylistic/max-len': ["error", { "tabWidth": 2 }], - '@stylistic/no-tabs': "error", - '@stylistic/quotes': ["error", "single"], - "@stylistic/jsx-pascal-case": [2], - "@stylistic/jsx-indent": [2, 2, { checkAttributes: true, indentLogicalExpressions: true }], - - 'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks - 'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies - }, +export default tseslint.config({ + files: ['packages/*/src/**/*.{ts?(x),js?(x)}'], + ignores: ["**/*.test.ts"], + extends: [ + js.configs.recommended, + ...tseslint.configs.recommended, + ], + plugins: { + '@stylistic': stylistic, + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh }, - { - files: ['**/src/**/*.{tsx,jsx}'], - plugins: { - 'react-refresh': reactRefresh, - }, - rules: { - 'react-refresh/only-export-components': 'warn', - }, + rules: { + '@stylistic/indent': ['error', 2], + '@stylistic/indent-binary-ops': ['error', 2], + '@stylistic/max-len': ['error', { tabWidth: 2 }], + '@stylistic/no-tabs': 'error', + '@stylistic/quotes': ['error', 'single'], + '@stylistic/jsx-pascal-case': [2], + '@stylistic/jsx-indent': [2, 2, { checkAttributes: true, indentLogicalExpressions: true }], + '@stylistic/semi': ['error', 'always'], + + 'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks + 'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies + + 'react-refresh/only-export-components': 'warn', }, -]; +}) diff --git a/package.json b/package.json index b2a267782..bf70c54c0 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,10 @@ "scripts": { "playground": "pnpm --filter playground dev", "test": "pnpm -r test", - "build": "pnpm -r build", + "build": "node ./scripts/build.js", "clean": "rimraf ./packages/*/dist", "clean:lib": "rimraf ./node_modules ./packages/*/node_modules", - "lint": "eslint --cache --no-warn-ignored", + "lint": "eslint . --cache", "pub": "npm run watchdog:build && lerna publish patch --yes --force-publish --exact --no-changelog", "pub:minor": "npm run watchdog:build && lerna publish minor --yes --force-publish --exact --no-changelog", "pub:major": "npm run watchdog:build && lerna publish major --yes --force-publish --exact --no-changelog", @@ -30,16 +30,19 @@ "@stylistic/eslint-plugin": "^1.7.0", "@types/node": "^20.11.30", "@types/react-router": "5.1.18", - "@typescript-eslint/parser": "^7.4.0", "@vitejs/plugin-react": "^4.2.1", "eslint": "^8.57.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.6", + "execa": "^8.0.1", "husky": "^9.0.11", + "less": "^4.2.0", "lint-staged": "^15.2.2", + "minimist": "^1.2.8", "rimraf": "^5.0.2", "rollup": "^4.13.0", "typescript": "^5.4.2", + "typescript-eslint": "^7.5.0", "vite": "^5.1.6", "vitest": "^1.3.1" },