@1adybug/prettier 0.0.10 → 0.0.11

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.
Files changed (2) hide show
  1. package/dist/index.js +6 -14
  2. package/package.json +2 -2
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,6 @@ 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
- const extensions = [
11
- ".ts",
12
- ".tsx",
13
- ".js",
14
- ".jsx",
15
- ".mjs",
16
- ".cjs"
17
- ];
18
10
  function getResolveAlias(filepath) {
19
11
  try {
20
12
  filepath = resolve(filepath);
@@ -31,7 +23,8 @@ function getResolveAlias(filepath) {
31
23
  if ("failed" === tsconfig.resultType) return;
32
24
  const matchPath = createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths);
33
25
  return function(importPath) {
34
- return matchPath(importPath, void 0, void 0, extensions);
26
+ importPath = importPath.replace(/^(.+?)\?.*$/, "$1");
27
+ return matchPath(importPath);
35
28
  };
36
29
  } catch (error) {
37
30
  return;
@@ -88,10 +81,9 @@ const otherPlugins = hasTailwindcss ? [
88
81
  let src_resolveAlias;
89
82
  function getResolvedPathDir(resolvedPath) {
90
83
  if (existsSync(resolvedPath) && statSync(resolvedPath).isFile()) return parse(resolvedPath).dir;
91
- for (const extension of extensions){
92
- const importPath = resolvedPath + extension;
93
- if (existsSync(importPath)) return parse(importPath).dir;
94
- }
84
+ const { dir, base } = parse(resolvedPath);
85
+ const list = readdirSync(dir);
86
+ for (const item of list)if (item.startsWith(`${base}.`) && statSync(join(dir, item)).isFile()) return dir;
95
87
  return resolvedPath;
96
88
  }
97
89
  const config = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1adybug/prettier",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "推荐的 Prettier 配置",
5
5
  "keywords": [
6
6
  "prettier",
@@ -38,8 +38,8 @@
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",
42
+ "@1adybug/prettier-plugin-remove-braces": "0.0.6",
43
43
  "@1adybug/prettier-plugin-block-padding": "0.0.12"
44
44
  },
45
45
  "devDependencies": {