@trigen/oxlint-config 9.0.1 → 9.0.3
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/package.json +1 -1
- package/src/module.js +2 -1
- package/src/plugin/extensions.js +72 -0
- package/src/plugin/index.js +3 -1
- package/src/plugin/naming-convention.js +18 -2
- package/src/subconfigs/basic.js +66 -1
- package/src/subconfigs/import.js +1 -6
- package/src/subconfigs/typescript-type-checked.js +0 -2
- package/src/subconfigs/typescript.js +1 -60
package/package.json
CHANGED
package/src/module.js
CHANGED
|
@@ -9,13 +9,14 @@ import {
|
|
|
9
9
|
} from './subconfigs/files.js'
|
|
10
10
|
|
|
11
11
|
export default {
|
|
12
|
+
jsPlugins: ['@trigen/oxlint-config/plugin'],
|
|
12
13
|
overrides: [
|
|
13
14
|
...bundlerConfig.overrides,
|
|
14
15
|
{
|
|
15
16
|
files: not(commonjsFiles),
|
|
16
17
|
plugins: ['import'],
|
|
17
18
|
rules: {
|
|
18
|
-
'
|
|
19
|
+
'trigen/extensions': ['error', 'ignorePackages']
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
]
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { posix as path } from 'node:path'
|
|
2
|
+
|
|
3
|
+
function getOptions(context) {
|
|
4
|
+
return {
|
|
5
|
+
ignorePackages: context.options[0] === 'ignorePackages'
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function isPackageImport(source) {
|
|
10
|
+
return !source.startsWith('.')
|
|
11
|
+
&& !source.startsWith('/')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function hasExtension(source) {
|
|
15
|
+
const cleanSource = source.split(/[?#]/)[0]
|
|
16
|
+
const basename = path.basename(cleanSource)
|
|
17
|
+
|
|
18
|
+
return path.extname(basename) !== ''
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function checkSource(context, options, node) {
|
|
22
|
+
const source = node.source?.value
|
|
23
|
+
|
|
24
|
+
if (typeof source !== 'string') {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (options.ignorePackages && isPackageImport(source)) {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (hasExtension(source)) {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
context.report({
|
|
37
|
+
node: node.source,
|
|
38
|
+
message: `Missing file extension for "${source}".`
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default {
|
|
43
|
+
meta: {
|
|
44
|
+
type: 'problem',
|
|
45
|
+
docs: {
|
|
46
|
+
description: 'Require import and export paths to include any file extension.'
|
|
47
|
+
},
|
|
48
|
+
schema: [
|
|
49
|
+
{
|
|
50
|
+
enum: [
|
|
51
|
+
'always',
|
|
52
|
+
'ignorePackages'
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
create(context) {
|
|
58
|
+
const options = getOptions(context)
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
ExportAllDeclaration(node) {
|
|
62
|
+
checkSource(context, options, node)
|
|
63
|
+
},
|
|
64
|
+
ExportNamedDeclaration(node) {
|
|
65
|
+
checkSource(context, options, node)
|
|
66
|
+
},
|
|
67
|
+
ImportDeclaration(node) {
|
|
68
|
+
checkSource(context, options, node)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/plugin/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import extensionsRule from './extensions.js'
|
|
1
2
|
import importOrderRule from './import-order.js'
|
|
2
3
|
import memberOrderingRule from './member-ordering.js'
|
|
3
4
|
import namedImportOrderRule from './named-import-order.js'
|
|
@@ -5,9 +6,10 @@ import namingConventionRule from './naming-convention.js'
|
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
meta: {
|
|
8
|
-
name: '
|
|
9
|
+
name: 'trigen'
|
|
9
10
|
},
|
|
10
11
|
rules: {
|
|
12
|
+
'extensions': extensionsRule,
|
|
11
13
|
'import-order': importOrderRule,
|
|
12
14
|
'member-ordering': memberOrderingRule,
|
|
13
15
|
'named-import-order': namedImportOrderRule,
|
|
@@ -33,11 +33,21 @@ function getSelectorOptions(options, selector, modifiers = []) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function getNormalizedName(name, option) {
|
|
36
|
+
let normalizedName = name
|
|
37
|
+
|
|
36
38
|
if (option.leadingUnderscore === 'allow') {
|
|
37
|
-
|
|
39
|
+
normalizedName = normalizedName.replace(/^_+/, '')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (option.leadingDollar === 'allow') {
|
|
43
|
+
normalizedName = normalizedName.replace(/^\$+/, '')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (option.trailingDollar === 'allow') {
|
|
47
|
+
normalizedName = normalizedName.replace(/\$+$/, '')
|
|
38
48
|
}
|
|
39
49
|
|
|
40
|
-
return
|
|
50
|
+
return normalizedName
|
|
41
51
|
}
|
|
42
52
|
|
|
43
53
|
function matchesFormat(name, format) {
|
|
@@ -194,6 +204,12 @@ export default {
|
|
|
194
204
|
leadingUnderscore: {
|
|
195
205
|
type: 'string'
|
|
196
206
|
},
|
|
207
|
+
leadingDollar: {
|
|
208
|
+
type: 'string'
|
|
209
|
+
},
|
|
210
|
+
trailingDollar: {
|
|
211
|
+
type: 'string'
|
|
212
|
+
},
|
|
197
213
|
modifiers: {
|
|
198
214
|
type: 'array',
|
|
199
215
|
items: {
|
package/src/subconfigs/basic.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
+
jsPlugins: ['@trigen/oxlint-config/plugin'],
|
|
6
7
|
rules: {
|
|
7
8
|
'eslint/constructor-super': 'error',
|
|
8
9
|
'eslint/for-direction': 'error',
|
|
@@ -237,6 +238,70 @@ export default {
|
|
|
237
238
|
'eslint/no-unneeded-ternary': 'error',
|
|
238
239
|
'eslint/operator-assignment': ['error', 'always'],
|
|
239
240
|
'eslint/prefer-object-spread': 'error',
|
|
240
|
-
'eslint/unicode-bom': 'error'
|
|
241
|
+
'eslint/unicode-bom': 'error',
|
|
242
|
+
'trigen/naming-convention': [
|
|
243
|
+
'error',
|
|
244
|
+
{
|
|
245
|
+
selector: 'default',
|
|
246
|
+
format: [
|
|
247
|
+
'camelCase',
|
|
248
|
+
'PascalCase',
|
|
249
|
+
'UPPER_CASE'
|
|
250
|
+
],
|
|
251
|
+
leadingDollar: 'allow',
|
|
252
|
+
trailingDollar: 'allow'
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
selector: 'variable',
|
|
256
|
+
format: [
|
|
257
|
+
'camelCase',
|
|
258
|
+
'UPPER_CASE',
|
|
259
|
+
'PascalCase'
|
|
260
|
+
],
|
|
261
|
+
leadingDollar: 'allow',
|
|
262
|
+
trailingDollar: 'allow'
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
selector: 'function',
|
|
266
|
+
format: ['camelCase', 'PascalCase'],
|
|
267
|
+
leadingDollar: 'allow',
|
|
268
|
+
trailingDollar: 'allow'
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
selector: 'parameter',
|
|
272
|
+
format: ['camelCase', 'PascalCase'],
|
|
273
|
+
leadingUnderscore: 'allow',
|
|
274
|
+
leadingDollar: 'allow',
|
|
275
|
+
trailingDollar: 'allow'
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
selector: 'typeLike',
|
|
279
|
+
format: ['PascalCase']
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
selector: 'interface',
|
|
283
|
+
format: ['PascalCase']
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
selector: 'enumMember',
|
|
287
|
+
format: ['PascalCase']
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
selector: 'classProperty',
|
|
291
|
+
format: [
|
|
292
|
+
'camelCase',
|
|
293
|
+
'UPPER_CASE',
|
|
294
|
+
'PascalCase'
|
|
295
|
+
],
|
|
296
|
+
modifiers: ['static'],
|
|
297
|
+
leadingDollar: 'allow',
|
|
298
|
+
trailingDollar: 'allow'
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
selector: ['objectLiteralProperty', 'objectLiteralMethod'],
|
|
302
|
+
format: null,
|
|
303
|
+
modifiers: ['requiresQuotes']
|
|
304
|
+
}
|
|
305
|
+
]
|
|
241
306
|
}
|
|
242
307
|
}
|
package/src/subconfigs/import.js
CHANGED
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
plugins: ['import'],
|
|
7
|
-
jsPlugins: [
|
|
8
|
-
{
|
|
9
|
-
name: 'trigen',
|
|
10
|
-
specifier: '@trigen/oxlint-config/plugin'
|
|
11
|
-
}
|
|
12
|
-
],
|
|
7
|
+
jsPlugins: ['@trigen/oxlint-config/plugin'],
|
|
13
8
|
rules: {
|
|
14
9
|
'import/no-absolute-path': 'error',
|
|
15
10
|
'import/no-dynamic-require': 'error',
|
|
@@ -54,8 +54,6 @@ export default {
|
|
|
54
54
|
'typescript/no-unnecessary-template-expression': 'error',
|
|
55
55
|
'typescript/no-unnecessary-type-arguments': 'error',
|
|
56
56
|
'typescript/consistent-type-imports': 'error',
|
|
57
|
-
'eslint/dot-notation': 'off',
|
|
58
|
-
'typescript/dot-notation': 'error',
|
|
59
57
|
'typescript/prefer-includes': 'error',
|
|
60
58
|
'typescript/prefer-nullish-coalescing': 'off',
|
|
61
59
|
'typescript/prefer-optional-chain': 'error',
|
|
@@ -12,12 +12,7 @@ export default {
|
|
|
12
12
|
{
|
|
13
13
|
files: tsFiles,
|
|
14
14
|
plugins: ['typescript'],
|
|
15
|
-
jsPlugins: [
|
|
16
|
-
{
|
|
17
|
-
name: 'trigen',
|
|
18
|
-
specifier: '@trigen/oxlint-config/plugin'
|
|
19
|
-
}
|
|
20
|
-
],
|
|
15
|
+
jsPlugins: ['@trigen/oxlint-config/plugin'],
|
|
21
16
|
rules: {
|
|
22
17
|
// Recommended
|
|
23
18
|
'typescript/ban-ts-comment': [
|
|
@@ -108,60 +103,6 @@ export default {
|
|
|
108
103
|
]
|
|
109
104
|
}
|
|
110
105
|
}
|
|
111
|
-
],
|
|
112
|
-
'trigen/naming-convention': [
|
|
113
|
-
'error',
|
|
114
|
-
{
|
|
115
|
-
selector: 'default',
|
|
116
|
-
format: [
|
|
117
|
-
'camelCase',
|
|
118
|
-
'PascalCase',
|
|
119
|
-
'UPPER_CASE'
|
|
120
|
-
]
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
selector: 'variable',
|
|
124
|
-
format: [
|
|
125
|
-
'camelCase',
|
|
126
|
-
'UPPER_CASE',
|
|
127
|
-
'PascalCase'
|
|
128
|
-
]
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
selector: 'function',
|
|
132
|
-
format: ['camelCase', 'PascalCase']
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
selector: 'parameter',
|
|
136
|
-
format: ['camelCase', 'PascalCase'],
|
|
137
|
-
leadingUnderscore: 'allow'
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
selector: 'typeLike',
|
|
141
|
-
format: ['PascalCase']
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
selector: 'interface',
|
|
145
|
-
format: ['PascalCase']
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
selector: 'enumMember',
|
|
149
|
-
format: ['PascalCase']
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
selector: 'classProperty',
|
|
153
|
-
format: [
|
|
154
|
-
'camelCase',
|
|
155
|
-
'UPPER_CASE',
|
|
156
|
-
'PascalCase'
|
|
157
|
-
],
|
|
158
|
-
modifiers: ['static']
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
selector: ['objectLiteralProperty', 'objectLiteralMethod'],
|
|
162
|
-
format: null,
|
|
163
|
-
modifiers: ['requiresQuotes']
|
|
164
|
-
}
|
|
165
106
|
]
|
|
166
107
|
}
|
|
167
108
|
},
|