Skip to content

Commit 913c1b6

Browse files
committed
update lint
1 parent 5512870 commit 913c1b6

8 files changed

+401
-405
lines changed

.eslintrc.cjs

Lines changed: 54 additions & 249 deletions
Original file line numberDiff line numberDiff line change
@@ -1,247 +1,70 @@
1-
// eslint-disable-next-line @typescript-eslint/no-var-requires
2-
const path = require('node:path')
3-
4-
const project = path.join(__dirname, 'tsconfig.json')
5-
6-
/** @type {import("eslint").Linter.RulesRecord} */
7-
const generalRules = {
8-
'no-self-compare': 'error',
9-
'no-unused-private-class-members': 'error',
10-
'no-constant-binary-expression': 'error',
11-
camelcase: ['error', { ignoreImports: false }],
12-
'default-case': 'error',
13-
'default-case-last': 'error',
14-
eqeqeq: 'warn',
15-
'func-name-matching': 'error',
16-
'logical-assignment-operators': 'error',
17-
'new-cap': 'error',
18-
'no-array-constructor': 'error',
19-
'no-caller': 'error',
20-
'no-console': 'error',
21-
'no-empty-function': 'off',
22-
'no-empty-static-block': 'error',
23-
'no-eval': 'error',
24-
'no-implied-eval': 'error',
25-
'no-new-func': 'error',
26-
'no-extend-native': 'error',
27-
'no-extra-bind': 'error',
28-
'no-extra-label': 'error',
29-
'no-label-var': 'error',
30-
'no-lonely-if': 'error',
31-
'no-multi-assign': 'error',
32-
'no-new-wrappers': 'error',
33-
'no-proto': 'error',
34-
'no-return-assign': 'error',
35-
'no-throw-literal': 'error',
36-
'no-unneeded-ternary': 'error',
37-
'no-useless-computed-key': 'error',
38-
'no-useless-constructor': 'off',
39-
'no-useless-return': 'error',
40-
'operator-assignment': 'error',
41-
'prefer-const': 'warn',
42-
'prefer-exponentiation-operator': 'error',
43-
'prefer-object-spread': 'error',
44-
'prefer-regex-literals': 'error',
45-
'prefer-spread': 'error',
46-
'require-await': 'warn',
47-
'symbol-description': 'warn',
48-
'no-inner-declarations': 'off',
49-
'no-unused-expressions': 'error',
50-
}
1+
'use strict'
512

52-
/** @type {import("eslint").Linter.RulesRecord} */
53-
const generalRulesForTypeScript = {
54-
'@typescript-eslint/consistent-type-imports': [
55-
'error',
56-
{
57-
prefer: 'type-imports',
58-
fixStyle: 'separate-type-imports',
59-
},
60-
],
61-
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
62-
'@typescript-eslint/array-type': ['error', { default: 'array' }],
63-
'@typescript-eslint/ban-ts-comment': 'off',
64-
'@typescript-eslint/consistent-generic-constructors': [
65-
'error',
66-
'constructor',
67-
],
68-
'@typescript-eslint/consistent-indexed-object-style': ['warn', 'record'],
69-
'@typescript-eslint/method-signature-style': ['error', 'property'],
70-
'@typescript-eslint/no-duplicate-enum-values': 'error',
71-
'@typescript-eslint/no-duplicate-type-constituents': 'error',
72-
'@typescript-eslint/no-dynamic-delete': 'warn',
73-
'@typescript-eslint/no-import-type-side-effects': 'error',
74-
'@typescript-eslint/no-meaningless-void-operator': 'warn',
75-
'@typescript-eslint/no-redundant-type-constituents': 'warn',
76-
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
77-
'@typescript-eslint/no-unnecessary-condition': 'warn',
78-
'@typescript-eslint/no-unnecessary-qualifier': 'error',
79-
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
80-
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
81-
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
82-
'@typescript-eslint/prefer-function-type': 'error',
83-
'@typescript-eslint/prefer-optional-chain': 'error',
84-
'@typescript-eslint/prefer-ts-expect-error': 'error',
85-
'@typescript-eslint/require-array-sort-compare': 'warn',
86-
'@typescript-eslint/switch-exhaustiveness-check': 'warn',
87-
'@typescript-eslint/unified-signatures': 'warn',
88-
'@typescript-eslint/naming-convention': [
89-
'error',
90-
{
91-
selector: 'interface',
92-
format: ['PascalCase'],
93-
},
94-
{
95-
selector: 'typeLike',
96-
format: ['PascalCase'],
97-
},
98-
],
99-
'@typescript-eslint/no-namespace': 'off',
100-
'@typescript-eslint/explicit-member-accessibility': [
101-
'error',
102-
{ overrides: { constructors: 'no-public' } },
103-
],
104-
}
105-
106-
/** @type {import("eslint").Linter.RulesRecord} */
107-
const typeCheckingRules = {
108-
'@typescript-eslint/no-unsafe-argument': 'warn',
109-
'@typescript-eslint/no-unsafe-assignment': 'warn',
110-
'@typescript-eslint/no-unsafe-return': 'warn',
111-
'@typescript-eslint/no-unsafe-member-access': 'warn',
112-
'@typescript-eslint/no-unsafe-call': 'warn',
113-
'@typescript-eslint/unbound-method': 'warn',
114-
'@typescript-eslint/restrict-template-expressions': 'warn',
115-
}
116-
117-
/** @type {import("eslint").Linter.RulesRecord} */
118-
const unicornRules = {
119-
'unicorn/better-regex': 'error',
120-
'unicorn/custom-error-definition': 'error',
121-
'unicorn/error-message': 'error',
122-
'unicorn/filename-case': [
123-
'error',
124-
{
125-
case: 'camelCase',
126-
},
127-
],
128-
'unicorn/new-for-builtins': 'error',
129-
'unicorn/no-array-method-this-argument': 'error',
130-
'unicorn/no-array-push-push': 'error',
131-
'unicorn/no-empty-file': 'error',
132-
'unicorn/no-instanceof-array': 'error',
133-
'unicorn/no-unnecessary-await': 'warn',
134-
'unicorn/no-useless-fallback-in-spread': 'warn',
135-
'unicorn/no-useless-length-check': 'warn',
136-
'unicorn/no-useless-spread': 'warn',
137-
'unicorn/no-useless-switch-case': 'warn',
138-
'unicorn/no-useless-undefined': 'warn',
139-
'unicorn/no-zero-fractions': 'error',
140-
'unicorn/number-literal-case': 'error',
141-
'unicorn/prefer-array-flat-map': 'warn',
142-
'unicorn/prefer-math-trunc': 'warn',
143-
'unicorn/prefer-modern-math-apis': 'error',
144-
'unicorn/prefer-negative-index': 'warn',
145-
'unicorn/prefer-node-protocol': 'error',
146-
'unicorn/prefer-optional-catch-binding': 'error',
147-
'unicorn/prefer-switch': 'warn',
148-
'unicorn/throw-new-error': 'error',
149-
}
150-
151-
/** @type {import("eslint").Linter.RulesRecord} */
152-
const spellRules = {
153-
'spellcheck/spell-checker': [
154-
'warn',
155-
{
156-
comments: true,
157-
strings: true,
158-
identifiers: true,
159-
templates: true,
160-
lang: 'en_US',
161-
skipWords: [
162-
'checkbox',
163-
'unary',
164-
'convertable',
165-
'baseexponent',
166-
'typeof',
167-
'str',
168-
'clipboardy',
169-
'esm',
170-
'cjs',
171-
'iife',
172-
'dts',
173-
'tsconfig',
174-
'minify',
175-
'rimraf',
176-
],
177-
},
178-
],
179-
}
180-
181-
/** @type {import("eslint").Linter.RulesRecord} */
182-
const jsdocRules = {
183-
'jsdoc/check-alignment': 'error',
184-
'jsdoc/check-indentation': 'error',
185-
'jsdoc/check-tag-names': 'error',
186-
'jsdoc/match-description': [
187-
'error',
188-
{ matchDescription: '^\n?([A-Z`\\d_][\\s\\S]*\\.)\\s*$' },
189-
],
190-
'jsdoc/no-bad-blocks': ['error', { preventAllMultiAsteriskBlocks: true }],
191-
'jsdoc/no-blank-block-descriptions': 'error',
192-
'jsdoc/no-blank-blocks': 'error',
193-
'jsdoc/no-multi-asterisks': 'error',
194-
'jsdoc/require-asterisk-prefix': 'error',
195-
'jsdoc/require-hyphen-before-param-description': 'warn',
196-
'jsdoc/require-param-description': 'error',
197-
'jsdoc/require-param-name': 'error',
198-
'jsdoc/require-throws': 'error',
199-
'jsdoc/require-jsdoc': 'off',
200-
}
201-
202-
/** @type {import("eslint").Linter.RulesRecord} */
203-
const securityRules = {
204-
'security/detect-object-injection': 'warn',
205-
}
206-
207-
const plugins = [
208-
'@typescript-eslint',
209-
'unicorn',
210-
'spellcheck',
211-
'jsdoc',
212-
'security',
213-
]
3+
const path = require('node:path')
2144

215-
const extendsFrom = [
216-
'eslint:recommended',
217-
'plugin:@typescript-eslint/recommended',
218-
]
5+
const {
6+
commonJsExtensions,
7+
esmExtensionsWhenTypeModule,
8+
} = require('eslint-config-polioan/common/constants')
2199

22010
/** @type {import("eslint").Linter.Config} */
22111
const config = {
12+
extends: [
13+
'polioan/configurations/comments',
14+
'polioan/configurations/general',
15+
'polioan/configurations/generalTypes',
16+
'polioan/configurations/regex',
17+
'polioan/configurations/spellcheck',
18+
],
22219
env: {
22320
browser: true,
224-
es2021: true,
22521
node: true,
22+
es2021: true,
23+
},
24+
settings: {},
25+
root: true,
26+
parser: '@typescript-eslint/parser',
27+
parserOptions: {
28+
ecmaVersion: 'latest',
29+
project: path.join(__dirname, 'tsconfig.json'),
30+
},
31+
plugins: [],
32+
rules: {
33+
'spellcheck/spell-checker': [
34+
'warn',
35+
{
36+
comments: true,
37+
strings: true,
38+
identifiers: true,
39+
templates: true,
40+
lang: 'en_US',
41+
skipWords: [
42+
'checkbox',
43+
'unary',
44+
'convertable',
45+
'baseexponent',
46+
'typeof',
47+
'str',
48+
'clipboardy',
49+
'esm',
50+
'cjs',
51+
'iife',
52+
'dts',
53+
'tsconfig',
54+
'minify',
55+
'rimraf',
56+
],
57+
},
58+
],
22659
},
22760
overrides: [
22861
{
229-
extends: [
230-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
231-
],
232-
files: ['*.ts'],
233-
parserOptions: {
234-
project,
235-
},
236-
rules: typeCheckingRules,
62+
files: commonJsExtensions,
63+
extends: ['polioan/configurations/commonJS'],
23764
},
23865
{
239-
files: ['test/**'],
240-
rules: {
241-
'@typescript-eslint/no-explicit-any': 'off',
242-
'@typescript-eslint/unbound-method': 'off',
243-
'security/detect-object-injection': 'off',
244-
},
66+
files: esmExtensionsWhenTypeModule,
67+
extends: ['polioan/configurations/esmModules'],
24568
},
24669
{
24770
files: ['examples/**'],
@@ -256,24 +79,6 @@ const config = {
25679
},
25780
},
25881
],
259-
parser: '@typescript-eslint/parser',
260-
root: true,
261-
parserOptions: {
262-
project,
263-
ecmaVersion: 'latest',
264-
sourceType: 'module',
265-
},
266-
settings: {},
267-
plugins,
268-
extends: extendsFrom,
269-
rules: {
270-
...generalRules,
271-
...generalRulesForTypeScript,
272-
...unicornRules,
273-
...spellRules,
274-
...jsdocRules,
275-
...securityRules,
276-
},
27782
}
27883

27984
module.exports = config

0 commit comments

Comments
 (0)