From dbf0dbbd9ab04f3ebc28b77ee6e9b2aef4f3ef42 Mon Sep 17 00:00:00 2001 From: Johann Schopplich Date: Mon, 18 Nov 2024 13:17:59 +0100 Subject: [PATCH] chore: enable `perfectionist` ESLint plugin --- docs/.vitepress/config.ts | 2 +- eslint.config.mjs | 29 ++++- package.json | 1 + playground/pages/jsonPlaceholder.vue | 2 +- pnpm-lock.yaml | 175 ++++++++++++++++++-------- src/kit.ts | 2 +- src/module.ts | 14 +-- src/openapi.ts | 4 +- src/runtime/composables/$api.ts | 14 +-- src/runtime/composables/useApiData.ts | 16 +-- src/runtime/openapi.ts | 6 +- src/runtime/server/$api.ts | 4 +- src/runtime/server/handler.ts | 6 +- src/runtime/types.ts | 2 +- src/runtime/utils.ts | 2 +- test/e2e.test.ts | 2 +- test/fixture/pages/$testApi-error.vue | 2 +- 17 files changed, 193 insertions(+), 90 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index a7a5ccb..1f8bd9d 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,6 +1,6 @@ -import { defineConfig } from 'vitepress' import type { DefaultTheme } from 'vitepress' import UnoCSS from 'unocss/vite' +import { defineConfig } from 'vitepress' import { description, version } from '../../package.json' import { github, name, ogImage, ogUrl, releases } from './meta' diff --git a/eslint.config.mjs b/eslint.config.mjs index db7232e..9707b8e 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,5 +1,5 @@ -// @ts-check import { createConfigForNuxt } from '@nuxt/eslint-config/flat' +import perfectionist from 'eslint-plugin-perfectionist' export default createConfigForNuxt({ features: { @@ -12,3 +12,30 @@ export default createConfigForNuxt({ ], }, }) + .append({ + plugins: { + perfectionist, + }, + rules: { + 'import/order': 'off', + 'perfectionist/sort-exports': ['error', { order: 'asc', type: 'natural' }], + 'perfectionist/sort-imports': ['error', { + groups: [ + 'type', + ['parent-type', 'sibling-type', 'index-type'], + 'builtin', + 'external', + ['internal', 'internal-type'], + ['parent', 'sibling', 'index'], + 'side-effect', + 'object', + 'unknown', + ], + newlinesBetween: 'ignore', + order: 'asc', + type: 'natural', + }], + 'perfectionist/sort-named-exports': ['error', { order: 'asc', type: 'natural' }], + 'perfectionist/sort-named-imports': ['error', { order: 'asc', type: 'natural' }], + }, + }) diff --git a/package.json b/package.json index de75ac6..8b18400 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "@types/node": "^22.9.0", "bumpp": "^9.8.1", "eslint": "^9.14.0", + "eslint-plugin-perfectionist": "^3.9.1", "nuxt": "^3.14.159", "openapi-typescript": "^7.4.3", "typescript": "^5.6.3", diff --git a/playground/pages/jsonPlaceholder.vue b/playground/pages/jsonPlaceholder.vue index 28ca28f..e85e5f5 100644 --- a/playground/pages/jsonPlaceholder.vue +++ b/playground/pages/jsonPlaceholder.vue @@ -1,7 +1,7 @@