@conorroberts/utils 0.0.113 → 0.0.117
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/db/migrate.mjs +1 -2
- package/dist/db/migrate.mjs.map +1 -1
- package/dist/db/validate-schema.mjs +1 -2
- package/dist/db/validate-schema.mjs.map +1 -1
- package/dist/env.d.mts +0 -1
- package/dist/env.mjs +2 -3
- package/dist/env.mjs.map +1 -1
- package/dist/images.mjs +1 -2
- package/dist/images.mjs.map +1 -1
- package/dist/oxlint/config.json +36 -3
- package/dist/oxlint/index.d.mts +2 -2
- package/dist/oxlint/index.mjs +67 -181
- package/dist/oxlint/index.mjs.map +1 -1
- package/dist/react.mjs +1 -6
- package/dist/react.mjs.map +1 -1
- package/dist/vscode/settings.json +47 -0
- package/package.json +16 -8
package/dist/oxlint/index.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { EMOJI_REGEX } from "valibot";
|
|
2
|
-
import { definePlugin, defineRule } from "oxlint/plugins";
|
|
3
|
-
|
|
2
|
+
import { definePlugin, defineRule } from "@oxlint/plugins";
|
|
4
3
|
//#region src/oxlint-plugins/jsx-component-pascal-case.js
|
|
5
4
|
/**
|
|
6
|
-
* @typedef {import("oxlint/plugins").Context} RuleContext
|
|
7
|
-
* @typedef {import("oxlint/plugins").ESTree.Node} ESTNode
|
|
8
|
-
* @typedef {import("oxlint/plugins").ESTree.Expression} ESTExpression
|
|
9
|
-
* @typedef {import("oxlint/plugins").ESTree.ReturnStatement} ReturnStatementNode
|
|
10
|
-
* @typedef {import("oxlint/plugins").ESTree.Function | import("oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
5
|
+
* @typedef {import("@oxlint/plugins").Context} RuleContext
|
|
6
|
+
* @typedef {import("@oxlint/plugins").ESTree.Node} ESTNode
|
|
7
|
+
* @typedef {import("@oxlint/plugins").ESTree.Expression} ESTExpression
|
|
8
|
+
* @typedef {import("@oxlint/plugins").ESTree.ReturnStatement} ReturnStatementNode
|
|
9
|
+
* @typedef {import("@oxlint/plugins").ESTree.Function | import("@oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
11
10
|
*/
|
|
12
11
|
/**
|
|
13
12
|
* @typedef {object} FunctionContext
|
|
@@ -86,7 +85,7 @@ const expressionContainsJsx$2 = (root) => {
|
|
|
86
85
|
}
|
|
87
86
|
return false;
|
|
88
87
|
};
|
|
89
|
-
const
|
|
88
|
+
const jsxComponentPascalCaseRule = defineRule({
|
|
90
89
|
meta: {
|
|
91
90
|
type: "problem",
|
|
92
91
|
docs: {
|
|
@@ -149,11 +148,7 @@ const rule$15 = defineRule({
|
|
|
149
148
|
};
|
|
150
149
|
}
|
|
151
150
|
});
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/oxlint-plugins/no-array-type.js
|
|
156
|
-
const rule$14 = defineRule({
|
|
151
|
+
const noArrayTypeRule = defineRule({
|
|
157
152
|
meta: {
|
|
158
153
|
type: "problem",
|
|
159
154
|
docs: {
|
|
@@ -172,16 +167,14 @@ const rule$14 = defineRule({
|
|
|
172
167
|
} };
|
|
173
168
|
}
|
|
174
169
|
});
|
|
175
|
-
const noArrayTypeRule = rule$14;
|
|
176
|
-
|
|
177
170
|
//#endregion
|
|
178
171
|
//#region src/oxlint-plugins/no-component-date-instantiation.js
|
|
179
172
|
/**
|
|
180
|
-
* @typedef {import("oxlint/plugins").Context} RuleContext
|
|
181
|
-
* @typedef {import("oxlint/plugins").ESTree.Node} ESTNode
|
|
182
|
-
* @typedef {import("oxlint/plugins").ESTree.NewExpression} NewExpressionNode
|
|
183
|
-
* @typedef {import("oxlint/plugins").ESTree.ReturnStatement} ReturnStatementNode
|
|
184
|
-
* @typedef {import("oxlint/plugins").ESTree.Function | import("oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
173
|
+
* @typedef {import("@oxlint/plugins").Context} RuleContext
|
|
174
|
+
* @typedef {import("@oxlint/plugins").ESTree.Node} ESTNode
|
|
175
|
+
* @typedef {import("@oxlint/plugins").ESTree.NewExpression} NewExpressionNode
|
|
176
|
+
* @typedef {import("@oxlint/plugins").ESTree.ReturnStatement} ReturnStatementNode
|
|
177
|
+
* @typedef {import("@oxlint/plugins").ESTree.Function | import("@oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
185
178
|
*/
|
|
186
179
|
/**
|
|
187
180
|
* @typedef {object} FunctionContext
|
|
@@ -247,7 +240,7 @@ const isDateInstantiation = (node) => {
|
|
|
247
240
|
if (node.callee.type === "Identifier" && node.callee.name === "Date") return true;
|
|
248
241
|
return false;
|
|
249
242
|
};
|
|
250
|
-
const
|
|
243
|
+
const noComponentDateInstantiationRule = defineRule({
|
|
251
244
|
meta: {
|
|
252
245
|
type: "problem",
|
|
253
246
|
docs: {
|
|
@@ -324,19 +317,17 @@ const rule$13 = defineRule({
|
|
|
324
317
|
};
|
|
325
318
|
}
|
|
326
319
|
});
|
|
327
|
-
const noComponentDateInstantiationRule = rule$13;
|
|
328
|
-
|
|
329
320
|
//#endregion
|
|
330
321
|
//#region src/oxlint-plugins/no-inline-components.js
|
|
331
322
|
/**
|
|
332
|
-
* @typedef {import("oxlint/plugins").Context} RuleContext
|
|
333
|
-
* @typedef {import("oxlint/plugins").ESTree.Node} ESTNode
|
|
334
|
-
* @typedef {import("oxlint/plugins").ESTree.Expression} ESTExpression
|
|
335
|
-
* @typedef {import("oxlint/plugins").ESTree.Pattern} ESTPattern
|
|
336
|
-
* @typedef {import("oxlint/plugins").ESTree.ReturnStatement} ReturnStatementNode
|
|
337
|
-
* @typedef {import("oxlint/plugins").ESTree.VariableDeclarator} VariableDeclaratorNode
|
|
338
|
-
* @typedef {import("oxlint/plugins").ESTree.AssignmentExpression} AssignmentExpressionNode
|
|
339
|
-
* @typedef {import("oxlint/plugins").ESTree.Function | import("oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
323
|
+
* @typedef {import("@oxlint/plugins").Context} RuleContext
|
|
324
|
+
* @typedef {import("@oxlint/plugins").ESTree.Node} ESTNode
|
|
325
|
+
* @typedef {import("@oxlint/plugins").ESTree.Expression} ESTExpression
|
|
326
|
+
* @typedef {import("@oxlint/plugins").ESTree.Pattern} ESTPattern
|
|
327
|
+
* @typedef {import("@oxlint/plugins").ESTree.ReturnStatement} ReturnStatementNode
|
|
328
|
+
* @typedef {import("@oxlint/plugins").ESTree.VariableDeclarator} VariableDeclaratorNode
|
|
329
|
+
* @typedef {import("@oxlint/plugins").ESTree.AssignmentExpression} AssignmentExpressionNode
|
|
330
|
+
* @typedef {import("@oxlint/plugins").ESTree.Function | import("@oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
340
331
|
*/
|
|
341
332
|
/**
|
|
342
333
|
* @typedef {object} RecordedAssignment
|
|
@@ -344,19 +335,12 @@ const noComponentDateInstantiationRule = rule$13;
|
|
|
344
335
|
* @property {string[]} names
|
|
345
336
|
*/
|
|
346
337
|
/**
|
|
347
|
-
* @typedef {object} NestedFunctionRecord
|
|
348
|
-
* @property {FunctionLikeNode} node
|
|
349
|
-
* @property {string} name
|
|
350
|
-
*/
|
|
351
|
-
/**
|
|
352
338
|
* @typedef {object} FunctionContext
|
|
353
339
|
* @property {FunctionLikeNode} node
|
|
354
|
-
* @property {FunctionContext | null} parent
|
|
355
340
|
* @property {string} name
|
|
356
341
|
* @property {boolean} returnsJsx
|
|
357
342
|
* @property {Set<string>} jsxBindingNames
|
|
358
343
|
* @property {RecordedAssignment[]} jsxAssignments
|
|
359
|
-
* @property {NestedFunctionRecord[]} nestedJsxChildren
|
|
360
344
|
*/
|
|
361
345
|
const JSX_NODE_TYPES$1 = new Set(["JSXElement", "JSXFragment"]);
|
|
362
346
|
const FUNCTION_NODE_TYPES$3 = new Set([
|
|
@@ -392,27 +376,6 @@ const getEnclosingFunction = (node) => {
|
|
|
392
376
|
return findFunction(isNode$4(node) ? node.parent ?? null : null);
|
|
393
377
|
};
|
|
394
378
|
/**
|
|
395
|
-
* @param {FunctionLikeNode} node
|
|
396
|
-
*/
|
|
397
|
-
const isFunctionUsedAsJsxProp = (node) => {
|
|
398
|
-
const checkJsxProp = (current) => {
|
|
399
|
-
if (!current) return false;
|
|
400
|
-
if (current.type === "JSXAttribute") return true;
|
|
401
|
-
if (isFunctionLike$4(current)) return false;
|
|
402
|
-
return checkJsxProp(isNode$4(current) ? current.parent ?? null : null);
|
|
403
|
-
};
|
|
404
|
-
return checkJsxProp(isNode$4(node) ? node.parent ?? null : null);
|
|
405
|
-
};
|
|
406
|
-
/**
|
|
407
|
-
* @param {FunctionLikeNode} node
|
|
408
|
-
*/
|
|
409
|
-
const isFunctionImmediatelyInvoked = (node) => {
|
|
410
|
-
const parent = isNode$4(node) ? node.parent ?? null : null;
|
|
411
|
-
if (!parent) return false;
|
|
412
|
-
if (parent.type === "CallExpression" && parent.callee === node) return true;
|
|
413
|
-
return false;
|
|
414
|
-
};
|
|
415
|
-
/**
|
|
416
379
|
* @param {ESTExpression | null | undefined} root
|
|
417
380
|
*/
|
|
418
381
|
const expressionContainsJsx$1 = (root) => {
|
|
@@ -522,30 +485,17 @@ const getFunctionName = (node) => {
|
|
|
522
485
|
*/
|
|
523
486
|
const describeFunction = (name) => name ? `function '${name}'` : "this function";
|
|
524
487
|
/**
|
|
525
|
-
* @param {string} name
|
|
526
|
-
*/
|
|
527
|
-
const describeNested = (name) => name ? `function '${name}'` : "an anonymous function";
|
|
528
|
-
/**
|
|
529
488
|
* @param {string[]} names
|
|
530
489
|
* @param {string} fnName
|
|
531
490
|
*/
|
|
532
491
|
const createAssignmentMessage = (names, fnName) => {
|
|
533
492
|
return `Avoid storing JSX in ${names.length === 0 ? "local variables" : names.length === 1 ? `local '${names[0]}'` : `locals ${names.map((name) => `'${name}'`).join(", ")}`} inside ${describeFunction(fnName)}; return the JSX directly instead.`;
|
|
534
493
|
};
|
|
535
|
-
|
|
536
|
-
* @param {string} childName
|
|
537
|
-
* @param {string} parentName
|
|
538
|
-
*/
|
|
539
|
-
const createNestedFunctionMessage = (childName, parentName) => `JSX-returning ${describeNested(childName)} should not be declared inside ${describeFunction(parentName)}. Extract it to module scope.`;
|
|
540
|
-
/**
|
|
541
|
-
* @param {string} name
|
|
542
|
-
*/
|
|
543
|
-
const createIIFEMessage = (name) => `JSX-returning ${describeNested(name)} should not be declared as an immediately invoked function expression (IIFE). Extract it to a named function at module scope.`;
|
|
544
|
-
const rule$12 = defineRule({
|
|
494
|
+
const noInlineComponentsRule = defineRule({
|
|
545
495
|
meta: {
|
|
546
496
|
type: "problem",
|
|
547
497
|
docs: {
|
|
548
|
-
description: "Disallow JSX
|
|
498
|
+
description: "Disallow storing JSX in locals within functions that return JSX.",
|
|
549
499
|
recommended: false
|
|
550
500
|
},
|
|
551
501
|
schema: []
|
|
@@ -561,12 +511,10 @@ const rule$12 = defineRule({
|
|
|
561
511
|
/** @type {FunctionContext} */
|
|
562
512
|
const fnCtx = {
|
|
563
513
|
node,
|
|
564
|
-
parent: currentFunction(),
|
|
565
514
|
name: getFunctionName(node),
|
|
566
515
|
returnsJsx: false,
|
|
567
516
|
jsxBindingNames: /* @__PURE__ */ new Set(),
|
|
568
|
-
jsxAssignments: []
|
|
569
|
-
nestedJsxChildren: []
|
|
517
|
+
jsxAssignments: []
|
|
570
518
|
};
|
|
571
519
|
functionStack.push(fnCtx);
|
|
572
520
|
if (node.type === "ArrowFunctionExpression" && node.body && node.body.type !== "BlockStatement") {
|
|
@@ -576,26 +524,11 @@ const rule$12 = defineRule({
|
|
|
576
524
|
const exitFunction = () => {
|
|
577
525
|
const fnCtx = functionStack.pop();
|
|
578
526
|
if (!fnCtx) return;
|
|
579
|
-
if (fnCtx.returnsJsx && isFunctionImmediatelyInvoked(fnCtx.node)) {
|
|
580
|
-
context.report({
|
|
581
|
-
node: fnCtx.node,
|
|
582
|
-
message: createIIFEMessage(fnCtx.name)
|
|
583
|
-
});
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
if (fnCtx.parent && fnCtx.returnsJsx && fnCtx.name && !isFunctionUsedAsJsxProp(fnCtx.node)) fnCtx.parent.nestedJsxChildren.push({
|
|
587
|
-
node: fnCtx.node,
|
|
588
|
-
name: fnCtx.name
|
|
589
|
-
});
|
|
590
527
|
if (!fnCtx.returnsJsx) return;
|
|
591
528
|
for (const assignment of fnCtx.jsxAssignments) context.report({
|
|
592
529
|
node: assignment.node,
|
|
593
530
|
message: createAssignmentMessage(assignment.names, fnCtx.name)
|
|
594
531
|
});
|
|
595
|
-
for (const nested of fnCtx.nestedJsxChildren) context.report({
|
|
596
|
-
node: nested.node,
|
|
597
|
-
message: createNestedFunctionMessage(nested.name, fnCtx.name)
|
|
598
|
-
});
|
|
599
532
|
};
|
|
600
533
|
/** @param {ReturnStatementNode} node */
|
|
601
534
|
const handleReturnStatement = (node) => {
|
|
@@ -689,15 +622,13 @@ const rule$12 = defineRule({
|
|
|
689
622
|
};
|
|
690
623
|
}
|
|
691
624
|
});
|
|
692
|
-
const noInlineComponentsRule = rule$12;
|
|
693
|
-
|
|
694
625
|
//#endregion
|
|
695
626
|
//#region src/oxlint-plugins/no-component-pure-functions.js
|
|
696
627
|
/**
|
|
697
|
-
* @typedef {import("oxlint/plugins").Context} RuleContext
|
|
698
|
-
* @typedef {import("oxlint/plugins").ESTree.Node} ESTNode
|
|
699
|
-
* @typedef {import("oxlint/plugins").ESTree.Function | import("oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
700
|
-
* @typedef {import("oxlint/plugins").ESTree.VariableDeclarator} VariableDeclaratorNode
|
|
628
|
+
* @typedef {import("@oxlint/plugins").Context} RuleContext
|
|
629
|
+
* @typedef {import("@oxlint/plugins").ESTree.Node} ESTNode
|
|
630
|
+
* @typedef {import("@oxlint/plugins").ESTree.Function | import("@oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
631
|
+
* @typedef {import("@oxlint/plugins").ESTree.VariableDeclarator} VariableDeclaratorNode
|
|
701
632
|
*/
|
|
702
633
|
const FUNCTION_NODE_TYPES$2 = new Set([
|
|
703
634
|
"FunctionDeclaration",
|
|
@@ -933,7 +864,7 @@ const isPureFunction$1 = (node) => {
|
|
|
933
864
|
if (accessesEnclosingScope$1(node, collectLocalNames$1(node))) return false;
|
|
934
865
|
return true;
|
|
935
866
|
};
|
|
936
|
-
const
|
|
867
|
+
const noComponentPureFunctionsRule = defineRule({
|
|
937
868
|
meta: {
|
|
938
869
|
type: "suggestion",
|
|
939
870
|
docs: {
|
|
@@ -965,12 +896,7 @@ const rule$11 = defineRule({
|
|
|
965
896
|
} };
|
|
966
897
|
}
|
|
967
898
|
});
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
//#endregion
|
|
971
|
-
//#region src/oxlint-plugins/no-delete.js
|
|
972
|
-
/** @typedef {import("oxlint/plugins").ESTree.Node} ESTNode */
|
|
973
|
-
const rule$10 = defineRule({
|
|
899
|
+
const noDeleteRule = defineRule({
|
|
974
900
|
meta: {
|
|
975
901
|
type: "problem",
|
|
976
902
|
docs: {
|
|
@@ -989,11 +915,9 @@ const rule$10 = defineRule({
|
|
|
989
915
|
} };
|
|
990
916
|
}
|
|
991
917
|
});
|
|
992
|
-
const noDeleteRule = rule$10;
|
|
993
|
-
|
|
994
918
|
//#endregion
|
|
995
919
|
//#region src/oxlint-plugins/no-emoji.js
|
|
996
|
-
/** @typedef {import("oxlint/plugins").ESTree.Node} ESTNode */
|
|
920
|
+
/** @typedef {import("@oxlint/plugins").ESTree.Node} ESTNode */
|
|
997
921
|
/**
|
|
998
922
|
* Regex pattern to match emojis within a string
|
|
999
923
|
* Based on valibot's EMOJI_REGEX but without anchors and with global flag
|
|
@@ -1019,7 +943,7 @@ const getEmojiPreview = (text) => {
|
|
|
1019
943
|
const preview = uniqueEmojis.slice(0, 3).join(" ");
|
|
1020
944
|
return uniqueEmojis.length > 3 ? `${preview} ...` : preview;
|
|
1021
945
|
};
|
|
1022
|
-
const
|
|
946
|
+
const noEmojiRule = defineRule({
|
|
1023
947
|
meta: {
|
|
1024
948
|
type: "problem",
|
|
1025
949
|
docs: {
|
|
@@ -1070,12 +994,7 @@ const rule$9 = defineRule({
|
|
|
1070
994
|
};
|
|
1071
995
|
}
|
|
1072
996
|
});
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
//#endregion
|
|
1076
|
-
//#region src/oxlint-plugins/no-finally.js
|
|
1077
|
-
/** @typedef {import("oxlint/plugins").ESTree.Node} ESTNode */
|
|
1078
|
-
const rule$8 = defineRule({
|
|
997
|
+
const noFinallyRule = defineRule({
|
|
1079
998
|
meta: {
|
|
1080
999
|
type: "problem",
|
|
1081
1000
|
docs: {
|
|
@@ -1094,12 +1013,7 @@ const rule$8 = defineRule({
|
|
|
1094
1013
|
} };
|
|
1095
1014
|
}
|
|
1096
1015
|
});
|
|
1097
|
-
const
|
|
1098
|
-
|
|
1099
|
-
//#endregion
|
|
1100
|
-
//#region src/oxlint-plugins/no-iife.js
|
|
1101
|
-
/** @typedef {import("oxlint/plugins").ESTree.Node} ESTNode */
|
|
1102
|
-
const rule$7 = defineRule({
|
|
1016
|
+
const noIifeRule = defineRule({
|
|
1103
1017
|
meta: {
|
|
1104
1018
|
type: "problem",
|
|
1105
1019
|
docs: {
|
|
@@ -1119,11 +1033,9 @@ const rule$7 = defineRule({
|
|
|
1119
1033
|
} };
|
|
1120
1034
|
}
|
|
1121
1035
|
});
|
|
1122
|
-
const noIifeRule = rule$7;
|
|
1123
|
-
|
|
1124
1036
|
//#endregion
|
|
1125
1037
|
//#region src/oxlint-plugins/no-nested-conditionals.js
|
|
1126
|
-
/** @typedef {import("oxlint/plugins").ESTree.Node} ESTNode */
|
|
1038
|
+
/** @typedef {import("@oxlint/plugins").ESTree.Node} ESTNode */
|
|
1127
1039
|
const DEFAULT_MAX_DEPTH = 2;
|
|
1128
1040
|
/**
|
|
1129
1041
|
* @param {unknown} node
|
|
@@ -1258,14 +1170,13 @@ const noNestedConditionalsRule = defineRule({
|
|
|
1258
1170
|
};
|
|
1259
1171
|
}
|
|
1260
1172
|
});
|
|
1261
|
-
|
|
1262
1173
|
//#endregion
|
|
1263
1174
|
//#region src/oxlint-plugins/no-nested-pure-functions.js
|
|
1264
1175
|
/**
|
|
1265
|
-
* @typedef {import("oxlint/plugins").Context} RuleContext
|
|
1266
|
-
* @typedef {import("oxlint/plugins").ESTree.Node} ESTNode
|
|
1267
|
-
* @typedef {import("oxlint/plugins").ESTree.Function | import("oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
1268
|
-
* @typedef {import("oxlint/plugins").ESTree.VariableDeclarator} VariableDeclaratorNode
|
|
1176
|
+
* @typedef {import("@oxlint/plugins").Context} RuleContext
|
|
1177
|
+
* @typedef {import("@oxlint/plugins").ESTree.Node} ESTNode
|
|
1178
|
+
* @typedef {import("@oxlint/plugins").ESTree.Function | import("@oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
1179
|
+
* @typedef {import("@oxlint/plugins").ESTree.VariableDeclarator} VariableDeclaratorNode
|
|
1269
1180
|
*/
|
|
1270
1181
|
const FUNCTION_NODE_TYPES$1 = new Set([
|
|
1271
1182
|
"FunctionDeclaration",
|
|
@@ -1492,7 +1403,7 @@ const isPureFunction = (node) => {
|
|
|
1492
1403
|
if (accessesEnclosingScope(node, collectLocalNames(node))) return false;
|
|
1493
1404
|
return true;
|
|
1494
1405
|
};
|
|
1495
|
-
const
|
|
1406
|
+
const noNestedPureFunctionsRule = defineRule({
|
|
1496
1407
|
meta: {
|
|
1497
1408
|
type: "suggestion",
|
|
1498
1409
|
docs: {
|
|
@@ -1524,12 +1435,7 @@ const rule$6 = defineRule({
|
|
|
1524
1435
|
} };
|
|
1525
1436
|
}
|
|
1526
1437
|
});
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1529
|
-
//#endregion
|
|
1530
|
-
//#region src/oxlint-plugins/no-promise-then.js
|
|
1531
|
-
/** @typedef {import("oxlint/plugins").ESTree.Node} ESTNode */
|
|
1532
|
-
const rule$5 = defineRule({
|
|
1438
|
+
const noPromiseThenRule = defineRule({
|
|
1533
1439
|
meta: {
|
|
1534
1440
|
type: "problem",
|
|
1535
1441
|
docs: {
|
|
@@ -1550,11 +1456,9 @@ const rule$5 = defineRule({
|
|
|
1550
1456
|
} };
|
|
1551
1457
|
}
|
|
1552
1458
|
});
|
|
1553
|
-
const noPromiseThenRule = rule$5;
|
|
1554
|
-
|
|
1555
1459
|
//#endregion
|
|
1556
1460
|
//#region src/oxlint-plugins/no-react-namespace.js
|
|
1557
|
-
/** @typedef {import("oxlint/plugins").ESTree.Node} ESTNode */
|
|
1461
|
+
/** @typedef {import("@oxlint/plugins").ESTree.Node} ESTNode */
|
|
1558
1462
|
/**
|
|
1559
1463
|
* Check if a MemberExpression is accessing the React namespace
|
|
1560
1464
|
* @param {ESTNode} node
|
|
@@ -1595,7 +1499,7 @@ const isTypeContext = (node) => {
|
|
|
1595
1499
|
};
|
|
1596
1500
|
return checkParent(node.parent);
|
|
1597
1501
|
};
|
|
1598
|
-
const
|
|
1502
|
+
const noReactNamespaceRule = defineRule({
|
|
1599
1503
|
meta: {
|
|
1600
1504
|
type: "problem",
|
|
1601
1505
|
docs: {
|
|
@@ -1617,11 +1521,9 @@ const rule$4 = defineRule({
|
|
|
1617
1521
|
} };
|
|
1618
1522
|
}
|
|
1619
1523
|
});
|
|
1620
|
-
const noReactNamespaceRule = rule$4;
|
|
1621
|
-
|
|
1622
1524
|
//#endregion
|
|
1623
1525
|
//#region src/oxlint-plugins/no-switch-plugin.js
|
|
1624
|
-
/** @typedef {import("oxlint/plugins").ESTree.Node} ESTNode */
|
|
1526
|
+
/** @typedef {import("@oxlint/plugins").ESTree.Node} ESTNode */
|
|
1625
1527
|
const noSwitchRule = defineRule({
|
|
1626
1528
|
meta: {
|
|
1627
1529
|
type: "problem",
|
|
@@ -1641,11 +1543,7 @@ const noSwitchRule = defineRule({
|
|
|
1641
1543
|
} };
|
|
1642
1544
|
}
|
|
1643
1545
|
});
|
|
1644
|
-
|
|
1645
|
-
//#endregion
|
|
1646
|
-
//#region src/oxlint-plugins/no-top-level-let.js
|
|
1647
|
-
/** @typedef {import("oxlint/plugins").ESTree.Node} ESTNode */
|
|
1648
|
-
const rule$3 = defineRule({
|
|
1546
|
+
const noTopLevelLetRule = defineRule({
|
|
1649
1547
|
meta: {
|
|
1650
1548
|
type: "problem",
|
|
1651
1549
|
docs: {
|
|
@@ -1665,14 +1563,14 @@ const rule$3 = defineRule({
|
|
|
1665
1563
|
* @param {unknown} node
|
|
1666
1564
|
* @returns {node is ESTNode & { type: string }}
|
|
1667
1565
|
*/
|
|
1668
|
-
const isNode
|
|
1566
|
+
const isNode = (node) => Boolean(node && typeof node === "object" && "type" in node);
|
|
1669
1567
|
/**
|
|
1670
1568
|
* @param {ESTNode} node
|
|
1671
1569
|
* @returns {boolean}
|
|
1672
1570
|
*/
|
|
1673
1571
|
const isTopLevelVariableDeclaration = (node) => {
|
|
1674
1572
|
const parent = node.parent;
|
|
1675
|
-
if (!parent || !isNode
|
|
1573
|
+
if (!parent || !isNode(parent)) return false;
|
|
1676
1574
|
if (parent.type === "Program") return true;
|
|
1677
1575
|
if (parent.type === "ExportNamedDeclaration" && parent.parent?.type === "Program") return true;
|
|
1678
1576
|
return false;
|
|
@@ -1682,7 +1580,7 @@ const rule$3 = defineRule({
|
|
|
1682
1580
|
* @returns {boolean}
|
|
1683
1581
|
*/
|
|
1684
1582
|
const isMutableObjectInit = (node) => {
|
|
1685
|
-
if (!node || !isNode
|
|
1583
|
+
if (!node || !isNode(node)) return false;
|
|
1686
1584
|
if (node.type === "ObjectExpression" || node.type === "ArrayExpression") return true;
|
|
1687
1585
|
if (node.type === "NewExpression" && node.callee?.type === "Identifier") return [
|
|
1688
1586
|
"Map",
|
|
@@ -1698,7 +1596,7 @@ const rule$3 = defineRule({
|
|
|
1698
1596
|
*/
|
|
1699
1597
|
const unwrapExpression = (node) => {
|
|
1700
1598
|
let current = node;
|
|
1701
|
-
while (current && isNode
|
|
1599
|
+
while (current && isNode(current)) {
|
|
1702
1600
|
if (current.type === "TSAsExpression" || current.type === "TSNonNullExpression") {
|
|
1703
1601
|
current = current.expression;
|
|
1704
1602
|
continue;
|
|
@@ -1713,7 +1611,7 @@ const rule$3 = defineRule({
|
|
|
1713
1611
|
*/
|
|
1714
1612
|
const getMemberRootName = (node) => {
|
|
1715
1613
|
let current = unwrapExpression(node);
|
|
1716
|
-
while (current && isNode
|
|
1614
|
+
while (current && isNode(current)) {
|
|
1717
1615
|
if (current.type === "MemberExpression") {
|
|
1718
1616
|
current = unwrapExpression(current.object);
|
|
1719
1617
|
continue;
|
|
@@ -1728,7 +1626,7 @@ const rule$3 = defineRule({
|
|
|
1728
1626
|
* @returns {string | null}
|
|
1729
1627
|
*/
|
|
1730
1628
|
const getMemberPropertyName = (node) => {
|
|
1731
|
-
if (!isNode
|
|
1629
|
+
if (!isNode(node) || node.type !== "MemberExpression") return null;
|
|
1732
1630
|
if (node.property?.type === "Identifier" && node.computed === false) return node.property.name;
|
|
1733
1631
|
if (node.property?.type === "Literal" && typeof node.property.value === "string") return node.property.value;
|
|
1734
1632
|
return null;
|
|
@@ -1768,7 +1666,7 @@ const rule$3 = defineRule({
|
|
|
1768
1666
|
if (rawNode.type !== "VariableDeclarator") return;
|
|
1769
1667
|
const declarator = rawNode;
|
|
1770
1668
|
const declaration = declarator.parent;
|
|
1771
|
-
if (!declaration || !isNode
|
|
1669
|
+
if (!declaration || !isNode(declaration) || declaration.type !== "VariableDeclaration") return;
|
|
1772
1670
|
if (declaration.kind !== "const") return;
|
|
1773
1671
|
if (!isTopLevelVariableDeclaration(declaration)) return;
|
|
1774
1672
|
if (!isMutableObjectInit(declarator.init)) return;
|
|
@@ -1778,7 +1676,7 @@ const rule$3 = defineRule({
|
|
|
1778
1676
|
AssignmentExpression(rawNode) {
|
|
1779
1677
|
if (rawNode.type !== "AssignmentExpression") return;
|
|
1780
1678
|
const left = rawNode.left;
|
|
1781
|
-
if (!left || !isNode
|
|
1679
|
+
if (!left || !isNode(left) || left.type !== "MemberExpression") return;
|
|
1782
1680
|
const rootName = getMemberRootName(left);
|
|
1783
1681
|
if (!rootName || !topLevelMutableBindings.has(rootName)) return;
|
|
1784
1682
|
context.report({
|
|
@@ -1790,7 +1688,7 @@ const rule$3 = defineRule({
|
|
|
1790
1688
|
UpdateExpression(rawNode) {
|
|
1791
1689
|
if (rawNode.type !== "UpdateExpression") return;
|
|
1792
1690
|
const argument = rawNode.argument;
|
|
1793
|
-
if (!argument || !isNode
|
|
1691
|
+
if (!argument || !isNode(argument) || argument.type !== "MemberExpression") return;
|
|
1794
1692
|
const rootName = getMemberRootName(argument);
|
|
1795
1693
|
if (!rootName || !topLevelMutableBindings.has(rootName)) return;
|
|
1796
1694
|
context.report({
|
|
@@ -1802,7 +1700,7 @@ const rule$3 = defineRule({
|
|
|
1802
1700
|
CallExpression(rawNode) {
|
|
1803
1701
|
if (rawNode.type !== "CallExpression") return;
|
|
1804
1702
|
const callee = rawNode.callee;
|
|
1805
|
-
if (!callee || !isNode
|
|
1703
|
+
if (!callee || !isNode(callee) || callee.type !== "MemberExpression") return;
|
|
1806
1704
|
const rootName = getMemberRootName(callee);
|
|
1807
1705
|
if (!rootName || !topLevelMutableBindings.has(rootName)) return;
|
|
1808
1706
|
const methodName = getMemberPropertyName(callee);
|
|
@@ -1816,12 +1714,7 @@ const rule$3 = defineRule({
|
|
|
1816
1714
|
};
|
|
1817
1715
|
}
|
|
1818
1716
|
});
|
|
1819
|
-
const
|
|
1820
|
-
|
|
1821
|
-
//#endregion
|
|
1822
|
-
//#region src/oxlint-plugins/no-type-cast.js
|
|
1823
|
-
/** @typedef {import("oxlint/plugins").ESTree.Node} ESTNode */
|
|
1824
|
-
const rule$2 = defineRule({
|
|
1717
|
+
const noTypeCastRule = defineRule({
|
|
1825
1718
|
meta: {
|
|
1826
1719
|
type: "problem",
|
|
1827
1720
|
docs: {
|
|
@@ -1857,12 +1750,10 @@ const rule$2 = defineRule({
|
|
|
1857
1750
|
};
|
|
1858
1751
|
}
|
|
1859
1752
|
});
|
|
1860
|
-
const noTypeCastRule = rule$2;
|
|
1861
|
-
|
|
1862
1753
|
//#endregion
|
|
1863
1754
|
//#region src/oxlint-plugins/no-void.js
|
|
1864
|
-
/** @typedef {import("oxlint/plugins").ESTree.Node} ESTNode */
|
|
1865
|
-
/** @typedef {import("oxlint/plugins").ESTree.UnaryExpression} UnaryExpression */
|
|
1755
|
+
/** @typedef {import("@oxlint/plugins").ESTree.Node} ESTNode */
|
|
1756
|
+
/** @typedef {import("@oxlint/plugins").ESTree.UnaryExpression} UnaryExpression */
|
|
1866
1757
|
/**
|
|
1867
1758
|
* The rule is only meant to block the JavaScript runtime `void` operator.
|
|
1868
1759
|
*
|
|
@@ -1873,7 +1764,7 @@ const noTypeCastRule = rule$2;
|
|
|
1873
1764
|
* @returns {node is UnaryExpression}
|
|
1874
1765
|
*/
|
|
1875
1766
|
const isRuntimeVoidOperator = (node) => node.type === "UnaryExpression" && node.operator === "void";
|
|
1876
|
-
const
|
|
1767
|
+
const noVoidRule = defineRule({
|
|
1877
1768
|
meta: {
|
|
1878
1769
|
type: "problem",
|
|
1879
1770
|
docs: {
|
|
@@ -1895,15 +1786,13 @@ const rule$1 = defineRule({
|
|
|
1895
1786
|
};
|
|
1896
1787
|
}
|
|
1897
1788
|
});
|
|
1898
|
-
const noVoidRule = rule$1;
|
|
1899
|
-
|
|
1900
1789
|
//#endregion
|
|
1901
1790
|
//#region src/oxlint-plugins/pretty-props.js
|
|
1902
1791
|
/**
|
|
1903
|
-
* @typedef {import("oxlint/plugins").Context} RuleContext
|
|
1904
|
-
* @typedef {import("oxlint/plugins").ESTree.Node} ESTNode
|
|
1905
|
-
* @typedef {import("oxlint/plugins").ESTree.Expression} ESTExpression
|
|
1906
|
-
* @typedef {import("oxlint/plugins").ESTree.Function | import("oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
1792
|
+
* @typedef {import("@oxlint/plugins").Context} RuleContext
|
|
1793
|
+
* @typedef {import("@oxlint/plugins").ESTree.Node} ESTNode
|
|
1794
|
+
* @typedef {import("@oxlint/plugins").ESTree.Expression} ESTExpression
|
|
1795
|
+
* @typedef {import("@oxlint/plugins").ESTree.Function | import("@oxlint/plugins").ESTree.ArrowFunctionExpression} FunctionLikeNode
|
|
1907
1796
|
*/
|
|
1908
1797
|
const JSX_NODE_TYPES = new Set(["JSXElement", "JSXFragment"]);
|
|
1909
1798
|
const FUNCTION_NODE_TYPES = new Set([
|
|
@@ -1972,7 +1861,7 @@ const functionReturnsJsx = (node) => {
|
|
|
1972
1861
|
}
|
|
1973
1862
|
return false;
|
|
1974
1863
|
};
|
|
1975
|
-
const
|
|
1864
|
+
const prettyPropsRule = defineRule({
|
|
1976
1865
|
meta: {
|
|
1977
1866
|
type: "problem",
|
|
1978
1867
|
docs: {
|
|
@@ -2060,8 +1949,6 @@ const rule = defineRule({
|
|
|
2060
1949
|
};
|
|
2061
1950
|
}
|
|
2062
1951
|
});
|
|
2063
|
-
const prettyPropsRule = rule;
|
|
2064
|
-
|
|
2065
1952
|
//#endregion
|
|
2066
1953
|
//#region src/oxlint-plugins/index.js
|
|
2067
1954
|
const plugin = definePlugin({
|
|
@@ -2087,8 +1974,7 @@ const plugin = definePlugin({
|
|
|
2087
1974
|
"pretty-props": prettyPropsRule
|
|
2088
1975
|
}
|
|
2089
1976
|
});
|
|
2090
|
-
var oxlint_plugins_default = plugin;
|
|
2091
|
-
|
|
2092
1977
|
//#endregion
|
|
2093
|
-
export {
|
|
1978
|
+
export { plugin as default };
|
|
1979
|
+
|
|
2094
1980
|
//# sourceMappingURL=index.mjs.map
|