From a6efa0957a6189001b85d1a1d68a90511dae2022 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Fri, 6 Sep 2024 04:49:07 +0200 Subject: [PATCH] feat: enable `perfectionist/sort-imports` et al, close #456 --- eslint.config.ts | 1 + scripts/typegen.ts | 4 +++- src/cli/constants.ts | 2 ++ src/cli/index.ts | 8 +++++--- src/cli/run.ts | 10 ++++++---- src/cli/stages/update-eslint-files.ts | 8 +++++--- src/cli/stages/update-package-json.ts | 6 ++++-- src/cli/stages/update-vscode-settings.ts | 8 +++++--- src/configs/astro.ts | 3 ++- src/configs/command.ts | 1 + src/configs/comments.ts | 3 ++- src/configs/disables.ts | 1 + src/configs/formatters.ts | 6 ++++-- src/configs/ignores.ts | 3 ++- src/configs/imports.ts | 4 ++-- src/configs/index.ts | 6 +++--- src/configs/javascript.ts | 15 +++------------ src/configs/jsdoc.ts | 1 + src/configs/jsonc.ts | 3 ++- src/configs/jsx.ts | 3 ++- src/configs/markdown.ts | 4 +++- src/configs/node.ts | 3 ++- src/configs/perfectionist.ts | 24 ++++++++++++++++++++++-- src/configs/react.ts | 4 +++- src/configs/regexp.ts | 1 + src/configs/solid.ts | 3 ++- src/configs/stylistic.ts | 3 ++- src/configs/svelte.ts | 3 ++- src/configs/test.ts | 3 ++- src/configs/toml.ts | 3 ++- src/configs/typescript.ts | 12 +++++++++++- src/configs/unicorn.ts | 3 ++- src/configs/unocss.ts | 1 + src/configs/vue.ts | 13 +++++++++++-- src/configs/yaml.ts | 3 ++- src/factory.ts | 9 ++++++--- src/plugins.ts | 4 ++-- src/types.ts | 9 +++++---- src/utils.ts | 2 ++ test/cli.spec.ts | 1 + test/fixtures.test.ts | 6 ++++-- test/types.ts | 3 ++- 42 files changed, 146 insertions(+), 67 deletions(-) diff --git a/eslint.config.ts b/eslint.config.ts index 478e4a43f0..10f6b4751e 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -1,5 +1,6 @@ // @ts-expect-error missing types import styleMigrate from '@stylistic/eslint-plugin-migrate' + import { antfu } from './src' export default antfu( diff --git a/scripts/typegen.ts b/scripts/typegen.ts index 423f8fc505..fda5fd1bfb 100644 --- a/scripts/typegen.ts +++ b/scripts/typegen.ts @@ -1,6 +1,8 @@ import fs from 'node:fs/promises' -import { flatConfigsToRulesDTS } from 'eslint-typegen/core' + import { builtinRules } from 'eslint/use-at-your-own-risk' +import { flatConfigsToRulesDTS } from 'eslint-typegen/core' + import { astro, combine, comments, formatters, imports, javascript, jsdoc, jsonc, jsx, markdown, node, perfectionist, react, regexp, solid, sortPackageJson, stylistic, svelte, test, toml, typescript, unicorn, unocss, vue, yaml } from '../src' const configs = await combine( diff --git a/src/cli/constants.ts b/src/cli/constants.ts index 914af8c109..f6c6e407f4 100644 --- a/src/cli/constants.ts +++ b/src/cli/constants.ts @@ -1,5 +1,7 @@ import c from 'picocolors' + import pkgJson from '../../package.json' + import type { ExtraLibrariesOption, FrameworkOption, PromItem } from './types' export { pkgJson } diff --git a/src/cli/index.ts b/src/cli/index.ts index a55be8d4d8..29164ab5a8 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -1,10 +1,12 @@ import process from 'node:process' + +import * as p from '@clack/prompts' import c from 'picocolors' -import { hideBin } from 'yargs/helpers' import yargs from 'yargs' -import * as p from '@clack/prompts' -import { run } from './run' +import { hideBin } from 'yargs/helpers' + import { pkgJson } from './constants' +import { run } from './run' function header(): void { // eslint-disable-next-line no-console diff --git a/src/cli/run.ts b/src/cli/run.ts index 6e17656cbf..788cedca2e 100644 --- a/src/cli/run.ts +++ b/src/cli/run.ts @@ -2,15 +2,17 @@ import fs from 'node:fs' import path from 'node:path' import process from 'node:process' -import c from 'picocolors' + import * as p from '@clack/prompts' +import c from 'picocolors' import { extra, extraOptions, frameworkOptions, frameworks } from './constants' -import { isGitClean } from './utils' -import type { ExtraLibrariesOption, FrameworkOption, PromItem, PromptResult } from './types' -import { updatePackageJson } from './stages/update-package-json' import { updateEslintFiles } from './stages/update-eslint-files' +import { updatePackageJson } from './stages/update-package-json' import { updateVscodeSettings } from './stages/update-vscode-settings' +import { isGitClean } from './utils' + +import type { ExtraLibrariesOption, FrameworkOption, PromItem, PromptResult } from './types' export interface CliRunOptions { /** diff --git a/src/cli/stages/update-eslint-files.ts b/src/cli/stages/update-eslint-files.ts index 66eb8af1eb..a19d830681 100644 --- a/src/cli/stages/update-eslint-files.ts +++ b/src/cli/stages/update-eslint-files.ts @@ -1,13 +1,15 @@ import fs from 'node:fs' import fsp from 'node:fs/promises' -import process from 'node:process' import path from 'node:path' -import c from 'picocolors' -import * as p from '@clack/prompts' +import process from 'node:process' +import * as p from '@clack/prompts' // @ts-expect-error missing types import parse from 'parse-gitignore' +import c from 'picocolors' + import { getEslintConfigContent } from '../utils' + import type { PromptResult } from '../types' export async function updateEslintFiles(result: PromptResult): Promise { diff --git a/src/cli/stages/update-package-json.ts b/src/cli/stages/update-package-json.ts index 5c51f866c0..1564d6b470 100644 --- a/src/cli/stages/update-package-json.ts +++ b/src/cli/stages/update-package-json.ts @@ -1,10 +1,12 @@ -import path from 'node:path' import fsp from 'node:fs/promises' +import path from 'node:path' import process from 'node:process' -import c from 'picocolors' + import * as p from '@clack/prompts' +import c from 'picocolors' import { dependenciesMap, pkgJson } from '../constants' + import type { ExtraLibrariesOption, PromptResult } from '../types' export async function updatePackageJson(result: PromptResult): Promise { diff --git a/src/cli/stages/update-vscode-settings.ts b/src/cli/stages/update-vscode-settings.ts index 94ad921198..a835f271e9 100644 --- a/src/cli/stages/update-vscode-settings.ts +++ b/src/cli/stages/update-vscode-settings.ts @@ -1,11 +1,13 @@ -import path from 'node:path' -import fsp from 'node:fs/promises' import fs from 'node:fs' +import fsp from 'node:fs/promises' +import path from 'node:path' import process from 'node:process' -import c from 'picocolors' + import * as p from '@clack/prompts' +import c from 'picocolors' import { vscodeSettingsString } from '../constants' + import type { PromptResult } from '../types' export async function updateVscodeSettings(result: PromptResult): Promise { diff --git a/src/configs/astro.ts b/src/configs/astro.ts index 70e4985896..b45b6aa1e2 100644 --- a/src/configs/astro.ts +++ b/src/configs/astro.ts @@ -1,7 +1,8 @@ -import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' import { GLOB_ASTRO } from '../globs' import { interopDefault } from '../utils' +import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' + export async function astro( options: OptionsOverrides & OptionsStylistic & OptionsFiles = {}, ): Promise { diff --git a/src/configs/command.ts b/src/configs/command.ts index d42fa44f90..9f2117690f 100644 --- a/src/configs/command.ts +++ b/src/configs/command.ts @@ -1,4 +1,5 @@ import createCommand from 'eslint-plugin-command/config' + import type { TypedFlatConfigItem } from '../types' export async function command(): Promise { diff --git a/src/configs/comments.ts b/src/configs/comments.ts index 14b00b74f9..c451b6e55f 100644 --- a/src/configs/comments.ts +++ b/src/configs/comments.ts @@ -1,6 +1,7 @@ -import type { TypedFlatConfigItem } from '../types' import { pluginComments } from '../plugins' +import type { TypedFlatConfigItem } from '../types' + export async function comments(): Promise { return [ { diff --git a/src/configs/disables.ts b/src/configs/disables.ts index 0d585ecca2..489727f468 100644 --- a/src/configs/disables.ts +++ b/src/configs/disables.ts @@ -1,4 +1,5 @@ import { GLOB_SRC, GLOB_SRC_EXT } from '../globs' + import type { TypedFlatConfigItem } from '../types' export async function disables(): Promise { diff --git a/src/configs/formatters.ts b/src/configs/formatters.ts index 4a7a5a12a5..e5a1bf0187 100644 --- a/src/configs/formatters.ts +++ b/src/configs/formatters.ts @@ -1,10 +1,12 @@ import { isPackageExists } from 'local-pkg' + import { GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_GRAPHQL, GLOB_HTML, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SVG, GLOB_XML } from '../globs' -import type { VendoredPrettierOptions } from '../vender/prettier-types' import { ensurePackages, interopDefault, isPackageInScope, parserPlain } from '../utils' -import type { OptionsFormatters, StylisticConfig, TypedFlatConfigItem } from '../types' import { StylisticConfigDefaults } from './stylistic' +import type { OptionsFormatters, StylisticConfig, TypedFlatConfigItem } from '../types' +import type { VendoredPrettierOptions } from '../vender/prettier-types' + export async function formatters( options: OptionsFormatters | true = {}, stylistic: StylisticConfig = {}, diff --git a/src/configs/ignores.ts b/src/configs/ignores.ts index 830fd68706..49f96499b8 100644 --- a/src/configs/ignores.ts +++ b/src/configs/ignores.ts @@ -1,6 +1,7 @@ -import type { TypedFlatConfigItem } from '../types' import { GLOB_EXCLUDE } from '../globs' +import type { TypedFlatConfigItem } from '../types' + export async function ignores(userIgnores: string[] = []): Promise { return [ { diff --git a/src/configs/imports.ts b/src/configs/imports.ts index 1ae2a263e9..fdf3a355fb 100644 --- a/src/configs/imports.ts +++ b/src/configs/imports.ts @@ -1,6 +1,7 @@ -import type { OptionsStylistic, TypedFlatConfigItem } from '../types' import { pluginAntfu, pluginImport } from '../plugins' +import type { OptionsStylistic, TypedFlatConfigItem } from '../types' + export async function imports(options: OptionsStylistic = {}): Promise { const { stylistic = true, @@ -24,7 +25,6 @@ export async function imports(options: OptionsStylistic = {}): Promise { @@ -186,17 +188,6 @@ export async function javascript( 'prefer-rest-params': 'error', 'prefer-spread': 'error', 'prefer-template': 'error', - 'sort-imports': [ - 'error', - { - allowSeparatedGroups: false, - ignoreCase: false, - ignoreDeclarationSort: true, - ignoreMemberSort: false, - memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], - }, - ], - 'symbol-description': 'error', 'unicode-bom': ['error', 'never'], 'unused-imports/no-unused-imports': isInEditor ? 'off' : 'error', diff --git a/src/configs/jsdoc.ts b/src/configs/jsdoc.ts index a966ed7572..261e92d466 100644 --- a/src/configs/jsdoc.ts +++ b/src/configs/jsdoc.ts @@ -1,4 +1,5 @@ import { interopDefault } from '../utils' + import type { OptionsStylistic, TypedFlatConfigItem } from '../types' export async function jsdoc(options: OptionsStylistic = {}): Promise { diff --git a/src/configs/jsonc.ts b/src/configs/jsonc.ts index 5fae6a95f2..b228ac8a92 100644 --- a/src/configs/jsonc.ts +++ b/src/configs/jsonc.ts @@ -1,7 +1,8 @@ -import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from '../globs' import { interopDefault } from '../utils' +import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' + export async function jsonc( options: OptionsFiles & OptionsStylistic & OptionsOverrides = {}, ): Promise { diff --git a/src/configs/jsx.ts b/src/configs/jsx.ts index 358b2c3bc3..3fff84d8ee 100644 --- a/src/configs/jsx.ts +++ b/src/configs/jsx.ts @@ -1,6 +1,7 @@ -import type { TypedFlatConfigItem } from '../types' import { GLOB_JSX, GLOB_TSX } from '../globs' +import type { TypedFlatConfigItem } from '../types' + export async function jsx(): Promise { return [ { diff --git a/src/configs/markdown.ts b/src/configs/markdown.ts index 6d38533a48..73b9715ddc 100644 --- a/src/configs/markdown.ts +++ b/src/configs/markdown.ts @@ -1,8 +1,10 @@ import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors' -import type { OptionsComponentExts, OptionsFiles, OptionsOverrides, TypedFlatConfigItem } from '../types' + import { GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN } from '../globs' import { interopDefault, parserPlain } from '../utils' +import type { OptionsComponentExts, OptionsFiles, OptionsOverrides, TypedFlatConfigItem } from '../types' + export async function markdown( options: OptionsFiles & OptionsComponentExts & OptionsOverrides = {}, ): Promise { diff --git a/src/configs/node.ts b/src/configs/node.ts index 286254f755..92bc46221a 100644 --- a/src/configs/node.ts +++ b/src/configs/node.ts @@ -1,6 +1,7 @@ -import type { TypedFlatConfigItem } from '../types' import { pluginNode } from '../plugins' +import type { TypedFlatConfigItem } from '../types' + export async function node(): Promise { return [ { diff --git a/src/configs/perfectionist.ts b/src/configs/perfectionist.ts index 6cfde27c0e..624a1263b2 100644 --- a/src/configs/perfectionist.ts +++ b/src/configs/perfectionist.ts @@ -1,8 +1,9 @@ -import type { TypedFlatConfigItem } from '../types' import { pluginPerfectionist } from '../plugins' +import type { TypedFlatConfigItem } from '../types' + /** - * Optional perfectionist plugin for props and items sorting. + * Perfectionist plugin for props and items sorting. * * @see https://github.com/azat-io/eslint-plugin-perfectionist */ @@ -13,6 +14,25 @@ export async function perfectionist(): Promise { plugins: { perfectionist: pluginPerfectionist, }, + rules: { + 'perfectionist/sort-exports': ['error', { order: 'asc', type: 'natural' }], + 'perfectionist/sort-imports': ['error', { + groups: [ + 'builtin', + 'external', + 'type', + ['internal', 'internal-type'], + ['parent', 'sibling', 'index'], + ['parent-type', 'sibling-type', 'index-type'], + 'object', + 'unknown', + ], + 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/src/configs/react.ts b/src/configs/react.ts index f82598ffb0..eb8c9ef92e 100644 --- a/src/configs/react.ts +++ b/src/configs/react.ts @@ -1,7 +1,9 @@ import { isPackageExists } from 'local-pkg' + +import { GLOB_SRC } from '../globs' import { ensurePackages, interopDefault, toArray } from '../utils' + import type { OptionsFiles, OptionsOverrides, OptionsTypeScriptWithTypes, TypedFlatConfigItem } from '../types' -import { GLOB_SRC } from '../globs' // react refresh const ReactRefreshAllowConstantExportPackages = [ diff --git a/src/configs/regexp.ts b/src/configs/regexp.ts index c0997b7f3d..73118cd2a3 100644 --- a/src/configs/regexp.ts +++ b/src/configs/regexp.ts @@ -1,4 +1,5 @@ import { configs } from 'eslint-plugin-regexp' + import type { OptionsOverrides, OptionsRegExp, TypedFlatConfigItem } from '../types' export async function regexp( diff --git a/src/configs/solid.ts b/src/configs/solid.ts index b5253a0b87..a4261dd68b 100644 --- a/src/configs/solid.ts +++ b/src/configs/solid.ts @@ -1,6 +1,7 @@ +import { GLOB_JSX, GLOB_TSX } from '../globs' import { ensurePackages, interopDefault, toArray } from '../utils' + import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsTypeScriptWithTypes, TypedFlatConfigItem } from '../types' -import { GLOB_JSX, GLOB_TSX } from '../globs' export async function solid( options: OptionsHasTypeScript & OptionsOverrides & OptionsFiles & OptionsTypeScriptWithTypes = {}, diff --git a/src/configs/stylistic.ts b/src/configs/stylistic.ts index e5d6524e60..ea4a3216df 100644 --- a/src/configs/stylistic.ts +++ b/src/configs/stylistic.ts @@ -1,6 +1,7 @@ +import { pluginAntfu } from '../plugins' import { interopDefault } from '../utils' + import type { OptionsOverrides, StylisticConfig, TypedFlatConfigItem } from '../types' -import { pluginAntfu } from '../plugins' export const StylisticConfigDefaults: StylisticConfig = { indent: 2, diff --git a/src/configs/svelte.ts b/src/configs/svelte.ts index 962bb253ad..2d4843defc 100644 --- a/src/configs/svelte.ts +++ b/src/configs/svelte.ts @@ -1,6 +1,7 @@ +import { GLOB_SVELTE } from '../globs' import { ensurePackages, interopDefault } from '../utils' + import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' -import { GLOB_SVELTE } from '../globs' export async function svelte( options: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles = {}, diff --git a/src/configs/test.ts b/src/configs/test.ts index 69893eb67d..bb5aca53ee 100644 --- a/src/configs/test.ts +++ b/src/configs/test.ts @@ -1,6 +1,7 @@ +import { GLOB_TESTS } from '../globs' import { interopDefault } from '../utils' + import type { OptionsFiles, OptionsIsInEditor, OptionsOverrides, TypedFlatConfigItem } from '../types' -import { GLOB_TESTS } from '../globs' // Hold the reference so we don't redeclare the plugin on each call let _pluginTest: any diff --git a/src/configs/toml.ts b/src/configs/toml.ts index 5c5eae2750..87c25f964f 100644 --- a/src/configs/toml.ts +++ b/src/configs/toml.ts @@ -1,7 +1,8 @@ -import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' import { GLOB_TOML } from '../globs' import { interopDefault } from '../utils' +import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' + export async function toml( options: OptionsOverrides & OptionsStylistic & OptionsFiles = {}, ): Promise { diff --git a/src/configs/typescript.ts b/src/configs/typescript.ts index a78e810a9b..29cc3b8440 100644 --- a/src/configs/typescript.ts +++ b/src/configs/typescript.ts @@ -1,9 +1,19 @@ import process from 'node:process' + import { GLOB_ASTRO_TS, GLOB_MARKDOWN, GLOB_TS, GLOB_TSX } from '../globs' -import type { OptionsComponentExts, OptionsFiles, OptionsOverrides, OptionsProjectType, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, TypedFlatConfigItem } from '../types' import { pluginAntfu } from '../plugins' import { interopDefault, renameRules } from '../utils' +import type { + OptionsComponentExts, + OptionsFiles, + OptionsOverrides, + OptionsProjectType, + OptionsTypeScriptParserOptions, + OptionsTypeScriptWithTypes, + TypedFlatConfigItem, +} from '../types' + export async function typescript( options: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & OptionsProjectType = {}, ): Promise { diff --git a/src/configs/unicorn.ts b/src/configs/unicorn.ts index 1bef369799..adee109a0b 100644 --- a/src/configs/unicorn.ts +++ b/src/configs/unicorn.ts @@ -1,6 +1,7 @@ -import type { OptionsUnicorn, TypedFlatConfigItem } from '../types' import { pluginUnicorn } from '../plugins' +import type { OptionsUnicorn, TypedFlatConfigItem } from '../types' + export async function unicorn(options: OptionsUnicorn = {}): Promise { return [ { diff --git a/src/configs/unocss.ts b/src/configs/unocss.ts index f6d1219283..92ed014fd3 100644 --- a/src/configs/unocss.ts +++ b/src/configs/unocss.ts @@ -1,4 +1,5 @@ import { ensurePackages, interopDefault } from '../utils' + import type { OptionsUnoCSS, TypedFlatConfigItem } from '../types' export async function unocss( diff --git a/src/configs/vue.ts b/src/configs/vue.ts index c24c340965..ea76db17fe 100644 --- a/src/configs/vue.ts +++ b/src/configs/vue.ts @@ -1,7 +1,16 @@ import { mergeProcessors } from 'eslint-merge-processors' -import { interopDefault } from '../utils' -import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic, OptionsVue, TypedFlatConfigItem } from '../types' + import { GLOB_VUE } from '../globs' +import { interopDefault } from '../utils' + +import type { + OptionsFiles, + OptionsHasTypeScript, + OptionsOverrides, + OptionsStylistic, + OptionsVue, + TypedFlatConfigItem, +} from '../types' export async function vue( options: OptionsVue & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles = {}, diff --git a/src/configs/yaml.ts b/src/configs/yaml.ts index d3f89be19a..e89ac1282d 100644 --- a/src/configs/yaml.ts +++ b/src/configs/yaml.ts @@ -1,7 +1,8 @@ -import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' import { GLOB_YAML } from '../globs' import { interopDefault } from '../utils' +import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types' + export async function yaml( options: OptionsOverrides & OptionsStylistic & OptionsFiles = {}, ): Promise { diff --git a/src/factory.ts b/src/factory.ts index 982d6cda17..b0ca1cc398 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -1,7 +1,8 @@ -import { isPackageExists } from 'local-pkg' import { FlatConfigComposer } from 'eslint-flat-config-utils' +import { isPackageExists } from 'local-pkg' + import type { Linter } from 'eslint' -import type { Awaitable, ConfigNames, OptionsConfig, TypedFlatConfigItem } from './types' + import { astro, command, @@ -30,10 +31,12 @@ import { vue, yaml, } from './configs' -import { interopDefault, isInEditorEnv } from './utils' import { formatters } from './configs/formatters' import { regexp } from './configs/regexp' +import { interopDefault, isInEditorEnv } from './utils' + import type { RuleOptions } from './typegen' +import type { Awaitable, ConfigNames, OptionsConfig, TypedFlatConfigItem } from './types' const flatConfigProps = [ 'name', diff --git a/src/plugins.ts b/src/plugins.ts index f9abd14a9c..4a00265261 100644 --- a/src/plugins.ts +++ b/src/plugins.ts @@ -1,10 +1,10 @@ // eslint-disable-next-line ts/ban-ts-comment // @ts-nocheck -export { default as pluginAntfu } from 'eslint-plugin-antfu' export { default as pluginComments } from '@eslint-community/eslint-plugin-eslint-comments' +export { default as pluginAntfu } from 'eslint-plugin-antfu' export * as pluginImport from 'eslint-plugin-import-x' export { default as pluginNode } from 'eslint-plugin-n' +export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist' export { default as pluginUnicorn } from 'eslint-plugin-unicorn' export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports' -export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist' diff --git a/src/types.ts b/src/types.ts index 6599c3f035..97d8b1c2b0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,10 +1,11 @@ -import type { FlatGitignoreOptions } from 'eslint-config-flat-gitignore' +import type { StylisticCustomizeOptions } from '@stylistic/eslint-plugin' import type { ParserOptions } from '@typescript-eslint/parser' -import type { Options as VueBlocksOptions } from 'eslint-processor-vue-blocks' import type { Linter } from 'eslint' -import type { StylisticCustomizeOptions } from '@stylistic/eslint-plugin' -import type { VendoredPrettierOptions } from './vender/prettier-types' +import type { FlatGitignoreOptions } from 'eslint-config-flat-gitignore' +import type { Options as VueBlocksOptions } from 'eslint-processor-vue-blocks' + import type { ConfigNames, RuleOptions } from './typegen' +import type { VendoredPrettierOptions } from './vender/prettier-types' export type Awaitable = T | Promise diff --git a/src/utils.ts b/src/utils.ts index 3fc608336e..d2179bb23f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,6 +1,8 @@ import process from 'node:process' import { fileURLToPath } from 'node:url' + import { isPackageExists } from 'local-pkg' + import type { Awaitable, TypedFlatConfigItem } from './types' const scopeUrl = fileURLToPath(new URL('.', import.meta.url)) diff --git a/test/cli.spec.ts b/test/cli.spec.ts index 16e6ee8391..466592353d 100644 --- a/test/cli.spec.ts +++ b/test/cli.spec.ts @@ -1,5 +1,6 @@ import { join } from 'node:path' import process from 'node:process' + import { execa } from 'execa' import fs from 'fs-extra' import { afterAll, beforeEach, expect, it } from 'vitest' diff --git a/test/fixtures.test.ts b/test/fixtures.test.ts index 70fc15a644..195c9b27b5 100644 --- a/test/fixtures.test.ts +++ b/test/fixtures.test.ts @@ -1,8 +1,10 @@ import { join, resolve } from 'node:path' -import { afterAll, beforeAll, it } from 'vitest' -import fs from 'fs-extra' + import { execa } from 'execa' import fg from 'fast-glob' +import fs from 'fs-extra' +import { afterAll, beforeAll, it } from 'vitest' + import type { OptionsConfig, TypedFlatConfigItem } from '../src/types' beforeAll(async () => { diff --git a/test/types.ts b/test/types.ts index 1f515aa389..aa113716af 100644 --- a/test/types.ts +++ b/test/types.ts @@ -1,5 +1,6 @@ import type { Linter } from 'eslint' -import type { TypedFlatConfigItem } from '../src'; + +import type { TypedFlatConfigItem } from '../src' // Make sure they are compatible ((): Linter.Config => ({} as TypedFlatConfigItem))();