@1adybug/prettier-plugin-sort-imports 0.0.9 → 0.0.10

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 +2 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -163,6 +163,8 @@ function formatImportStatements(statements) {
163
163
  return statements.map(formatImportStatement).join("\n");
164
164
  }
165
165
  function parseImports(code) {
166
+ const hasImportOrExport = /^\s*(import|export)\s/m.test(code);
167
+ if (!hasImportOrExport) return [];
166
168
  const ast = parse(code, {
167
169
  sourceType: "module",
168
170
  plugins: [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@1adybug/prettier-plugin-sort-imports",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "description": "一个 Prettier 插件,用于对 JavaScript/TypeScript 文件的导入语句进行分组和排序",
6
6
  "keywords": [
7
7
  "prettier",