@soybeanjs/oxc-config 0.1.4 → 0.2.0
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/dist/plugins/import.d.ts +3978 -51
- package/dist/plugins/import.js +77 -11
- package/package.json +2 -1
package/dist/plugins/import.js
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/@oxlint+plugins@1.66.0/node_modules/@oxlint/plugins/index.js
|
|
2
|
+
/**
|
|
3
|
+
* Define a plugin.
|
|
4
|
+
*
|
|
5
|
+
* No-op function, just to provide type safety. Input is passed through unchanged.
|
|
6
|
+
*
|
|
7
|
+
* @param plugin - Plugin to define
|
|
8
|
+
* @returns Same plugin as passed in
|
|
9
|
+
*/
|
|
10
|
+
function definePlugin(plugin) {
|
|
11
|
+
return plugin;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Define a rule.
|
|
15
|
+
*
|
|
16
|
+
* No-op function, just to provide type safety. Input is passed through unchanged.
|
|
17
|
+
*
|
|
18
|
+
* @param rule - Rule to define
|
|
19
|
+
* @returns Same rule as passed in
|
|
20
|
+
*/
|
|
21
|
+
function defineRule(rule) {
|
|
22
|
+
return rule;
|
|
23
|
+
}
|
|
24
|
+
const FILE_CONTEXT = Object.freeze({
|
|
25
|
+
get filename() {
|
|
26
|
+
throw Error("Cannot access `context.filename` in `createOnce`");
|
|
27
|
+
},
|
|
28
|
+
getFilename() {
|
|
29
|
+
throw Error("Cannot call `context.getFilename` in `createOnce`");
|
|
30
|
+
},
|
|
31
|
+
get physicalFilename() {
|
|
32
|
+
throw Error("Cannot access `context.physicalFilename` in `createOnce`");
|
|
33
|
+
},
|
|
34
|
+
getPhysicalFilename() {
|
|
35
|
+
throw Error("Cannot call `context.getPhysicalFilename` in `createOnce`");
|
|
36
|
+
},
|
|
37
|
+
get cwd() {
|
|
38
|
+
throw Error("Cannot access `context.cwd` in `createOnce`");
|
|
39
|
+
},
|
|
40
|
+
getCwd() {
|
|
41
|
+
throw Error("Cannot call `context.getCwd` in `createOnce`");
|
|
42
|
+
},
|
|
43
|
+
get sourceCode() {
|
|
44
|
+
throw Error("Cannot access `context.sourceCode` in `createOnce`");
|
|
45
|
+
},
|
|
46
|
+
getSourceCode() {
|
|
47
|
+
throw Error("Cannot call `context.getSourceCode` in `createOnce`");
|
|
48
|
+
},
|
|
49
|
+
get languageOptions() {
|
|
50
|
+
throw Error("Cannot access `context.languageOptions` in `createOnce`");
|
|
51
|
+
},
|
|
52
|
+
get settings() {
|
|
53
|
+
throw Error("Cannot access `context.settings` in `createOnce`");
|
|
54
|
+
},
|
|
55
|
+
extend(extension) {
|
|
56
|
+
return Object.freeze(Object.assign(Object.create(this), extension));
|
|
57
|
+
},
|
|
58
|
+
get parserOptions() {
|
|
59
|
+
throw Error("Cannot access `context.parserOptions` in `createOnce`");
|
|
60
|
+
},
|
|
61
|
+
get parserPath() {
|
|
62
|
+
throw Error("Cannot access `context.parserPath` in `createOnce`");
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
1
67
|
//#region src/plugins/import/shared/imports.ts
|
|
2
68
|
function isTypeKind(kind) {
|
|
3
|
-
return kind === "type"
|
|
69
|
+
return kind === "type";
|
|
4
70
|
}
|
|
5
71
|
function isImportDeclaration(node) {
|
|
6
72
|
return Boolean(node) && typeof node === "object" && node.type === "ImportDeclaration";
|
|
@@ -58,7 +124,7 @@ function buildTypeImportStatement(node, sourceCode) {
|
|
|
58
124
|
});
|
|
59
125
|
}
|
|
60
126
|
function canFixInlineTypeImport(node) {
|
|
61
|
-
return !isTypeImport(node) && node.specifiers != null && hasInlineTypeSpecifier(node)
|
|
127
|
+
return !isTypeImport(node) && node.specifiers != null && hasInlineTypeSpecifier(node);
|
|
62
128
|
}
|
|
63
129
|
function createImportStatementParts() {
|
|
64
130
|
return {
|
|
@@ -103,7 +169,7 @@ function mergeImportGroup(group, sourceCode) {
|
|
|
103
169
|
const typeParts = createImportStatementParts();
|
|
104
170
|
const sourceText = sourceCode.getText(group[0].node.source);
|
|
105
171
|
for (const item of group) {
|
|
106
|
-
if (
|
|
172
|
+
if ((item.node.specifiers?.length ?? 0) === 0) return null;
|
|
107
173
|
if (sourceCode.getCommentsBefore(item.node).length > 0 && item !== group[0]) return null;
|
|
108
174
|
for (const specifier of item.node.specifiers ?? []) if (isTypeImport(item.node) || isInlineTypeSpecifier(specifier)) appendSpecifierText(typeParts, specifier, sourceCode);
|
|
109
175
|
else appendSpecifierText(valueParts, specifier, sourceCode);
|
|
@@ -148,7 +214,7 @@ function getStartWithComments(node, sourceCode) {
|
|
|
148
214
|
|
|
149
215
|
//#endregion
|
|
150
216
|
//#region src/plugins/import/rules/merge-duplicates.ts
|
|
151
|
-
const mergeDuplicatesRule = {
|
|
217
|
+
const mergeDuplicatesRule = defineRule({
|
|
152
218
|
meta: {
|
|
153
219
|
type: "layout",
|
|
154
220
|
fixable: "code",
|
|
@@ -179,11 +245,11 @@ const mergeDuplicatesRule = {
|
|
|
179
245
|
}
|
|
180
246
|
} };
|
|
181
247
|
}
|
|
182
|
-
};
|
|
248
|
+
});
|
|
183
249
|
|
|
184
250
|
//#endregion
|
|
185
251
|
//#region src/plugins/import/rules/no-inline-type-import.ts
|
|
186
|
-
const noInlineTypeImportRule = {
|
|
252
|
+
const noInlineTypeImportRule = defineRule({
|
|
187
253
|
meta: {
|
|
188
254
|
type: "layout",
|
|
189
255
|
fixable: "code",
|
|
@@ -209,11 +275,11 @@ const noInlineTypeImportRule = {
|
|
|
209
275
|
});
|
|
210
276
|
} };
|
|
211
277
|
}
|
|
212
|
-
};
|
|
278
|
+
});
|
|
213
279
|
|
|
214
280
|
//#endregion
|
|
215
281
|
//#region src/plugins/import/rules/type-after-value.ts
|
|
216
|
-
const typeAfterValueRule = {
|
|
282
|
+
const typeAfterValueRule = defineRule({
|
|
217
283
|
meta: {
|
|
218
284
|
type: "layout",
|
|
219
285
|
fixable: "code",
|
|
@@ -271,18 +337,18 @@ const typeAfterValueRule = {
|
|
|
271
337
|
}
|
|
272
338
|
} };
|
|
273
339
|
}
|
|
274
|
-
};
|
|
340
|
+
});
|
|
275
341
|
|
|
276
342
|
//#endregion
|
|
277
343
|
//#region src/plugins/import/index.ts
|
|
278
|
-
const plugin = {
|
|
344
|
+
const plugin = definePlugin({
|
|
279
345
|
meta: { name: "soybeanjs-import" },
|
|
280
346
|
rules: {
|
|
281
347
|
"merge-duplicates": mergeDuplicatesRule,
|
|
282
348
|
"no-inline-type-import": noInlineTypeImportRule,
|
|
283
349
|
"type-after-value": typeAfterValueRule
|
|
284
350
|
}
|
|
285
|
-
};
|
|
351
|
+
});
|
|
286
352
|
|
|
287
353
|
//#endregion
|
|
288
354
|
export { plugin as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soybeanjs/oxc-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "SoybeanJS's oxlint and oxfmt config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"registry": "https://registry.npmjs.org/"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
+
"@oxlint/plugins": "^1.66.0",
|
|
49
50
|
"@soybeanjs/cli": "^1.7.2",
|
|
50
51
|
"@soybeanjs/oxc-config": "link:dist",
|
|
51
52
|
"@types/node": "^25.9.1",
|