From d86cbb818d5a8966ad1ecf800147c055dc5a61f9 Mon Sep 17 00:00:00 2001 From: Xin Yao Date: Mon, 29 Apr 2024 10:54:34 +0800 Subject: [PATCH] feat: add eslint perfectionist plugin --- eslint/index.js | 1 + eslint/perfectionist.js | 10 ++++++++++ eslint/presets.js | 2 ++ package.json | 1 + pnpm-lock.yaml | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 52 insertions(+) create mode 100644 eslint/perfectionist.js diff --git a/eslint/index.js b/eslint/index.js index 0426669..28aeb14 100644 --- a/eslint/index.js +++ b/eslint/index.js @@ -2,6 +2,7 @@ export * from './eslint-comments.js' export * from './js.js' export * from './jsonc.js' export * from './markdown.js' +export * from './perfectionist.js' export * from './presets.js' export * from './react.js' export * from './typescript.js' diff --git a/eslint/perfectionist.js b/eslint/perfectionist.js new file mode 100644 index 0000000..f450e42 --- /dev/null +++ b/eslint/perfectionist.js @@ -0,0 +1,10 @@ +import perfectionistPlugin from 'eslint-plugin-perfectionist' + +/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */ +export const perfectionist = [ + { + plugins: { + perfectionist: perfectionistPlugin, + }, + }, +] diff --git a/eslint/presets.js b/eslint/presets.js index e9c22c9..420e4fe 100644 --- a/eslint/presets.js +++ b/eslint/presets.js @@ -2,6 +2,7 @@ import { eslintComments } from './eslint-comments.js' import { imports, js, jsx, unicorn } from './js.js' import { jsonc, pkgOrder } from './jsonc.js' import { markdown } from './markdown.js' +import { perfectionist } from './perfectionist.js' import { GLOB_EXCLUDE } from './shared.js' import { typescript } from './typescript.js' import { vue } from './vue.js' @@ -27,6 +28,7 @@ export const basic = [ ...markdown, ...eslintComments, ...prettier, + ...perfectionist, ] /** @type { FlatESLintConfigItem[] } */ diff --git a/package.json b/package.json index e6e4ae6..2c53ab1 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "eslint-plugin-import-x": "^0.5.0", "eslint-plugin-jsonc": "^2.15.1", "eslint-plugin-markdown": "^4.0.1", + "eslint-plugin-perfectionist": "^2.10.0", "eslint-plugin-prettier": "^5.1.3", "eslint-plugin-react": "^7.34.1", "eslint-plugin-react-hooks": "^4.6.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b039bc5..cd2d222 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,6 +41,9 @@ importers: eslint-plugin-markdown: specifier: ^4.0.1 version: 4.0.1(eslint@9.1.1) + eslint-plugin-perfectionist: + specifier: ^2.10.0 + version: 2.10.0(eslint@9.1.1)(typescript@5.4.5)(vue-eslint-parser@9.4.2(eslint@9.1.1)) eslint-plugin-prettier: specifier: ^5.1.3 version: 5.1.3(eslint-config-prettier@9.1.0(eslint@9.1.1))(eslint@9.1.1)(prettier@3.2.5) @@ -854,6 +857,24 @@ packages: peerDependencies: eslint: '>=8' + eslint-plugin-perfectionist@2.10.0: + resolution: {integrity: sha512-P+tdrkHeMWBc55+DZsoDOAftV1WCsEoHaKm6JC7zajFus/syfT4vUPBFb3atGFSuyaVnGQGHlcKpP9X3Q0gH/w==} + peerDependencies: + astro-eslint-parser: ^0.16.0 + eslint: '>=8.0.0' + svelte: '>=3.0.0' + svelte-eslint-parser: ^0.33.0 + vue-eslint-parser: '>=9.0.0' + peerDependenciesMeta: + astro-eslint-parser: + optional: true + svelte: + optional: true + svelte-eslint-parser: + optional: true + vue-eslint-parser: + optional: true + eslint-plugin-prettier@5.1.3: resolution: {integrity: sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==} engines: {node: ^14.18.0 || >=16.0.0} @@ -1617,6 +1638,9 @@ packages: ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + natural-compare-lite@1.4.0: + resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} + natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} @@ -3256,6 +3280,18 @@ snapshots: transitivePeerDependencies: - supports-color + eslint-plugin-perfectionist@2.10.0(eslint@9.1.1)(typescript@5.4.5)(vue-eslint-parser@9.4.2(eslint@9.1.1)): + dependencies: + '@typescript-eslint/utils': 7.7.1(eslint@9.1.1)(typescript@5.4.5) + eslint: 9.1.1 + minimatch: 9.0.4 + natural-compare-lite: 1.4.0 + optionalDependencies: + vue-eslint-parser: 9.4.2(eslint@9.1.1) + transitivePeerDependencies: + - supports-color + - typescript + eslint-plugin-prettier@5.1.3(eslint-config-prettier@9.1.0(eslint@9.1.1))(eslint@9.1.1)(prettier@3.2.5): dependencies: eslint: 9.1.1 @@ -4075,6 +4111,8 @@ snapshots: ms@2.1.3: {} + natural-compare-lite@1.4.0: {} + natural-compare@1.4.0: {} node-fetch-native@1.6.1: {}