corsa-oxlint 0.7.0 → 0.7.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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isStringArrayLikeTypeTexts } from "../utils.js";
|
|
1
2
|
import { createNativeRule } from "./rule_creator.js";
|
|
2
3
|
import { memberObject, memberPropertyName } from "./ast.js";
|
|
3
4
|
import { isArrayLikeNode, typeTextsAtNode } from "./type_utils.js";
|
|
@@ -20,9 +21,7 @@ const requireArraySortCompareRule = createNativeRule("require-array-sort-compare
|
|
|
20
21
|
});
|
|
21
22
|
} }));
|
|
22
23
|
function isStringArrayLike(context, node) {
|
|
23
|
-
return typeTextsAtNode(context, node)
|
|
24
|
-
return text === "string[]" || text === "readonly string[]" || text.startsWith("Array<string>") || text.startsWith("ReadonlyArray<string>");
|
|
25
|
-
});
|
|
24
|
+
return isStringArrayLikeTypeTexts(typeTextsAtNode(context, node));
|
|
26
25
|
}
|
|
27
26
|
function resolveOptions(options) {
|
|
28
27
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require_array_sort_compare.js","names":[],"sources":["../../ts/rules/require_array_sort_compare.ts"],"sourcesContent":["import { memberObject, memberPropertyName } from \"./ast\";\nimport { createNativeRule } from \"./rule_creator\";\nimport { isArrayLikeNode, typeTextsAtNode } from \"./type_utils\";\n\ntype Options = {\n ignoreStringArrays?: boolean;\n};\n\nconst defaults: Required<Options> = {\n ignoreStringArrays: true,\n};\n\nexport const requireArraySortCompareRule = createNativeRule(\n \"require-array-sort-compare\",\n {\n docs: {\n description: \"Require compare callbacks for array sorting calls.\",\n },\n messages: {\n requireCompare: \"Require a compare argument for array sorting.\",\n },\n schema: { type: \"array\" },\n },\n (context) => ({\n CallExpression(node: any) {\n if (node.arguments.length !== 0) {\n return;\n }\n const methodName = memberPropertyName(node.callee);\n if (methodName !== \"sort\" && methodName !== \"toSorted\") {\n return;\n }\n const object = memberObject(node.callee) as any;\n if (!object || !isArrayLikeNode(context, object)) {\n return;\n }\n if (\n resolveOptions(context.options).ignoreStringArrays &&\n isStringArrayLike(context, object)\n ) {\n return;\n }\n context.report({ node, messageId: \"requireCompare\" });\n },\n }),\n);\n\nfunction isStringArrayLike(context: any, node: any): boolean {\n return typeTextsAtNode(context, node)
|
|
1
|
+
{"version":3,"file":"require_array_sort_compare.js","names":[],"sources":["../../ts/rules/require_array_sort_compare.ts"],"sourcesContent":["import { memberObject, memberPropertyName } from \"./ast\";\nimport { createNativeRule } from \"./rule_creator\";\nimport { isArrayLikeNode, typeTextsAtNode } from \"./type_utils\";\nimport { isStringArrayLikeTypeTexts } from \"../utils\";\n\ntype Options = {\n ignoreStringArrays?: boolean;\n};\n\nconst defaults: Required<Options> = {\n ignoreStringArrays: true,\n};\n\nexport const requireArraySortCompareRule = createNativeRule(\n \"require-array-sort-compare\",\n {\n docs: {\n description: \"Require compare callbacks for array sorting calls.\",\n },\n messages: {\n requireCompare: \"Require a compare argument for array sorting.\",\n },\n schema: { type: \"array\" },\n },\n (context) => ({\n CallExpression(node: any) {\n if (node.arguments.length !== 0) {\n return;\n }\n const methodName = memberPropertyName(node.callee);\n if (methodName !== \"sort\" && methodName !== \"toSorted\") {\n return;\n }\n const object = memberObject(node.callee) as any;\n if (!object || !isArrayLikeNode(context, object)) {\n return;\n }\n if (\n resolveOptions(context.options).ignoreStringArrays &&\n isStringArrayLike(context, object)\n ) {\n return;\n }\n context.report({ node, messageId: \"requireCompare\" });\n },\n }),\n);\n\nfunction isStringArrayLike(context: any, node: any): boolean {\n return isStringArrayLikeTypeTexts(typeTextsAtNode(context, node));\n}\n\nfunction resolveOptions(options: readonly unknown[]): Required<Options> {\n return { ...defaults, ...(options[0] as Options | undefined) };\n}\n"],"mappings":";;;;;AASA,MAAM,WAA8B,EAClC,oBAAoB,MACrB;AAED,MAAa,8BAA8B,iBACzC,8BACA;CACE,MAAM,EACJ,aAAa,sDACd;CACD,UAAU,EACR,gBAAgB,iDACjB;CACD,QAAQ,EAAE,MAAM,SAAS;CAC1B,GACA,aAAa,EACZ,eAAe,MAAW;AACxB,KAAI,KAAK,UAAU,WAAW,EAC5B;CAEF,MAAM,aAAa,mBAAmB,KAAK,OAAO;AAClD,KAAI,eAAe,UAAU,eAAe,WAC1C;CAEF,MAAM,SAAS,aAAa,KAAK,OAAO;AACxC,KAAI,CAAC,UAAU,CAAC,gBAAgB,SAAS,OAAO,CAC9C;AAEF,KACE,eAAe,QAAQ,QAAQ,CAAC,sBAChC,kBAAkB,SAAS,OAAO,CAElC;AAEF,SAAQ,OAAO;EAAE;EAAM,WAAW;EAAkB,CAAC;GAExD,EACF;AAED,SAAS,kBAAkB,SAAc,MAAoB;AAC3D,QAAO,2BAA2B,gBAAgB,SAAS,KAAK,CAAC;;AAGnE,SAAS,eAAe,SAAgD;AACtE,QAAO;EAAE,GAAG;EAAU,GAAI,QAAQ;EAA4B"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TypeTextKind, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText } from "@corsa-bind/napi";
|
|
1
|
+
import { TypeTextKind, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText } from "@corsa-bind/napi";
|
|
2
2
|
|
|
3
3
|
//#region src/bindings/nodejs/typescript_oxlint/ts/utils.d.ts
|
|
4
4
|
declare namespace utils_d_exports {
|
|
5
|
-
export { TypeTextKind, Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText };
|
|
5
|
+
export { TypeTextKind, Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText };
|
|
6
6
|
}
|
|
7
7
|
declare const Utils: Readonly<{
|
|
8
8
|
classifyTypeText: typeof classifyTypeText;
|
|
@@ -14,9 +14,10 @@ declare const Utils: Readonly<{
|
|
|
14
14
|
isAnyLikeTypeTexts: typeof isAnyLikeTypeTexts;
|
|
15
15
|
isUnknownLikeTypeTexts: typeof isUnknownLikeTypeTexts;
|
|
16
16
|
isArrayLikeTypeTexts: typeof isArrayLikeTypeTexts;
|
|
17
|
+
isStringArrayLikeTypeTexts: typeof isStringArrayLikeTypeTexts;
|
|
17
18
|
isPromiseLikeTypeTexts: typeof isPromiseLikeTypeTexts;
|
|
18
19
|
isErrorLikeTypeTexts: typeof isErrorLikeTypeTexts;
|
|
19
20
|
}>;
|
|
20
21
|
//#endregion
|
|
21
|
-
export { type TypeTextKind, Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText, utils_d_exports };
|
|
22
|
+
export { type TypeTextKind, Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText, utils_d_exports };
|
|
22
23
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { Utils as Utils$1, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText } from "@corsa-bind/napi";
|
|
2
|
+
import { Utils as Utils$1, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText } from "@corsa-bind/napi";
|
|
3
3
|
//#region src/bindings/nodejs/typescript_oxlint/ts/utils.ts
|
|
4
4
|
var utils_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
Utils: () => Utils,
|
|
@@ -10,6 +10,7 @@ var utils_exports = /* @__PURE__ */ __exportAll({
|
|
|
10
10
|
isErrorLikeTypeTexts: () => isErrorLikeTypeTexts,
|
|
11
11
|
isNumberLikeTypeTexts: () => isNumberLikeTypeTexts,
|
|
12
12
|
isPromiseLikeTypeTexts: () => isPromiseLikeTypeTexts,
|
|
13
|
+
isStringArrayLikeTypeTexts: () => isStringArrayLikeTypeTexts,
|
|
13
14
|
isStringLikeTypeTexts: () => isStringLikeTypeTexts,
|
|
14
15
|
isUnknownLikeTypeTexts: () => isUnknownLikeTypeTexts,
|
|
15
16
|
splitTopLevelTypeText: () => splitTopLevelTypeText,
|
|
@@ -17,6 +18,6 @@ var utils_exports = /* @__PURE__ */ __exportAll({
|
|
|
17
18
|
});
|
|
18
19
|
const Utils = Utils$1;
|
|
19
20
|
//#endregion
|
|
20
|
-
export { Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText, utils_exports };
|
|
21
|
+
export { Utils, classifyTypeText, isAnyLikeTypeTexts, isArrayLikeTypeTexts, isBigIntLikeTypeTexts, isErrorLikeTypeTexts, isNumberLikeTypeTexts, isPromiseLikeTypeTexts, isStringArrayLikeTypeTexts, isStringLikeTypeTexts, isUnknownLikeTypeTexts, splitTopLevelTypeText, splitTypeText, utils_exports };
|
|
21
22
|
|
|
22
23
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["NodeUtils"],"sources":["../ts/utils.ts"],"sourcesContent":["import {\n Utils as NodeUtils,\n classifyTypeText,\n isAnyLikeTypeTexts,\n isArrayLikeTypeTexts,\n isBigIntLikeTypeTexts,\n isErrorLikeTypeTexts,\n isNumberLikeTypeTexts,\n isPromiseLikeTypeTexts,\n isStringLikeTypeTexts,\n isUnknownLikeTypeTexts,\n splitTopLevelTypeText,\n splitTypeText,\n} from \"@corsa-bind/napi\";\n\nexport type { TypeTextKind } from \"@corsa-bind/napi\";\n\nexport {\n classifyTypeText,\n isAnyLikeTypeTexts,\n isArrayLikeTypeTexts,\n isBigIntLikeTypeTexts,\n isErrorLikeTypeTexts,\n isNumberLikeTypeTexts,\n isPromiseLikeTypeTexts,\n isStringLikeTypeTexts,\n isUnknownLikeTypeTexts,\n splitTopLevelTypeText,\n splitTypeText,\n};\n\nexport const Utils = NodeUtils;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["NodeUtils"],"sources":["../ts/utils.ts"],"sourcesContent":["import {\n Utils as NodeUtils,\n classifyTypeText,\n isAnyLikeTypeTexts,\n isArrayLikeTypeTexts,\n isBigIntLikeTypeTexts,\n isErrorLikeTypeTexts,\n isNumberLikeTypeTexts,\n isPromiseLikeTypeTexts,\n isStringArrayLikeTypeTexts,\n isStringLikeTypeTexts,\n isUnknownLikeTypeTexts,\n splitTopLevelTypeText,\n splitTypeText,\n} from \"@corsa-bind/napi\";\n\nexport type { TypeTextKind } from \"@corsa-bind/napi\";\n\nexport {\n classifyTypeText,\n isAnyLikeTypeTexts,\n isArrayLikeTypeTexts,\n isBigIntLikeTypeTexts,\n isErrorLikeTypeTexts,\n isNumberLikeTypeTexts,\n isPromiseLikeTypeTexts,\n isStringArrayLikeTypeTexts,\n isStringLikeTypeTexts,\n isUnknownLikeTypeTexts,\n splitTopLevelTypeText,\n splitTypeText,\n};\n\nexport const Utils = NodeUtils;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiCA,MAAa,QAAQA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corsa-oxlint",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Type-aware Oxlint helpers powered by corsa and typescript-go",
|
|
5
5
|
"homepage": "https://github.com/ubugeeei/corsa-bind/tree/main/src/bindings/nodejs/typescript_oxlint",
|
|
6
6
|
"bugs": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@oxlint/plugins": "1.57.0",
|
|
63
63
|
"oxlint": "1.57.0",
|
|
64
|
-
"@corsa-bind/napi": "0.7.
|
|
64
|
+
"@corsa-bind/napi": "0.7.1"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=22"
|