@magicdawn/eslint-config 1.5.15 → 1.6.1

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 +57 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -111,6 +111,62 @@ const mgCustomJsonOrder = { tsconfig: [{
111
111
  ]
112
112
  }] };
113
113
 
114
+ //#endregion
115
+ //#region src/perfection-list/sort-imports.ts
116
+ /**
117
+ * https://perfectionist.dev/rules/sort-imports#groups
118
+ *
119
+ * modifier & selector are terms of perfectionist
120
+ */
121
+ /**
122
+ [
123
+ 'type-import',
124
+ ['value-builtin', 'value-external'],
125
+ 'type-internal',
126
+ 'value-internal',
127
+ ['type-parent', 'type-sibling', 'type-index'],
128
+ ['value-parent', 'value-sibling', 'value-index'],
129
+ 'ts-equals-import',
130
+ 'unknown',
131
+ ]
132
+ */
133
+ /**
134
+ https://github.com/sxzz/eslint-config/blob/main/src/configs/sort.ts
135
+ builtin',
136
+ 'external',
137
+ 'internal',
138
+ 'parent',
139
+ 'subpath',
140
+ 'sibling',
141
+ 'index',
142
+ 'style',
143
+ 'type',
144
+ 'side-effect',
145
+ 'side-effect-style',
146
+ */
147
+ const generalOrder = [
148
+ "builtin",
149
+ "external",
150
+ "tsconfig-path",
151
+ "subpath",
152
+ "internal",
153
+ "parent",
154
+ "index",
155
+ "sibling"
156
+ ];
157
+ function addModifier(modifier) {
158
+ return generalOrder.map((x) => {
159
+ if (typeof x === "string") return `${modifier}-${x}`;
160
+ throw new Error("should not reach here");
161
+ });
162
+ }
163
+ const customSortImportGroups = [
164
+ "side-effect-style",
165
+ "side-effect",
166
+ ...generalOrder,
167
+ ...addModifier("type")
168
+ ];
169
+
114
170
  //#endregion
115
171
  //#region src/from-sxzz.ts
116
172
  function fromSxzz(options, ...moreConfigs) {
@@ -173,12 +229,7 @@ function fromSxzz(options, ...moreConfigs) {
173
229
  `^[$].+`,
174
230
  ...internalPattern ?? []
175
231
  ]);
176
- options$1[0].groups = uniq([
177
- ...groups ?? [],
178
- "side-effect-style",
179
- "side-effect",
180
- ...options$1[0].groups ?? []
181
- ]);
232
+ options$1[0].groups = uniq([...groups ?? [], ...customSortImportGroups]);
182
233
  }
183
234
  return config;
184
235
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@magicdawn/eslint-config",
3
3
  "type": "module",
4
- "version": "1.5.15",
4
+ "version": "1.6.1",
5
5
  "packageManager": "pnpm@10.26.2+sha512.0e308ff2005fc7410366f154f625f6631ab2b16b1d2e70238444dd6ae9d630a8482d92a451144debc492416896ed16f7b114a86ec68b8404b2443869e68ffda6",
6
6
  "description": "magicdawn's eslint-config",
7
7
  "author": "magicdawn",