-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint): update to eslint@9 and use flat config
- Loading branch information
Showing
22 changed files
with
1,210 additions
and
1,261 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const eslint = require('@tomjs/eslint'); | ||
|
||
/** | ||
* @type {import('eslint').Linter.Config[]} | ||
*/ | ||
module.exports = [ | ||
...eslint, | ||
{ ignores: ['public', 'dist', 'build', 'packages/*/es', 'packages/*/lib'] }, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export const GLOB_EXCLUDE = [ | ||
'**/node_modules', | ||
'**/dist', | ||
'**/package-lock.json', | ||
'**/yarn.lock', | ||
'**/pnpm-lock.yaml', | ||
'**/bun.lockb', | ||
|
||
'**/output', | ||
'**/coverage', | ||
'**/temp', | ||
'**/.temp', | ||
'**/tmp', | ||
'**/.tmp', | ||
'**/.history', | ||
'**/.vitepress/cache', | ||
'**/.nuxt', | ||
'**/.next', | ||
'**/.svelte-kit', | ||
'**/.vercel', | ||
'**/.changeset', | ||
'**/.idea', | ||
'**/.cache', | ||
'**/.output', | ||
'**/.vite-inspect', | ||
'**/.yarn', | ||
'**/vite.config.*.timestamp-*', | ||
|
||
'**/CHANGELOG*.md', | ||
'**/*.min.*', | ||
'**/LICENSE*', | ||
'**/__snapshots__', | ||
'**/auto-import?(s).d.ts', | ||
'**/components.d.ts', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import js from './javascript'; | ||
import nodeJs from './node/javascript'; | ||
import node from './node/typescript'; | ||
import reactJs from './react/javascript'; | ||
import react from './react/typescript'; | ||
import ts from './typescript'; | ||
import vueJs from './vue/javascript'; | ||
import vue from './vue/typescript'; | ||
import vue2Js from './vue2/javascript'; | ||
import vue2 from './vue2/typescript'; | ||
|
||
export const meta = { | ||
name: '@tomjs/eslint', | ||
version: require('../package.json').version, | ||
}; | ||
|
||
const configs = { | ||
ts, | ||
js, | ||
node, | ||
'node/js': nodeJs, | ||
vue, | ||
'vue/js': vueJs, | ||
vue2, | ||
'vue2/js': vue2Js, | ||
react, | ||
'react/js': reactJs, | ||
}; | ||
|
||
export default { | ||
meta, | ||
configs, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,60 @@ | ||
import type { ESLintConfig } from 'eslint-define-config'; | ||
import eslint from '@eslint/js'; | ||
import type { Linter } from 'eslint'; | ||
import importPlugin from 'eslint-plugin-import'; | ||
import prettierRecommended from 'eslint-plugin-prettier/recommended'; | ||
import simpleImportSort from 'eslint-plugin-simple-import-sort'; | ||
import globals from 'globals'; | ||
import { GLOB_EXCLUDE } from './globs'; | ||
|
||
export default { | ||
env: { | ||
es6: true, | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
}, | ||
plugins: ['import', 'simple-import-sort'], | ||
extends: ['eslint:recommended', 'plugin:prettier/recommended'], | ||
overrides: [ | ||
{ | ||
env: { | ||
node: true, | ||
}, | ||
files: ['.*rc.{js,cjs}'], | ||
parserOptions: { | ||
sourceType: 'script', | ||
}, | ||
const config: Linter.Config[] = [ | ||
eslint.configs.recommended, | ||
importPlugin.flatConfigs.recommended, | ||
prettierRecommended, | ||
{ | ||
plugins: { | ||
'simple-import-sort': simpleImportSort, | ||
}, | ||
], | ||
rules: { | ||
/**************************** base ****************************/ | ||
'no-unused-vars': [ | ||
'error', | ||
{ | ||
args: 'after-used', | ||
ignoreRestSiblings: true, | ||
argsIgnorePattern: '^_', | ||
}, | ||
], | ||
'no-empty': ['error', { allowEmptyCatch: true }], | ||
rules: { | ||
/**************************** base ****************************/ | ||
'no-unused-vars': [ | ||
'error', | ||
{ | ||
args: 'after-used', | ||
ignoreRestSiblings: true, | ||
argsIgnorePattern: '^_', | ||
}, | ||
], | ||
'no-empty': ['error', { allowEmptyCatch: true }], | ||
|
||
/************************* import sort *************************/ | ||
'simple-import-sort/imports': [ | ||
'error', | ||
{ | ||
groups: [ | ||
['^\\u0000'], | ||
['^node:', '^@?\\w', '^', '^\\.'], | ||
// Style imports. | ||
['^.+\\.(scss|less|css)$'], | ||
], | ||
/************************* import sort *************************/ | ||
'simple-import-sort/imports': [ | ||
'error', | ||
{ | ||
groups: [ | ||
['^\\u0000'], | ||
['^node:', '^@?\\w', '^', '^\\.'], | ||
// Style imports. | ||
['^.+\\.(scss|less|css)$'], | ||
], | ||
}, | ||
], | ||
'simple-import-sort/exports': 'error', | ||
/************************* import *************************/ | ||
'import/first': 'error', | ||
'import/newline-after-import': 'error', | ||
'import/no-duplicates': 'error', | ||
'import/no-unresolved': 'off', | ||
}, | ||
ignores: [...GLOB_EXCLUDE], | ||
}, | ||
{ | ||
files: ['.*rc.{js,cjs,mjs}', '*.config.{js,cjs,mjs}'], | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
}, | ||
], | ||
'simple-import-sort/exports': 'error', | ||
'import/first': 'error', | ||
'import/newline-after-import': 'error', | ||
'import/no-duplicates': 'error', | ||
}, | ||
}, | ||
} as ESLintConfig; | ||
]; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
import type { ESLintConfig } from 'eslint-define-config'; | ||
import type { Linter } from 'eslint'; | ||
import node from 'eslint-plugin-n'; | ||
import nodeImport from 'eslint-plugin-node-import'; | ||
import globals from 'globals'; | ||
import javascript from '../javascript'; | ||
|
||
export default { | ||
env: { | ||
node: true, | ||
browser: false, | ||
es6: true, | ||
const config: Linter.Config[] = [ | ||
...javascript, | ||
node.configs['flat/recommended'], | ||
{ | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
}, | ||
}, | ||
plugins: { | ||
'node-import': nodeImport, | ||
}, | ||
rules: { | ||
// disable rules | ||
'n/shebang': 'off', | ||
'n/hashbang': 'off', | ||
'n/no-process-exit': 'off', | ||
// enable rules | ||
'n/no-path-concat': 'error', | ||
// disallow imports of built-in Node.js modules without the node: prefix | ||
'node-import/prefer-node-protocol': 'error', | ||
// fix bug | ||
'n/no-missing-import': 'off', | ||
'n/no-missing-require': 'off', | ||
'n/no-extraneous-import': 'off', | ||
'n/no-extraneous-require': 'off', | ||
'n/no-unpublished-require': 'off', | ||
'n/no-unpublished-import': 'off', | ||
}, | ||
}, | ||
extends: ['../javascript', 'plugin:n/recommended'], | ||
plugins: ['node-import'], | ||
rules: { | ||
// disable rules | ||
'n/shebang': 'off', | ||
'n/hashbang': 'off', | ||
'n/no-process-exit': 'off', | ||
// enable rules | ||
'n/no-path-concat': 'error', | ||
// disallow imports of built-in Node.js modules without the node: prefix | ||
'node-import/prefer-node-protocol': 'error', | ||
// fix bug | ||
'n/no-missing-import': 'off', | ||
'n/no-missing-require': 'off', | ||
'n/no-extraneous-import': 'off', | ||
'n/no-extraneous-require': 'off', | ||
'n/no-unpublished-require': 'off', | ||
'n/no-unpublished-import': 'off', | ||
}, | ||
} as ESLintConfig; | ||
]; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
import type { ESLintConfig } from 'eslint-define-config'; | ||
import type { Linter } from 'eslint'; | ||
import typescript from '../typescript'; | ||
import javascript from './javascript'; | ||
|
||
export default { | ||
env: { | ||
node: true, | ||
es6: true, | ||
}, | ||
extends: ['./javascript', '../typescript'], | ||
rules: {}, | ||
} as ESLintConfig; | ||
const config: Linter.Config[] = [...javascript, ...typescript]; | ||
|
||
export default config; |
Oops, something went wrong.