Skip to content

Commit 4bd1531

Browse files
committed
chore(lint): sort for imports (#8113)
1 parent 1c2aef0 commit 4bd1531

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+589
-360
lines changed

.eslintrc.cjs

Lines changed: 13 additions & 0 deletions
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',
@@ -93,6 +94,18 @@ module.exports = defineConfig({
9394
'@typescript-eslint/consistent-type-imports': [
9495
'error',
9596
{ prefer: 'type-imports' }
97+
],
98+
99+
'import/order': 'error',
100+
'sort-imports': [
101+
'error',
102+
{
103+
ignoreCase: false,
104+
ignoreDeclarationSort: true,
105+
ignoreMemberSort: false,
106+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
107+
allowSeparatedGroups: false
108+
}
96109
]
97110
},
98111
overrides: [

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"esbuild": "^0.14.27",
4848
"eslint": "^8.14.0",
4949
"eslint-define-config": "^1.4.0",
50+
"eslint-plugin-import": "^2.26.0",
5051
"eslint-plugin-node": "^11.1.0",
5152
"execa": "^5.1.1",
5253
"fs-extra": "^10.1.0",
@@ -79,10 +80,13 @@
7980
"prettier --write --ignore-unknown"
8081
],
8182
"packages/*/{src,types}/**/*.ts": [
82-
"eslint --ext .ts"
83+
"eslint --fix"
8384
],
8485
"packages/**/*.d.ts": [
85-
"eslint --ext .ts"
86+
"eslint --fix"
87+
],
88+
"playground/**/__tests__/**/*.ts": [
89+
"eslint --fix"
8690
]
8791
},
8892
"packageManager": "[email protected]",

packages/plugin-react/src/fast-refresh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { types as t } from '@babel/core'
21
import fs from 'fs'
32
import path from 'path'
3+
import type { types as t } from '@babel/core'
44

55
export const runtimePublicPath = '/@react-refresh'
66

packages/plugin-react/src/jsx-runtime/babel-import-to-require.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type * as babelCore from '@babel/core'
2-
import type { types as t, Visitor } from '@babel/core'
2+
import type { Visitor, types as t } from '@babel/core'
33

44
/**
55
* Replace this:

packages/plugin-react/src/jsx-runtime/babel-restore-jsx.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import babelRestoreJSX from './babel-restore-jsx'
21
import * as babel from '@babel/core'
2+
import babelRestoreJSX from './babel-restore-jsx'
33

44
function jsx(code: string) {
55
return babel.transform(code, {

packages/plugin-react/src/jsx-runtime/restore-jsx.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { restoreJSX } from './restore-jsx'
21
import * as babel from '@babel/core'
2+
import { restoreJSX } from './restore-jsx'
33

44
async function jsx(sourceCode: string) {
55
const [ast] = await restoreJSX(babel, sourceCode, 'test.js')

packages/plugin-vue/src/handleHotUpdate.ts

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 8 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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(

0 commit comments

Comments
 (0)