Skip to content

Commit

Permalink
feat: move disable rules to the end, remove deprecated rules
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 4, 2024
1 parent 402435f commit c3e2d2a
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 46 deletions.
1 change: 0 additions & 1 deletion src/configs/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export async function astro(
? {
'style/indent': 'off',
'style/jsx-closing-tag-location': 'off',
'style/jsx-indent': 'off',
'style/jsx-one-expression-per-line': 'off',
'style/no-multiple-empty-lines': 'off',
}
Expand Down
55 changes: 55 additions & 0 deletions src/configs/disables.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { GLOB_SRC, GLOB_SRC_EXT } from '../globs'
import type { TypedFlatConfigItem } from '../types'

export async function disables(): Promise<TypedFlatConfigItem[]> {
return [
{
files: [`scripts/${GLOB_SRC}`],
name: 'antfu/disables/scripts',
rules: {
'no-console': 'off',
'ts/explicit-function-return-type': 'off',
'unicorn/consistent-function-scoping': 'off',
},
},
{
files: [`cli/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
name: 'antfu/disables/cli',
rules: {
'no-console': 'off',
},
},
{
files: ['**/bin/**/*', `**/bin.${GLOB_SRC_EXT}`],
name: 'antfu/disables/bin',
rules: {
'antfu/no-import-dist': 'off',
'antfu/no-import-node-modules-by-path': 'off',
},
},
{
files: ['**/*.d.?([cm])ts'],
name: 'antfu/disables/dts',
rules: {
'eslint-comments/no-unlimited-disable': 'off',
'import/no-duplicates': 'off',
'no-restricted-syntax': 'off',
'unused-imports/no-unused-vars': 'off',
},
},
{
files: ['**/*.{test,spec}.([tj])s?(x)'],
name: 'antfu/disables/test',
rules: {
'no-unused-expressions': 'off',
},
},
{
files: ['**/*.js', '**/*.cjs'],
name: 'antfu/disables/cjs',
rules: {
'ts/no-require-imports': 'off',
},
},
]
}
9 changes: 0 additions & 9 deletions src/configs/imports.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { OptionsStylistic, TypedFlatConfigItem } from '../types'
import { pluginAntfu, pluginImport } from '../plugins'
import { GLOB_SRC_EXT } from '../globs'

export async function imports(options: OptionsStylistic = {}): Promise<TypedFlatConfigItem[]> {
const {
Expand Down Expand Up @@ -34,13 +33,5 @@ export async function imports(options: OptionsStylistic = {}): Promise<TypedFlat
: {},
},
},
{
files: ['**/bin/**/*', `**/bin.${GLOB_SRC_EXT}`],
name: 'antfu/imports/disables/bin',
rules: {
'antfu/no-import-dist': 'off',
'antfu/no-import-node-modules-by-path': 'off',
},
},
]
}
1 change: 1 addition & 0 deletions src/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export * from './unocss'
export * from './vue'
export * from './yaml'
export * from './regexp'
export * from './disables'
8 changes: 0 additions & 8 deletions src/configs/javascript.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import globals from 'globals'
import type { OptionsIsInEditor, OptionsOverrides, TypedFlatConfigItem } from '../types'
import { pluginAntfu, pluginUnusedImports } from '../plugins'
import { GLOB_SRC, GLOB_SRC_EXT } from '../globs'

export async function javascript(
options: OptionsIsInEditor & OptionsOverrides = {},
Expand Down Expand Up @@ -219,12 +218,5 @@ export async function javascript(
...overrides,
},
},
{
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
name: 'antfu/javascript/disables/cli',
rules: {
'no-console': 'off',
},
},
]
}
1 change: 0 additions & 1 deletion src/configs/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export async function markdown(
'ts/no-unused-expressions': 'off',
'ts/no-unused-vars': 'off',
'ts/no-use-before-define': 'off',
'ts/no-var-requires': 'off',

'unicode-bom': 'off',
'unused-imports/no-unused-imports': 'off',
Expand Down
1 change: 1 addition & 0 deletions src/configs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export async function test(
'test/prefer-lowercase-title': 'error',

'ts/explicit-function-return-type': 'off',
'unicorn/consistent-function-scoping': 'off',

...overrides,
},
Expand Down
27 changes: 0 additions & 27 deletions src/configs/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export async function typescript(
{ '@typescript-eslint': 'ts' },
),
'no-dupe-class-members': 'off',
'no-loss-of-precision': 'off',
'no-redeclare': 'off',
'no-use-before-define': 'off',
'no-useless-constructor': 'off',
Expand All @@ -138,7 +137,6 @@ export async function typescript(
'ts/no-extraneous-class': 'off',
'ts/no-import-type-side-effects': 'error',
'ts/no-invalid-void-type': 'off',
'ts/no-loss-of-precision': 'error',
'ts/no-non-null-assertion': 'off',
'ts/no-redeclare': 'error',
'ts/no-require-imports': 'error',
Expand Down Expand Up @@ -173,30 +171,5 @@ export async function typescript(
},
}]
: [],
{
files: ['**/*.d.?([cm])ts'],
name: 'antfu/typescript/disables/dts',
rules: {
'eslint-comments/no-unlimited-disable': 'off',
'import/no-duplicates': 'off',
'no-restricted-syntax': 'off',
'unused-imports/no-unused-vars': 'off',
},
},
{
files: ['**/*.{test,spec}.ts?(x)'],
name: 'antfu/typescript/disables/test',
rules: {
'no-unused-expressions': 'off',
},
},
{
files: ['**/*.js', '**/*.cjs'],
name: 'antfu/typescript/disables/cjs',
rules: {
'ts/no-require-imports': 'off',
'ts/no-var-requires': 'off',
},
},
]
}
5 changes: 5 additions & 0 deletions src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
astro,
command,
comments,
disables,
ignores,
imports,
javascript,
Expand Down Expand Up @@ -282,6 +283,10 @@ export function antfu(
))
}

configs.push(
disables(),
)

if ('files' in options) {
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.')
}
Expand Down

0 comments on commit c3e2d2a

Please sign in to comment.