@1adybug/prettier-plugin-sort-imports 0.0.17 → 0.0.18

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 (3) hide show
  1. package/README.md +12 -23
  2. package/README.zh-CN.md +10 -17
  3. package/package.json +65 -72
package/README.md CHANGED
@@ -44,9 +44,11 @@ npx prettier --write "src/**/*.{js,ts,jsx,tsx}"
44
44
  ### Basic Sorting
45
45
 
46
46
  ```typescript
47
- import React, { useEffect, useState } from "react"
48
47
  import { Button } from "antd"
48
+ import React, { useEffect, useState } from "react"
49
+
49
50
  import { sum } from "./utils"
51
+
50
52
  import "./styles.css"
51
53
  ```
52
54
 
@@ -81,13 +83,14 @@ export default {
81
83
  Result:
82
84
 
83
85
  ```typescript
84
- import React, { useState } from "react"
85
-
86
86
  import { Button } from "antd"
87
87
  import { format } from "date-fns"
88
+ import React, { useState } from "react"
88
89
 
89
90
  import { Header } from "./components/Header"
91
+
90
92
  import { sum } from "./utils"
93
+
91
94
  import "./styles.css"
92
95
  ```
93
96
 
@@ -201,12 +204,8 @@ export default {
201
204
 
202
205
  return order.indexOf(a.name) - order.indexOf(b.name)
203
206
  },
204
- sortImportStatement: (a, b) => {
205
- return a.path.localeCompare(b.path)
206
- },
207
- sortImportContent: (a, b) => {
208
- return a.name.localeCompare(b.name)
209
- },
207
+ sortImportStatement: (a, b) => a.path.localeCompare(b.path),
208
+ sortImportContent: (a, b) => a.name.localeCompare(b.name),
210
209
 
211
210
  // Configuration
212
211
  separator: "\n",
@@ -449,12 +448,7 @@ separator: (group, index) => {
449
448
 
450
449
  ```typescript
451
450
  import Default, * as Namespace from "module"
452
- import {
453
- type TypeA,
454
- type TypeB,
455
- VariableA,
456
- VariableB,
457
- } from "module"
451
+ import { type TypeA, type TypeB, VariableA, VariableB } from "module"
458
452
  ```
459
453
 
460
454
  **Custom behavior**:
@@ -473,11 +467,7 @@ createPlugin({
473
467
  ```
474
468
 
475
469
  ```typescript
476
- import {
477
- API_KEY,
478
- type User,
479
- getUser,
480
- } from "api"
470
+ import { type User, API_KEY, getUser } from "api"
481
471
  ```
482
472
 
483
473
  ### Import Statement Sorting
@@ -495,11 +485,10 @@ import { c } from "c-module"
495
485
  Comments follow the import statements they are attached to:
496
486
 
497
487
  ```typescript
498
- // React related imports
499
- import React from "react"
500
-
501
488
  // UI components
502
489
  import { Button } from "antd"
490
+ // React related imports
491
+ import React from "react"
503
492
 
504
493
  // Utilities
505
494
  import { sum } from "./utils"
package/README.zh-CN.md CHANGED
@@ -43,9 +43,11 @@ npx prettier --write "src/**/*.{js,ts,jsx,tsx}"
43
43
  ### 基本排序
44
44
 
45
45
  ```typescript
46
- import React, { useEffect, useState } from "react"
47
46
  import { Button } from "antd"
47
+ import React, { useEffect, useState } from "react"
48
+
48
49
  import { sum } from "./utils"
50
+
49
51
  import "./styles.css"
50
52
  ```
51
53
 
@@ -80,13 +82,14 @@ export default {
80
82
  结果:
81
83
 
82
84
  ```typescript
83
- import React, { useState } from "react"
84
-
85
85
  import { Button } from "antd"
86
86
  import { format } from "date-fns"
87
+ import React, { useState } from "react"
87
88
 
88
89
  import { Header } from "./components/Header"
90
+
89
91
  import { sum } from "./utils"
92
+
90
93
  import "./styles.css"
91
94
  ```
92
95
 
@@ -441,12 +444,7 @@ separator: (group, index) => {
441
444
 
442
445
  ```typescript
443
446
  import Default, * as Namespace from "module"
444
- import {
445
- type TypeA,
446
- type TypeB,
447
- VariableA,
448
- VariableB,
449
- } from "module"
447
+ import { type TypeA, type TypeB, VariableA, VariableB } from "module"
450
448
  ```
451
449
 
452
450
  **自定义行为**:
@@ -465,11 +463,7 @@ createPlugin({
465
463
  ```
466
464
 
467
465
  ```typescript
468
- import {
469
- API_KEY,
470
- type User,
471
- getUser,
472
- } from "api"
466
+ import { type User, API_KEY, getUser } from "api"
473
467
  ```
474
468
 
475
469
  ### 导入语句排序
@@ -487,11 +481,10 @@ import { c } from "c-module"
487
481
  注释会跟随它们所附加的导入语句一起移动:
488
482
 
489
483
  ```typescript
490
- // React 相关导入
491
- import React from "react"
492
-
493
484
  // UI 组件
494
485
  import { Button } from "antd"
486
+ // React 相关导入
487
+ import React from "react"
495
488
 
496
489
  // 工具函数
497
490
  import { sum } from "./utils"
package/package.json CHANGED
@@ -1,74 +1,67 @@
1
1
  {
2
- "name": "@1adybug/prettier-plugin-sort-imports",
3
- "type": "module",
4
- "version": "0.0.17",
5
- "description": "一个 Prettier 插件,用于对 JavaScript/TypeScript 文件的导入语句进行分组和排序",
6
- "keywords": [
7
- "prettier",
8
- "plugin",
9
- "import",
10
- "sort",
11
- "organize",
12
- "typescript",
13
- "javascript"
14
- ],
15
- "author": "1adybug <lurongv@qq.com>",
16
- "license": "MIT",
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/1adybug/prettier-plugin-sort-imports.git"
20
- },
21
- "homepage": "https://github.com/1adybug/prettier-plugin-sort-imports#readme",
22
- "bugs": {
23
- "url": "https://github.com/1adybug/prettier-plugin-sort-imports/issues"
24
- },
25
- "sideEffects": false,
26
- "publishConfig": {
27
- "access": "public",
28
- "registry": "https://registry.npmjs.com/"
29
- },
30
- "exports": {
31
- ".": {
32
- "types": "./dist/index.d.ts",
33
- "import": "./dist/index.js",
34
- "require": "./dist/index.js"
35
- }
36
- },
37
- "main": "./dist/index.js",
38
- "module": "./dist/index.js",
39
- "types": "./dist/index.d.ts",
40
- "files": [
41
- "dist"
42
- ],
43
- "scripts": {
44
- "build": "rslib build",
45
- "dev": "rslib build --watch",
46
- "prepublishOnly": "npm run build",
47
- "format": "prettier --write .",
48
- "test": "bun test",
49
- "test:watch": "bun test --watch",
50
- "fg": "npm run format && git add . && git commit -m \"✨feature: format\"",
51
- "ucr": "npx zixulu acr"
52
- },
53
- "devDependencies": {
54
- "@rslib/core": "^0.15.0",
55
- "@types/babel__core": "^7.20.5",
56
- "@types/bun": "latest",
57
- "@types/node": "^22.18.6",
58
- "json5": "^2.2.3",
59
- "prettier": "^3.6.2",
60
- "prettier-plugin-block-padding": "^0.0.6",
61
- "prettier-plugin-tailwindcss": "^0.7.0",
62
- "supports-color": "^10.2.2",
63
- "typescript": "^5.9.2"
64
- },
65
- "peerDependencies": {
66
- "prettier": "^3.0.0"
67
- },
68
- "dependencies": {
69
- "@babel/core": "^7.28.4",
70
- "@babel/parser": "^7.28.4",
71
- "@babel/traverse": "^7.28.4",
72
- "@babel/types": "^7.28.4"
2
+ "name": "@1adybug/prettier-plugin-sort-imports",
3
+ "version": "0.0.18",
4
+ "description": "一个 Prettier 插件,用于对 JavaScript/TypeScript 文件的导入语句进行分组和排序",
5
+ "keywords": [
6
+ "prettier",
7
+ "plugin",
8
+ "import",
9
+ "sort",
10
+ "organize",
11
+ "typescript",
12
+ "javascript"
13
+ ],
14
+ "author": "1adybug <lurongv@qq.com>",
15
+ "license": "MIT",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/1adybug/prettier.git"
19
+ },
20
+ "homepage": "https://github.com/1adybug/prettier/tree/main/packages/prettier-plugin-sort-imports",
21
+ "bugs": {
22
+ "url": "https://github.com/1adybug/prettier/issues"
23
+ },
24
+ "type": "module",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js",
29
+ "require": "./dist/index.js"
73
30
  }
74
- }
31
+ },
32
+ "main": "./dist/index.js",
33
+ "module": "./dist/index.js",
34
+ "types": "./dist/index.d.ts",
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "sideEffects": false,
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "registry": "https://registry.npmjs.com/"
42
+ },
43
+ "dependencies": {
44
+ "@babel/core": "^7.28.4",
45
+ "@babel/parser": "^7.28.4",
46
+ "@babel/traverse": "^7.28.4",
47
+ "@babel/types": "^7.28.4"
48
+ },
49
+ "devDependencies": {
50
+ "@rslib/core": "^0.15.0",
51
+ "@types/babel__core": "^7.20.5",
52
+ "@types/bun": "latest",
53
+ "@types/node": "^22.18.6",
54
+ "json5": "^2.2.3",
55
+ "supports-color": "^10.2.2",
56
+ "typescript": "^5.9.2"
57
+ },
58
+ "peerDependencies": {
59
+ "prettier": "^3.0.0"
60
+ },
61
+ "scripts": {
62
+ "build": "rslib build",
63
+ "dev": "rslib build --watch",
64
+ "test": "bun test",
65
+ "test:watch": "bun test --watch"
66
+ }
67
+ }