@1adybug/prettier-plugin-sort-imports 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -4
- package/dist/types.d.ts +2 -2
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "module";
|
|
2
|
-
import { relative } from "path";
|
|
3
2
|
import { format } from "prettier";
|
|
4
3
|
import { parse as parser_parse } from "@babel/parser";
|
|
5
4
|
import traverse from "@babel/traverse";
|
|
@@ -575,9 +574,8 @@ function preprocessImports(text, options, config = {}) {
|
|
|
575
574
|
"babel-ts"
|
|
576
575
|
];
|
|
577
576
|
if (!parser || !supportedParsers.includes(parser)) return text;
|
|
578
|
-
const
|
|
579
|
-
const
|
|
580
|
-
const imports = parseImports(text, relativeFilepath);
|
|
577
|
+
const filepath = options.filepath;
|
|
578
|
+
const imports = parseImports(text, filepath);
|
|
581
579
|
if (0 === imports.length) return text;
|
|
582
580
|
const optionsConfig = options;
|
|
583
581
|
const finalConfig = {
|
package/dist/types.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface ImportContent {
|
|
|
14
14
|
}
|
|
15
15
|
/** 导入语句 */
|
|
16
16
|
export interface ImportStatement {
|
|
17
|
-
/**
|
|
17
|
+
/** Absolute path of current file */
|
|
18
18
|
filepath?: string;
|
|
19
19
|
/** 导入的模块路径,可以是相对路径或绝对路径,比如 react, react-dom 或者 ./utils/index,@/utils/index 等 */
|
|
20
20
|
path: string;
|
|
@@ -39,7 +39,7 @@ export interface ImportStatement {
|
|
|
39
39
|
}
|
|
40
40
|
/** 分组 */
|
|
41
41
|
export interface Group {
|
|
42
|
-
/**
|
|
42
|
+
/** Absolute path of current file */
|
|
43
43
|
filepath?: string;
|
|
44
44
|
/** 分组名称,默认为 default */
|
|
45
45
|
name: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1adybug/prettier-plugin-sort-imports",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "一个 Prettier 插件,用于对 JavaScript/TypeScript 文件的导入语句进行分组和排序",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prettier",
|
|
@@ -43,12 +43,13 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/core": "^7.28.4",
|
|
45
45
|
"@babel/parser": "^7.28.4",
|
|
46
|
-
"@babel/traverse": "^7.28.
|
|
46
|
+
"@babel/traverse": "^7.28.5",
|
|
47
47
|
"@babel/types": "^7.28.4"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@rslib/core": "^0.15.0",
|
|
51
51
|
"@types/babel__core": "^7.20.5",
|
|
52
|
+
"@types/babel__traverse": "^7.28.0",
|
|
52
53
|
"@types/bun": "latest",
|
|
53
54
|
"@types/node": "^22.18.6",
|
|
54
55
|
"json5": "^2.2.3",
|