chore(eslint): migrate config (#1518)

Reviewed-on: daoyoucloud/tachybase#1518
Co-authored-by: TomyJan <TomyJan6@gmail.com>
Co-committed-by: TomyJan <TomyJan6@gmail.com>
This commit is contained in:
TomyJan 2024-09-09 16:14:18 +08:00 committed by TomyJan
parent 72f29a0c58
commit 17845e4a80
5 changed files with 348 additions and 463 deletions

View File

@ -1,34 +0,0 @@
node_modules
lib
dist
build
coverage
expected
website
gh-pages
weex
build.ts
packages/vue
packages/element
esm
doc-site
public
packages/*/*/client.d.ts
packages/*/*/server.d.ts
packages/*/*/client.js
packages/*/*/server.js
packages/core/build
packages/core/devtools
packages/core/database/src/sql-parser/index.js
**/.dumi/tmp
**/.dumi/tmp-test
**/.dumi/tmp-production
packages/core/cli/templates/plugin/src/client/*.tpl
packages/app/client/src/.plugins
docker
storage
benchmark
packages/core/cli/src
packages/core/cli/bin
# temp
packages/plugins/@hera/plugin-core/src/client/features/departments/index.tsx

View File

@ -1,80 +0,0 @@
{
"env": {
"node": true,
"es6": true,
"browser": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:promise/recommended",
// "plugin:import/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"react",
"react-hooks",
"prettier",
"promise",
"jest-dom",
"testing-library"
//"import"
],
"globals": {
"sleep": true,
"prettyFormat": true
},
"settings": {
"react": {
"version": "detect"
}
},
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
"project": "./tsconfig.json"
},
"rules": {
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/ban-types": "off",
"no-unused-vars": "off",
"no-useless-catch": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": "off",
"react/display-name": "off",
"react/prop-types": "off",
"no-explicit-any": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-var-requires": "off",
"promise/always-return": "off"
},
"overrides": [
{
"files": [
"**/e2e/**/*.{ts,js,tsx,jsx}",
"**/__e2e__/**/*.{ts,js,tsx,jsx}"
],
"rules": {
"@typescript-eslint/no-floating-promises": "error"
}
},
{
"files": [
"packages/plugins/@hera/**/*.{ts,js,tsx,jsx}",
"packages/plugins/@hera/**/*.{ts,js,tsx,jsx}"
],
"rules": {
"eqeqeq": ["error", "smart"]
}
}
]
}

137
eslint.config.mjs Normal file
View File

@ -0,0 +1,137 @@
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import prettier from "eslint-plugin-prettier";
import promise from "eslint-plugin-promise";
import jestDom from "eslint-plugin-jest-dom";
import testingLibrary from "eslint-plugin-testing-library";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [{
ignores: [
"**/node_modules",
"**/lib",
"**/dist",
"**/build",
"**/coverage",
"**/expected",
"**/website",
"**/gh-pages",
"**/weex",
"**/build.ts",
"packages/vue",
"packages/element",
"**/esm",
"**/doc-site",
"**/public",
"packages/*/*/client.d.ts",
"packages/*/*/server.d.ts",
"packages/*/*/client.js",
"packages/*/*/server.js",
"packages/core/build",
"packages/core/devtools",
"packages/core/database/src/sql-parser/index.js",
"**/.dumi/tmp",
"**/.dumi/tmp-test",
"**/.dumi/tmp-production",
"packages/core/cli/templates/plugin/src/client/*.tpl",
"packages/app/client/src/.plugins",
"**/docker",
"**/storage",
"**/benchmark",
"packages/core/cli/src",
"packages/core/cli/bin",
"packages/plugins/@hera/plugin-core/src/client/features/departments/index.tsx",
],
}, ...fixupConfigRules(compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:promise/recommended",
"plugin:prettier/recommended",
)), {
plugins: {
"@typescript-eslint": fixupPluginRules(typescriptEslint),
react: fixupPluginRules(react),
"react-hooks": fixupPluginRules(reactHooks),
prettier: fixupPluginRules(prettier),
promise: fixupPluginRules(promise),
"jest-dom": jestDom,
"testing-library": testingLibrary,
},
languageOptions: {
globals: {
...globals.node,
...globals.es2020,
...globals.browser,
sleep: true,
prettyFormat: true,
},
parser: tsParser,
ecmaVersion: 11,
sourceType: "module",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
project: "./tsconfig.json",
},
},
settings: {
react: {
version: "detect",
},
},
rules: {
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/ban-types": "off",
"no-unused-vars": "off",
"no-useless-catch": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": "off",
"react/display-name": "off",
"react/prop-types": "off",
"no-explicit-any": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-var-requires": "off",
"promise/always-return": "off",
},
}, {
files: ["**/e2e/**/*.{ts,js,tsx,jsx}", "**/__e2e__/**/*.{ts,js,tsx,jsx}"],
rules: {
"@typescript-eslint/no-floating-promises": "error",
},
}, {
files: [
"packages/plugins/@hera/**/*.{ts,js,tsx,jsx}",
"packages/plugins/@hera/**/*.{ts,js,tsx,jsx}",
],
rules: {
eqeqeq: ["error", "smart"],
},
}];

View File

@ -49,6 +49,9 @@
"@commitlint/cli": "^16.3.0",
"@commitlint/config-conventional": "^16.2.4",
"@commitlint/prompt-cli": "^16.3.0",
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.10.0",
"@ianvs/prettier-plugin-sort-imports": "^4.2.1",
"@tachybase/build": "workspace:*",
"@tachybase/cli": "workspace:*",
@ -64,6 +67,7 @@
"commander": "^9.5.0",
"eslint-plugin-jest-dom": "^5.4.0",
"eslint-plugin-testing-library": "^5.11.1",
"globals": "^15.9.0",
"husky": "^9.0.11",
"lint-staged": "^13.3.0",
"prettier": "^3.2.5",

File diff suppressed because it is too large Load Diff