@1adybug/prettier 0.0.19 → 0.0.21
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 +8 -8
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -59,8 +59,8 @@ function isReact(path) {
|
|
|
59
59
|
function isBuiltin(path) {
|
|
60
60
|
return path.startsWith("node:") || builtinModules.includes(path);
|
|
61
61
|
}
|
|
62
|
-
function isAbsolute(path) {
|
|
63
|
-
return !!
|
|
62
|
+
function isAbsolute(path, resolveAlias) {
|
|
63
|
+
return !!resolveAlias?.(path);
|
|
64
64
|
}
|
|
65
65
|
function isRelative(path) {
|
|
66
66
|
return path.startsWith("./") || path.startsWith("../");
|
|
@@ -77,10 +77,10 @@ function compareGroupName(a, b) {
|
|
|
77
77
|
const bInfo = JSON.parse(b);
|
|
78
78
|
return orders.indexOf(aInfo.type) - orders.indexOf(bInfo.type) || aInfo.dir.localeCompare(bInfo.dir);
|
|
79
79
|
}
|
|
80
|
-
function getModuleType(path) {
|
|
80
|
+
function getModuleType(path, resolveAlias) {
|
|
81
81
|
if (isReact(path)) return "react";
|
|
82
82
|
if (isBuiltin(path)) return "builtin";
|
|
83
|
-
if (isAbsolute(path)) return "absolute";
|
|
83
|
+
if (isAbsolute(path, resolveAlias)) return "absolute";
|
|
84
84
|
if (isRelative(path)) return "relative";
|
|
85
85
|
return "third-party";
|
|
86
86
|
}
|
|
@@ -93,7 +93,6 @@ const otherPlugins = hasTailwindcss ? [
|
|
|
93
93
|
prettier_plugin_block_padding,
|
|
94
94
|
prettier_plugin_remove_braces
|
|
95
95
|
];
|
|
96
|
-
let src_resolveAlias;
|
|
97
96
|
function getResolvedPathDir(resolvedPath) {
|
|
98
97
|
if (existsSync(resolvedPath) && statSync(resolvedPath).isFile()) return parse(resolvedPath).dir;
|
|
99
98
|
const { dir, base } = parse(resolvedPath);
|
|
@@ -103,10 +102,11 @@ function getResolvedPathDir(resolvedPath) {
|
|
|
103
102
|
}
|
|
104
103
|
const config = {
|
|
105
104
|
getGroup ({ path, filepath }) {
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
let resolveAlias;
|
|
106
|
+
if (filepath) resolveAlias ??= getResolveAlias(filepath);
|
|
107
|
+
const type = getModuleType(path, resolveAlias);
|
|
108
108
|
let dir = "";
|
|
109
|
-
if ("absolute" === type) dir = getResolvedPathDir(
|
|
109
|
+
if ("absolute" === type) dir = getResolvedPathDir(resolveAlias(path));
|
|
110
110
|
if ("relative" === type && !!filepath) dir = getResolvedPathDir(resolve(filepath, "../", path));
|
|
111
111
|
const info = {
|
|
112
112
|
type,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1adybug/prettier",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "推荐的 Prettier 配置",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prettier",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"prettier-plugin-tailwindcss": "^0.7.1",
|
|
40
40
|
"tsconfig-paths": "^4.2.0",
|
|
41
|
-
"@1adybug/prettier-plugin-block-padding": "0.0.
|
|
42
|
-
"@1adybug/prettier-plugin-
|
|
43
|
-
"@1adybug/prettier-plugin-
|
|
41
|
+
"@1adybug/prettier-plugin-block-padding": "0.0.15",
|
|
42
|
+
"@1adybug/prettier-plugin-sort-imports": "0.0.26",
|
|
43
|
+
"@1adybug/prettier-plugin-remove-braces": "0.0.8"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rslib/core": "^0.18.2",
|