@1stg/eslint-config 8.0.0 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/_util.js +25 -14
- package/base.d.ts +3 -0
- package/base.js +160 -109
- package/index.d.ts +1 -0
- package/index.js +1 -6
- package/loose.d.ts +3 -0
- package/loose.js +38 -30
- package/overrides.d.ts +24 -0
- package/overrides.js +330 -265
- package/package.json +43 -38
- package/recommended.d.ts +3 -0
- package/recommended.js +6 -1
package/CHANGELOG.md
CHANGED
package/_util.js
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
|
|
5
|
+
import { preferPrettier } from '@1stg/config'
|
|
6
|
+
import {
|
|
5
7
|
isMonorepo,
|
|
6
8
|
isPkgAvailable,
|
|
7
9
|
getMonorepoPkgs,
|
|
8
10
|
tryRequirePkg,
|
|
9
|
-
}
|
|
11
|
+
} from '@pkgr/utils'
|
|
12
|
+
import configPrettier from 'eslint-config-prettier'
|
|
13
|
+
import prettierRecommended from 'eslint-plugin-prettier/recommended'
|
|
14
|
+
import tseslint from 'typescript-eslint'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @type {string[]}
|
|
18
|
+
*/
|
|
19
|
+
let allowModules = []
|
|
10
20
|
|
|
11
21
|
if (isMonorepo()) {
|
|
12
|
-
|
|
22
|
+
allowModules = getMonorepoPkgs().reduce((acc, pkg) => {
|
|
13
23
|
const pkgJson = tryRequirePkg(path.resolve(pkg, 'package.json'))
|
|
14
24
|
if (!pkgJson) {
|
|
15
25
|
return acc
|
|
@@ -21,15 +31,16 @@ if (isMonorepo()) {
|
|
|
21
31
|
Object.keys(peerDependencies),
|
|
22
32
|
Object.keys(dependencies),
|
|
23
33
|
)
|
|
24
|
-
}, [])
|
|
34
|
+
}, /** @type {string[]} */ ([]))
|
|
25
35
|
}
|
|
26
36
|
|
|
27
|
-
|
|
37
|
+
export { allowModules }
|
|
38
|
+
|
|
39
|
+
export const isTsAvailable = isPkgAvailable('typescript')
|
|
28
40
|
|
|
29
|
-
|
|
41
|
+
export const isWebpackAvailable = isPkgAvailable('webpack')
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
exports.webpackSpecVars = [
|
|
43
|
+
export const webpackSpecVars = [
|
|
33
44
|
'__non_webpack_require__',
|
|
34
45
|
'__resourceQuery',
|
|
35
46
|
'__webpack_chunk_load__',
|
|
@@ -42,11 +53,11 @@ exports.webpackSpecVars = [
|
|
|
42
53
|
'DEBUG',
|
|
43
54
|
]
|
|
44
55
|
|
|
45
|
-
|
|
56
|
+
export const magicNumbers = [
|
|
46
57
|
-1, 0, 1, 2, 3, 5, 7, 10, 12, 15, 20, 24, 30, 31, 50, 60, 100, 365, 366, 500,
|
|
47
58
|
768, 1000, 1024, 3600, 4200, 8080,
|
|
48
59
|
]
|
|
49
60
|
|
|
50
|
-
|
|
51
|
-
?
|
|
52
|
-
|
|
61
|
+
export const prettierExtends = tseslint.config(
|
|
62
|
+
preferPrettier ? configPrettier : prettierRecommended,
|
|
63
|
+
)
|
package/base.d.ts
ADDED
package/base.js
CHANGED
|
@@ -1,123 +1,174 @@
|
|
|
1
|
-
|
|
2
|
-
const { getGlobals } = require('eslint-plugin-mdx')
|
|
1
|
+
// @ts-check
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import eslint from '@eslint/js'
|
|
4
|
+
import eslintCommentsConfigs from '@eslint-community/eslint-plugin-eslint-comments/configs'
|
|
5
|
+
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
|
|
6
|
+
import css from 'eslint-plugin-css'
|
|
7
|
+
import importX from 'eslint-plugin-import-x'
|
|
8
|
+
import { getGlobals } from 'eslint-plugin-mdx'
|
|
9
|
+
import n from 'eslint-plugin-n'
|
|
10
|
+
import promise from 'eslint-plugin-promise'
|
|
11
|
+
import regexp from 'eslint-plugin-regexp'
|
|
12
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort'
|
|
13
|
+
import sonarjs from 'eslint-plugin-sonarjs'
|
|
14
|
+
import unicorn from 'eslint-plugin-unicorn'
|
|
15
|
+
import globals from 'globals'
|
|
16
|
+
import tseslint from 'typescript-eslint'
|
|
17
|
+
|
|
18
|
+
import {
|
|
5
19
|
isTsAvailable,
|
|
6
20
|
isWebpackAvailable,
|
|
7
21
|
magicNumbers,
|
|
8
22
|
webpackSpecVars,
|
|
9
23
|
prettierExtends,
|
|
10
|
-
}
|
|
24
|
+
} from './_util.js'
|
|
11
25
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
'
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
ignoreDestructuring: true,
|
|
43
|
-
allow: isWebpackAvailable ? webpackSpecVars : undefined,
|
|
26
|
+
export const base = tseslint.config([
|
|
27
|
+
eslint.configs.recommended,
|
|
28
|
+
eslintCommentsConfigs.recommended,
|
|
29
|
+
css.configs['flat/recommended'],
|
|
30
|
+
importX.flatConfigs.recommended,
|
|
31
|
+
n.configs['flat/recommended'],
|
|
32
|
+
promise.configs['flat/recommended'],
|
|
33
|
+
regexp.configs['flat/recommended'],
|
|
34
|
+
sonarjs.configs.recommended,
|
|
35
|
+
unicorn.configs.recommended,
|
|
36
|
+
prettierExtends,
|
|
37
|
+
{
|
|
38
|
+
name: '@1stg/base',
|
|
39
|
+
plugins: {
|
|
40
|
+
'simple-import-sort': simpleImportSort,
|
|
41
|
+
},
|
|
42
|
+
settings: {
|
|
43
|
+
'import-x/external-module-folders': [
|
|
44
|
+
'node_modules',
|
|
45
|
+
'node_modules/@d-ts',
|
|
46
|
+
'node_modules/@types',
|
|
47
|
+
],
|
|
48
|
+
'import-x/resolver-next': [createTypeScriptImportResolver()],
|
|
49
|
+
},
|
|
50
|
+
languageOptions: {
|
|
51
|
+
sourceType: 'module',
|
|
52
|
+
ecmaVersion: 'latest',
|
|
53
|
+
globals: {
|
|
54
|
+
...globals.builtin,
|
|
55
|
+
...(isWebpackAvailable && getGlobals(webpackSpecVars)),
|
|
44
56
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
2,
|
|
52
|
-
{
|
|
53
|
-
alphabetize: {
|
|
54
|
-
order: 'asc',
|
|
57
|
+
},
|
|
58
|
+
rules: {
|
|
59
|
+
'@eslint-community/eslint-comments/disable-enable-pair': [
|
|
60
|
+
2,
|
|
61
|
+
{
|
|
62
|
+
allowWholeFile: true,
|
|
55
63
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
],
|
|
65
|
+
'@eslint-community/eslint-comments/no-unused-disable': 2,
|
|
66
|
+
'arrow-body-style': 2,
|
|
67
|
+
camelcase: [
|
|
68
|
+
2,
|
|
69
|
+
{
|
|
70
|
+
properties: 'never',
|
|
71
|
+
ignoreDestructuring: true,
|
|
72
|
+
allow: isWebpackAvailable ? webpackSpecVars : undefined,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
curly: [2, 'all'],
|
|
76
|
+
'import-x/first': 2,
|
|
77
|
+
'import-x/newline-after-import': 2,
|
|
78
|
+
'import-x/no-duplicates': 2,
|
|
79
|
+
'import-x/order': [
|
|
80
|
+
2,
|
|
81
|
+
{
|
|
82
|
+
alphabetize: {
|
|
83
|
+
order: 'asc',
|
|
84
|
+
},
|
|
85
|
+
'newlines-between': 'always',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
'no-else-return': [
|
|
89
|
+
2,
|
|
90
|
+
{
|
|
91
|
+
allowElseIf: false,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
'no-empty': [
|
|
95
|
+
2,
|
|
96
|
+
{
|
|
97
|
+
allowEmptyCatch: true,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
'no-empty-function': 2,
|
|
101
|
+
'no-labels': isTsAvailable ? 0 : 2, // sonar/no-labels
|
|
102
|
+
'no-magic-numbers': [
|
|
103
|
+
2,
|
|
104
|
+
{
|
|
105
|
+
enforceConst: true,
|
|
106
|
+
ignore: magicNumbers,
|
|
107
|
+
ignoreArrayIndexes: true,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
'no-negated-condition': 2,
|
|
111
|
+
'no-process-exit': 0, // suspended by unicorn/no-process-exit
|
|
83
112
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
113
|
+
// The following rules are duplicate with `eslint-plugin-import`
|
|
114
|
+
'n/no-extraneous-import': 0,
|
|
115
|
+
'n/no-extraneous-require': 0,
|
|
116
|
+
'n/no-missing-import': 0,
|
|
117
|
+
'n/no-missing-require': 0,
|
|
89
118
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
'unicorn/consistent-function-scoping': 0,
|
|
105
|
-
'unicorn/filename-case': [
|
|
106
|
-
2,
|
|
107
|
-
{
|
|
108
|
-
cases: {
|
|
109
|
-
kebabCase: true,
|
|
110
|
-
pascalCase: true,
|
|
119
|
+
'n/no-unsupported-features/es-syntax': 0,
|
|
120
|
+
'n/no-unsupported-features/node-builtins': 0,
|
|
121
|
+
'n/no-unpublished-import': 0,
|
|
122
|
+
'n/no-unpublished-require': 0,
|
|
123
|
+
'prefer-const': 2,
|
|
124
|
+
'prefer-object-spread': 2,
|
|
125
|
+
'simple-import-sort/exports': 2,
|
|
126
|
+
'unicorn/catch-error-name': [
|
|
127
|
+
2,
|
|
128
|
+
{
|
|
129
|
+
name: 'error',
|
|
130
|
+
ignore: ['^e(rr)?$'],
|
|
111
131
|
},
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
132
|
+
],
|
|
133
|
+
'unicorn/consistent-function-scoping': 0,
|
|
134
|
+
'unicorn/filename-case': [
|
|
135
|
+
2,
|
|
136
|
+
{
|
|
137
|
+
cases: {
|
|
138
|
+
kebabCase: true,
|
|
139
|
+
pascalCase: true,
|
|
140
|
+
},
|
|
141
|
+
// ignore UPPER_CASE markdown or yaml filenames
|
|
142
|
+
ignore: [/^[A-Z](([\dA-Z]+_)*[\dA-Z]+)?\.(mdx?|ya?ml)$/],
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
'unicorn/no-array-reduce': 0,
|
|
146
|
+
'unicorn/no-null': 0,
|
|
147
|
+
'unicorn/no-unreadable-array-destructuring': 0, // conflict with `no-unused-vars`
|
|
148
|
+
'unicorn/prefer-module': 0,
|
|
149
|
+
'unicorn/prefer-object-from-entries': 0,
|
|
150
|
+
'unicorn/prevent-abbreviations': 0,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
ignores: [
|
|
155
|
+
'**/*.less',
|
|
156
|
+
'**/*.log',
|
|
157
|
+
'**/*.patch',
|
|
158
|
+
'**/*.sass',
|
|
159
|
+
'**/*.scss',
|
|
160
|
+
'**/.type-coverage',
|
|
161
|
+
'**/coverage',
|
|
162
|
+
'**/dist',
|
|
163
|
+
'**/lib',
|
|
164
|
+
'**/node_modules',
|
|
165
|
+
'**/CHANGELOG.md',
|
|
166
|
+
'**/yarn.lock',
|
|
167
|
+
'**/package-lock.json',
|
|
168
|
+
'**/pnpm-lock.yaml',
|
|
169
|
+
'**/.yarn',
|
|
170
|
+
'!.github',
|
|
171
|
+
'!.*.{cjs,js,mjs,cts,ts,mts}',
|
|
115
172
|
],
|
|
116
|
-
'unicorn/no-array-reduce': 0,
|
|
117
|
-
'unicorn/no-null': 0,
|
|
118
|
-
'unicorn/no-unreadable-array-destructuring': 0, // conflict with `no-unused-vars`
|
|
119
|
-
'unicorn/prefer-module': 0,
|
|
120
|
-
'unicorn/prefer-object-from-entries': 0,
|
|
121
|
-
'unicorn/prevent-abbreviations': 0,
|
|
122
173
|
},
|
|
123
|
-
|
|
174
|
+
])
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { recommended as default } from './recommended.js'
|
package/index.js
CHANGED
package/loose.d.ts
ADDED
package/loose.js
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
import tseslint from 'typescript-eslint'
|
|
4
|
+
|
|
5
|
+
import { recommended } from './recommended.js'
|
|
6
|
+
|
|
7
|
+
export const loose = tseslint.config([
|
|
8
|
+
recommended,
|
|
9
|
+
{
|
|
10
|
+
rules: {
|
|
11
|
+
'@angular-eslint/template/no-negated-async': 0,
|
|
12
|
+
'@typescript-eslint/member-ordering': 0,
|
|
13
|
+
'@typescript-eslint/naming-convention': 0,
|
|
14
|
+
'@typescript-eslint/no-explicit-any': 0,
|
|
15
|
+
'@typescript-eslint/no-floating-promises': 0,
|
|
16
|
+
'@typescript-eslint/no-magic-numbers': 0,
|
|
17
|
+
'@typescript-eslint/no-type-alias': 0,
|
|
18
|
+
'@typescript-eslint/no-unnecessary-condition': 0,
|
|
19
|
+
'@typescript-eslint/no-unsafe-assignment': 0,
|
|
20
|
+
'@typescript-eslint/no-unsafe-member-access': 0,
|
|
21
|
+
'@typescript-eslint/no-unsafe-return': 0,
|
|
22
|
+
'@typescript-eslint/prefer-ts-expect-error': 0,
|
|
23
|
+
'@typescript-eslint/restrict-plus-operands': 0,
|
|
24
|
+
'@typescript-eslint/sort-type-union-intersection-members': 0,
|
|
25
|
+
'@typescript-eslint/unbound-method': 0,
|
|
26
|
+
'accessor-pairs': 0,
|
|
27
|
+
'no-magic-numbers': 0,
|
|
28
|
+
'no-negated-condition': 0, // not auto-fixable
|
|
29
|
+
'promise/always-return': 0,
|
|
30
|
+
'promise/catch-or-return': 0,
|
|
31
|
+
'unicorn/explicit-length-check': 0,
|
|
32
|
+
'unicorn/no-array-for-each': 0,
|
|
33
|
+
'unicorn/no-fn-reference-in-iterator': 0,
|
|
34
|
+
'unicorn/prefer-number-properties': 0,
|
|
35
|
+
'unicorn/prefer-prototype-methods': 0,
|
|
36
|
+
'unicorn/prefer-spread': 0,
|
|
37
|
+
},
|
|
30
38
|
},
|
|
31
|
-
|
|
39
|
+
])
|
package/overrides.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils'
|
|
2
|
+
|
|
3
|
+
export const js: TSESLint.FlatConfig.ConfigArray
|
|
4
|
+
export const ts: TSESLint.FlatConfig.ConfigArray
|
|
5
|
+
export const dTs: TSESLint.FlatConfig.Config
|
|
6
|
+
export const react: TSESLint.FlatConfig.ConfigArray
|
|
7
|
+
export const vue: TSESLint.FlatConfig.ConfigArray
|
|
8
|
+
export const md: TSESLint.FlatConfig.ConfigArray
|
|
9
|
+
export const mdx: TSESLint.FlatConfig.ConfigArray
|
|
10
|
+
export const test: TSESLint.FlatConfig.Config
|
|
11
|
+
export const tests: TSESLint.FlatConfig.Config
|
|
12
|
+
export const jest: TSESLint.FlatConfig.ConfigArray
|
|
13
|
+
export const script: TSESLint.FlatConfig.Config
|
|
14
|
+
export const scripts: TSESLint.FlatConfig.Config
|
|
15
|
+
export const story: TSESLint.FlatConfig.Config
|
|
16
|
+
export const stories: TSESLint.FlatConfig.Config
|
|
17
|
+
export const config: TSESLint.FlatConfig.Config
|
|
18
|
+
export const configs: TSESLint.FlatConfig.Config
|
|
19
|
+
export const jsonc: TSESLint.FlatConfig.ConfigArray
|
|
20
|
+
export const json5: TSESLint.FlatConfig.ConfigArray
|
|
21
|
+
export const toml: TSESLint.FlatConfig.ConfigArray
|
|
22
|
+
export const yaml: TSESLint.FlatConfig.ConfigArray
|
|
23
|
+
export const yml: TSESLint.FlatConfig.ConfigArray
|
|
24
|
+
export const overrides: TSESLint.FlatConfig.ConfigArray
|