@1adybug/prettier 0.0.10 → 0.0.12
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 +13 -14
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, statSync } from "fs";
|
|
1
|
+
import { existsSync, readdirSync, statSync } from "fs";
|
|
2
2
|
import { builtinModules, createRequire } from "module";
|
|
3
3
|
import { join, parse, resolve } from "path";
|
|
4
4
|
import prettier_plugin_block_padding from "@1adybug/prettier-plugin-block-padding";
|
|
@@ -7,14 +7,13 @@ import { createPlugin } from "@1adybug/prettier-plugin-sort-imports";
|
|
|
7
7
|
import { createMatchPath, loadConfig } from "tsconfig-paths";
|
|
8
8
|
import * as __rspack_external_prettier_plugin_tailwindcss_a3404f7e from "prettier-plugin-tailwindcss";
|
|
9
9
|
const src_require = createRequire(import.meta.url);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
];
|
|
10
|
+
function fileExistsWithAnyExtension(path) {
|
|
11
|
+
if (existsSync(path)) return true;
|
|
12
|
+
const { dir, base } = parse(path);
|
|
13
|
+
if (!existsSync(dir)) return false;
|
|
14
|
+
const list = readdirSync(dir);
|
|
15
|
+
return list.some((item)=>item.startsWith(`${base}.`));
|
|
16
|
+
}
|
|
18
17
|
function getResolveAlias(filepath) {
|
|
19
18
|
try {
|
|
20
19
|
filepath = resolve(filepath);
|
|
@@ -31,7 +30,8 @@ function getResolveAlias(filepath) {
|
|
|
31
30
|
if ("failed" === tsconfig.resultType) return;
|
|
32
31
|
const matchPath = createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths);
|
|
33
32
|
return function(importPath) {
|
|
34
|
-
|
|
33
|
+
importPath = importPath.replace(/^(.+?)\?.*$/, "$1");
|
|
34
|
+
return matchPath(importPath, void 0, fileExistsWithAnyExtension, void 0);
|
|
35
35
|
};
|
|
36
36
|
} catch (error) {
|
|
37
37
|
return;
|
|
@@ -88,10 +88,9 @@ const otherPlugins = hasTailwindcss ? [
|
|
|
88
88
|
let src_resolveAlias;
|
|
89
89
|
function getResolvedPathDir(resolvedPath) {
|
|
90
90
|
if (existsSync(resolvedPath) && statSync(resolvedPath).isFile()) return parse(resolvedPath).dir;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
91
|
+
const { dir, base } = parse(resolvedPath);
|
|
92
|
+
const list = readdirSync(dir);
|
|
93
|
+
for (const item of list)if (item.startsWith(`${base}.`) && statSync(join(dir, item)).isFile()) return dir;
|
|
95
94
|
return resolvedPath;
|
|
96
95
|
}
|
|
97
96
|
const config = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1adybug/prettier",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
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-remove-braces": "0.0.6",
|
|
42
41
|
"@1adybug/prettier-plugin-sort-imports": "0.0.20",
|
|
43
|
-
"@1adybug/prettier-plugin-block-padding": "0.0.12"
|
|
42
|
+
"@1adybug/prettier-plugin-block-padding": "0.0.12",
|
|
43
|
+
"@1adybug/prettier-plugin-remove-braces": "0.0.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@rslib/core": "^0.18.2",
|