@imranbarbhuiya/oxc-config 0.1.9 → 0.1.11
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/cli/index.d.ts +1 -1
- package/dist/cli/index.js +78 -66
- package/dist/cli/index.js.map +1 -1
- package/dist/common.js +4 -25
- package/dist/common.js.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/nest.js +2 -2
- package/dist/nest.js.map +1 -1
- package/dist/node.js +0 -7
- package/dist/node.js.map +1 -1
- package/dist/plugins/api-error.d.ts +2 -3
- package/dist/plugins/api-error.js +144 -135
- package/dist/plugins/api-error.js.map +1 -1
- package/dist/plugins/central-icons.d.ts +2 -3
- package/dist/plugins/central-icons.js +45 -47
- package/dist/plugins/central-icons.js.map +1 -1
- package/dist/plugins/i18n.d.ts +2 -3
- package/dist/plugins/i18n.js +46 -49
- package/dist/plugins/i18n.js.map +1 -1
- package/dist/plugins/native-tailwind.d.ts +2 -3
- package/dist/plugins/native-tailwind.js +93 -95
- package/dist/plugins/native-tailwind.js.map +1 -1
- package/dist/plugins/nest.d.ts +2 -3
- package/dist/plugins/nest.js +32 -27
- package/dist/plugins/nest.js.map +1 -1
- package/dist/plugins/restricted-syntax.d.ts +5 -0
- package/dist/plugins/restricted-syntax.js +115 -0
- package/dist/plugins/restricted-syntax.js.map +1 -0
- package/dist/typescript.js +9 -14
- package/dist/typescript.js.map +1 -1
- package/package.json +62 -64
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { TSESLint } from "@typescript-eslint/utils";
|
|
2
1
|
//#region src/plugins/native-tailwind.d.ts
|
|
3
|
-
declare const
|
|
2
|
+
declare const _default: import("@oxlint/plugins").Plugin;
|
|
4
3
|
//#endregion
|
|
5
|
-
export {
|
|
4
|
+
export { _default as default };
|
|
6
5
|
//# sourceMappingURL=native-tailwind.d.ts.map
|
|
@@ -1,110 +1,108 @@
|
|
|
1
|
+
import { definePlugin, defineRule } from "@oxlint/plugins";
|
|
2
|
+
|
|
1
3
|
//#region src/plugins/native-tailwind.ts
|
|
2
|
-
const
|
|
4
|
+
const FORBIDDEN = /* @__PURE__ */ new Set(["flex-col"]);
|
|
5
|
+
const classNameRules = defineRule({
|
|
3
6
|
meta: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
docs: { description: "Disallow Tailwind flex-col, and standalone flex" },
|
|
11
|
-
fixable: "code",
|
|
12
|
-
schema: [],
|
|
13
|
-
messages: {
|
|
14
|
-
forbidden: "Class '{{cls}}' is the default in react-native, so no need to explicitly set it.",
|
|
15
|
-
flexOnly: "Class 'flex' should be removed or changed to 'flex-row' for explicit direction."
|
|
16
|
-
},
|
|
17
|
-
hasSuggestions: true
|
|
7
|
+
type: "problem",
|
|
8
|
+
docs: { description: "Disallow Tailwind flex-col, and standalone flex" },
|
|
9
|
+
fixable: "code",
|
|
10
|
+
messages: {
|
|
11
|
+
forbidden: "Class '{{cls}}' is the default in react-native, so no need to explicitly set it.",
|
|
12
|
+
flexOnly: "Class 'flex' should be removed or changed to 'flex-row' for explicit direction."
|
|
18
13
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
node,
|
|
32
|
-
messageId: "forbidden",
|
|
33
|
-
data: { cls: "flex, flex-row" },
|
|
34
|
-
fix(fixer) {
|
|
35
|
-
const finalClasses = classes.filter((cl) => cl !== "flex" && !FORBIDDEN.has(cl)).join(" ");
|
|
36
|
-
const quote = raw.startsWith("'") ? "'" : "\"";
|
|
37
|
-
return fixer.replaceText(node, `${quote}${finalClasses}${quote}`);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (hasFlex && hasFlexCol) {
|
|
43
|
-
context.report({
|
|
44
|
-
node,
|
|
45
|
-
messageId: "forbidden",
|
|
46
|
-
data: { cls: "flex, flex-col" },
|
|
47
|
-
fix(fixer) {
|
|
48
|
-
const finalClasses = classes.filter((cl) => cl !== "flex" && cl !== "flex-col" && !FORBIDDEN.has(cl)).join(" ");
|
|
49
|
-
const quote = raw.startsWith("'") ? "'" : "\"";
|
|
50
|
-
return fixer.replaceText(node, `${quote}${finalClasses}${quote}`);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (hasFlexCol && !hasFlex) {
|
|
56
|
-
context.report({
|
|
57
|
-
node,
|
|
58
|
-
messageId: "forbidden",
|
|
59
|
-
data: { cls: "flex-col" },
|
|
60
|
-
fix(fixer) {
|
|
61
|
-
const finalClasses = classes.filter((cl) => cl !== "flex-col" && !FORBIDDEN.has(cl)).join(" ");
|
|
62
|
-
const quote = raw.startsWith("'") ? "'" : "\"";
|
|
63
|
-
return fixer.replaceText(node, `${quote}${finalClasses}${quote}`);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (hasFlex && !hasFlexCol) {
|
|
69
|
-
context.report({
|
|
70
|
-
node,
|
|
71
|
-
messageId: "flexOnly",
|
|
72
|
-
data: { cls: "flex" },
|
|
73
|
-
suggest: [{
|
|
74
|
-
messageId: "flexOnly",
|
|
75
|
-
data: { cls: "flex" },
|
|
76
|
-
fix(fixer) {
|
|
77
|
-
const finalClasses = classes.map((cl) => cl === "flex" ? "flex-row" : cl).join(" ");
|
|
78
|
-
const quote = raw.startsWith("'") ? "'" : "\"";
|
|
79
|
-
return fixer.replaceText(node, `${quote}${finalClasses}${quote}`);
|
|
80
|
-
}
|
|
81
|
-
}]
|
|
82
|
-
});
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (offendingForbidden.length > 0) context.report({
|
|
14
|
+
hasSuggestions: true
|
|
15
|
+
},
|
|
16
|
+
createOnce(context) {
|
|
17
|
+
function reportAndFix(node, text, raw) {
|
|
18
|
+
const classes = text.trim().split(/\s+/);
|
|
19
|
+
const hasFlex = classes.includes("flex");
|
|
20
|
+
const hasFlexCol = classes.includes("flex-col");
|
|
21
|
+
const hasFlexRow = classes.includes("flex-row");
|
|
22
|
+
const offendingForbidden = classes.filter((cl) => FORBIDDEN.has(cl));
|
|
23
|
+
if (!hasFlex && offendingForbidden.length === 0) return;
|
|
24
|
+
if (hasFlex && hasFlexRow) {
|
|
25
|
+
context.report({
|
|
86
26
|
node,
|
|
87
27
|
messageId: "forbidden",
|
|
88
|
-
data: { cls:
|
|
28
|
+
data: { cls: "flex, flex-row" },
|
|
89
29
|
fix(fixer) {
|
|
90
|
-
const finalClasses = classes.filter((cl) => !FORBIDDEN.has(cl)).join(" ");
|
|
91
|
-
const quote = raw.startsWith("'") ? "'" : "\"";
|
|
30
|
+
const finalClasses = classes.filter((cl) => cl !== "flex" && !FORBIDDEN.has(cl)).join(" ");
|
|
31
|
+
const quote = (raw ?? "\"").startsWith("'") ? "'" : "\"";
|
|
92
32
|
return fixer.replaceText(node, `${quote}${finalClasses}${quote}`);
|
|
93
33
|
}
|
|
94
34
|
});
|
|
35
|
+
return;
|
|
95
36
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
37
|
+
if (hasFlex && hasFlexCol) {
|
|
38
|
+
context.report({
|
|
39
|
+
node,
|
|
40
|
+
messageId: "forbidden",
|
|
41
|
+
data: { cls: "flex, flex-col" },
|
|
42
|
+
fix(fixer) {
|
|
43
|
+
const finalClasses = classes.filter((cl) => cl !== "flex" && cl !== "flex-col" && !FORBIDDEN.has(cl)).join(" ");
|
|
44
|
+
const quote = (raw ?? "\"").startsWith("'") ? "'" : "\"";
|
|
45
|
+
return fixer.replaceText(node, `${quote}${finalClasses}${quote}`);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (hasFlexCol && !hasFlex) {
|
|
51
|
+
context.report({
|
|
52
|
+
node,
|
|
53
|
+
messageId: "forbidden",
|
|
54
|
+
data: { cls: "flex-col" },
|
|
55
|
+
fix(fixer) {
|
|
56
|
+
const finalClasses = classes.filter((cl) => cl !== "flex-col" && !FORBIDDEN.has(cl)).join(" ");
|
|
57
|
+
const quote = (raw ?? "\"").startsWith("'") ? "'" : "\"";
|
|
58
|
+
return fixer.replaceText(node, `${quote}${finalClasses}${quote}`);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (hasFlex && !hasFlexCol) {
|
|
64
|
+
context.report({
|
|
65
|
+
node,
|
|
66
|
+
messageId: "flexOnly",
|
|
67
|
+
data: { cls: "flex" },
|
|
68
|
+
suggest: [{
|
|
69
|
+
messageId: "flexOnly",
|
|
70
|
+
data: { cls: "flex" },
|
|
71
|
+
fix(fixer) {
|
|
72
|
+
const finalClasses = classes.map((cl) => cl === "flex" ? "flex-row" : cl).join(" ");
|
|
73
|
+
const quote = (raw ?? "\"").startsWith("'") ? "'" : "\"";
|
|
74
|
+
return fixer.replaceText(node, `${quote}${finalClasses}${quote}`);
|
|
75
|
+
}
|
|
76
|
+
}]
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (offendingForbidden.length > 0) context.report({
|
|
81
|
+
node,
|
|
82
|
+
messageId: "forbidden",
|
|
83
|
+
data: { cls: offendingForbidden.join(", ") },
|
|
84
|
+
fix(fixer) {
|
|
85
|
+
const finalClasses = classes.filter((cl) => !FORBIDDEN.has(cl)).join(" ");
|
|
86
|
+
const quote = (raw ?? "\"").startsWith("'") ? "'" : "\"";
|
|
87
|
+
return fixer.replaceText(node, `${quote}${finalClasses}${quote}`);
|
|
101
88
|
}
|
|
102
|
-
|
|
103
|
-
} };
|
|
89
|
+
});
|
|
104
90
|
}
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
return { JSXAttribute(attr) {
|
|
92
|
+
if (attr.name.type !== "JSXIdentifier" || attr.name.name !== "className") return;
|
|
93
|
+
if (attr.value?.type === "Literal" && typeof attr.value.value === "string") {
|
|
94
|
+
reportAndFix(attr.value, attr.value.value, attr.value.raw);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (attr.value?.type === "JSXExpressionContainer" && attr.value.expression.type === "Literal" && typeof attr.value.expression.value === "string") reportAndFix(attr.value.expression, attr.value.expression.value, attr.value.expression.raw);
|
|
98
|
+
} };
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
var native_tailwind_default = definePlugin({
|
|
102
|
+
meta: { name: "eslint-plugin-mahir-native-tailwind" },
|
|
103
|
+
rules: { "class-name-rules": classNameRules }
|
|
104
|
+
});
|
|
107
105
|
|
|
108
106
|
//#endregion
|
|
109
|
-
export {
|
|
107
|
+
export { native_tailwind_default as default };
|
|
110
108
|
//# sourceMappingURL=native-tailwind.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-tailwind.js","names":[],"sources":["../../src/plugins/native-tailwind.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"native-tailwind.js","names":[],"sources":["../../src/plugins/native-tailwind.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\nconst FORBIDDEN = new Set(['flex-col']);\n\nconst classNameRules = defineRule({\n\tmeta: {\n\t\ttype: 'problem',\n\t\tdocs: {\n\t\t\tdescription: 'Disallow Tailwind flex-col, and standalone flex',\n\t\t},\n\t\tfixable: 'code',\n\t\tmessages: {\n\t\t\tforbidden: \"Class '{{cls}}' is the default in react-native, so no need to explicitly set it.\",\n\t\t\tflexOnly: \"Class 'flex' should be removed or changed to 'flex-row' for explicit direction.\",\n\t\t},\n\t\thasSuggestions: true,\n\t},\n\tcreateOnce(context) {\n\t\tfunction reportAndFix(node: ESTree.Node, text: string, raw: string | null) {\n\t\t\tconst classes = text.trim().split(/\\s+/);\n\t\t\tconst hasFlex = classes.includes('flex');\n\t\t\tconst hasFlexCol = classes.includes('flex-col');\n\t\t\tconst hasFlexRow = classes.includes('flex-row');\n\t\t\tconst offendingForbidden = classes.filter((cl) => FORBIDDEN.has(cl));\n\n\t\t\tif (!hasFlex && offendingForbidden.length === 0) return;\n\n\t\t\tif (hasFlex && hasFlexRow) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: 'flex, flex-row' },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => cl !== 'flex' && !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (hasFlex && hasFlexCol) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: 'flex, flex-col' },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => cl !== 'flex' && cl !== 'flex-col' && !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (hasFlexCol && !hasFlex) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: 'flex-col' },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => cl !== 'flex-col' && !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (hasFlex && !hasFlexCol) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'flexOnly',\n\t\t\t\t\tdata: { cls: 'flex' },\n\t\t\t\t\tsuggest: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessageId: 'flexOnly',\n\t\t\t\t\t\t\tdata: { cls: 'flex' },\n\t\t\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\t\t\tconst replacedClasses = classes.map((cl) => (cl === 'flex' ? 'flex-row' : cl));\n\t\t\t\t\t\t\t\tconst finalClasses = replacedClasses.join(' ');\n\t\t\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (offendingForbidden.length > 0) {\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'forbidden',\n\t\t\t\t\tdata: { cls: offendingForbidden.join(', ') },\n\t\t\t\t\tfix(fixer) {\n\t\t\t\t\t\tconst kept = classes.filter((cl) => !FORBIDDEN.has(cl));\n\t\t\t\t\t\tconst finalClasses = kept.join(' ');\n\t\t\t\t\t\tconst quote = (raw ?? '\"').startsWith(\"'\") ? \"'\" : '\"';\n\t\t\t\t\t\treturn fixer.replaceText(node, `${quote}${finalClasses}${quote}`);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tJSXAttribute(attr) {\n\t\t\t\tif (attr.name.type !== 'JSXIdentifier' || attr.name.name !== 'className') return;\n\n\t\t\t\tif (attr.value?.type === 'Literal' && typeof attr.value.value === 'string') {\n\t\t\t\t\treportAndFix(attr.value, attr.value.value, attr.value.raw);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tattr.value?.type === 'JSXExpressionContainer' &&\n\t\t\t\t\tattr.value.expression.type === 'Literal' &&\n\t\t\t\t\ttypeof attr.value.expression.value === 'string'\n\t\t\t\t)\n\t\t\t\t\treportAndFix(attr.value.expression, attr.value.expression.value, attr.value.expression.raw);\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlugin({\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-native-tailwind',\n\t},\n\trules: {\n\t\t'class-name-rules': classNameRules,\n\t},\n});\n"],"mappings":";;;AAIA,MAAM,4BAAY,IAAI,IAAI,CAAC,UAAU,CAAC;AAEtC,MAAM,iBAAiB,WAAW;CACjC,MAAM;EACL,MAAM;EACN,MAAM,EACL,aAAa,kDACd;EACA,SAAS;EACT,UAAU;GACT,WAAW;GACX,UAAU;EACX;EACA,gBAAgB;CACjB;CACA,WAAW,SAAS;EACnB,SAAS,aAAa,MAAmB,MAAc,KAAoB;GAC1E,MAAM,UAAU,KAAK,KAAK,CAAC,CAAC,MAAM,KAAK;GACvC,MAAM,UAAU,QAAQ,SAAS,MAAM;GACvC,MAAM,aAAa,QAAQ,SAAS,UAAU;GAC9C,MAAM,aAAa,QAAQ,SAAS,UAAU;GAC9C,MAAM,qBAAqB,QAAQ,QAAQ,OAAO,UAAU,IAAI,EAAE,CAAC;GAEnE,IAAI,CAAC,WAAW,mBAAmB,WAAW,GAAG;GAEjD,IAAI,WAAW,YAAY;IAC1B,QAAQ,OAA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ts
|
|
3
|
-
declare const
|
|
2
|
+
declare const _default: import("@oxlint/plugins").Plugin;
|
|
4
3
|
//#endregion
|
|
5
|
-
export {
|
|
4
|
+
export { _default as default };
|
|
6
5
|
//# sourceMappingURL=nest.d.ts.map
|
package/dist/plugins/nest.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { definePlugin, defineRule } from "@oxlint/plugins";
|
|
2
|
+
|
|
1
3
|
//#region src/plugins/nest.ts
|
|
2
4
|
const DEFAULT_LOCALE = "en-US";
|
|
3
5
|
function isSortable(node) {
|
|
@@ -5,7 +7,7 @@ function isSortable(node) {
|
|
|
5
7
|
}
|
|
6
8
|
function nodeName(node) {
|
|
7
9
|
if (node.type === "Identifier") return node.name;
|
|
8
|
-
if (node.
|
|
10
|
+
if (node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier") return node.callee.object.name;
|
|
9
11
|
return "";
|
|
10
12
|
}
|
|
11
13
|
function isFactoryProviderInjectArray(node) {
|
|
@@ -15,43 +17,46 @@ function isFactoryProviderInjectArray(node) {
|
|
|
15
17
|
if (property.parent.type !== "ObjectExpression") return false;
|
|
16
18
|
return property.parent.properties.some((item) => item.type === "Property" && item.key.type === "Identifier" && item.key.name === "useFactory");
|
|
17
19
|
}
|
|
18
|
-
const
|
|
20
|
+
const sortModuleMetadataArrays = defineRule({
|
|
19
21
|
meta: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
type: "suggestion",
|
|
23
|
+
docs: { description: "Ensure Module metadata arrays are sorted alphabetically" },
|
|
24
|
+
fixable: "code",
|
|
25
|
+
schema: [{
|
|
26
|
+
type: "object",
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
properties: { locale: { type: "string" } }
|
|
29
|
+
}],
|
|
30
|
+
messages: { moduleMetadataArraysAreSorted: "`Module` metadata arrays should be sorted in ASC alphabetical order" },
|
|
31
|
+
defaultOptions: [{ locale: DEFAULT_LOCALE }]
|
|
22
32
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
properties: { locale: { type: "string" } }
|
|
32
|
-
}],
|
|
33
|
-
messages: { moduleMetadataArraysAreSorted: "`Module` metadata arrays should be sorted in ASC alphabetical order" }
|
|
34
|
-
},
|
|
35
|
-
defaultOptions: [{ locale: DEFAULT_LOCALE }],
|
|
36
|
-
create(context) {
|
|
37
|
-
const locale = context.options[0].locale ?? DEFAULT_LOCALE;
|
|
38
|
-
const sourceCode = context.sourceCode;
|
|
39
|
-
return { "ClassDeclaration > Decorator[expression.callee.name=\"Module\"] Property > ArrayExpression"(node) {
|
|
33
|
+
createOnce(context) {
|
|
34
|
+
let locale = DEFAULT_LOCALE;
|
|
35
|
+
return {
|
|
36
|
+
before() {
|
|
37
|
+
locale = context.options[0]?.locale ?? DEFAULT_LOCALE;
|
|
38
|
+
},
|
|
39
|
+
"ClassDeclaration > Decorator[expression.callee.name=\"Module\"] Property > ArrayExpression"(node) {
|
|
40
|
+
if (node.type !== "ArrayExpression") return;
|
|
40
41
|
if (isFactoryProviderInjectArray(node)) return;
|
|
41
42
|
const sortable = node.elements.filter(isSortable);
|
|
42
43
|
const sorted = sortable.toSorted((left, right) => nodeName(left).localeCompare(nodeName(right), locale));
|
|
43
44
|
if (sortable.every((element, index) => element === sorted[index])) return;
|
|
44
|
-
const texts = sorted.map((element) => sourceCode.getText(element));
|
|
45
|
+
const texts = sorted.map((element) => context.sourceCode.getText(element));
|
|
45
46
|
context.report({
|
|
46
47
|
node,
|
|
47
48
|
messageId: "moduleMetadataArraysAreSorted",
|
|
48
49
|
fix: (fixer) => sortable.map((element, index) => fixer.replaceText(element, texts[index] ?? ""))
|
|
49
50
|
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
var nest_default = definePlugin({
|
|
56
|
+
meta: { name: "eslint-plugin-mahir-nest" },
|
|
57
|
+
rules: { "sort-module-metadata-arrays": sortModuleMetadataArrays }
|
|
58
|
+
});
|
|
54
59
|
|
|
55
60
|
//#endregion
|
|
56
|
-
export {
|
|
61
|
+
export { nest_default as default };
|
|
57
62
|
//# sourceMappingURL=nest.js.map
|
package/dist/plugins/nest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nest.js","names":[],"sources":["../../src/plugins/nest.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"nest.js","names":[],"sources":["../../src/plugins/nest.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\nconst DEFAULT_LOCALE = 'en-US';\n\nfunction isSortable(node: ESTree.ArrayExpressionElement): node is ESTree.CallExpression | ESTree.IdentifierName | ESTree.IdentifierReference {\n\treturn node?.type === 'Identifier' || node?.type === 'CallExpression';\n}\n\nfunction nodeName(node: ESTree.CallExpression | ESTree.IdentifierName | ESTree.IdentifierReference) {\n\tif (node.type === 'Identifier') return node.name;\n\tif (node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier') return node.callee.object.name;\n\treturn '';\n}\n\nfunction isFactoryProviderInjectArray(node: ESTree.ArrayExpression) {\n\tif (node.parent.type !== 'Property') return false;\n\tconst property = node.parent;\n\tif (property.key.type !== 'Identifier' || property.key.name !== 'inject') return false;\n\tif (property.parent.type !== 'ObjectExpression') return false;\n\treturn property.parent.properties.some(\n\t\t(item) => item.type === 'Property' && item.key.type === 'Identifier' && item.key.name === 'useFactory',\n\t);\n}\n\nconst sortModuleMetadataArrays = defineRule({\n\tmeta: {\n\t\ttype: 'suggestion',\n\t\tdocs: {\n\t\t\tdescription: 'Ensure Module metadata arrays are sorted alphabetically',\n\t\t},\n\t\tfixable: 'code',\n\t\tschema: [\n\t\t\t{\n\t\t\t\ttype: 'object',\n\t\t\t\tadditionalProperties: false,\n\t\t\t\tproperties: {\n\t\t\t\t\tlocale: { type: 'string' },\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tmessages: {\n\t\t\tmoduleMetadataArraysAreSorted: '`Module` metadata arrays should be sorted in ASC alphabetical order',\n\t\t},\n\t\tdefaultOptions: [{ locale: DEFAULT_LOCALE }],\n\t},\n\tcreateOnce(context) {\n\t\tlet locale = DEFAULT_LOCALE;\n\t\treturn {\n\t\t\tbefore() {\n\t\t\t\tconst options = context.options[0] as { locale?: string } | undefined;\n\t\t\t\tlocale = options?.locale ?? DEFAULT_LOCALE;\n\t\t\t},\n\t\t\t'ClassDeclaration > Decorator[expression.callee.name=\"Module\"] Property > ArrayExpression'(node) {\n\t\t\t\tif (node.type !== 'ArrayExpression') return;\n\t\t\t\tif (isFactoryProviderInjectArray(node)) return;\n\t\t\t\tconst sortable = node.elements.filter(isSortable);\n\t\t\t\tconst sorted = sortable.toSorted((left, right) => nodeName(left).localeCompare(nodeName(right), locale));\n\t\t\t\tif (sortable.every((element, index) => element === sorted[index])) return;\n\t\t\t\tconst texts = sorted.map((element) => context.sourceCode.getText(element));\n\t\t\t\tcontext.report({\n\t\t\t\t\tnode,\n\t\t\t\t\tmessageId: 'moduleMetadataArraysAreSorted',\n\t\t\t\t\tfix: (fixer) => sortable.map((element, index) => fixer.replaceText(element, texts[index] ?? '')),\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlugin({\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-nest',\n\t},\n\trules: {\n\t\t'sort-module-metadata-arrays': sortModuleMetadataArrays,\n\t},\n});\n"],"mappings":";;;AAIA,MAAM,iBAAiB;AAEvB,SAAS,WAAW,MAAyH;CAC5I,OAAO,MAAM,SAAS,gBAAgB,MAAM,SAAS;AACtD;AAEA,SAAS,SAAS,MAAkF;CACnG,IAAI,KAAK,SAAS,cAAc,OAAO,KAAK;CAC5C,IAAI,KAAK,OAAO,SAAS,sBAAsB,KAAK,OA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AAE,CAAC;IAChG,CAAC;GACF;EACD;CACD;AACD,CAAC;AAED,mBAAe,aAAa;CAC3B,MAAM,EACL,MAAM,2BACP;CACA,OAAO,EACN,+BAA+B,yBAChC;AACD,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { definePlugin, defineRule } from "@oxlint/plugins";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/restricted-syntax.ts
|
|
4
|
+
function restrictionSelector(restriction) {
|
|
5
|
+
return typeof restriction === "string" ? restriction : restriction.selector;
|
|
6
|
+
}
|
|
7
|
+
function restrictionMessage(restriction) {
|
|
8
|
+
if (typeof restriction === "string") return `Using '${restriction}' is not allowed.`;
|
|
9
|
+
return restriction.message ?? `Using '${restriction.selector}' is not allowed.`;
|
|
10
|
+
}
|
|
11
|
+
function isAstNode(value) {
|
|
12
|
+
return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
|
|
13
|
+
}
|
|
14
|
+
function pathValue(node, path) {
|
|
15
|
+
let current = node;
|
|
16
|
+
for (const part of path.split(".")) {
|
|
17
|
+
if (current == null || typeof current !== "object") return void 0;
|
|
18
|
+
current = current[part];
|
|
19
|
+
}
|
|
20
|
+
return current;
|
|
21
|
+
}
|
|
22
|
+
function matchAttributes(node, attributes) {
|
|
23
|
+
for (const attribute of attributes.matchAll(/\[([^\]]+)\]/g)) {
|
|
24
|
+
const expression = attribute[1];
|
|
25
|
+
const equal = /^(.+?)=(?:'([^']*)'|"([^"]*)")$/.exec(expression);
|
|
26
|
+
if (!equal) return false;
|
|
27
|
+
if (String(pathValue(node, equal[1].trim())) !== (equal[2] ?? equal[3])) return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
function matchSimple(node, simple) {
|
|
32
|
+
const type = /^(?<type>[A-Za-z]+)/.exec(simple)?.groups?.type;
|
|
33
|
+
if (!type || node.type !== type) return false;
|
|
34
|
+
const not = /:not\((?<inner>[^)]*)\)/.exec(simple);
|
|
35
|
+
if (not?.groups?.inner && matchAttributes(node, not.groups.inner)) return false;
|
|
36
|
+
return matchAttributes(node, simple.replace(/:not\([^)]*\)/g, ""));
|
|
37
|
+
}
|
|
38
|
+
function matchSelector(node, selector) {
|
|
39
|
+
const parts = selector.split(/\s*>\s*/);
|
|
40
|
+
let current = node;
|
|
41
|
+
for (let index = parts.length - 1; index >= 0; index--) {
|
|
42
|
+
if (!current || !matchSimple(current, parts[index] ?? "")) return false;
|
|
43
|
+
current = index > 0 ? current.parent : current;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
function walk(node, visit, seen = /* @__PURE__ */ new Set()) {
|
|
48
|
+
if (seen.has(node)) return;
|
|
49
|
+
seen.add(node);
|
|
50
|
+
visit(node);
|
|
51
|
+
for (const key of Object.keys(node)) {
|
|
52
|
+
if (key === "parent" || key === "loc" || key === "range") continue;
|
|
53
|
+
const child = node[key];
|
|
54
|
+
if (Array.isArray(child)) {
|
|
55
|
+
for (const item of child) if (isAstNode(item)) walk(item, visit, seen);
|
|
56
|
+
} else if (isAstNode(child)) walk(child, visit, seen);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const noRestrictedSyntax = defineRule({
|
|
60
|
+
meta: {
|
|
61
|
+
type: "suggestion",
|
|
62
|
+
docs: { description: "Disallow specified syntax via ESLint selectors" },
|
|
63
|
+
schema: {
|
|
64
|
+
type: "array",
|
|
65
|
+
items: { oneOf: [{
|
|
66
|
+
type: "string",
|
|
67
|
+
minLength: 1
|
|
68
|
+
}, {
|
|
69
|
+
type: "object",
|
|
70
|
+
additionalProperties: false,
|
|
71
|
+
required: ["selector"],
|
|
72
|
+
properties: {
|
|
73
|
+
selector: {
|
|
74
|
+
type: "string",
|
|
75
|
+
minLength: 1
|
|
76
|
+
},
|
|
77
|
+
message: {
|
|
78
|
+
type: "string",
|
|
79
|
+
minLength: 1
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}] }
|
|
83
|
+
},
|
|
84
|
+
messages: { restricted: "{{message}}" }
|
|
85
|
+
},
|
|
86
|
+
createOnce(context) {
|
|
87
|
+
let restrictions = [];
|
|
88
|
+
return {
|
|
89
|
+
before() {
|
|
90
|
+
restrictions = Array.isArray(context.options) ? [...context.options] : [];
|
|
91
|
+
return restrictions.length > 0;
|
|
92
|
+
},
|
|
93
|
+
Program(program) {
|
|
94
|
+
walk(program, (node) => {
|
|
95
|
+
for (const restriction of restrictions) {
|
|
96
|
+
if (!matchSelector(node, restrictionSelector(restriction))) continue;
|
|
97
|
+
context.report({
|
|
98
|
+
node,
|
|
99
|
+
messageId: "restricted",
|
|
100
|
+
data: { message: restrictionMessage(restriction) }
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
var restricted_syntax_default = definePlugin({
|
|
109
|
+
meta: { name: "eslint-plugin-mahir-restricted-syntax" },
|
|
110
|
+
rules: { "no-restricted-syntax": noRestrictedSyntax }
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { restricted_syntax_default as default };
|
|
115
|
+
//# sourceMappingURL=restricted-syntax.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restricted-syntax.js","names":[],"sources":["../../src/plugins/restricted-syntax.ts"],"sourcesContent":["import { definePlugin, defineRule } from '@oxlint/plugins';\n\nimport type { ESTree } from '@oxlint/plugins';\n\ntype Restriction =\n\t| string\n\t| {\n\t\t\tmessage?: string;\n\t\t\tselector: string;\n\t };\n\nfunction restrictionSelector(restriction: Restriction) {\n\treturn typeof restriction === 'string' ? restriction : restriction.selector;\n}\n\nfunction restrictionMessage(restriction: Restriction) {\n\tif (typeof restriction === 'string') return `Using '${restriction}' is not allowed.`;\n\treturn restriction.message ?? `Using '${restriction.selector}' is not allowed.`;\n}\n\nfunction isAstNode(value: unknown): value is ESTree.Node {\n\treturn typeof value === 'object' && value !== null && 'type' in value && typeof (value as { type: unknown }).type === 'string';\n}\n\nfunction pathValue(node: ESTree.Node, path: string) {\n\tlet current: unknown = node;\n\tfor (const part of path.split('.')) {\n\t\tif (current == null || typeof current !== 'object') return undefined;\n\t\tcurrent = (current as Record<string, unknown>)[part];\n\t}\n\treturn current;\n}\n\nfunction matchAttributes(node: ESTree.Node, attributes: string) {\n\tfor (const attribute of attributes.matchAll(/\\[([^\\]]+)\\]/g)) {\n\t\tconst expression = attribute[1];\n\t\tconst equal = /^(.+?)=(?:'([^']*)'|\"([^\"]*)\")$/.exec(expression);\n\t\tif (!equal) return false;\n\t\tif (String(pathValue(node, equal[1].trim())) !== (equal[2] ?? equal[3])) return false;\n\t}\n\treturn true;\n}\n\nfunction matchSimple(node: ESTree.Node, simple: string) {\n\tconst type = /^(?<type>[A-Za-z]+)/.exec(simple)?.groups?.type;\n\tif (!type || node.type !== type) return false;\n\tconst not = /:not\\((?<inner>[^)]*)\\)/.exec(simple);\n\tif (not?.groups?.inner && matchAttributes(node, not.groups.inner)) return false;\n\treturn matchAttributes(node, simple.replace(/:not\\([^)]*\\)/g, ''));\n}\n\nfunction matchSelector(node: ESTree.Node, selector: string) {\n\tconst parts = selector.split(/\\s*>\\s*/);\n\tlet current: ESTree.Node | null | undefined = node;\n\tfor (let index = parts.length - 1; index >= 0; index--) {\n\t\tif (!current || !matchSimple(current, parts[index] ?? '')) return false;\n\t\tcurrent = index > 0 ? current.parent : current;\n\t}\n\treturn true;\n}\n\nfunction walk(node: ESTree.Node, visit: (current: ESTree.Node) => void, seen = new Set<ESTree.Node>()) {\n\tif (seen.has(node)) return;\n\tseen.add(node);\n\tvisit(node);\n\tfor (const key of Object.keys(node)) {\n\t\tif (key === 'parent' || key === 'loc' || key === 'range') continue;\n\t\tconst child = (node as unknown as Record<string, unknown>)[key];\n\t\tif (Array.isArray(child)) {\n\t\t\tfor (const item of child) if (isAstNode(item)) walk(item, visit, seen);\n\t\t} else if (isAstNode(child)) walk(child, visit, seen);\n\t}\n}\n\nconst noRestrictedSyntax = defineRule({\n\tmeta: {\n\t\ttype: 'suggestion',\n\t\tdocs: {\n\t\t\tdescription: 'Disallow specified syntax via ESLint selectors',\n\t\t},\n\t\tschema: {\n\t\t\ttype: 'array',\n\t\t\titems: {\n\t\t\t\toneOf: [\n\t\t\t\t\t{ type: 'string', minLength: 1 },\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t\trequired: ['selector'],\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tselector: { type: 'string', minLength: 1 },\n\t\t\t\t\t\t\tmessage: { type: 'string', minLength: 1 },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tmessages: {\n\t\t\trestricted: '{{message}}',\n\t\t},\n\t},\n\tcreateOnce(context) {\n\t\tlet restrictions: Restriction[] = [];\n\t\treturn {\n\t\t\tbefore() {\n\t\t\t\trestrictions = Array.isArray(context.options) ? [...(context.options as Restriction[])] : [];\n\t\t\t\treturn restrictions.length > 0;\n\t\t\t},\n\t\t\tProgram(program) {\n\t\t\t\twalk(program, (node) => {\n\t\t\t\t\tfor (const restriction of restrictions) {\n\t\t\t\t\t\tif (!matchSelector(node, restrictionSelector(restriction))) continue;\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tmessageId: 'restricted',\n\t\t\t\t\t\t\tdata: { message: restrictionMessage(restriction) },\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t};\n\t},\n});\n\nexport default definePlugin({\n\tmeta: {\n\t\tname: 'eslint-plugin-mahir-restricted-syntax',\n\t},\n\trules: {\n\t\t'no-restricted-syntax': noRestrictedSyntax,\n\t},\n});\n"],"mappings":";;;AAWA,SAAS,oBAAoB,aAA0B;CACtD,OAAO,OAAO,gBAAgB,W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CAAC,GAAG;MAC5D,QAAQ,OAAO;OACd;OACA,WAAW;OACX,MAAM,EAAE,SAAS,mBAAmB,WAAW,EAAE;MAClD,CAAC;KACF;IACD,CAAC;GACF;EACD;CACD;AACD,CAAC;AAED,gCAAe,aAAa;CAC3B,MAAM,EACL,MAAM,wCACP;CACA,OAAO,EACN,wBAAwB,mBACzB;AACD,CAAC"}
|
package/dist/typescript.js
CHANGED
|
@@ -4,7 +4,7 @@ import { defineConfig } from "oxlint";
|
|
|
4
4
|
//#region src/typescript.ts
|
|
5
5
|
const config = defineConfig({
|
|
6
6
|
plugins: nativePlugins,
|
|
7
|
-
jsPlugins: [packagePlugin("sonarjs", "eslint-plugin-sonarjs")
|
|
7
|
+
jsPlugins: [packagePlugin("sonarjs", "eslint-plugin-sonarjs")],
|
|
8
8
|
rules: {
|
|
9
9
|
"typescript/adjacent-overload-signatures": 2,
|
|
10
10
|
"typescript/array-type": [2, { default: "array" }],
|
|
@@ -23,18 +23,18 @@ const config = defineConfig({
|
|
|
23
23
|
}],
|
|
24
24
|
"typescript/consistent-type-definitions": 2,
|
|
25
25
|
"typescript/consistent-type-exports": [2, { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
26
|
-
"
|
|
26
|
+
"default-param-last": 2,
|
|
27
27
|
"typescript/dot-notation": [2, {
|
|
28
28
|
allowKeywords: true,
|
|
29
29
|
allowPattern: "(^[A-Z])|(^[a-z]+(_[a-z]+)+$)",
|
|
30
30
|
allowPrivateClassPropertyAccess: true
|
|
31
31
|
}],
|
|
32
|
-
"typescript
|
|
33
|
-
"typescript
|
|
32
|
+
"typescript/method-signature-style": [2, "property"],
|
|
33
|
+
"typescript/no-array-constructor": 2,
|
|
34
34
|
"typescript/no-array-delete": 0,
|
|
35
35
|
"typescript/no-base-to-string": [1, { ignoredTypeNames: ["RegExp"] }],
|
|
36
36
|
"typescript/no-confusing-non-null-assertion": 2,
|
|
37
|
-
"
|
|
37
|
+
"no-dupe-class-members": 2,
|
|
38
38
|
"typescript/no-duplicate-enum-values": 2,
|
|
39
39
|
"typescript/no-duplicate-type-constituents": 2,
|
|
40
40
|
"typescript/no-dynamic-delete": 1,
|
|
@@ -54,7 +54,6 @@ const config = defineConfig({
|
|
|
54
54
|
ignoreParameters: true,
|
|
55
55
|
ignoreProperties: true
|
|
56
56
|
}],
|
|
57
|
-
"typescript-js/no-invalid-this": 2,
|
|
58
57
|
"typescript/no-invalid-void-type": [2, {
|
|
59
58
|
allowAsThisParameter: true,
|
|
60
59
|
allowInGenericTypeArguments: true
|
|
@@ -68,7 +67,7 @@ const config = defineConfig({
|
|
|
68
67
|
"typescript/no-namespace": 0,
|
|
69
68
|
"typescript/no-non-null-asserted-nullish-coalescing": 2,
|
|
70
69
|
"typescript/no-non-null-asserted-optional-chain": 2,
|
|
71
|
-
"
|
|
70
|
+
"no-redeclare": [2, { builtinGlobals: true }],
|
|
72
71
|
"typescript/no-redundant-type-constituents": 0,
|
|
73
72
|
"typescript/no-require-imports": 2,
|
|
74
73
|
"typescript/no-this-alias": [2, {
|
|
@@ -88,17 +87,16 @@ const config = defineConfig({
|
|
|
88
87
|
"typescript/no-unsafe-member-access": 0,
|
|
89
88
|
"typescript/no-unsafe-return": 0,
|
|
90
89
|
"typescript/no-unsafe-unary-minus": 0,
|
|
91
|
-
"
|
|
90
|
+
"no-unused-expressions": 2,
|
|
92
91
|
"typescript/no-unused-vars": 0,
|
|
93
|
-
"
|
|
92
|
+
"no-use-before-define": [2, {
|
|
94
93
|
classes: true,
|
|
95
94
|
functions: false,
|
|
96
95
|
variables: true
|
|
97
96
|
}],
|
|
98
|
-
"
|
|
97
|
+
"no-useless-constructor": 2,
|
|
99
98
|
"typescript/only-throw-error": 2,
|
|
100
99
|
"typescript/prefer-as-const": 0,
|
|
101
|
-
"typescript-js/prefer-as-const": 0,
|
|
102
100
|
"typescript/prefer-for-of": 2,
|
|
103
101
|
"typescript/prefer-function-type": 2,
|
|
104
102
|
"typescript/prefer-includes": 2,
|
|
@@ -125,13 +123,10 @@ const config = defineConfig({
|
|
|
125
123
|
"consistent-return": 0,
|
|
126
124
|
"default-case": 0,
|
|
127
125
|
"default-case-last": 0,
|
|
128
|
-
"default-param-last": 0,
|
|
129
126
|
"dot-notation": 0,
|
|
130
127
|
"import/no-dynamic-require": 0,
|
|
131
128
|
"no-shadow": 0,
|
|
132
129
|
"no-undef": 0,
|
|
133
|
-
"no-use-before-define": 0,
|
|
134
|
-
"no-useless-constructor": 0,
|
|
135
130
|
"sonarjs/no-all-duplicated-branches": 2,
|
|
136
131
|
"sonarjs/no-collapsible-if": 2,
|
|
137
132
|
"sonarjs/no-collection-size-mischeck": 2,
|