Skip to content

Commit

Permalink
feat: remove eslint-config-standard and add eslint-plugin-import-x
Browse files Browse the repository at this point in the history
  • Loading branch information
tjx666 committed May 24, 2024
1 parent 28c1a8a commit 05ea2de
Show file tree
Hide file tree
Showing 11 changed files with 726 additions and 401 deletions.
3 changes: 2 additions & 1 deletion fixtures/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"devDependencies": {
"@vitejs/plugin-vue": "^4.1.0",
"@yutengjing/eslint-config-vue": "workspace:*",
"eslint-define-config": "^2.1.0"
"eslint-define-config": "^2.1.0",
"vite": "^2.6.4"
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@
},
"devDependencies": {
"@types/eslint": "^8.56.10",
"@types/node": "^20.12.8",
"@types/node": "^20.12.12",
"@yutengjing/eslint-config-react": "workspace:*",
"@yutengjing/eslint-config-typescript": "workspace:*",
"@yutengjing/eslint-config-vue": "workspace:*",
"@yutengjing/eslint-plugin": "workspace:*",
"@yutengjing/prettier-config": "^1.2.0",
"@yutengjing/prettier-config": "^1.3.0",
"@yutengjing/tsconfig-node-commonjs": "^0.0.5",
"bumpp": "^9.4.1",
"eslint": "^8.57.0",
"eslint-plugin-eslint-plugin": "^6.1.0",
"lint-staged": "^15.2.2",
"lint-staged": "^15.2.4",
"prettier": "^3.2.5",
"react": "^18.3.1",
"rimraf": "^5.0.5",
"rimraf": "^5.0.7",
"simple-git-hooks": "^2.11.1",
"typescript": "^5.4.5",
"vite": "^5.2.11"
Expand Down
99 changes: 46 additions & 53 deletions packages/basic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ const error = 'error';

module.exports = defineConfig({
extends: [
'plugin:import/recommended',
'plugin:import-x/recommended',
'plugin:promise/recommended',
'standard',
'plugin:regexp/recommended',
'plugin:eslint-comments/recommended',
'plugin:jsdoc/recommended',
'plugin:unicorn/recommended',
'plugin:json-schema-validator/recommended',
'plugin:jsonc/recommended-with-jsonc',
'plugin:jsonc/prettier',
'plugin:yml/standard',
'plugin:yml/prettier',
'plugin:markdown/recommended',
'plugin:markdown/recommended-legacy',
'plugin:node-dependencies/recommended',
'prettier',
],
Expand Down Expand Up @@ -51,53 +49,30 @@ module.exports = defineConfig({
'!.vscode',
'**/.vitepress/cache',
],
plugins: ['html', 'no-only-tests', 'unused-imports', 'simple-import-sort', '@yutengjing'],
plugins: [
'eslint-plugin-n',
'html',
'no-only-tests',
'unused-imports',
'simple-import-sort',
'@yutengjing',
],
settings: {
'import/resolver': {
'import-x/resolver': {
node: { extensions: ['.js', '.mjs', '.cjs'] },
},
},
overrides: [
{
files: ['*.json', '*.jsonc', '*.json5'],
parser: 'jsonc-eslint-parser',
rules: {
'json-schema-validator/no-invalid': [
error,
{
schemas: [
{
fileMatch: ['package.json'],
schema: {
type: 'object',
properties: {
pnpm: {
type: 'object',
properties: {
overrides: {
type: 'object',
additionalProperties: {
type: 'string',
pattern: '^[^\\^].+',
},
},
},
},
},
},
},
],
},
],
},
},
{
files: ['*.yaml', '*.yml'],
parser: 'yaml-eslint-parser',
},
{
files: ['package.json'],
files: ['*.json', '*.jsonc', '*.json5'],
parser: 'jsonc-eslint-parser',
},
{
files: ['package.json'],
rules: {
'jsonc/sort-keys': [
error,
Expand All @@ -109,6 +84,10 @@ module.exports = defineConfig({
pathPattern: '^(?:dev|peer|optional|bundled|neverBuilt)?[Dd]ependencies$',
order: { type: 'asc' },
},
{
pathPattern: '^resolutions$',
order: { type: 'asc' },
},
{
pathPattern: '^exports.*$',
order: ['types', 'require', 'import'],
Expand Down Expand Up @@ -144,7 +123,7 @@ module.exports = defineConfig({
'@typescript-eslint/no-use-before-define': off,
'@typescript-eslint/no-var-requires': off,
'@typescript-eslint/comma-dangle': off,
'import/no-unresolved': off,
'import-x/no-unresolved': off,
'no-alert': off,
'no-console': off,
'no-restricted-imports': off,
Expand All @@ -161,17 +140,26 @@ module.exports = defineConfig({
'@yutengjing/no-vue-filename-index': error,
'@yutengjing/prefer-jsdoc': error,

'n/handle-callback-err': [error, '^(err|error)$'],
'n/no-deprecated-api': error,
'n/no-exports-assign': error,
'n/no-new-require': error,
'n/no-path-concat': error,
'n/prefer-global/buffer': [error, 'never'],
'n/prefer-global/process': [error, 'never'],
'n/process-exit-as-throw': error,

// import
'import/extensions': [error, 'ignorePackages', { js: 'never', ts: 'never', tsx: 'never' }],
'import/namespace': off,
'import/newline-after-import': error,
'import/no-absolute-path': off,
'import/no-duplicates': error,
'import/no-mutable-exports': error,
'import/no-named-as-default-member': off,
'import/no-named-as-default': off,
'import/no-unresolved': off,
'import/order': off,
'import-x/consistent-type-specifier-style': [error, 'prefer-top-level'],
'import-x/namespace': off,
'import-x/newline-after-import': error,
'import-x/no-absolute-path': off,
'import-x/no-duplicates': error,
'import-x/no-mutable-exports': error,
'import-x/no-named-as-default-member': off,
'import-x/no-named-as-default': off,
'import-x/no-unresolved': error,
'import-x/order': off,

// import order
// https://github.com/lydell/eslint-plugin-simple-import-sort/blob/main/examples/.eslintrc.js#L69
Expand All @@ -181,8 +169,13 @@ module.exports = defineConfig({
groups: [
// Side effect imports.
['^\\u0000'],
// Node.js builtins prefixed with `node:`.
['^node:'],
// Node.js builtins
[
'^node:',
`^(${require('node:module')
.builtinModules.filter((mod) => mod !== 'constants')
.join('|')})(/.*|$)`,
],
// framework
['^astro', '^react', '^vue'],
// Packages.
Expand Down
16 changes: 7 additions & 9 deletions packages/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,20 @@
"dependencies": {
"@yutengjing/eslint-plugin": "workspace:*",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-define-config": "^2.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsdoc": "^48.2.3",
"eslint-plugin-json-schema-validator": "^5.1.0",
"eslint-plugin-html": "^8.1.1",
"eslint-plugin-import-x": "^0.5.0",
"eslint-plugin-jsdoc": "^48.2.6",
"eslint-plugin-jsonc": "^2.15.1",
"eslint-plugin-markdown": "^3.0.1",
"eslint-plugin-n": "^17.4.0",
"eslint-plugin-markdown": "^5.0.0",
"eslint-plugin-n": "^17.7.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-node-dependencies": "^0.12.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-regexp": "^2.5.0",
"eslint-plugin-regexp": "^2.6.0",
"eslint-plugin-simple-import-sort": "^12.1.0",
"eslint-plugin-unicorn": "^52.0.0",
"eslint-plugin-unicorn": "^53.0.0",
"eslint-plugin-unused-imports": "^3.2.0",
"eslint-plugin-yml": "^1.14.0",
"jsonc-eslint-parser": "^2.4.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test": "mocha tests --recursive"
},
"dependencies": {
"autocorrect-node": "^2.9.0"
"autocorrect-node": "^2.10.0"
},
"devDependencies": {
"mocha": "^10.4.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.6"
"eslint-plugin-react-refresh": "^0.4.7"
}
}
11 changes: 8 additions & 3 deletions packages/typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const error = 'error';
module.exports = defineConfig({
extends: [
'@yutengjing/eslint-config-basic',
'plugin:import/typescript',
'plugin:import-x/typescript',
'plugin:@typescript-eslint/recommended',
'prettier',
],
settings: {
'import/resolver': {
'import-x/resolver': {
node: {
extensions: ['.js', '.jsx', '.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts', '.d.ts'],
},
Expand All @@ -34,6 +34,8 @@ module.exports = defineConfig({
{
files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
rules: {
'import-x/no-unresolved': off,
'import-x/default': off,
'no-useless-constructor': off,
'jsdoc/require-param-type': off,
'jsdoc/require-returns-check': off,
Expand All @@ -42,7 +44,10 @@ module.exports = defineConfig({
// seems will cause error whe lint json if put in rules
'@typescript-eslint/consistent-type-imports': [
error,
{ prefer: 'type-imports', disallowTypeAnnotations: false },
{
prefer: 'type-imports',
fixStyle: 'separate-type-imports',
},
],
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"typescript": "^5.4.5"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"@yutengjing/eslint-config-basic": "workspace:*",
"eslint-define-config": "^2.1.0",
"eslint-import-resolver-typescript": "^3.6.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = defineConfig({
'prettier',
],
settings: {
'import/resolver': {
'import-x/resolver': {
node: { extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.d.ts', '.vue'] },
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
"@yutengjing/eslint-config-typescript": "workspace:*",
"eslint-define-config": "^2.1.0",
"eslint-plugin-css": "^0.9.2",
"eslint-plugin-vue": "^9.25.0"
"eslint-plugin-vue": "^9.26.0"
}
}
Loading

0 comments on commit 05ea2de

Please sign in to comment.