Skip to content

Commit c3e2d2a

Browse files
committedSep 4, 2024
feat: move disable rules to the end, remove deprecated rules
1 parent 402435f commit c3e2d2a

9 files changed

+62
-46
lines changed
 

‎src/configs/astro.ts

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export async function astro(
5858
? {
5959
'style/indent': 'off',
6060
'style/jsx-closing-tag-location': 'off',
61-
'style/jsx-indent': 'off',
6261
'style/jsx-one-expression-per-line': 'off',
6362
'style/no-multiple-empty-lines': 'off',
6463
}

‎src/configs/disables.ts

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { GLOB_SRC, GLOB_SRC_EXT } from '../globs'
2+
import type { TypedFlatConfigItem } from '../types'
3+
4+
export async function disables(): Promise<TypedFlatConfigItem[]> {
5+
return [
6+
{
7+
files: [`scripts/${GLOB_SRC}`],
8+
name: 'antfu/disables/scripts',
9+
rules: {
10+
'no-console': 'off',
11+
'ts/explicit-function-return-type': 'off',
12+
'unicorn/consistent-function-scoping': 'off',
13+
},
14+
},
15+
{
16+
files: [`cli/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
17+
name: 'antfu/disables/cli',
18+
rules: {
19+
'no-console': 'off',
20+
},
21+
},
22+
{
23+
files: ['**/bin/**/*', `**/bin.${GLOB_SRC_EXT}`],
24+
name: 'antfu/disables/bin',
25+
rules: {
26+
'antfu/no-import-dist': 'off',
27+
'antfu/no-import-node-modules-by-path': 'off',
28+
},
29+
},
30+
{
31+
files: ['**/*.d.?([cm])ts'],
32+
name: 'antfu/disables/dts',
33+
rules: {
34+
'eslint-comments/no-unlimited-disable': 'off',
35+
'import/no-duplicates': 'off',
36+
'no-restricted-syntax': 'off',
37+
'unused-imports/no-unused-vars': 'off',
38+
},
39+
},
40+
{
41+
files: ['**/*.{test,spec}.([tj])s?(x)'],
42+
name: 'antfu/disables/test',
43+
rules: {
44+
'no-unused-expressions': 'off',
45+
},
46+
},
47+
{
48+
files: ['**/*.js', '**/*.cjs'],
49+
name: 'antfu/disables/cjs',
50+
rules: {
51+
'ts/no-require-imports': 'off',
52+
},
53+
},
54+
]
55+
}

‎src/configs/imports.ts

-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { OptionsStylistic, TypedFlatConfigItem } from '../types'
22
import { pluginAntfu, pluginImport } from '../plugins'
3-
import { GLOB_SRC_EXT } from '../globs'
43

54
export async function imports(options: OptionsStylistic = {}): Promise<TypedFlatConfigItem[]> {
65
const {
@@ -34,13 +33,5 @@ export async function imports(options: OptionsStylistic = {}): Promise<TypedFlat
3433
: {},
3534
},
3635
},
37-
{
38-
files: ['**/bin/**/*', `**/bin.${GLOB_SRC_EXT}`],
39-
name: 'antfu/imports/disables/bin',
40-
rules: {
41-
'antfu/no-import-dist': 'off',
42-
'antfu/no-import-node-modules-by-path': 'off',
43-
},
44-
},
4536
]
4637
}

‎src/configs/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ export * from './unocss'
2424
export * from './vue'
2525
export * from './yaml'
2626
export * from './regexp'
27+
export * from './disables'

‎src/configs/javascript.ts

-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import globals from 'globals'
22
import type { OptionsIsInEditor, OptionsOverrides, TypedFlatConfigItem } from '../types'
33
import { pluginAntfu, pluginUnusedImports } from '../plugins'
4-
import { GLOB_SRC, GLOB_SRC_EXT } from '../globs'
54

65
export async function javascript(
76
options: OptionsIsInEditor & OptionsOverrides = {},
@@ -219,12 +218,5 @@ export async function javascript(
219218
...overrides,
220219
},
221220
},
222-
{
223-
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
224-
name: 'antfu/javascript/disables/cli',
225-
rules: {
226-
'no-console': 'off',
227-
},
228-
},
229221
]
230222
}

‎src/configs/markdown.ts

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ export async function markdown(
7878
'ts/no-unused-expressions': 'off',
7979
'ts/no-unused-vars': 'off',
8080
'ts/no-use-before-define': 'off',
81-
'ts/no-var-requires': 'off',
8281

8382
'unicode-bom': 'off',
8483
'unused-imports/no-unused-imports': 'off',

‎src/configs/test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export async function test(
5353
'test/prefer-lowercase-title': 'error',
5454

5555
'ts/explicit-function-return-type': 'off',
56+
'unicorn/consistent-function-scoping': 'off',
5657

5758
...overrides,
5859
},

‎src/configs/typescript.ts

-27
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ export async function typescript(
119119
{ '@typescript-eslint': 'ts' },
120120
),
121121
'no-dupe-class-members': 'off',
122-
'no-loss-of-precision': 'off',
123122
'no-redeclare': 'off',
124123
'no-use-before-define': 'off',
125124
'no-useless-constructor': 'off',
@@ -138,7 +137,6 @@ export async function typescript(
138137
'ts/no-extraneous-class': 'off',
139138
'ts/no-import-type-side-effects': 'error',
140139
'ts/no-invalid-void-type': 'off',
141-
'ts/no-loss-of-precision': 'error',
142140
'ts/no-non-null-assertion': 'off',
143141
'ts/no-redeclare': 'error',
144142
'ts/no-require-imports': 'error',
@@ -173,30 +171,5 @@ export async function typescript(
173171
},
174172
}]
175173
: [],
176-
{
177-
files: ['**/*.d.?([cm])ts'],
178-
name: 'antfu/typescript/disables/dts',
179-
rules: {
180-
'eslint-comments/no-unlimited-disable': 'off',
181-
'import/no-duplicates': 'off',
182-
'no-restricted-syntax': 'off',
183-
'unused-imports/no-unused-vars': 'off',
184-
},
185-
},
186-
{
187-
files: ['**/*.{test,spec}.ts?(x)'],
188-
name: 'antfu/typescript/disables/test',
189-
rules: {
190-
'no-unused-expressions': 'off',
191-
},
192-
},
193-
{
194-
files: ['**/*.js', '**/*.cjs'],
195-
name: 'antfu/typescript/disables/cjs',
196-
rules: {
197-
'ts/no-require-imports': 'off',
198-
'ts/no-var-requires': 'off',
199-
},
200-
},
201174
]
202175
}

‎src/factory.ts

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
astro,
77
command,
88
comments,
9+
disables,
910
ignores,
1011
imports,
1112
javascript,
@@ -282,6 +283,10 @@ export function antfu(
282283
))
283284
}
284285

286+
configs.push(
287+
disables(),
288+
)
289+
285290
if ('files' in options) {
286291
throw new Error('[@antfu/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.')
287292
}

0 commit comments

Comments
 (0)
Please sign in to comment.