Skip to content

Commit 7f1672e

Browse files
author
keindev
committed
refactor: fix eslint conf and refactor
1 parent de10602 commit 7f1672e

13 files changed

+9825
-220
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
node_modules
2-
example
31
lib

.eslintrc

Lines changed: 131 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,93 +5,152 @@
55
"commonjs": true
66
},
77
"parser": "@typescript-eslint/parser",
8-
"extends": ["airbnb-base", "plugin:@typescript-eslint/recommended", "prettier", "plugin:jest/recommended"],
9-
"plugins": ["@typescript-eslint", "jest"],
8+
"parserOptions": {
9+
"project": "./tsconfig.json",
10+
"tsconfigRootDir": "."
11+
},
12+
"extends": [
13+
"eslint:recommended",
14+
"plugin:node/recommended",
15+
"plugin:@typescript-eslint/recommended",
16+
"plugin:promise/recommended",
17+
"plugin:jest/recommended",
18+
"prettier"
19+
],
20+
"plugins": ["@typescript-eslint", "optimize-regex", "jest"],
1021
"rules": {
22+
"@typescript-eslint/brace-style": ["error", "1tbs"],
23+
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }],
24+
"@typescript-eslint/func-call-spacing": ["error", "never"],
25+
"@typescript-eslint/indent": ["error", 2, { "SwitchCase": 1 }],
26+
"@typescript-eslint/interface-name-prefix": "off",
27+
"@typescript-eslint/member-delimiter-style": ["error", { "multiline": { "delimiter": "semi" } }],
1128
"@typescript-eslint/member-ordering": "error",
1229
"@typescript-eslint/naming-convention": [
1330
"error",
14-
{
15-
"selector": "interface",
16-
"format": ["PascalCase"],
17-
"custom": {
18-
"regex": "^I[A-Z]",
19-
"match": true
20-
}
21-
}
22-
],
23-
"@typescript-eslint/no-shadow": ["error"],
24-
"no-shadow": "off",
25-
"max-lines-per-function": [
26-
"error",
27-
{
28-
"max": 40
29-
}
30-
],
31-
"import/prefer-default-export": 0,
32-
"import/extensions": 0,
33-
"max-len": [
34-
"error",
35-
{
36-
"code": 120,
37-
"ignoreComments": true
38-
}
31+
{ "selector": "interface", "format": ["PascalCase"], "custom": { "regex": "^I[A-Z]", "match": true } }
3932
],
40-
"indent": [
33+
"@typescript-eslint/no-magic-numbers": [
4134
"error",
42-
2,
4335
{
44-
"SwitchCase": 1
45-
}
46-
],
47-
"lines-between-class-members": 0,
48-
"no-bitwise": 0,
49-
"no-plusplus": 0,
50-
"no-underscore-dangle": [
51-
"error",
52-
{
53-
"allowAfterThis": true
36+
"ignoreNumericLiteralTypes": true,
37+
"ignoreEnums": true,
38+
"enforceConst": true,
39+
"ignoreReadonlyClassProperties": true,
40+
"ignoreArrayIndexes": true,
41+
"ignoreDefaultValues": true,
42+
"ignore": [0, 1, 2, 8, 10, 16]
5443
}
5544
],
45+
"@typescript-eslint/no-parameter-properties": "error",
46+
"@typescript-eslint/no-shadow": "error",
47+
"@typescript-eslint/no-unnecessary-type-arguments": "warn",
48+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_$" }],
49+
"@typescript-eslint/no-useless-constructor": "error",
50+
"@typescript-eslint/prefer-for-of": "warn",
51+
"@typescript-eslint/prefer-function-type": "warn",
52+
"@typescript-eslint/prefer-readonly": "warn",
53+
"@typescript-eslint/semi": ["error"],
54+
"@typescript-eslint/unbound-method": "off",
55+
"array-bracket-newline": ["error", { "multiline": true }],
56+
"arrow-body-style": ["error", "as-needed"],
57+
"arrow-parens": ["error", "as-needed"],
58+
"arrow-spacing": "error",
59+
"block-scoped-var": "error",
60+
"curly": ["error", "multi", "consistent"],
61+
"eol-last": "error",
62+
"eqeqeq": "error",
63+
"generator-star-spacing": ["error", "before"],
64+
"import/extensions": "off",
65+
"import/prefer-default-export": "off",
66+
"indent": "off",
67+
"key-spacing": "error",
68+
"keyword-spacing": "error",
69+
"lines-between-class-members": "off",
70+
"max-classes-per-file": ["error", 1],
71+
"max-len": ["error", { "code": 120, "ignoreComments": true }],
72+
"max-lines-per-function": ["error", { "max": 40 }],
73+
"new-parens": "error",
74+
"no-alert": "warn",
75+
"no-bitwise": "off",
76+
"no-confusing-arrow": "error",
77+
"no-console": "warn",
78+
"no-dupe-class-members": "off",
79+
"no-else-return": ["error", { "allowElseIf": false }],
80+
"no-labels": "error",
81+
"no-lone-blocks": "error",
82+
"no-magic-numbers": "off",
83+
"no-multi-spaces": "error",
84+
"no-multiple-empty-lines": "error",
85+
"no-nested-ternary": "error",
86+
"no-new": "error",
87+
"no-new-func": "error",
88+
"no-new-object": "error",
89+
"no-new-wrappers": "error",
90+
"no-plusplus": "off",
91+
"no-return-await": "error",
92+
"no-self-compare": "error",
93+
"no-sequences": "error",
94+
"no-shadow": "off",
95+
"no-tabs": "error",
96+
"no-template-curly-in-string": "error",
97+
"no-throw-literal": "error",
98+
"no-trailing-spaces": "error",
99+
"no-underscore-dangle": ["error", { "allowAfterThis": true }],
100+
"no-unneeded-ternary": "error",
101+
"no-unused-expressions": "error",
102+
"no-useless-call": "error",
103+
"no-useless-computed-key": "error",
104+
"no-useless-concat": "error",
105+
"no-useless-rename": "error",
106+
"no-useless-return": "error",
107+
"no-var": "error",
108+
"no-whitespace-before-property": "error",
109+
"node/no-empty-function": "off",
110+
"node/no-missing-import": "off",
111+
"node/no-missing-require": "off",
112+
"node/no-unsupported-features/es-syntax": "off",
113+
"node/shebang": "off",
114+
"object-curly-newline": "error",
115+
"object-curly-spacing": ["error", "always"],
116+
"object-shorthand": ["error", "always"],
117+
"optimize-regex/optimize-regex": "warn",
56118
"padding-line-between-statements": [
57119
"error",
58-
{
59-
"blankLine": "always",
60-
"prev": "*",
61-
"next": "return"
62-
},
63-
{
64-
"blankLine": "always",
65-
"prev": ["const", "let", "var"],
66-
"next": "*"
67-
},
68-
{
69-
"blankLine": "any",
70-
"prev": ["const", "let", "var"],
71-
"next": ["const", "let", "var"]
72-
},
73-
{
74-
"blankLine": "always",
75-
"prev": "*",
76-
"next": "if"
77-
},
78-
{
79-
"blankLine": "any",
80-
"prev": "if",
81-
"next": "if"
82-
}
83-
]
120+
{ "blankLine": "always", "prev": "*", "next": "return" },
121+
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
122+
{ "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"] },
123+
{ "blankLine": "always", "prev": "*", "next": "if" },
124+
{ "blankLine": "any", "prev": "if", "next": "if" }
125+
],
126+
"prefer-arrow-callback": "error",
127+
"prefer-const": "error",
128+
"prefer-destructuring": "error",
129+
"prefer-promise-reject-errors": "error",
130+
"promise/prefer-await-to-then": "error",
131+
"quotes": ["warn", "single", { "avoidEscape": true }],
132+
"radix": "error",
133+
"require-atomic-updates": "off",
134+
"rest-spread-spacing": ["error", "never"],
135+
"semi": "off",
136+
"semi-spacing": "error",
137+
"space-before-blocks": "error",
138+
"space-before-function-paren": ["error", { "anonymous": "always", "named": "never", "asyncArrow": "always" }],
139+
"space-in-parens": "error",
140+
"space-infix-ops": "error",
141+
"space-unary-ops": "error",
142+
"spaced-comment": ["error", "always"],
143+
"switch-colon-spacing": "error",
144+
"template-curly-spacing": "error"
84145
},
85146
"overrides": [
86147
{
87-
"files": "*.test.ts",
148+
"files": ["*.test.ts", "*.mock.ts"],
88149
"rules": {
89-
"max-lines-per-function": [
90-
"error",
91-
{
92-
"max": 200
93-
}
94-
]
150+
"@typescript-eslint/no-explicit-any": "off",
151+
"@typescript-eslint/no-magic-numbers": "off",
152+
"max-lines-per-function": ["error", { "max": 200 }],
153+
"no-underscore-dangle": "off"
95154
}
96155
}
97156
],

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"singleQuote": true,
44
"tabWidth": 2,
55
"endOfLine": "lf",
6-
"trailingComma": "es5"
6+
"trailingComma": "es5",
7+
"arrowParens": "avoid"
78
}

docs/api/classes/progressbar.progressbar-1.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,49 +141,49 @@ ___
141141

142142
### MAX\_PERCENT
143143

144-
`Static` **MAX\_PERCENT**: *number*= 100
144+
`Readonly` `Static` **MAX\_PERCENT**: *100*= 100
145145

146146
___
147147

148148
### MAX\_POINT\_POSITION
149149

150-
`Static` **MAX\_POINT\_POSITION**: *number*= 1
150+
`Readonly` `Static` **MAX\_POINT\_POSITION**: *1*= 1
151151

152152
___
153153

154154
### MAX\_RATIO
155155

156-
`Static` **MAX\_RATIO**: *number*= 1
156+
`Readonly` `Static` **MAX\_RATIO**: *1*= 1
157157

158158
___
159159

160160
### MIN\_PERCENT
161161

162-
`Static` **MIN\_PERCENT**: *number*= 0
162+
`Readonly` `Static` **MIN\_PERCENT**: *0*= 0
163163

164164
___
165165

166166
### MIN\_POINT\_POSITION
167167

168-
`Static` **MIN\_POINT\_POSITION**: *number*= 0
168+
`Readonly` `Static` **MIN\_POINT\_POSITION**: *0*= 0
169169

170170
___
171171

172172
### MIN\_RATIO
173173

174-
`Static` **MIN\_RATIO**: *number*= 0
174+
`Readonly` `Static` **MIN\_RATIO**: *0*= 0
175175

176176
___
177177

178178
### TICK
179179

180-
`Static` **TICK**: *number*= 1
180+
`Readonly` `Static` **TICK**: *1*= 1
181181

182182
___
183183

184184
### TIME\_DIMENSION
185185

186-
`Static` **TIME\_DIMENSION**: *number*= 1000
186+
`Readonly` `Static` **TIME\_DIMENSION**: *1000*= 1000
187187

188188
## Accessors
189189

docs/api/classes/tasktree.tasktree-1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Singleton to manage the task tree
2626

2727
### TIMEOUT
2828

29-
`Static` **TIMEOUT**: *number*= 100
29+
`Readonly` `Static` **TIMEOUT**: *100*= 100
3030

3131
## Methods
3232

0 commit comments

Comments
 (0)