Skip to content

Commit 79cfe50

Browse files
committed
add eslint edit table
1 parent e6a1772 commit 79cfe50

16 files changed

Lines changed: 1555 additions & 606 deletions

File tree

chat2db-client/.eslintrc.js

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
env: {
4+
browser: true,
5+
es2021: true,
6+
},
7+
plugins: ['@typescript-eslint', 'babel', 'react-hooks', 'react'],
8+
extends: [
9+
'eslint:recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:react/recommended',
12+
// 'airbnb-base', // airbnb-base中已经包含了eslint-plugin-import
13+
// 'prettier', // 使得eslint中的样式规范失效,遵循prettier中的样式规范
14+
// 'prettier/@typescript-eslint', // 使得@typescript-eslint中的样式规范失效,遵循prettier中的样式规范
15+
],
16+
overrides: [
17+
{
18+
env: {
19+
node: true,
20+
},
21+
files: ['.eslintrc.{js,cjs}'], //
22+
parserOptions: {
23+
sourceType: 'script',
24+
},
25+
},
26+
],
27+
parserOptions: {
28+
ecmaVersion: 'latest',
29+
sourceType: 'module',
30+
},
31+
rules: {
32+
'func-names': 0, // 函数表达式必须有名字
33+
'one-var': [1, 'never'], // 连续声明
34+
'prefer-const': 1, // 首选const
35+
'no-unused-expressions': 0, // 禁止无用的表达式
36+
'new-cap': 2, // 构造函数首字母大写
37+
'prefer-arrow-callback': 2, // 首选箭头函数
38+
'arrow-body-style': 0, // 箭头函数体使用大括号
39+
'max-len': [
40+
// 一行最大长度
41+
1,
42+
{
43+
code: 120,
44+
ignoreStrings: true,
45+
ignoreUrls: true,
46+
ignoreRegExpLiterals: true,
47+
},
48+
],
49+
'consistent-return': 'off', // return 后面是否允许省略
50+
'default-case': 2, // switch 语句必须有 default
51+
'prefer-rest-params': 2, // 必须使用解构 ...args 来代替 arguments
52+
'no-script-url': 0, // 禁止使用 javascript:void(0)
53+
// 'no-console': [ // 禁止使用 console
54+
// 2,
55+
// {
56+
// allow: ['info', 'error', 'warn'],
57+
// },
58+
// ],
59+
'no-duplicate-imports': 2, // 禁止重复 import
60+
'newline-per-chained-call': 2, // 链式调用必须换行
61+
'no-underscore-dangle': 2, // 禁止标识符中有悬空下划线
62+
'eol-last': 2, // 文件以单一的换行符结束
63+
'no-useless-rename': 2, // 禁止无用的重命名
64+
'no-undef': 0, // 禁止使用未定义的变量
65+
'class-methods-use-this': 0, // class 的非静态方法必须包含 this
66+
'prefer-destructuring': 0, // 优先使用数组和对象解构
67+
'no-unused-vars': 0, // 禁止未使用过的变量
68+
'@typescript-eslint/no-unused-vars': 1, // 禁止未使用过的变量
69+
'react/self-closing-comp': 2, // 非单行 JSX 必须使用括号包裹
70+
'react/jsx-indent-props': [2, 2], // jsx props 缩进
71+
'no-plusplus': 0, // 禁止使用 ++,--
72+
'react/jsx-uses-vars': 1, // jsx 文件中禁止使用变量
73+
// 'react/no-multi-comp': [ // 禁止一个文件中定义多个组件
74+
// 2,
75+
// {
76+
// ignoreStateless: true,
77+
// },
78+
// ],
79+
'react/jsx-uses-react': 2, // jsx 文件中禁止使用 React
80+
'react/react-in-jsx-scope': 2, // jsx 文件中禁止使用 React
81+
'react/sort-comp': 1, // 组件内方法顺序
82+
'react/jsx-tag-spacing': 2, // jsx 中的属性禁止使用空格
83+
'react/jsx-no-bind': 0, // jsx 中禁止使用 bind
84+
'react/jsx-closing-bracket-location': 2, // jsx 中的右括号必须换行
85+
'react/prefer-stateless-function': 0, // 优先使用无状态组件
86+
'react/display-name': 0, // 组件必须写 displayName
87+
'react/prop-types': 0, // 组件必须写 propTypes
88+
'import/prefer-default-export': 0, // 优先使用 export default
89+
'@typescript-eslint/no-var-requires': 2, // 禁止 require() 使用表达式
90+
'no-use-before-define': 0, // 禁止定义前使用
91+
'@typescript-eslint/no-use-before-define': [
92+
// 禁止定义前使用
93+
0,
94+
// {
95+
// functions: false,
96+
// },
97+
],
98+
'@typescript-eslint/explicit-function-return-type': 0, // 函数必须有返回值
99+
'@typescript-eslint/interface-name-prefix': 0, // 接口名称必须以 I 开头
100+
'@typescript-eslint/explicit-module-boundary-types': 0, // 导出函数和类的公共方法必须声明返回类型
101+
'no-shadow': 0, // 禁止变量名与上层作用域内的定义过的变量重复
102+
'@typescript-eslint/no-shadow': 1, // 禁止变量名与上层作用域内的定义过的变量重复TODO: 为2是不是好点?
103+
'no-invalid-this': 0, // 禁止 this 关键字出现在类和类对象之外
104+
'no-await-in-loop': 'off', // 禁止在循环中出现 await
105+
'array-callback-return': 'off', // 数组方法的回调函数中必须有 return 语句
106+
'no-restricted-syntax': 'off', // 禁止使用特定的语法
107+
'@typescript-eslint/no-explicit-any': 0, // 禁止使用 any
108+
'import/no-extraneous-dependencies': 0, // 禁止使用无关的 package
109+
'import/no-unresolved': 0, // 禁止使用无关的 package
110+
'@typescript-eslint/explicit-member-accessibility': 0, // 类的成员之间是否需要空行
111+
'@typescript-eslint/no-object-literal-type-assertion': 0, // 禁止使用 as Type
112+
'react/no-find-dom-node': 0, // 禁止使用 findDOMNode
113+
'no-param-reassign': [
114+
// 禁止对函数参数再赋值
115+
2,
116+
{
117+
props: false,
118+
},
119+
],
120+
'arrow-parens': 0, // 箭头函数参数括号
121+
indent: 0, // 缩进
122+
'operator-linebreak': [0], // 换行符位置
123+
'max-classes-per-file': [2, 10], // 一个文件最多定义几个类
124+
'@typescript-eslint/no-empty-function': [0], // 禁止空函数
125+
'import/extensions': 0, // 禁止导入文件时带上文件后缀
126+
},
127+
};

chat2db-client/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/src/.umi-test
88
/dist
99
.swc
10+
./yarn-error.log
1011

1112

1213
/release

chat2db-client/.vscode/settings.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"editor.formatOnSave": true,
99
"prettier.bracketSpacing": true, // 在对象,数组括号与文字之间加空格 "{ foo: bar }"
1010
"[typescriptreact]": {
11-
"editor.defaultFormatter": "vscode.typescript-language-features"
11+
"editor.defaultFormatter": "esbenp.prettier-vscode"
1212
},
1313
"[less]": {
1414
"editor.defaultFormatter": "esbenp.prettier-vscode"
@@ -22,6 +22,7 @@
2222
"ahooks",
2323
"antd",
2424
"Appstore",
25+
"asar",
2526
"AZUREAI",
2627
"bgcolor",
2728
"Cascader",
@@ -40,27 +41,35 @@
4041
"fulltext",
4142
"gtag",
4243
"hexi",
44+
"icns",
4345
"Iconfont",
4446
"indexs",
4547
"JDBC",
4648
"KEYPAIR",
4749
"KINGBASE",
50+
"linebreak",
4851
"lsof",
4952
"MARIADB",
5053
"Mddhhmmss",
5154
"Menlo",
5255
"netstat",
56+
"nsis",
5357
"OCEANBASE",
5458
"OPENAI",
59+
"packagejson",
60+
"Parens",
5561
"pgsql",
62+
"plusplus",
5663
"pnpm",
5764
"POSTGRESQL",
65+
"Prec",
5866
"remaininguses",
5967
"RESTAI",
6068
"scrollbar",
6169
"Sercurity",
6270
"sortablejs",
6371
"SQLSERVER",
72+
"tailwindcss",
6473
"Tigger",
6574
"ueabe",
6675
"ueabf",

chat2db-client/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,23 @@
5353
"@types/react": "^18.0.33",
5454
"@types/react-dom": "^18.0.11",
5555
"@types/uuid": "^9.0.1",
56+
"@typescript-eslint/eslint-plugin": "^6.7.2",
57+
"@typescript-eslint/parser": "^6.7.2",
5658
"@umijs/plugins": "^4.0.55",
5759
"concurrently": "^8.1.0",
5860
"cross-env": "^7.0.3",
5961
"electron-builder": "^23.6.0",
6062
"electron-debug": "^3.2.0",
6163
"electron-reload": "^2.0.0-alpha.1",
64+
"eslint": "^8.49.0",
65+
"eslint-config-airbnb-base": "^15.0.0",
66+
"eslint-config-prettier": "^9.0.0",
67+
"eslint-import-resolver-webpack": "^0.13.7",
68+
"eslint-plugin-babel": "^5.3.1",
69+
"eslint-plugin-import": "^2.28.1",
70+
"eslint-plugin-prettier": "^5.0.0",
71+
"eslint-plugin-react": "^7.33.2",
72+
"eslint-plugin-react-hooks": "^4.6.0",
6273
"is-electron": "^2.2.2",
6374
"prettier": "^2",
6475
"prettier-plugin-organize-imports": "^2",

chat2db-client/src/blocks/DatabaseTableEditor/BaseInfo/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import React, { memo, useState, useContext, useEffect, useImperativeHandle, ForwardedRef, forwardRef } from 'react';
1+
import React, { useContext, useEffect, useImperativeHandle, ForwardedRef, forwardRef } from 'react';
22
import styles from './index.less';
33
import classnames from 'classnames';
44
import { Form, Input } from 'antd';
55
import { Context } from '../index';
66
import { IBaseInfo } from '@/typings';
77
import i18n from '@/i18n';
88

9-
109
export interface IBaseInfoRef {
1110
getBaseInfo: () => IBaseInfo;
1211
}
@@ -51,4 +50,4 @@ const BaseInfo = forwardRef((props: IProps, ref: ForwardedRef<IBaseInfoRef>) =>
5150
);
5251
});
5352

54-
export default BaseInfo
53+
export default BaseInfo;

0 commit comments

Comments
 (0)