Skip to content

Commit

Permalink
chore(lint): sort for imports (#8113)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored May 11, 2022
1 parent ce9606c commit ca80e9d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 17 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = defineConfig({
'plugin:node/recommended',
'plugin:@typescript-eslint/recommended'
],
plugins: ['import'],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
Expand Down Expand Up @@ -86,6 +87,18 @@ module.exports = defineConfig({
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports' }
],

'import/order': 'error',
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: false
}
]
},
overrides: [
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"preinstall": "npx only-allow pnpm",
"format": "prettier --write .",
"lint": "eslint packages/*/{src,types}/**",
"lint": "eslint packages/*/{src,types}/** playground/**/__tests__/**/*.*",
"test": "run-s test-unit test-serve test-build",
"test-serve": "vitest run -c vitest.config.e2e.ts",
"test-build": "cross-env VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
Expand Down Expand Up @@ -48,6 +48,7 @@
"esbuild": "^0.14.38",
"eslint": "^8.15.0",
"eslint-define-config": "^1.4.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"execa": "^5.1.1",
"fs-extra": "^10.1.0",
Expand Down Expand Up @@ -80,10 +81,13 @@
"prettier --write --ignore-unknown"
],
"packages/*/{src,types}/**/*.ts": [
"eslint --ext .ts"
"eslint --fix"
],
"packages/**/*.d.ts": [
"eslint --ext .ts"
"eslint --fix"
],
"playground/**/__tests__/**/*.ts": [
"eslint --fix"
]
},
"packageManager": "pnpm@6.32.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/handleHotUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import _debug from 'debug'
import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc'
import type { HmrContext, ModuleNode } from 'vite'
import {
createDescriptor,
getDescriptor,
setPrevDescriptor
} from './utils/descriptorCache'
import { getResolvedScript, setResolvedScript } from './script'
import type { ModuleNode, HmrContext } from 'vite'
import type { ResolvedOptions } from '.'

const debug = _debug('vite:hmr')
Expand Down
16 changes: 8 additions & 8 deletions packages/plugin-vue/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import path from 'path'
import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc'
import type { ResolvedOptions } from '.'
import type { PluginContext, SourceMap, TransformPluginContext } from 'rollup'
import { normalizePath } from '@rollup/pluginutils'
import type { RawSourceMap } from 'source-map'
import { SourceMapConsumer, SourceMapGenerator } from 'source-map'
import { transformWithEsbuild } from 'vite'
import {
createDescriptor,
getPrevDescriptor,
setSrcDescriptor
} from './utils/descriptorCache'
import type { PluginContext, SourceMap, TransformPluginContext } from 'rollup'
import { normalizePath } from '@rollup/pluginutils'
import { resolveScript, isUseInlineTemplate } from './script'
import { isUseInlineTemplate, resolveScript } from './script'
import { transformTemplateInMain } from './template'
import { isOnlyTemplateChanged, isEqualBlock } from './handleHotUpdate'
import type { RawSourceMap } from 'source-map'
import { SourceMapConsumer, SourceMapGenerator } from 'source-map'
import { isEqualBlock, isOnlyTemplateChanged } from './handleHotUpdate'
import { createRollupError } from './utils/error'
import { transformWithEsbuild } from 'vite'
import { EXPORT_HELPER_ID } from './helper'
import type { ResolvedOptions } from '.'

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export async function transformMain(
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/script.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SFCDescriptor, SFCScriptBlock } from 'vue/compiler-sfc'
import type { ResolvedOptions } from '.'
import { resolveTemplateCompilerOptions } from './template'
import type { ResolvedOptions } from '.'

// ssr and non ssr builds would output different script content
const clientCache = new WeakMap<SFCDescriptor, SFCScriptBlock | null>()
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/style.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { SFCDescriptor } from 'vue/compiler-sfc'
import type { ExistingRawSourceMap, TransformPluginContext } from 'rollup'
import type { ResolvedOptions } from '.'
import type { RawSourceMap } from 'source-map'
import { formatPostcssSourceMap } from 'vite'
import type { ResolvedOptions } from '.'

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export async function transformStyle(
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-vue/src/template.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import path from 'path'
import slash from 'slash'
import type {
CompilerOptions,
SFCDescriptor,
SFCTemplateCompileOptions,
SFCTemplateCompileResults,
CompilerOptions
SFCTemplateCompileResults
} from 'vue/compiler-sfc'
import type { PluginContext, TransformPluginContext } from 'rollup'
import type { ResolvedOptions } from '.'
import { getResolvedScript } from './script'
import { createRollupError } from './utils/error'
import type { ResolvedOptions } from '.'

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export async function transformTemplateAsModule(
Expand Down

0 comments on commit ca80e9d

Please sign in to comment.