Skip to content

Commit

Permalink
Simplify eslint.config.mts
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed Aug 27, 2024
1 parent 8297b2e commit 4558949
Showing 1 changed file with 7 additions and 47 deletions.
54 changes: 7 additions & 47 deletions codemods/eslint.config.mts
Original file line number Diff line number Diff line change
@@ -1,70 +1,37 @@
import js from '@eslint/js'
import prettierConfig from 'eslint-config-prettier'
import globals from 'globals'
import { config, configs, parser, plugin } from 'typescript-eslint'

const { browser, node, nodeBuiltin } = globals

export const vitestGlobals = {
suite: false,
test: false,
describe: false,
it: false,
expectTypeOf: false,
assertType: false,
expect: false,
assert: false,
vitest: false,
vi: false,
beforeAll: false,
afterAll: false,
beforeEach: false,
afterEach: false,
onTestFailed: false,
onTestFinished: false,
} satisfies Record<string, boolean>
import { config, configs, parser } from 'typescript-eslint'

const ESLintConfig = config(
{ name: 'ignores', ignores: ['**/dist/', '**/__testfixtures__/'] },
{ name: 'ignores', ignores: ['**/dist/'] },
{ name: 'javascript', ...js.configs.recommended },
...configs.recommended,
...configs.stylistic,
{ name: 'prettier-config', ...prettierConfig },
{
name: 'main',
languageOptions: {
globals: {
...vitestGlobals,
...nodeBuiltin,
...browser,
...node,
},
parser,
parserOptions: {
projectService: true,
projectService: {
defaultProject: './tsconfig.json',
},
ecmaVersion: 'latest',
},
},
rules: {
'prefer-const': [2],
'no-undef': [0],
'@typescript-eslint/consistent-type-imports': [
2,
{ fixStyle: 'separate-type-imports', disallowTypeAnnotations: false },
],
'@typescript-eslint/consistent-type-exports': [2],
'@typescript-eslint/no-unused-vars': [0],
'@typescript-eslint/array-type': [2, { default: 'array-simple' }],
'@typescript-eslint/no-explicit-any': [0],
'@typescript-eslint/no-empty-interface': [
'@typescript-eslint/no-empty-object-type': [
2,
{ allowSingleExtends: true },
{ allowInterfaces: 'with-single-extends' },
],
'@typescript-eslint/no-unsafe-argument': [0],
'@typescript-eslint/no-restricted-types': [2],
'@typescript-eslint/no-empty-object-type': [2],
'@typescript-eslint/no-unsafe-function-type': [2],
'@typescript-eslint/no-wrapper-object-types': [2],
'@typescript-eslint/no-namespace': [
2,
{ allowDeclarations: true, allowDefinitionFiles: true },
Expand All @@ -81,23 +48,16 @@ const ESLintConfig = config(
},
],
},
plugins: { '@typescript-eslint': plugin },
linterOptions: { reportUnusedDisableDirectives: 2 },
},
{
name: 'commonjs',
files: ['**/*.c[jt]s'],
languageOptions: { sourceType: 'commonjs' },
rules: {
'@typescript-eslint/no-var-requires': [0],
'@typescript-eslint/no-require-imports': [0],
},
},
{
name: 'typescript-declaration-files',
files: ['**/*.d.?(c|m)ts'],
rules: { '@typescript-eslint/no-empty-object-type': [0] },
},
)

export default ESLintConfig

0 comments on commit 4558949

Please sign in to comment.