Skip to content

Commit ca80e9d

Browse files
authored
chore(lint): sort for imports (#8113)
1 parent ce9606c commit ca80e9d

File tree

7 files changed

+34
-17
lines changed

7 files changed

+34
-17
lines changed

.eslintrc.cjs

+13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = defineConfig({
88
'plugin:node/recommended',
99
'plugin:@typescript-eslint/recommended'
1010
],
11+
plugins: ['import'],
1112
parser: '@typescript-eslint/parser',
1213
parserOptions: {
1314
sourceType: 'module',
@@ -86,6 +87,18 @@ module.exports = defineConfig({
8687
'@typescript-eslint/consistent-type-imports': [
8788
'error',
8889
{ prefer: 'type-imports' }
90+
],
91+
92+
'import/order': 'error',
93+
'sort-imports': [
94+
'error',
95+
{
96+
ignoreCase: false,
97+
ignoreDeclarationSort: true,
98+
ignoreMemberSort: false,
99+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
100+
allowSeparatedGroups: false
101+
}
89102
]
90103
},
91104
overrides: [

package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"scripts": {
1616
"preinstall": "npx only-allow pnpm",
1717
"format": "prettier --write .",
18-
"lint": "eslint packages/*/{src,types}/**",
18+
"lint": "eslint packages/*/{src,types}/** playground/**/__tests__/**/*.*",
1919
"test": "run-s test-unit test-serve test-build",
2020
"test-serve": "vitest run -c vitest.config.e2e.ts",
2121
"test-build": "cross-env VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
@@ -48,6 +48,7 @@
4848
"esbuild": "^0.14.38",
4949
"eslint": "^8.15.0",
5050
"eslint-define-config": "^1.4.0",
51+
"eslint-plugin-import": "^2.26.0",
5152
"eslint-plugin-node": "^11.1.0",
5253
"execa": "^5.1.1",
5354
"fs-extra": "^10.1.0",
@@ -80,10 +81,13 @@
8081
"prettier --write --ignore-unknown"
8182
],
8283
"packages/*/{src,types}/**/*.ts": [
83-
"eslint --ext .ts"
84+
"eslint --fix"
8485
],
8586
"packages/**/*.d.ts": [
86-
"eslint --ext .ts"
87+
"eslint --fix"
88+
],
89+
"playground/**/__tests__/**/*.ts": [
90+
"eslint --fix"
8791
]
8892
},
8993
"packageManager": "[email protected]",

packages/plugin-vue/src/handleHotUpdate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import _debug from 'debug'
22
import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc'
3+
import type { HmrContext, ModuleNode } from 'vite'
34
import {
45
createDescriptor,
56
getDescriptor,
67
setPrevDescriptor
78
} from './utils/descriptorCache'
89
import { getResolvedScript, setResolvedScript } from './script'
9-
import type { ModuleNode, HmrContext } from 'vite'
1010
import type { ResolvedOptions } from '.'
1111

1212
const debug = _debug('vite:hmr')

packages/plugin-vue/src/main.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import path from 'path'
22
import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc'
3-
import type { ResolvedOptions } from '.'
3+
import type { PluginContext, SourceMap, TransformPluginContext } from 'rollup'
4+
import { normalizePath } from '@rollup/pluginutils'
5+
import type { RawSourceMap } from 'source-map'
6+
import { SourceMapConsumer, SourceMapGenerator } from 'source-map'
7+
import { transformWithEsbuild } from 'vite'
48
import {
59
createDescriptor,
610
getPrevDescriptor,
711
setSrcDescriptor
812
} from './utils/descriptorCache'
9-
import type { PluginContext, SourceMap, TransformPluginContext } from 'rollup'
10-
import { normalizePath } from '@rollup/pluginutils'
11-
import { resolveScript, isUseInlineTemplate } from './script'
13+
import { isUseInlineTemplate, resolveScript } from './script'
1214
import { transformTemplateInMain } from './template'
13-
import { isOnlyTemplateChanged, isEqualBlock } from './handleHotUpdate'
14-
import type { RawSourceMap } from 'source-map'
15-
import { SourceMapConsumer, SourceMapGenerator } from 'source-map'
15+
import { isEqualBlock, isOnlyTemplateChanged } from './handleHotUpdate'
1616
import { createRollupError } from './utils/error'
17-
import { transformWithEsbuild } from 'vite'
1817
import { EXPORT_HELPER_ID } from './helper'
18+
import type { ResolvedOptions } from '.'
1919

2020
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
2121
export async function transformMain(

packages/plugin-vue/src/script.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { SFCDescriptor, SFCScriptBlock } from 'vue/compiler-sfc'
2-
import type { ResolvedOptions } from '.'
32
import { resolveTemplateCompilerOptions } from './template'
3+
import type { ResolvedOptions } from '.'
44

55
// ssr and non ssr builds would output different script content
66
const clientCache = new WeakMap<SFCDescriptor, SFCScriptBlock | null>()

packages/plugin-vue/src/style.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { SFCDescriptor } from 'vue/compiler-sfc'
22
import type { ExistingRawSourceMap, TransformPluginContext } from 'rollup'
3-
import type { ResolvedOptions } from '.'
43
import type { RawSourceMap } from 'source-map'
54
import { formatPostcssSourceMap } from 'vite'
5+
import type { ResolvedOptions } from '.'
66

77
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
88
export async function transformStyle(

packages/plugin-vue/src/template.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import path from 'path'
22
import slash from 'slash'
33
import type {
4+
CompilerOptions,
45
SFCDescriptor,
56
SFCTemplateCompileOptions,
6-
SFCTemplateCompileResults,
7-
CompilerOptions
7+
SFCTemplateCompileResults
88
} from 'vue/compiler-sfc'
99
import type { PluginContext, TransformPluginContext } from 'rollup'
10-
import type { ResolvedOptions } from '.'
1110
import { getResolvedScript } from './script'
1211
import { createRollupError } from './utils/error'
12+
import type { ResolvedOptions } from '.'
1313

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

0 commit comments

Comments
 (0)