@agilebot/eslint-plugin 0.9.4 → 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.
Files changed (3) hide show
  1. package/LICENSE +9 -9
  2. package/dist/index.mjs +32 -51
  3. 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,10 +5,8 @@ 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
- //#region rolldown:runtime
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/";
@@ -20,7 +18,6 @@ const hasDocs = [
20
18
  "react-better-exhaustive-deps"
21
19
  ];
22
20
  const createRule = ESLintUtils.RuleCreator((name) => hasDocs.includes(name) ? `${docBaseUrl}${name}.md` : `${docBaseUrl}${name}.test.js`);
23
-
24
21
  //#endregion
25
22
  //#region src/rules/enforce-mui-icon-alias.js
26
23
  const RULE_NAME$18 = "enforce-mui-icon-alias";
@@ -52,7 +49,6 @@ var enforce_mui_icon_alias_default = createRule({
52
49
  } };
53
50
  }
54
51
  });
55
-
56
52
  //#endregion
57
53
  //#region src/util/context.js
58
54
  /**
@@ -64,7 +60,6 @@ var enforce_mui_icon_alias_default = createRule({
64
60
  function getSetting(context, name) {
65
61
  return context.settings[`agilebot/${name}`];
66
62
  }
67
-
68
63
  //#endregion
69
64
  //#region src/rules/import-monorepo.js
70
65
  const RULE_NAME$17 = "import-monorepo";
@@ -101,7 +96,6 @@ var import_monorepo_default = createRule({
101
96
  } };
102
97
  }
103
98
  });
104
-
105
99
  //#endregion
106
100
  //#region src/util/intl.js
107
101
  /**
@@ -157,7 +151,6 @@ function sortedTemplateElements(node) {
157
151
  function templateLiteralDisplayStr(node) {
158
152
  return sortedTemplateElements(node).map((e) => !e.value ? "*" : e.value.raw).join("");
159
153
  }
160
-
161
154
  //#endregion
162
155
  //#region src/util/translations.js
163
156
  /**
@@ -198,7 +191,6 @@ function getIntlIds(context) {
198
191
  });
199
192
  return results;
200
193
  }
201
-
202
194
  //#endregion
203
195
  //#region src/rules/intl-id-missing.js
204
196
  const RULE_NAME$16 = "intl-id-missing";
@@ -265,7 +257,6 @@ var intl_id_missing_default = createRule({
265
257
  };
266
258
  }
267
259
  });
268
-
269
260
  //#endregion
270
261
  //#region src/rules/intl-id-naming.js
271
262
  const RULE_NAME$15 = "intl-id-naming";
@@ -331,7 +322,6 @@ var intl_id_naming_default = createRule({
331
322
  };
332
323
  }
333
324
  });
334
-
335
325
  //#endregion
336
326
  //#region src/rules/intl-id-prefix.js
337
327
  const RULE_NAME$14 = "intl-id-prefix";
@@ -384,7 +374,6 @@ var intl_id_prefix_default = createRule({
384
374
  };
385
375
  }
386
376
  });
387
-
388
377
  //#endregion
389
378
  //#region src/rules/intl-id-unused.js
390
379
  const RULE_NAME$13 = "intl-id-unused";
@@ -444,7 +433,6 @@ var intl_id_unused_default = createRule({
444
433
  };
445
434
  }
446
435
  });
447
-
448
436
  //#endregion
449
437
  //#region src/rules/intl-no-default.js
450
438
  const RULE_NAME$12 = "intl-no-default";
@@ -480,7 +468,6 @@ var intl_no_default_default = createRule({
480
468
  };
481
469
  }
482
470
  });
483
-
484
471
  //#endregion
485
472
  //#region src/rules/no-async-array-methods.js
486
473
  const RULE_NAME$11 = "no-async-array-methods";
@@ -527,7 +514,6 @@ var no_async_array_methods_default = createRule({
527
514
  } };
528
515
  }
529
516
  });
530
-
531
517
  //#endregion
532
518
  //#region src/rules/no-extends-error.js
533
519
  const RULE_NAME$10 = "no-extends-error";
@@ -552,7 +538,6 @@ var no_extends_error_default = createRule({
552
538
  } };
553
539
  }
554
540
  });
555
-
556
541
  //#endregion
557
542
  //#region src/rules/no-import-css.js
558
543
  const RULE_NAME$9 = "no-import-css";
@@ -579,7 +564,6 @@ var no_import_css_default = createRule({
579
564
  } };
580
565
  }
581
566
  });
582
-
583
567
  //#endregion
584
568
  //#region src/rules/no-then-catch-finally.js
585
569
  const RULE_NAME$8 = "no-then-catch-finally";
@@ -621,7 +605,12 @@ var no_then_catch_finally_default = createRule({
621
605
  function isThenCatchFinally(node) {
622
606
  return node.property && (node.property.name === "then" || node.property.name === "catch" || node.property.name === "finally");
623
607
  }
624
- return { [`${AST_NODE_TYPES.CallExpression} > ${AST_NODE_TYPES.MemberExpression}.callee`]: (node) => {
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) => {
625
614
  if (isTopLevelScoped(node)) return;
626
615
  if (!isThenCatchFinally(node)) return;
627
616
  const callExpression = node.object;
@@ -633,7 +622,6 @@ var no_then_catch_finally_default = createRule({
633
622
  } };
634
623
  }
635
624
  });
636
-
637
625
  //#endregion
638
626
  //#region src/rules/no-unnecessary-template-literals.js
639
627
  const RULE_NAME$7 = "no-unnecessary-template-literals";
@@ -663,7 +651,6 @@ var no_unnecessary_template_literals_default = createRule({
663
651
  } };
664
652
  }
665
653
  });
666
-
667
654
  //#endregion
668
655
  //#region src/rules/react-better-exhaustive-deps.js
669
656
  /**
@@ -834,9 +821,9 @@ var react_better_exhaustive_deps_default = {
834
821
  } else if (options.checkMemoizedVariableIsStatic && (name === "useMemo" || name === "useCallback")) {
835
822
  const hookArgs = callee.parent.arguments;
836
823
  if (hookArgs.length < 2) return false;
837
- const dependencies$1 = hookArgs[1].elements;
838
- if (dependencies$1.length === 0) return true;
839
- for (const dependencyNode of dependencies$1) {
824
+ const dependencies = hookArgs[1].elements;
825
+ if (dependencies.length === 0) return true;
826
+ for (const dependencyNode of dependencies) {
840
827
  const dependencyRefernece = resolved.scope.references.find((reference) => reference.identifier === dependencyNode);
841
828
  if (dependencyRefernece !== void 0 && memoizedIsStableKnownHookValue(dependencyRefernece.resolved)) continue;
842
829
  else return false;
@@ -973,7 +960,7 @@ var react_better_exhaustive_deps_default = {
973
960
  });
974
961
  });
975
962
  if (setStateInsideEffectWithoutDeps) {
976
- const { suggestedDependencies: suggestedDependencies$1 } = collectRecommendations({
963
+ const { suggestedDependencies } = collectRecommendations({
977
964
  dependencies,
978
965
  declaredDependencies: [],
979
966
  stableDependencies,
@@ -982,11 +969,11 @@ var react_better_exhaustive_deps_default = {
982
969
  });
983
970
  reportProblem({
984
971
  node: reactiveHook,
985
- 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$1.join(", ") + `] as a second argument to the ${reactiveHookName} Hook.`,
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.`,
986
973
  suggest: [{
987
- desc: `Add dependencies array: [${suggestedDependencies$1.join(", ")}]`,
974
+ desc: `Add dependencies array: [${suggestedDependencies.join(", ")}]`,
988
975
  fix(fixer) {
989
- return fixer.insertTextAfter(node, `, [${suggestedDependencies$1.join(", ")}]`);
976
+ return fixer.insertTextAfter(node, `, [${suggestedDependencies.join(", ")}]`);
990
977
  }
991
978
  }]
992
979
  });
@@ -1101,8 +1088,8 @@ var react_better_exhaustive_deps_default = {
1101
1088
  return declaredDepKeys.join(",") === sortedDeclaredDepKeys.join(",");
1102
1089
  }
1103
1090
  if (areDeclaredDepsAlphabetized()) suggestedDeps.sort();
1104
- function formatDependency(path$2) {
1105
- const members = path$2.split(".");
1091
+ function formatDependency(path) {
1092
+ const members = path.split(".");
1106
1093
  let finalPath = "";
1107
1094
  for (let i = 0; i < members.length; i++) {
1108
1095
  if (i !== 0) {
@@ -1346,8 +1333,8 @@ function collectRecommendations({ dependencies, declaredDependencies, stableDepe
1346
1333
  const node = getOrCreateNodeByPath(depTree, key);
1347
1334
  node.isSatisfiedRecursively = true;
1348
1335
  });
1349
- function getOrCreateNodeByPath(rootNode, path$2) {
1350
- const keys = path$2.split(".");
1336
+ function getOrCreateNodeByPath(rootNode, path) {
1337
+ const keys = path.split(".");
1351
1338
  let node = rootNode;
1352
1339
  for (const key of keys) {
1353
1340
  let child = node.children.get(key);
@@ -1359,8 +1346,8 @@ function collectRecommendations({ dependencies, declaredDependencies, stableDepe
1359
1346
  }
1360
1347
  return node;
1361
1348
  }
1362
- function markAllParentsByPath(rootNode, path$2, fn) {
1363
- const keys = path$2.split(".");
1349
+ function markAllParentsByPath(rootNode, path, fn) {
1350
+ const keys = path.split(".");
1364
1351
  let node = rootNode;
1365
1352
  for (const key of keys) {
1366
1353
  const child = node.children.get(key);
@@ -1374,16 +1361,16 @@ function collectRecommendations({ dependencies, declaredDependencies, stableDepe
1374
1361
  scanTreeRecursively(depTree, missingDependencies, satisfyingDependencies, (key) => key);
1375
1362
  function scanTreeRecursively(node, missingPaths, satisfyingPaths, keyToPath) {
1376
1363
  node.children.forEach((child, key) => {
1377
- const path$2 = keyToPath(key);
1364
+ const path = keyToPath(key);
1378
1365
  if (child.isSatisfiedRecursively) {
1379
- if (child.isSubtreeUsed) satisfyingPaths.add(path$2);
1366
+ if (child.isSubtreeUsed) satisfyingPaths.add(path);
1380
1367
  return;
1381
1368
  }
1382
1369
  if (child.isUsed) {
1383
- missingPaths.add(path$2);
1370
+ missingPaths.add(path);
1384
1371
  return;
1385
1372
  }
1386
- scanTreeRecursively(child, missingPaths, satisfyingPaths, (childKey) => path$2 + "." + childKey);
1373
+ scanTreeRecursively(child, missingPaths, satisfyingPaths, (childKey) => path + "." + childKey);
1387
1374
  });
1388
1375
  }
1389
1376
  const suggestedDependencies = [];
@@ -1612,7 +1599,6 @@ function isAncestorNodeOf(a, b) {
1612
1599
  function isUseEffectEventIdentifier(node) {
1613
1600
  return false;
1614
1601
  }
1615
-
1616
1602
  //#endregion
1617
1603
  //#region src/rules/react-hook-use-ref.js
1618
1604
  const RULE_NAME$5 = "react-hook-use-ref";
@@ -1638,7 +1624,6 @@ var react_hook_use_ref_default = createRule({
1638
1624
  });
1639
1625
  } }))
1640
1626
  });
1641
-
1642
1627
  //#endregion
1643
1628
  //#region src/rules/react-prefer-sx-prop.js
1644
1629
  const RULE_NAME$4 = "react-prefer-sx-prop";
@@ -1689,7 +1674,6 @@ var react_prefer_sx_prop_default = createRule({
1689
1674
  } };
1690
1675
  }
1691
1676
  });
1692
-
1693
1677
  //#endregion
1694
1678
  //#region src/util/tss.js
1695
1679
  /**
@@ -1764,7 +1748,6 @@ function loopStylesObj(node, callback) {
1764
1748
  else callback(property.value);
1765
1749
  });
1766
1750
  }
1767
-
1768
1751
  //#endregion
1769
1752
  //#region src/rules/tss-class-naming.js
1770
1753
  const RULE_NAME$3 = "tss-class-naming";
@@ -1797,7 +1780,6 @@ var tss_class_naming_default = createRule({
1797
1780
  } };
1798
1781
  }
1799
1782
  });
1800
-
1801
1783
  //#endregion
1802
1784
  //#region ../../node_modules/.pnpm/color-name@2.0.0/node_modules/color-name/index.js
1803
1785
  var color_name_default = {
@@ -2542,7 +2524,6 @@ var color_name_default = {
2542
2524
  50
2543
2525
  ]
2544
2526
  };
2545
-
2546
2527
  //#endregion
2547
2528
  //#region src/rules/tss-no-color-name.js
2548
2529
  const RULE_NAME$2 = "tss-no-color-name";
@@ -2572,7 +2553,6 @@ var tss_no_color_name_default = createRule({
2572
2553
  } };
2573
2554
  }
2574
2555
  });
2575
-
2576
2556
  //#endregion
2577
2557
  //#region src/rules/tss-no-color-value.js
2578
2558
  const RULE_NAME$1 = "tss-no-color-value";
@@ -2604,7 +2584,6 @@ var tss_no_color_value_default = createRule({
2604
2584
  } };
2605
2585
  }
2606
2586
  });
2607
-
2608
2587
  //#endregion
2609
2588
  //#region src/rules/tss-unused-classes.js
2610
2589
  const RULE_NAME = "tss-unused-classes";
@@ -2664,7 +2643,6 @@ var tss_unused_classes_default = createRule({
2664
2643
  };
2665
2644
  }
2666
2645
  });
2667
-
2668
2646
  //#endregion
2669
2647
  //#region src/rules/index.js
2670
2648
  const rules = {
@@ -2688,13 +2666,18 @@ const rules = {
2688
2666
  [RULE_NAME$1]: tss_no_color_value_default,
2689
2667
  [RULE_NAME]: tss_unused_classes_default
2690
2668
  };
2691
-
2692
2669
  //#endregion
2693
2670
  //#region src/index.js
2694
2671
  const plugin = {
2672
+ /**
2673
+ * @type {import('eslint').Linter.RulesRecord}
2674
+ */
2695
2675
  rules: {},
2696
2676
  configs: { recommended: {
2697
2677
  plugins: ["@agilebot"],
2678
+ /**
2679
+ * @type {import('eslint').Linter.RulesRecord}
2680
+ */
2698
2681
  rules: {},
2699
2682
  settings: { react: { version: "18.0.0" } }
2700
2683
  } }
@@ -2704,7 +2687,5 @@ Object.keys(rules).forEach((name) => {
2704
2687
  plugin.rules[name] = rule;
2705
2688
  if (rule.meta && rule.meta.docs && rule.meta.docs.recommended) plugin.configs.recommended.rules[`@agilebot/${name}`] = rule.meta.type === "problem" ? "error" : "warn";
2706
2689
  });
2707
- var src_default = plugin;
2708
-
2709
2690
  //#endregion
2710
- export { src_default as default };
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.4",
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.4"
30
+ "@agilebot/eslint-utils": "0.9.5"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "eslint": "^9.0.0"