Skip to content

Commit

Permalink
feat: refactor eslint.config
Browse files Browse the repository at this point in the history
- specify exact file mask for every shared config
- dry the last vue config with the normal config
  • Loading branch information
kirillgroshkov committed Jul 22, 2024
1 parent cbe42bd commit fc7c92d
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions cfg/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,37 @@ const tseslint = require('typescript-eslint')
const hasJest = require('node:fs').existsSync('./node_modules/jest')
// console.log({ hasJest })

const defaultFiles = ['**/*.ts', '**/*.tsx']

module.exports = [
eslint.configs.recommended,
{
...eslint.configs.recommended,
files: defaultFiles,
},
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-type-checked.ts
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.recommendedTypeChecked.map(c => ({
...c,
files: defaultFiles,
})),
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic-type-checked.ts
...tseslint.configs.stylisticTypeChecked,
...tseslint.configs.stylisticTypeChecked.map(c => ({
...c,
files: defaultFiles,
})),
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/configs/recommended.js
require('eslint-plugin-unicorn').configs['flat/recommended'],
// https://eslint.vuejs.org/user-guide/#user-guide
...require('eslint-plugin-vue').configs['flat/recommended'],
{
files: ['**/*.ts', '**/*.tsx'],
...getConfig(),
...require('eslint-plugin-unicorn').configs['flat/recommended'],
files: defaultFiles,
},
// https://eslint.vuejs.org/user-guide/#user-guide
// ...require('eslint-plugin-vue').configs['flat/recommended'],
...require('eslint-plugin-vue').configs['flat/recommended'].map(c => ({
...c,
files: defaultFiles,
})),
{
files: ['*.vue', '**/*.vue'],
languageOptions: {
parserOptions: {
project: 'tsconfig.json',
parser: tseslint.parser,
extraFileExtensions: ['.vue', '.html'],
},
},
plugins: getConfig().plugins,
rules: getConfig().rules,
files: defaultFiles,
...getConfig(),
},
{
ignores: ['**/__exclude/**', '**/*.scss', '**/*.js'],
Expand All @@ -63,10 +69,10 @@ function getConfig() {
// testcafe
fixture: 'readonly',
},
parser: tseslint.parser,
// parser: tseslint.parser,
parserOptions: {
project: 'tsconfig.json',
ecmaVersion: 'latest',
parser: tseslint.parser,
extraFileExtensions: ['.vue', '.html'],
},
},
Expand Down

0 comments on commit fc7c92d

Please sign in to comment.