Skip to content

Commit 425caf3

Browse files
authored
Merge pull request #23 from retejs/improve-lint
Improve lint
2 parents c1879f8 + 9e0ba55 commit 425caf3

40 files changed

+2705
-1272
lines changed

.eslintrc

Lines changed: 0 additions & 120 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.vscode
22
node_modules
33
bin
4+
coverage
5+
.rete-cli
6+
.sonar

.npmignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ node_modules
44
.github
55
CODE_OF_CONDUCT.md
66
CONTRIBUTING.md
7-
release.config.js
8-
release.config.js
9-
release.config.js
10-
release.config.js
7+
.rete-cli
8+
.sonar

configs/eslint.mjs

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
import tseslint from 'typescript-eslint';
2+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
3+
import stylistic from '@stylistic/eslint-plugin';
4+
import stylisticEslintPluginTs from '@stylistic/eslint-plugin-ts';
5+
import eslint from '@eslint/js';
6+
import tsParser from '@typescript-eslint/parser';
7+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
8+
9+
const namingConventions = [
10+
{
11+
selector: 'default',
12+
format: ['camelCase'],
13+
}, {
14+
selector: 'variable',
15+
format: ['camelCase', 'UPPER_CASE'],
16+
leadingUnderscore: 'allow',
17+
}, {
18+
selector: 'function',
19+
format: ['camelCase'],
20+
leadingUnderscore: 'allow',
21+
}, {
22+
selector: 'typeLike',
23+
format: ['PascalCase'],
24+
}, {
25+
selector: 'enumMember',
26+
format: ['UPPER_CASE'],
27+
}, {
28+
selector: 'typeProperty',
29+
format: ['camelCase', 'PascalCase'],
30+
}, {
31+
selector: 'import',
32+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
33+
}
34+
]
35+
36+
export function extendNamingConventions(...list) {
37+
const selectors = list.map(convention => convention.selector)
38+
39+
return [
40+
...namingConventions.filter(convention => !selectors.includes(convention.selector)),
41+
...list
42+
]
43+
}
44+
45+
export default tseslint.config(
46+
eslint.configs.recommended,
47+
...tseslint.configs.strictTypeChecked,
48+
...tseslint.configs.stylisticTypeChecked,
49+
stylistic.configs['all-flat'],
50+
{
51+
languageOptions: {
52+
parser: tsParser,
53+
parserOptions: {
54+
projectService: true
55+
},
56+
},
57+
},
58+
{
59+
files: ['src/**/*.{ts,tsx}', 'test/**/*.{ts,tsx}'],
60+
plugins: {
61+
'@typescript-eslint': typescriptEslint,
62+
'simple-import-sort': simpleImportSort,
63+
'@stylistic': stylistic,
64+
'@stylistic/ts': stylisticEslintPluginTs,
65+
},
66+
rules: {
67+
'@typescript-eslint/consistent-type-definitions': 'off',
68+
'no-cond-assign': 'error',
69+
'no-console': 'error',
70+
'no-constant-condition': 'error',
71+
'no-duplicate-imports': 'warn',
72+
'no-control-regex': 'warn',
73+
'no-dupe-args': 'error',
74+
'no-dupe-keys': 'error',
75+
'no-duplicate-case': 'error',
76+
'no-empty-character-class': 'error',
77+
'no-empty': 'warn',
78+
'no-extra-boolean-cast': 'error',
79+
'no-extra-semi': 'error',
80+
'no-func-assign': 'error',
81+
'no-inner-declarations': 'error',
82+
'no-unsafe-negation': 'error',
83+
'no-sparse-arrays': 'error',
84+
'no-unreachable': 'error',
85+
'default-case': 'warn',
86+
eqeqeq: 'warn',
87+
'no-caller': 'error',
88+
'no-else-return': 'error',
89+
'no-eq-null': 'error',
90+
'no-eval': 'error',
91+
'no-fallthrough': 'error',
92+
'no-implied-eval': 'error',
93+
'no-labels': 'error',
94+
'no-loop-func': 'error',
95+
'no-multi-spaces': 'error',
96+
'no-new': 'error',
97+
'no-proto': 'error',
98+
'no-redeclare': 'off',
99+
'@typescript-eslint/no-redeclare': 'error',
100+
'no-self-compare': 'error',
101+
'init-declarations': ['error', 'always'],
102+
'no-undefined': 'error',
103+
'comma-dangle': ['error', 'never'],
104+
semi: 'off',
105+
'no-shadow': 'off',
106+
'@typescript-eslint/no-shadow': 'error',
107+
'no-unused-vars': 'off',
108+
109+
'@typescript-eslint/no-unused-vars': ['error', {
110+
argsIgnorePattern: '^_',
111+
varsIgnorePattern: '^_',
112+
caughtErrorsIgnorePattern: '^_',
113+
}],
114+
115+
'object-curly-spacing': ['error', 'always'],
116+
117+
camelcase: ['error', {
118+
properties: 'always',
119+
}],
120+
121+
'comma-spacing': ['warn', {
122+
before: false,
123+
after: true,
124+
}],
125+
126+
'@stylistic/indent': ['error', 2],
127+
'newline-after-var': ['error', 'always'],
128+
'no-mixed-spaces-and-tabs': 'error',
129+
130+
'no-multiple-empty-lines': ['warn', {
131+
max: 1,
132+
}],
133+
134+
'space-before-blocks': ['error', 'always'],
135+
'space-in-parens': ['error', 'never'],
136+
137+
// 'space-before-function-paren': ['error', {
138+
// anonymous: 'always',
139+
// named: 'never',
140+
// }],
141+
142+
'keyword-spacing': 'error',
143+
'max-depth': ['warn', 4],
144+
145+
'max-len': ['warn', 120, 4, {
146+
ignoreComments: true,
147+
}],
148+
149+
'max-params': ['warn', 7],
150+
'max-statements': ['warn', 12],
151+
'simple-import-sort/imports': 'warn',
152+
'simple-import-sort/exports': 'warn',
153+
complexity: ['error', 10],
154+
'no-trailing-spaces': 'error',
155+
'eol-last': ['error', 'always'],
156+
157+
'@typescript-eslint/naming-convention': ['error', ...namingConventions],
158+
'padded-blocks': ['error', 'never'],
159+
'spaced-comment': ['error', 'always'],
160+
'@typescript-eslint/no-unsafe-return': 'warn',
161+
'@typescript-eslint/no-unsafe-argument': 'warn',
162+
'@typescript-eslint/no-unsafe-assignment': 'warn',
163+
'@typescript-eslint/no-unsafe-member-access': 'warn',
164+
'@typescript-eslint/no-unsafe-call': 'warn',
165+
'@typescript-eslint/no-unnecessary-type-parameters': 'warn',
166+
'@typescript-eslint/no-unnecessary-condition': 'warn',
167+
'@typescript-eslint/no-confusing-void-expression': 'warn',
168+
'@typescript-eslint/no-non-null-assertion': 'warn',
169+
'@typescript-eslint/no-dynamic-delete': 'warn',
170+
'@typescript-eslint/no-explicit-any': 'warn',
171+
172+
'@stylistic/semi': ['error', 'never'],
173+
'@stylistic/padded-blocks': ['error', 'never'],
174+
'@stylistic/object-curly-spacing': ['error', 'always'],
175+
'@stylistic/quotes': ['error', 'single', {
176+
avoidEscape: true,
177+
allowTemplateLiterals: true,
178+
}],
179+
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
180+
'@stylistic/space-before-function-paren': ['error', {
181+
anonymous: 'always',
182+
named: 'never',
183+
}],
184+
'@stylistic/quote-props': ['error', 'as-needed'],
185+
'@stylistic/object-property-newline': ['error', { 'allowAllPropertiesOnSameLine': true }],
186+
'@stylistic/member-delimiter-style': ['error', {
187+
"multiline": {
188+
"delimiter": "none",
189+
"requireLast": true
190+
},
191+
"singleline": {
192+
"delimiter": "comma",
193+
"requireLast": false
194+
},
195+
"multilineDetection": "brackets"
196+
}],
197+
'@stylistic/no-extra-parens': ['error', 'all', { 'ignoreJSX': 'multi-line' }],
198+
'@stylistic/arrow-parens': ['error', 'as-needed'],
199+
'@stylistic/no-confusing-arrow': "off",
200+
'@stylistic/array-element-newline': 'off',
201+
'@typescript-eslint/restrict-template-expressions': ['error', { 'allowNumber': true }],
202+
'@stylistic/lines-around-comment': ['error', { 'beforeBlockComment': false, 'beforeLineComment': false }],
203+
'@stylistic/lines-between-class-members': 'off',
204+
'@stylistic/array-bracket-newline': ['error', 'consistent'],
205+
'@stylistic/dot-location': ['error', 'property'],
206+
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
207+
'@stylistic/operator-linebreak': ['error', 'before'],
208+
}
209+
},
210+
{
211+
files: ['test/**/*.ts'],
212+
rules: {
213+
'no-magic-numbers': 'off',
214+
'@typescript-eslint/no-confusing-void-expression': 'off',
215+
}
216+
}
217+
)

configs/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"skipLibCheck": true,
5+
"plugins": [
6+
{
7+
"name": "ts-plugin-type-coverage",
8+
"strict": true,
9+
"notOnlyInCWD": true
10+
}
11+
]
12+
}
13+
}

eslint.config.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import tseslint from 'typescript-eslint';
2+
import configs from './configs/eslint.mjs';
3+
4+
export default tseslint.config(
5+
...configs,
6+
{
7+
rules: {
8+
'no-console': 'off',
9+
'no-undefined': 'off',
10+
'@typescript-eslint/no-require-imports': 'off',
11+
}
12+
}
13+
)

0 commit comments

Comments
 (0)