prettier-plugin-sort 0.0.1 → 0.0.2
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/README.md +2 -2
- package/dist/index.js +6 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -146,8 +146,8 @@ The shape of `importOrderTypeImports` mirrors conventions in the ESLint ecosyste
|
|
|
146
146
|
|
|
147
147
|
Using `import { c, type B, a } from 'mod';` as an example:
|
|
148
148
|
|
|
149
|
-
| Mode | Result
|
|
150
|
-
| -------------- |
|
|
149
|
+
| Mode | Result |
|
|
150
|
+
| -------------- | ---------------------------------------------------------------- |
|
|
151
151
|
| `separate` | `import type { B } from 'mod';`<br>`import { a, c } from 'mod';` |
|
|
152
152
|
| `inline-first` | `import { type B, a, c } from 'mod';` |
|
|
153
153
|
| `inline-last` | `import { a, c, type B } from 'mod';` |
|
package/dist/index.js
CHANGED
|
@@ -240,7 +240,7 @@ function parseImport(stmt) {
|
|
|
240
240
|
leadingComments
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
|
-
const m = /^import\s+(type\s+)?([\s\S]+?)\s
|
|
243
|
+
const m = /^import\s+(type\s+)?([\s\S]+?)\s*from\s*(['"])([^'"]+)\3\s*;?$/.exec(trimmed);
|
|
244
244
|
if (!m) {
|
|
245
245
|
return null;
|
|
246
246
|
}
|
|
@@ -491,7 +491,11 @@ function sortImports(text, rawOptions) {
|
|
|
491
491
|
}
|
|
492
492
|
const replacement = lines.join(`
|
|
493
493
|
`);
|
|
494
|
-
|
|
494
|
+
const trailing = text.slice(block.end);
|
|
495
|
+
const suffix = trailing.trim() ? `
|
|
496
|
+
|
|
497
|
+
` + trailing.trimStart() : trailing;
|
|
498
|
+
return text.slice(0, block.start) + replacement + suffix;
|
|
495
499
|
}
|
|
496
500
|
|
|
497
501
|
// src/sort-package.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-sort",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "An all-in-one Prettier plugin to sort imports, package.json keys, and more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"imports",
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"prettier-plugin",
|
|
13
13
|
"sort"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://github.com/xueelf/
|
|
15
|
+
"homepage": "https://github.com/xueelf/prettier-plugin-sort",
|
|
16
16
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/xueelf/
|
|
17
|
+
"url": "https://github.com/xueelf/prettier-plugin-sort/issues"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/xueelf/
|
|
21
|
+
"url": "git+https://github.com/xueelf/prettier-plugin-sort.git"
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"author": "Yuki <admin@yuki.sh>",
|