@agilebot/eslint-plugin 0.9.3 → 0.9.5
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/LICENSE +9 -9
- package/dist/index.mjs +39 -52
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Agilebot, Inc.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Agilebot, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/index.mjs
CHANGED
|
@@ -5,16 +5,19 @@ import * as path$1 from "node:path";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { isCamelCase, isPascalCase, tsImport } from "@agilebot/eslint-utils";
|
|
7
7
|
import * as Components from "eslint-plugin-react/lib/util/Components.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
11
|
-
|
|
8
|
+
//#region \0rolldown/runtime.js
|
|
9
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
12
10
|
//#endregion
|
|
13
11
|
//#region src/util/rule.js
|
|
14
12
|
const docBaseUrl = "https://github.com/sh-agilebot/frontend-toolkit/blob/master/packages/eslint-plugin/src/rules/";
|
|
15
|
-
const hasDocs = [
|
|
13
|
+
const hasDocs = [
|
|
14
|
+
"enforce-mui-icon-alias",
|
|
15
|
+
"intl-id-missing",
|
|
16
|
+
"intl-id-prefix",
|
|
17
|
+
"intl-no-default",
|
|
18
|
+
"react-better-exhaustive-deps"
|
|
19
|
+
];
|
|
16
20
|
const createRule = ESLintUtils.RuleCreator((name) => hasDocs.includes(name) ? `${docBaseUrl}${name}.md` : `${docBaseUrl}${name}.test.js`);
|
|
17
|
-
|
|
18
21
|
//#endregion
|
|
19
22
|
//#region src/rules/enforce-mui-icon-alias.js
|
|
20
23
|
const RULE_NAME$18 = "enforce-mui-icon-alias";
|
|
@@ -46,7 +49,6 @@ var enforce_mui_icon_alias_default = createRule({
|
|
|
46
49
|
} };
|
|
47
50
|
}
|
|
48
51
|
});
|
|
49
|
-
|
|
50
52
|
//#endregion
|
|
51
53
|
//#region src/util/context.js
|
|
52
54
|
/**
|
|
@@ -58,7 +60,6 @@ var enforce_mui_icon_alias_default = createRule({
|
|
|
58
60
|
function getSetting(context, name) {
|
|
59
61
|
return context.settings[`agilebot/${name}`];
|
|
60
62
|
}
|
|
61
|
-
|
|
62
63
|
//#endregion
|
|
63
64
|
//#region src/rules/import-monorepo.js
|
|
64
65
|
const RULE_NAME$17 = "import-monorepo";
|
|
@@ -95,7 +96,6 @@ var import_monorepo_default = createRule({
|
|
|
95
96
|
} };
|
|
96
97
|
}
|
|
97
98
|
});
|
|
98
|
-
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region src/util/intl.js
|
|
101
101
|
/**
|
|
@@ -151,7 +151,6 @@ function sortedTemplateElements(node) {
|
|
|
151
151
|
function templateLiteralDisplayStr(node) {
|
|
152
152
|
return sortedTemplateElements(node).map((e) => !e.value ? "*" : e.value.raw).join("");
|
|
153
153
|
}
|
|
154
|
-
|
|
155
154
|
//#endregion
|
|
156
155
|
//#region src/util/translations.js
|
|
157
156
|
/**
|
|
@@ -192,7 +191,6 @@ function getIntlIds(context) {
|
|
|
192
191
|
});
|
|
193
192
|
return results;
|
|
194
193
|
}
|
|
195
|
-
|
|
196
194
|
//#endregion
|
|
197
195
|
//#region src/rules/intl-id-missing.js
|
|
198
196
|
const RULE_NAME$16 = "intl-id-missing";
|
|
@@ -259,7 +257,6 @@ var intl_id_missing_default = createRule({
|
|
|
259
257
|
};
|
|
260
258
|
}
|
|
261
259
|
});
|
|
262
|
-
|
|
263
260
|
//#endregion
|
|
264
261
|
//#region src/rules/intl-id-naming.js
|
|
265
262
|
const RULE_NAME$15 = "intl-id-naming";
|
|
@@ -325,7 +322,6 @@ var intl_id_naming_default = createRule({
|
|
|
325
322
|
};
|
|
326
323
|
}
|
|
327
324
|
});
|
|
328
|
-
|
|
329
325
|
//#endregion
|
|
330
326
|
//#region src/rules/intl-id-prefix.js
|
|
331
327
|
const RULE_NAME$14 = "intl-id-prefix";
|
|
@@ -378,7 +374,6 @@ var intl_id_prefix_default = createRule({
|
|
|
378
374
|
};
|
|
379
375
|
}
|
|
380
376
|
});
|
|
381
|
-
|
|
382
377
|
//#endregion
|
|
383
378
|
//#region src/rules/intl-id-unused.js
|
|
384
379
|
const RULE_NAME$13 = "intl-id-unused";
|
|
@@ -438,7 +433,6 @@ var intl_id_unused_default = createRule({
|
|
|
438
433
|
};
|
|
439
434
|
}
|
|
440
435
|
});
|
|
441
|
-
|
|
442
436
|
//#endregion
|
|
443
437
|
//#region src/rules/intl-no-default.js
|
|
444
438
|
const RULE_NAME$12 = "intl-no-default";
|
|
@@ -474,7 +468,6 @@ var intl_no_default_default = createRule({
|
|
|
474
468
|
};
|
|
475
469
|
}
|
|
476
470
|
});
|
|
477
|
-
|
|
478
471
|
//#endregion
|
|
479
472
|
//#region src/rules/no-async-array-methods.js
|
|
480
473
|
const RULE_NAME$11 = "no-async-array-methods";
|
|
@@ -521,7 +514,6 @@ var no_async_array_methods_default = createRule({
|
|
|
521
514
|
} };
|
|
522
515
|
}
|
|
523
516
|
});
|
|
524
|
-
|
|
525
517
|
//#endregion
|
|
526
518
|
//#region src/rules/no-extends-error.js
|
|
527
519
|
const RULE_NAME$10 = "no-extends-error";
|
|
@@ -546,7 +538,6 @@ var no_extends_error_default = createRule({
|
|
|
546
538
|
} };
|
|
547
539
|
}
|
|
548
540
|
});
|
|
549
|
-
|
|
550
541
|
//#endregion
|
|
551
542
|
//#region src/rules/no-import-css.js
|
|
552
543
|
const RULE_NAME$9 = "no-import-css";
|
|
@@ -573,7 +564,6 @@ var no_import_css_default = createRule({
|
|
|
573
564
|
} };
|
|
574
565
|
}
|
|
575
566
|
});
|
|
576
|
-
|
|
577
567
|
//#endregion
|
|
578
568
|
//#region src/rules/no-then-catch-finally.js
|
|
579
569
|
const RULE_NAME$8 = "no-then-catch-finally";
|
|
@@ -615,7 +605,12 @@ var no_then_catch_finally_default = createRule({
|
|
|
615
605
|
function isThenCatchFinally(node) {
|
|
616
606
|
return node.property && (node.property.name === "then" || node.property.name === "catch" || node.property.name === "finally");
|
|
617
607
|
}
|
|
618
|
-
return {
|
|
608
|
+
return {
|
|
609
|
+
/**
|
|
610
|
+
* Reports a violation if a restricted function is used with then/catch/finally
|
|
611
|
+
* @param {*} node - The node to check
|
|
612
|
+
*/
|
|
613
|
+
[`${AST_NODE_TYPES.CallExpression} > ${AST_NODE_TYPES.MemberExpression}.callee`]: (node) => {
|
|
619
614
|
if (isTopLevelScoped(node)) return;
|
|
620
615
|
if (!isThenCatchFinally(node)) return;
|
|
621
616
|
const callExpression = node.object;
|
|
@@ -627,7 +622,6 @@ var no_then_catch_finally_default = createRule({
|
|
|
627
622
|
} };
|
|
628
623
|
}
|
|
629
624
|
});
|
|
630
|
-
|
|
631
625
|
//#endregion
|
|
632
626
|
//#region src/rules/no-unnecessary-template-literals.js
|
|
633
627
|
const RULE_NAME$7 = "no-unnecessary-template-literals";
|
|
@@ -657,7 +651,6 @@ var no_unnecessary_template_literals_default = createRule({
|
|
|
657
651
|
} };
|
|
658
652
|
}
|
|
659
653
|
});
|
|
660
|
-
|
|
661
654
|
//#endregion
|
|
662
655
|
//#region src/rules/react-better-exhaustive-deps.js
|
|
663
656
|
/**
|
|
@@ -828,9 +821,9 @@ var react_better_exhaustive_deps_default = {
|
|
|
828
821
|
} else if (options.checkMemoizedVariableIsStatic && (name === "useMemo" || name === "useCallback")) {
|
|
829
822
|
const hookArgs = callee.parent.arguments;
|
|
830
823
|
if (hookArgs.length < 2) return false;
|
|
831
|
-
const dependencies
|
|
832
|
-
if (dependencies
|
|
833
|
-
for (const dependencyNode of dependencies
|
|
824
|
+
const dependencies = hookArgs[1].elements;
|
|
825
|
+
if (dependencies.length === 0) return true;
|
|
826
|
+
for (const dependencyNode of dependencies) {
|
|
834
827
|
const dependencyRefernece = resolved.scope.references.find((reference) => reference.identifier === dependencyNode);
|
|
835
828
|
if (dependencyRefernece !== void 0 && memoizedIsStableKnownHookValue(dependencyRefernece.resolved)) continue;
|
|
836
829
|
else return false;
|
|
@@ -967,7 +960,7 @@ var react_better_exhaustive_deps_default = {
|
|
|
967
960
|
});
|
|
968
961
|
});
|
|
969
962
|
if (setStateInsideEffectWithoutDeps) {
|
|
970
|
-
const { suggestedDependencies
|
|
963
|
+
const { suggestedDependencies } = collectRecommendations({
|
|
971
964
|
dependencies,
|
|
972
965
|
declaredDependencies: [],
|
|
973
966
|
stableDependencies,
|
|
@@ -976,11 +969,11 @@ var react_better_exhaustive_deps_default = {
|
|
|
976
969
|
});
|
|
977
970
|
reportProblem({
|
|
978
971
|
node: reactiveHook,
|
|
979
|
-
message: `React Hook ${reactiveHookName} contains a call to '${setStateInsideEffectWithoutDeps}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [` + suggestedDependencies
|
|
972
|
+
message: `React Hook ${reactiveHookName} contains a call to '${setStateInsideEffectWithoutDeps}'. Without a list of dependencies, this can lead to an infinite chain of updates. To fix this, pass [` + suggestedDependencies.join(", ") + `] as a second argument to the ${reactiveHookName} Hook.`,
|
|
980
973
|
suggest: [{
|
|
981
|
-
desc: `Add dependencies array: [${suggestedDependencies
|
|
974
|
+
desc: `Add dependencies array: [${suggestedDependencies.join(", ")}]`,
|
|
982
975
|
fix(fixer) {
|
|
983
|
-
return fixer.insertTextAfter(node, `, [${suggestedDependencies
|
|
976
|
+
return fixer.insertTextAfter(node, `, [${suggestedDependencies.join(", ")}]`);
|
|
984
977
|
}
|
|
985
978
|
}]
|
|
986
979
|
});
|
|
@@ -1095,8 +1088,8 @@ var react_better_exhaustive_deps_default = {
|
|
|
1095
1088
|
return declaredDepKeys.join(",") === sortedDeclaredDepKeys.join(",");
|
|
1096
1089
|
}
|
|
1097
1090
|
if (areDeclaredDepsAlphabetized()) suggestedDeps.sort();
|
|
1098
|
-
function formatDependency(path
|
|
1099
|
-
const members = path
|
|
1091
|
+
function formatDependency(path) {
|
|
1092
|
+
const members = path.split(".");
|
|
1100
1093
|
let finalPath = "";
|
|
1101
1094
|
for (let i = 0; i < members.length; i++) {
|
|
1102
1095
|
if (i !== 0) {
|
|
@@ -1340,8 +1333,8 @@ function collectRecommendations({ dependencies, declaredDependencies, stableDepe
|
|
|
1340
1333
|
const node = getOrCreateNodeByPath(depTree, key);
|
|
1341
1334
|
node.isSatisfiedRecursively = true;
|
|
1342
1335
|
});
|
|
1343
|
-
function getOrCreateNodeByPath(rootNode, path
|
|
1344
|
-
const keys = path
|
|
1336
|
+
function getOrCreateNodeByPath(rootNode, path) {
|
|
1337
|
+
const keys = path.split(".");
|
|
1345
1338
|
let node = rootNode;
|
|
1346
1339
|
for (const key of keys) {
|
|
1347
1340
|
let child = node.children.get(key);
|
|
@@ -1353,8 +1346,8 @@ function collectRecommendations({ dependencies, declaredDependencies, stableDepe
|
|
|
1353
1346
|
}
|
|
1354
1347
|
return node;
|
|
1355
1348
|
}
|
|
1356
|
-
function markAllParentsByPath(rootNode, path
|
|
1357
|
-
const keys = path
|
|
1349
|
+
function markAllParentsByPath(rootNode, path, fn) {
|
|
1350
|
+
const keys = path.split(".");
|
|
1358
1351
|
let node = rootNode;
|
|
1359
1352
|
for (const key of keys) {
|
|
1360
1353
|
const child = node.children.get(key);
|
|
@@ -1368,16 +1361,16 @@ function collectRecommendations({ dependencies, declaredDependencies, stableDepe
|
|
|
1368
1361
|
scanTreeRecursively(depTree, missingDependencies, satisfyingDependencies, (key) => key);
|
|
1369
1362
|
function scanTreeRecursively(node, missingPaths, satisfyingPaths, keyToPath) {
|
|
1370
1363
|
node.children.forEach((child, key) => {
|
|
1371
|
-
const path
|
|
1364
|
+
const path = keyToPath(key);
|
|
1372
1365
|
if (child.isSatisfiedRecursively) {
|
|
1373
|
-
if (child.isSubtreeUsed) satisfyingPaths.add(path
|
|
1366
|
+
if (child.isSubtreeUsed) satisfyingPaths.add(path);
|
|
1374
1367
|
return;
|
|
1375
1368
|
}
|
|
1376
1369
|
if (child.isUsed) {
|
|
1377
|
-
missingPaths.add(path
|
|
1370
|
+
missingPaths.add(path);
|
|
1378
1371
|
return;
|
|
1379
1372
|
}
|
|
1380
|
-
scanTreeRecursively(child, missingPaths, satisfyingPaths, (childKey) => path
|
|
1373
|
+
scanTreeRecursively(child, missingPaths, satisfyingPaths, (childKey) => path + "." + childKey);
|
|
1381
1374
|
});
|
|
1382
1375
|
}
|
|
1383
1376
|
const suggestedDependencies = [];
|
|
@@ -1606,7 +1599,6 @@ function isAncestorNodeOf(a, b) {
|
|
|
1606
1599
|
function isUseEffectEventIdentifier(node) {
|
|
1607
1600
|
return false;
|
|
1608
1601
|
}
|
|
1609
|
-
|
|
1610
1602
|
//#endregion
|
|
1611
1603
|
//#region src/rules/react-hook-use-ref.js
|
|
1612
1604
|
const RULE_NAME$5 = "react-hook-use-ref";
|
|
@@ -1632,7 +1624,6 @@ var react_hook_use_ref_default = createRule({
|
|
|
1632
1624
|
});
|
|
1633
1625
|
} }))
|
|
1634
1626
|
});
|
|
1635
|
-
|
|
1636
1627
|
//#endregion
|
|
1637
1628
|
//#region src/rules/react-prefer-sx-prop.js
|
|
1638
1629
|
const RULE_NAME$4 = "react-prefer-sx-prop";
|
|
@@ -1683,7 +1674,6 @@ var react_prefer_sx_prop_default = createRule({
|
|
|
1683
1674
|
} };
|
|
1684
1675
|
}
|
|
1685
1676
|
});
|
|
1686
|
-
|
|
1687
1677
|
//#endregion
|
|
1688
1678
|
//#region src/util/tss.js
|
|
1689
1679
|
/**
|
|
@@ -1758,7 +1748,6 @@ function loopStylesObj(node, callback) {
|
|
|
1758
1748
|
else callback(property.value);
|
|
1759
1749
|
});
|
|
1760
1750
|
}
|
|
1761
|
-
|
|
1762
1751
|
//#endregion
|
|
1763
1752
|
//#region src/rules/tss-class-naming.js
|
|
1764
1753
|
const RULE_NAME$3 = "tss-class-naming";
|
|
@@ -1791,7 +1780,6 @@ var tss_class_naming_default = createRule({
|
|
|
1791
1780
|
} };
|
|
1792
1781
|
}
|
|
1793
1782
|
});
|
|
1794
|
-
|
|
1795
1783
|
//#endregion
|
|
1796
1784
|
//#region ../../node_modules/.pnpm/color-name@2.0.0/node_modules/color-name/index.js
|
|
1797
1785
|
var color_name_default = {
|
|
@@ -2536,7 +2524,6 @@ var color_name_default = {
|
|
|
2536
2524
|
50
|
|
2537
2525
|
]
|
|
2538
2526
|
};
|
|
2539
|
-
|
|
2540
2527
|
//#endregion
|
|
2541
2528
|
//#region src/rules/tss-no-color-name.js
|
|
2542
2529
|
const RULE_NAME$2 = "tss-no-color-name";
|
|
@@ -2566,7 +2553,6 @@ var tss_no_color_name_default = createRule({
|
|
|
2566
2553
|
} };
|
|
2567
2554
|
}
|
|
2568
2555
|
});
|
|
2569
|
-
|
|
2570
2556
|
//#endregion
|
|
2571
2557
|
//#region src/rules/tss-no-color-value.js
|
|
2572
2558
|
const RULE_NAME$1 = "tss-no-color-value";
|
|
@@ -2598,7 +2584,6 @@ var tss_no_color_value_default = createRule({
|
|
|
2598
2584
|
} };
|
|
2599
2585
|
}
|
|
2600
2586
|
});
|
|
2601
|
-
|
|
2602
2587
|
//#endregion
|
|
2603
2588
|
//#region src/rules/tss-unused-classes.js
|
|
2604
2589
|
const RULE_NAME = "tss-unused-classes";
|
|
@@ -2658,7 +2643,6 @@ var tss_unused_classes_default = createRule({
|
|
|
2658
2643
|
};
|
|
2659
2644
|
}
|
|
2660
2645
|
});
|
|
2661
|
-
|
|
2662
2646
|
//#endregion
|
|
2663
2647
|
//#region src/rules/index.js
|
|
2664
2648
|
const rules = {
|
|
@@ -2682,13 +2666,18 @@ const rules = {
|
|
|
2682
2666
|
[RULE_NAME$1]: tss_no_color_value_default,
|
|
2683
2667
|
[RULE_NAME]: tss_unused_classes_default
|
|
2684
2668
|
};
|
|
2685
|
-
|
|
2686
2669
|
//#endregion
|
|
2687
2670
|
//#region src/index.js
|
|
2688
2671
|
const plugin = {
|
|
2672
|
+
/**
|
|
2673
|
+
* @type {import('eslint').Linter.RulesRecord}
|
|
2674
|
+
*/
|
|
2689
2675
|
rules: {},
|
|
2690
2676
|
configs: { recommended: {
|
|
2691
2677
|
plugins: ["@agilebot"],
|
|
2678
|
+
/**
|
|
2679
|
+
* @type {import('eslint').Linter.RulesRecord}
|
|
2680
|
+
*/
|
|
2692
2681
|
rules: {},
|
|
2693
2682
|
settings: { react: { version: "18.0.0" } }
|
|
2694
2683
|
} }
|
|
@@ -2698,7 +2687,5 @@ Object.keys(rules).forEach((name) => {
|
|
|
2698
2687
|
plugin.rules[name] = rule;
|
|
2699
2688
|
if (rule.meta && rule.meta.docs && rule.meta.docs.recommended) plugin.configs.recommended.rules[`@agilebot/${name}`] = rule.meta.type === "problem" ? "error" : "warn";
|
|
2700
2689
|
});
|
|
2701
|
-
var src_default = plugin;
|
|
2702
|
-
|
|
2703
2690
|
//#endregion
|
|
2704
|
-
export {
|
|
2691
|
+
export { plugin as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agilebot/eslint-plugin",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Agilebot's ESLint plugin",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@typescript-eslint/utils": "~8.29.0",
|
|
29
29
|
"eslint-plugin-react": "^7.37.2",
|
|
30
|
-
"@agilebot/eslint-utils": "0.9.
|
|
30
|
+
"@agilebot/eslint-utils": "0.9.5"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"eslint": "^9.0.0"
|