eslint-plugin-wyrm 0.0.8 → 0.0.9

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 (69) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +38 -26
  3. package/dist/_virtual/rolldown_runtime.mjs +10 -5
  4. package/dist/rules/distribute-boolean-casts.mjs +1 -1
  5. package/dist/rules/index.d.mts +35 -23
  6. package/dist/rules/index.mjs +24 -0
  7. package/dist/rules/no-constant-template-expression.d.mts +3 -3
  8. package/dist/rules/no-constant-template-expression.mjs +44 -40
  9. package/dist/rules/no-convoluted-logical-expressions.d.mts +7 -0
  10. package/dist/rules/no-convoluted-logical-expressions.mjs +126 -0
  11. package/dist/rules/no-duplicated-return.d.mts +2 -2
  12. package/dist/rules/no-duplicated-return.mjs +2 -15
  13. package/dist/rules/no-else-break.d.mts +2 -2
  14. package/dist/rules/no-else-break.mjs +3 -2
  15. package/dist/rules/no-else-continue.d.mts +2 -2
  16. package/dist/rules/no-else-continue.mjs +3 -2
  17. package/dist/rules/no-else-throw.d.mts +2 -2
  18. package/dist/rules/no-else-throw.mjs +3 -2
  19. package/dist/rules/no-empty-attribute.d.mts +9 -0
  20. package/dist/rules/no-empty-attribute.mjs +77 -0
  21. package/dist/rules/no-empty-comment.d.mts +3 -3
  22. package/dist/rules/no-empty-comment.mjs +0 -1
  23. package/dist/rules/no-empty-jsx-expression.d.mts +2 -2
  24. package/dist/rules/no-empty-jsx-expression.mjs +0 -1
  25. package/dist/rules/no-empty-literal-iteration.d.mts +7 -0
  26. package/dist/rules/no-empty-literal-iteration.mjs +98 -0
  27. package/dist/rules/no-extra-false-fallback.mjs +4 -2
  28. package/dist/rules/no-extra-nested-boolean-cast.d.mts +2 -2
  29. package/dist/rules/no-extra-nested-boolean-cast.mjs +5 -3
  30. package/dist/rules/no-first-last.d.mts +7 -0
  31. package/dist/rules/no-first-last.mjs +171 -0
  32. package/dist/rules/no-inline-jsdoc-tag.d.mts +9 -0
  33. package/dist/rules/no-inline-jsdoc-tag.mjs +155 -0
  34. package/dist/rules/no-invalid-date-literal.d.mts +2 -2
  35. package/dist/rules/no-jsx-statement.d.mts +2 -2
  36. package/dist/rules/no-optional-type-guard-param.d.mts +2 -2
  37. package/dist/rules/no-redundant-function-declaration.d.mts +7 -0
  38. package/dist/rules/no-redundant-function-declaration.mjs +60 -0
  39. package/dist/rules/no-return-to-void.mjs +10 -1
  40. package/dist/rules/no-sloppy-length-check.d.mts +8 -0
  41. package/dist/rules/no-sloppy-length-check.mjs +249 -0
  42. package/dist/rules/no-suspicious-jsx-semicolon.d.mts +2 -2
  43. package/dist/rules/no-suspicious-jsx-semicolon.mjs +13 -0
  44. package/dist/rules/no-ternary-return.d.mts +3 -3
  45. package/dist/rules/no-ternary-return.mjs +2 -0
  46. package/dist/rules/no-unassigned-todo.d.mts +7 -0
  47. package/dist/rules/no-unassigned-todo.mjs +38 -0
  48. package/dist/rules/no-unused-param-read.d.mts +7 -0
  49. package/dist/rules/no-unused-param-read.mjs +34 -0
  50. package/dist/rules/no-useless-computed-key.d.mts +7 -0
  51. package/dist/rules/no-useless-computed-key.mjs +39 -0
  52. package/dist/rules/no-useless-iife.d.mts +2 -2
  53. package/dist/rules/no-useless-iife.mjs +89 -9
  54. package/dist/rules/no-useless-logical-fallback.mjs +4 -3
  55. package/dist/rules/no-useless-return-undefined.mjs +1 -0
  56. package/dist/rules/no-useless-use-strict.d.mts +7 -0
  57. package/dist/rules/no-useless-use-strict.mjs +61 -0
  58. package/dist/rules/no-useless-usememo.d.mts +7 -0
  59. package/dist/rules/no-useless-usememo.mjs +132 -0
  60. package/dist/rules/no-whitespace-property.d.mts +2 -2
  61. package/dist/rules/no-whitespace-property.mjs +2 -1
  62. package/dist/rules/prefer-catch-method.d.mts +2 -2
  63. package/dist/rules/prefer-catch-method.mjs +3 -1
  64. package/dist/rules/prefer-early-return.d.mts +2 -2
  65. package/dist/rules/prefer-early-return.mjs +3 -1
  66. package/dist/rules/prefer-repeat.d.mts +2 -2
  67. package/dist/rules/unsafe-asserted-chain.mjs +17 -10
  68. package/dist/utils/compareTokens.mjs +20 -0
  69. package/package.json +10 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.9](https://github.com/mchevestrier/eslint-plugin-wyrm/compare/eslint-plugin-wyrm-v0.0.8...eslint-plugin-wyrm-v0.0.9) (2025-11-30)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * add no-convoluted-logical-expressions ([28586c1](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/28586c121b85d2f48dcfa0ef1c4707373f4f041b))
9
+ * add no-empty-attribute ([b22ff03](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/b22ff0368226d692e22977dce02061ac9afe9b6f))
10
+ * add no-empty-literal-iteration ([630c8ef](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/630c8ef4ac9cc50f2e381b38b6a64ef8001e3033))
11
+ * add no-first-last ([516a527](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/516a52739ae5d256973acf396e2d4d9f457f8e7f))
12
+ * add no-inline-jsdoc-tag ([f82a538](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/f82a538b29282743cdc5bde61fe3ff0683372088))
13
+ * add no-redundant-function-declaration ([8f4e20e](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/8f4e20eebd76d7cc97763a821b5968139e08b443))
14
+ * add no-sloppy-length-check ([676f230](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/676f2304ca497669375f16219d926bf3dcf6b4d3))
15
+ * add no-unassigned-todo ([42ba01a](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/42ba01a01fc4bef061d50a4b7454964fbd68ca48))
16
+ * add no-unused-param-read ([1f6c997](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/1f6c9972aa949da09a077a4f916749e25eef38bc))
17
+ * add no-useless-computed-key ([37e7b97](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/37e7b97d6151d8a24672f8365f76c6100b34212e))
18
+ * add no-useless-use-strict ([fbffbc2](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/fbffbc2545121f3d2bfb696105fa98b28d7c69c9))
19
+ * add no-useless-usememo ([349221d](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/349221d26e86a6c8f1bb3fc4b4f8e9ace98a7fa8))
20
+ * improve some rules ([73f3b99](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/73f3b99284b0b66ccd7ff0a3ac0f529f4bd1ad93))
21
+
3
22
  ## [0.0.8](https://github.com/mchevestrier/eslint-plugin-wyrm/compare/eslint-plugin-wyrm-v0.0.7...eslint-plugin-wyrm-v0.0.8) (2025-11-16)
4
23
 
5
24
 
package/README.md CHANGED
@@ -49,31 +49,43 @@ export default defineConfig([
49
49
  💡 Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).\
50
50
  💭 Requires [type information](https://typescript-eslint.io/linting/typed-linting).
51
51
 
52
- | Name                            | Description | 💼 | 🔧 | 💡 | 💭 |
53
- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------ | :---------- | :-- | :-- | :-- |
54
- | [distribute-boolean-casts](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/distribute-boolean-casts.md) | Enforce that boolean casts are distributed over logical expressions | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
55
- | [no-constant-template-expression](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-constant-template-expression.md) | Disallow constant string expressions in template literals | ☑️ | | 💡 | 💭 |
56
- | [no-duplicated-return](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-duplicated-return.md) | Forbid duplicated branches with early returns | 🟩 ✅ 🟪 ☑️ | | | |
57
- | [no-else-break](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-else-break.md) | Forbid unnecessary `else` block after a `break` statement | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
58
- | [no-else-continue](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-else-continue.md) | Forbid unnecessary `else` block after a `continue` statement | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
59
- | [no-else-throw](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-else-throw.md) | Forbid unnecessary `else` block after a `throw` statement | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
60
- | [no-empty-comment](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-empty-comment.md) | Forbid empty comments | 🟪 ☑️ | | | |
61
- | [no-empty-jsx-expression](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-empty-jsx-expression.md) | Forbid empty JSX expression containers | 🟩 ✅ 🟪 ☑️ | | | |
62
- | [no-extra-false-fallback](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-extra-false-fallback.md) | Forbid extra `?? false` in conditions and predicates | 🟪 ☑️ | | 💡 | |
63
- | [no-extra-nested-boolean-cast](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-extra-nested-boolean-cast.md) | Forbid extra boolean casts in conditions and predicates | 🟪 ☑️ | | | |
64
- | [no-invalid-date-literal](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-invalid-date-literal.md) | Disallow invalid date literals | 🟩 ✅ 🟪 ☑️ | | | |
65
- | [no-jsx-statement](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-jsx-statement.md) | Forbid JSX expression statements | 🟩 🟪 ☑️ | | | |
66
- | [no-optional-type-guard-param](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-optional-type-guard-param.md) | Forbid optional parameters in type guards | 🟩 ✅ 🟪 ☑️ | | | |
67
- | [no-return-to-void](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-return-to-void.md) | Forbid returning values in void-returning callbacks | ☑️ | | | 💭 |
68
- | [no-suspicious-jsx-semicolon](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-suspicious-jsx-semicolon.md) | Forbid suspicious semicolons in JSX | 🟩 ✅ 🟪 ☑️ | | | |
69
- | [no-ternary-return](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-ternary-return.md) | Disallow ternary conditions in return statements | 🟪 ☑️ | 🔧 | | |
70
- | [no-useless-iife](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-useless-iife.md) | Forbid useless IIFEs | 🟩 ✅ 🟪 ☑️ | | 💡 | |
71
- | [no-useless-logical-fallback](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-useless-logical-fallback.md) | Forbid useless fallback values for logical expressions | ✅ ☑️ | | 💡 | 💭 |
72
- | [no-useless-return-undefined](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-useless-return-undefined.md) | Forbid returning `undefined` in void-returning callbacks | ☑️ | | | 💭 |
73
- | [no-whitespace-property](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-whitespace-property.md) | Forbid leading or trailing whitespace in object keys | 🟪 ☑️ | | | |
74
- | [prefer-catch-method](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/prefer-catch-method.md) | Enforce usage of `Promise.prototype.catch()` when it improves readability | 🟩 ✅ 🟪 ☑️ | | 💡 | |
75
- | [prefer-early-return](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/prefer-early-return.md) | Require early returns when possible | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
76
- | [prefer-repeat](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/prefer-repeat.md) | Enforce usage of `String.prototype.repeat` | 🟩 🟪 ☑️ | | 💡 | |
77
- | [unsafe-asserted-chain](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/unsafe-asserted-chain.md) | Disallow unsafe type assertions on optional chained expressions | ☑️ | | | 💭 |
52
+ | Name                              | Description | 💼 | 🔧 | 💡 | 💭 |
53
+ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------ | :---------- | :-- | :-- | :-- |
54
+ | [distribute-boolean-casts](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/distribute-boolean-casts.md) | Enforce that boolean casts are distributed over logical expressions | 🟪 ☑️ | 🔧 | | |
55
+ | [no-constant-template-expression](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-constant-template-expression.md) | Disallow constant string expressions in template literals | ☑️ | | 💡 | 💭 |
56
+ | [no-convoluted-logical-expressions](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-convoluted-logical-expressions.md) | Forbid simplifiable logical expressions | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
57
+ | [no-duplicated-return](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-duplicated-return.md) | Forbid duplicated branches with early returns | 🟩 ✅ 🟪 ☑️ | | | |
58
+ | [no-else-break](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-else-break.md) | Forbid unnecessary `else` block after a `break` statement | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
59
+ | [no-else-continue](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-else-continue.md) | Forbid unnecessary `else` block after a `continue` statement | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
60
+ | [no-else-throw](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-else-throw.md) | Forbid unnecessary `else` block after a `throw` statement | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
61
+ | [no-empty-attribute](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-empty-attribute.md) | Forbid some empty JSX attributes | 🟪 ☑️ | | | |
62
+ | [no-empty-comment](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-empty-comment.md) | Forbid empty comments | 🟪 ☑️ | | | |
63
+ | [no-empty-jsx-expression](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-empty-jsx-expression.md) | Forbid empty JSX expression containers | 🟩 🟪 ☑️ | | | |
64
+ | [no-empty-literal-iteration](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-empty-literal-iteration.md) | Forbid iterating over empty literals | 🟪 ☑️ | | | |
65
+ | [no-extra-false-fallback](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-extra-false-fallback.md) | Forbid extra `?? false` in conditions and predicates | 🟪 ☑️ | | 💡 | |
66
+ | [no-extra-nested-boolean-cast](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-extra-nested-boolean-cast.md) | Forbid extra boolean casts in conditions and predicates | 🟪 ☑️ | | | |
67
+ | [no-first-last](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-first-last.md) | Forbid confusing naming for "first" or "last" | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
68
+ | [no-inline-jsdoc-tag](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-inline-jsdoc-tag.md) | Forbid JSDoc tags in code comments | 🟪 ☑️ | | | |
69
+ | [no-invalid-date-literal](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-invalid-date-literal.md) | Disallow invalid date literals | 🟩 🟪 ☑️ | | | |
70
+ | [no-jsx-statement](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-jsx-statement.md) | Forbid JSX expression statements | 🟩 ✅ 🟪 ☑️ | | | |
71
+ | [no-optional-type-guard-param](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-optional-type-guard-param.md) | Forbid optional parameters in type guards | 🟩 🟪 ☑️ | | | |
72
+ | [no-redundant-function-declaration](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-redundant-function-declaration.md) | Forbid redundant function declarations | 🟩 🟪 ☑️ | 🔧 | | |
73
+ | [no-return-to-void](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-return-to-void.md) | Forbid returning values in void-returning callbacks | ☑️ | | | 💭 |
74
+ | [no-sloppy-length-check](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-sloppy-length-check.md) | Forbid sloppy collection size checks | 🟩 ✅ 🟪 ☑️ | | | |
75
+ | [no-suspicious-jsx-semicolon](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-suspicious-jsx-semicolon.md) | Forbid suspicious semicolons in JSX | 🟩 ✅ 🟪 ☑️ | | | |
76
+ | [no-ternary-return](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-ternary-return.md) | Disallow ternary conditions in return statements | 🟪 ☑️ | 🔧 | | |
77
+ | [no-unassigned-todo](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-unassigned-todo.md) | Forbid unassigned TODO comments | 🟪 ☑️ | | | |
78
+ | [no-unused-param-read](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-unused-param-read.md) | Forbid referencing parameters marked as unused with a leading underscore | 🟪 ☑️ | | | |
79
+ | [no-useless-computed-key](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-useless-computed-key.md) | Forbid useless computed keys | 🟪 ☑️ | 🔧 | | |
80
+ | [no-useless-iife](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-useless-iife.md) | Forbid useless IIFEs | 🟩 ✅ 🟪 ☑️ | | 💡 | |
81
+ | [no-useless-logical-fallback](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-useless-logical-fallback.md) | Forbid useless fallback values for logical expressions | ✅ ☑️ | | 💡 | 💭 |
82
+ | [no-useless-return-undefined](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-useless-return-undefined.md) | Forbid returning `undefined` in void-returning callbacks | ☑️ | | | 💭 |
83
+ | [no-useless-use-strict](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-useless-use-strict.md) | Forbid useless "use strict" directives. | 🟪 ☑️ | | | |
84
+ | [no-useless-usememo](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-useless-usememo.md) | Forbid useless `useMemo()` | 🟪 ☑️ | | | |
85
+ | [no-whitespace-property](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/no-whitespace-property.md) | Forbid leading or trailing whitespace in object keys | 🟪 ☑️ | | | |
86
+ | [prefer-catch-method](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/prefer-catch-method.md) | Enforce usage of `Promise.prototype.catch()` when it improves readability | 🟩 ✅ 🟪 ☑️ | | 💡 | |
87
+ | [prefer-early-return](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/prefer-early-return.md) | Require early returns when possible | 🟪 ☑️ | 🔧 | | |
88
+ | [prefer-repeat](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/prefer-repeat.md) | Enforce usage of `String.prototype.repeat` | 🟩 ✅ 🟪 ☑️ | | 💡 | |
89
+ | [unsafe-asserted-chain](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/packages/eslint-plugin-wyrm/docs/rules/unsafe-asserted-chain.md) | Disallow unsafe type assertions on optional chained expressions | ☑️ | | | 💭 |
78
90
 
79
91
  <!-- end auto-generated rules list -->
@@ -2,12 +2,17 @@ import { createRequire } from "node:module";
2
2
 
3
3
  //#region rolldown:runtime
4
4
  var __defProp = Object.defineProperty;
5
- var __export = (all) => {
5
+ var __export = (all, symbols) => {
6
6
  let target = {};
7
- for (var name in all) __defProp(target, name, {
8
- get: all[name],
9
- enumerable: true
10
- });
7
+ for (var name in all) {
8
+ __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ }
13
+ if (symbols) {
14
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
15
+ }
11
16
  return target;
12
17
  };
13
18
 
@@ -11,7 +11,7 @@ var distribute_boolean_casts_default = createRule({
11
11
  type: "suggestion",
12
12
  docs: {
13
13
  description: "Enforce that boolean casts are distributed over logical expressions",
14
- recommended: true
14
+ strict: true
15
15
  },
16
16
  fixable: "code",
17
17
  schema: [],
@@ -1,31 +1,43 @@
1
1
  import { _default } from "./distribute-boolean-casts.mjs";
2
2
  import { _default as _default$1 } from "./no-constant-template-expression.mjs";
3
- import { _default as _default$2 } from "./no-duplicated-return.mjs";
4
- import { _default as _default$3 } from "./no-else-break.mjs";
5
- import { _default as _default$4 } from "./no-else-continue.mjs";
6
- import { _default as _default$5 } from "./no-else-throw.mjs";
7
- import { _default as _default$6 } from "./no-empty-comment.mjs";
8
- import { _default as _default$7 } from "./no-empty-jsx-expression.mjs";
9
- import { _default as _default$8 } from "./no-extra-false-fallback.mjs";
10
- import { _default as _default$9 } from "./no-extra-nested-boolean-cast.mjs";
11
- import { _default as _default$10 } from "./no-invalid-date-literal.mjs";
12
- import { _default as _default$11 } from "./no-jsx-statement.mjs";
13
- import { _default as _default$12 } from "./no-optional-type-guard-param.mjs";
14
- import { _default as _default$13 } from "./no-return-to-void.mjs";
15
- import { _default as _default$14 } from "./no-suspicious-jsx-semicolon.mjs";
16
- import { _default as _default$15 } from "./no-ternary-return.mjs";
17
- import { _default as _default$16 } from "./no-useless-iife.mjs";
18
- import { _default as _default$17 } from "./no-useless-logical-fallback.mjs";
19
- import { _default as _default$18 } from "./no-useless-return-undefined.mjs";
20
- import { _default as _default$19 } from "./no-whitespace-property.mjs";
21
- import { _default as _default$20 } from "./prefer-catch-method.mjs";
22
- import { _default as _default$21 } from "./prefer-early-return.mjs";
23
- import { _default as _default$22 } from "./prefer-repeat.mjs";
24
- import { _default as _default$23 } from "./unsafe-asserted-chain.mjs";
3
+ import { _default as _default$2 } from "./no-convoluted-logical-expressions.mjs";
4
+ import { _default as _default$3 } from "./no-duplicated-return.mjs";
5
+ import { _default as _default$4 } from "./no-else-break.mjs";
6
+ import { _default as _default$5 } from "./no-else-continue.mjs";
7
+ import { _default as _default$6 } from "./no-else-throw.mjs";
8
+ import { _default as _default$7 } from "./no-empty-attribute.mjs";
9
+ import { _default as _default$8 } from "./no-empty-comment.mjs";
10
+ import { _default as _default$9 } from "./no-empty-jsx-expression.mjs";
11
+ import { _default as _default$10 } from "./no-empty-literal-iteration.mjs";
12
+ import { _default as _default$11 } from "./no-extra-false-fallback.mjs";
13
+ import { _default as _default$12 } from "./no-extra-nested-boolean-cast.mjs";
14
+ import { _default as _default$13 } from "./no-first-last.mjs";
15
+ import { _default as _default$14 } from "./no-inline-jsdoc-tag.mjs";
16
+ import { _default as _default$15 } from "./no-invalid-date-literal.mjs";
17
+ import { _default as _default$16 } from "./no-jsx-statement.mjs";
18
+ import { _default as _default$17 } from "./no-optional-type-guard-param.mjs";
19
+ import { _default as _default$18 } from "./no-redundant-function-declaration.mjs";
20
+ import { _default as _default$19 } from "./no-return-to-void.mjs";
21
+ import { _default as _default$20 } from "./no-sloppy-length-check.mjs";
22
+ import { _default as _default$21 } from "./no-suspicious-jsx-semicolon.mjs";
23
+ import { _default as _default$22 } from "./no-ternary-return.mjs";
24
+ import { _default as _default$23 } from "./no-unassigned-todo.mjs";
25
+ import { _default as _default$24 } from "./no-unused-param-read.mjs";
26
+ import { _default as _default$25 } from "./no-useless-computed-key.mjs";
27
+ import { _default as _default$26 } from "./no-useless-iife.mjs";
28
+ import { _default as _default$27 } from "./no-useless-logical-fallback.mjs";
29
+ import { _default as _default$28 } from "./no-useless-return-undefined.mjs";
30
+ import { _default as _default$29 } from "./no-useless-use-strict.mjs";
31
+ import { _default as _default$30 } from "./no-useless-usememo.mjs";
32
+ import { _default as _default$31 } from "./no-whitespace-property.mjs";
33
+ import { _default as _default$32 } from "./prefer-catch-method.mjs";
34
+ import { _default as _default$33 } from "./prefer-early-return.mjs";
35
+ import { _default as _default$34 } from "./prefer-repeat.mjs";
36
+ import { _default as _default$35 } from "./unsafe-asserted-chain.mjs";
25
37
 
26
38
  //#region lib/rules/index.d.ts
27
39
  declare namespace index_d_exports {
28
- export { _default as "distribute-boolean-casts", _default$1 as "no-constant-template-expression", _default$2 as "no-duplicated-return", _default$3 as "no-else-break", _default$4 as "no-else-continue", _default$5 as "no-else-throw", _default$6 as "no-empty-comment", _default$7 as "no-empty-jsx-expression", _default$8 as "no-extra-false-fallback", _default$9 as "no-extra-nested-boolean-cast", _default$10 as "no-invalid-date-literal", _default$11 as "no-jsx-statement", _default$12 as "no-optional-type-guard-param", _default$13 as "no-return-to-void", _default$14 as "no-suspicious-jsx-semicolon", _default$15 as "no-ternary-return", _default$16 as "no-useless-iife", _default$17 as "no-useless-logical-fallback", _default$18 as "no-useless-return-undefined", _default$19 as "no-whitespace-property", _default$20 as "prefer-catch-method", _default$21 as "prefer-early-return", _default$22 as "prefer-repeat", _default$23 as "unsafe-asserted-chain" };
40
+ export { _default as "distribute-boolean-casts", _default$1 as "no-constant-template-expression", _default$2 as "no-convoluted-logical-expressions", _default$3 as "no-duplicated-return", _default$4 as "no-else-break", _default$5 as "no-else-continue", _default$6 as "no-else-throw", _default$7 as "no-empty-attribute", _default$8 as "no-empty-comment", _default$9 as "no-empty-jsx-expression", _default$10 as "no-empty-literal-iteration", _default$11 as "no-extra-false-fallback", _default$12 as "no-extra-nested-boolean-cast", _default$13 as "no-first-last", _default$14 as "no-inline-jsdoc-tag", _default$15 as "no-invalid-date-literal", _default$16 as "no-jsx-statement", _default$17 as "no-optional-type-guard-param", _default$18 as "no-redundant-function-declaration", _default$19 as "no-return-to-void", _default$20 as "no-sloppy-length-check", _default$21 as "no-suspicious-jsx-semicolon", _default$22 as "no-ternary-return", _default$23 as "no-unassigned-todo", _default$24 as "no-unused-param-read", _default$25 as "no-useless-computed-key", _default$26 as "no-useless-iife", _default$27 as "no-useless-logical-fallback", _default$28 as "no-useless-return-undefined", _default$29 as "no-useless-use-strict", _default$30 as "no-useless-usememo", _default$31 as "no-whitespace-property", _default$32 as "prefer-catch-method", _default$33 as "prefer-early-return", _default$34 as "prefer-repeat", _default$35 as "unsafe-asserted-chain" };
29
41
  }
30
42
  //#endregion
31
43
  export { index_d_exports };
@@ -1,23 +1,35 @@
1
1
  import { __export } from "../_virtual/rolldown_runtime.mjs";
2
2
  import distribute_boolean_casts_default from "./distribute-boolean-casts.mjs";
3
3
  import no_constant_template_expression_default from "./no-constant-template-expression.mjs";
4
+ import no_convoluted_logical_expressions_default from "./no-convoluted-logical-expressions.mjs";
4
5
  import no_duplicated_return_default from "./no-duplicated-return.mjs";
5
6
  import no_else_break_default from "./no-else-break.mjs";
6
7
  import no_else_continue_default from "./no-else-continue.mjs";
7
8
  import no_else_throw_default from "./no-else-throw.mjs";
9
+ import no_empty_attribute_default from "./no-empty-attribute.mjs";
8
10
  import no_empty_comment_default from "./no-empty-comment.mjs";
9
11
  import no_empty_jsx_expression_default from "./no-empty-jsx-expression.mjs";
12
+ import no_empty_literal_iteration_default from "./no-empty-literal-iteration.mjs";
10
13
  import no_extra_false_fallback_default from "./no-extra-false-fallback.mjs";
11
14
  import no_extra_nested_boolean_cast_default from "./no-extra-nested-boolean-cast.mjs";
15
+ import no_first_last_default from "./no-first-last.mjs";
16
+ import no_inline_jsdoc_tag_default from "./no-inline-jsdoc-tag.mjs";
12
17
  import no_invalid_date_literal_default from "./no-invalid-date-literal.mjs";
13
18
  import no_jsx_statement_default from "./no-jsx-statement.mjs";
14
19
  import no_optional_type_guard_param_default from "./no-optional-type-guard-param.mjs";
20
+ import no_redundant_function_declaration_default from "./no-redundant-function-declaration.mjs";
15
21
  import no_return_to_void_default from "./no-return-to-void.mjs";
22
+ import no_sloppy_length_check_default from "./no-sloppy-length-check.mjs";
16
23
  import no_suspicious_jsx_semicolon_default from "./no-suspicious-jsx-semicolon.mjs";
17
24
  import no_ternary_return_default from "./no-ternary-return.mjs";
25
+ import no_unassigned_todo_default from "./no-unassigned-todo.mjs";
26
+ import no_unused_param_read_default from "./no-unused-param-read.mjs";
27
+ import no_useless_computed_key_default from "./no-useless-computed-key.mjs";
18
28
  import no_useless_iife_default from "./no-useless-iife.mjs";
19
29
  import no_useless_logical_fallback_default from "./no-useless-logical-fallback.mjs";
20
30
  import no_useless_return_undefined_default from "./no-useless-return-undefined.mjs";
31
+ import no_useless_use_strict_default from "./no-useless-use-strict.mjs";
32
+ import no_useless_usememo_default from "./no-useless-usememo.mjs";
21
33
  import no_whitespace_property_default from "./no-whitespace-property.mjs";
22
34
  import prefer_catch_method_default from "./prefer-catch-method.mjs";
23
35
  import prefer_early_return_default from "./prefer-early-return.mjs";
@@ -28,23 +40,35 @@ import unsafe_asserted_chain_default from "./unsafe-asserted-chain.mjs";
28
40
  var rules_exports = /* @__PURE__ */ __export({
29
41
  "distribute-boolean-casts": () => distribute_boolean_casts_default,
30
42
  "no-constant-template-expression": () => no_constant_template_expression_default,
43
+ "no-convoluted-logical-expressions": () => no_convoluted_logical_expressions_default,
31
44
  "no-duplicated-return": () => no_duplicated_return_default,
32
45
  "no-else-break": () => no_else_break_default,
33
46
  "no-else-continue": () => no_else_continue_default,
34
47
  "no-else-throw": () => no_else_throw_default,
48
+ "no-empty-attribute": () => no_empty_attribute_default,
35
49
  "no-empty-comment": () => no_empty_comment_default,
36
50
  "no-empty-jsx-expression": () => no_empty_jsx_expression_default,
51
+ "no-empty-literal-iteration": () => no_empty_literal_iteration_default,
37
52
  "no-extra-false-fallback": () => no_extra_false_fallback_default,
38
53
  "no-extra-nested-boolean-cast": () => no_extra_nested_boolean_cast_default,
54
+ "no-first-last": () => no_first_last_default,
55
+ "no-inline-jsdoc-tag": () => no_inline_jsdoc_tag_default,
39
56
  "no-invalid-date-literal": () => no_invalid_date_literal_default,
40
57
  "no-jsx-statement": () => no_jsx_statement_default,
41
58
  "no-optional-type-guard-param": () => no_optional_type_guard_param_default,
59
+ "no-redundant-function-declaration": () => no_redundant_function_declaration_default,
42
60
  "no-return-to-void": () => no_return_to_void_default,
61
+ "no-sloppy-length-check": () => no_sloppy_length_check_default,
43
62
  "no-suspicious-jsx-semicolon": () => no_suspicious_jsx_semicolon_default,
44
63
  "no-ternary-return": () => no_ternary_return_default,
64
+ "no-unassigned-todo": () => no_unassigned_todo_default,
65
+ "no-unused-param-read": () => no_unused_param_read_default,
66
+ "no-useless-computed-key": () => no_useless_computed_key_default,
45
67
  "no-useless-iife": () => no_useless_iife_default,
46
68
  "no-useless-logical-fallback": () => no_useless_logical_fallback_default,
47
69
  "no-useless-return-undefined": () => no_useless_return_undefined_default,
70
+ "no-useless-use-strict": () => no_useless_use_strict_default,
71
+ "no-useless-usememo": () => no_useless_usememo_default,
48
72
  "no-whitespace-property": () => no_whitespace_property_default,
49
73
  "prefer-catch-method": () => prefer_catch_method_default,
50
74
  "prefer-early-return": () => prefer_early_return_default,
@@ -1,10 +1,10 @@
1
1
  import { WyrmPluginDocs } from "../utils/createRule.mjs";
2
- import { ESLintUtils } from "@typescript-eslint/utils";
2
+ import { TSESLint } from "@typescript-eslint/utils";
3
3
 
4
4
  //#region lib/rules/no-constant-template-expression.d.ts
5
5
 
6
- declare const _default: ESLintUtils.RuleModule<"noConstantTemplateExpression" | "replaceByString", [{
6
+ declare const _default: TSESLint.RuleModule<"noConstantTemplateExpression" | "replaceByString", [{
7
7
  minAllowedLength: number;
8
- }], WyrmPluginDocs, ESLintUtils.RuleListener>;
8
+ }], WyrmPluginDocs, TSESLint.RuleListener>;
9
9
  //#endregion
10
10
  export { _default };
@@ -1,6 +1,7 @@
1
1
  import { createRule } from "../utils/createRule.mjs";
2
2
  import path from "node:path";
3
3
  import { ASTUtils, AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
4
+ import * as ts from "typescript";
4
5
 
5
6
  //#region lib/rules/no-constant-template-expression.ts
6
7
  /**
@@ -25,7 +26,7 @@ const DEFAULT_MIN_ALLOWED_LENGTH = 10;
25
26
  var no_constant_template_expression_default = createRule({
26
27
  name,
27
28
  meta: {
28
- type: "problem",
29
+ type: "suggestion",
29
30
  docs: {
30
31
  description: "Disallow constant string expressions in template literals",
31
32
  requiresTypeChecking: true,
@@ -46,49 +47,52 @@ var no_constant_template_expression_default = createRule({
46
47
  },
47
48
  defaultOptions: [{ minAllowedLength: DEFAULT_MIN_ALLOWED_LENGTH }],
48
49
  create(context, [options]) {
50
+ function checkExpression(expr, quasis, scope) {
51
+ if (expr.type === AST_NODE_TYPES.Identifier) {
52
+ const variable = ASTUtils.findVariable(scope, expr);
53
+ if (variable) {
54
+ const { references, defs } = variable;
55
+ if (references.length > 2) return;
56
+ const def = defs.at(-1);
57
+ if (def?.parent?.type === AST_NODE_TYPES.VariableDeclaration && (def.parent.parent.type === AST_NODE_TYPES.ExportNamedDeclaration || def.parent.parent.type === AST_NODE_TYPES.ExportDefaultDeclaration)) return;
58
+ }
59
+ }
60
+ const services = ESLintUtils.getParserServices(context);
61
+ const checker = services.program.getTypeChecker();
62
+ const value = getLiteralValue(services.getTypeAtLocation(expr), checker);
63
+ if (value === null) return;
64
+ if (value.length >= options.minAllowedLength) return;
65
+ const sym = services.getSymbolAtLocation(expr);
66
+ if (sym && sym.getFlags() & ts.SymbolFlags.EnumMember && !quasis.some((quasi) => quasi.value.cooked)) return;
67
+ context.report({
68
+ node: expr,
69
+ messageId: "noConstantTemplateExpression",
70
+ data: { value },
71
+ suggest: [{
72
+ messageId: "replaceByString",
73
+ data: { value },
74
+ *fix(fixer) {
75
+ const [identStart, identEnd] = expr.range;
76
+ const previousQuasi = quasis.toReversed().find((quasi) => quasi.range[1] <= identStart);
77
+ const nextQuasi = quasis.find((quasi) => quasi.range[0] >= identEnd);
78
+ /* v8 ignore if -- @preserve */
79
+ if (!previousQuasi || !nextQuasi) {
80
+ console.error("No previous/next quasi found. This should never happen.");
81
+ return;
82
+ }
83
+ const start = previousQuasi.range[1];
84
+ const end = nextQuasi.range[0];
85
+ const range = [start - 2, end + 1];
86
+ yield fixer.replaceTextRange(range, value);
87
+ }
88
+ }]
89
+ });
90
+ }
49
91
  return { TemplateLiteral(node) {
50
92
  const { expressions, quasis } = node;
51
93
  if (quasis.some((quasi) => quasi.value.cooked.includes(" "))) return;
52
94
  const scope = context.sourceCode.getScope(node);
53
- for (const expr of expressions) {
54
- if (expr.type === AST_NODE_TYPES.Identifier) {
55
- const variable = ASTUtils.findVariable(scope, expr);
56
- if (variable) {
57
- const { references, defs } = variable;
58
- if (references.length > 2) continue;
59
- const def = defs.at(-1);
60
- if (def?.parent?.type === AST_NODE_TYPES.VariableDeclaration && (def.parent.parent.type === AST_NODE_TYPES.ExportNamedDeclaration || def.parent.parent.type === AST_NODE_TYPES.ExportDefaultDeclaration)) continue;
61
- }
62
- }
63
- const services = ESLintUtils.getParserServices(context);
64
- const checker = services.program.getTypeChecker();
65
- const value = getLiteralValue(services.getTypeAtLocation(expr), checker);
66
- if (value === null) continue;
67
- if (value.length >= options.minAllowedLength) return;
68
- context.report({
69
- node: expr,
70
- messageId: "noConstantTemplateExpression",
71
- data: { value },
72
- suggest: [{
73
- messageId: "replaceByString",
74
- data: { value },
75
- *fix(fixer) {
76
- const [identStart, identEnd] = expr.range;
77
- const previousQuasi = quasis.toReversed().find((quasi) => quasi.range[1] <= identStart);
78
- const nextQuasi = quasis.find((quasi) => quasi.range[0] >= identEnd);
79
- /* v8 ignore if -- @preserve */
80
- if (!previousQuasi || !nextQuasi) {
81
- console.error("No previous/next quasi found. This should never happen.");
82
- return;
83
- }
84
- const start = previousQuasi.range[1];
85
- const end = nextQuasi.range[0];
86
- const range = [start - 2, end + 1];
87
- yield fixer.replaceTextRange(range, value);
88
- }
89
- }]
90
- });
91
- }
95
+ for (const expr of expressions) checkExpression(expr, quasis, scope);
92
96
  } };
93
97
  }
94
98
  });
@@ -0,0 +1,7 @@
1
+ import { WyrmPluginDocs } from "../utils/createRule.mjs";
2
+ import * as _typescript_eslint_utils_ts_eslint3 from "@typescript-eslint/utils/ts-eslint";
3
+
4
+ //#region lib/rules/no-convoluted-logical-expressions.d.ts
5
+ declare const _default: _typescript_eslint_utils_ts_eslint3.RuleModule<"noConvolutedLogicalExpression", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint3.RuleListener>;
6
+ //#endregion
7
+ export { _default };
@@ -0,0 +1,126 @@
1
+ import { createRule } from "../utils/createRule.mjs";
2
+ import path from "node:path";
3
+ import { AST_NODE_TYPES } from "@typescript-eslint/utils";
4
+
5
+ //#region lib/rules/no-convoluted-logical-expressions.ts
6
+ const { name } = path.parse(import.meta.filename);
7
+ var no_convoluted_logical_expressions_default = createRule({
8
+ name,
9
+ meta: {
10
+ type: "suggestion",
11
+ docs: {
12
+ description: "Forbid simplifiable logical expressions",
13
+ recommended: true
14
+ },
15
+ fixable: "code",
16
+ schema: [],
17
+ messages: { noConvolutedLogicalExpression: "This logical expression can be simplified" }
18
+ },
19
+ defaultOptions: [],
20
+ create(context) {
21
+ function checkDisjunctionOfTernaryExpressions(node, left, right) {
22
+ if (left.test.type !== AST_NODE_TYPES.Identifier) return;
23
+ if (!isNullishLiteral(left.alternate)) return;
24
+ const leftAlternateText = context.sourceCode.getText(left.alternate);
25
+ if (leftAlternateText !== context.sourceCode.getText(right.alternate)) return;
26
+ const identifierName = left.test.name;
27
+ const leftConsequentText = context.sourceCode.getText(left.consequent);
28
+ const rightConsequentText = context.sourceCode.getText(right.consequent);
29
+ const op = node.operator;
30
+ if (isNegatedIdentifier(right.test, left.test.name)) {
31
+ context.report({
32
+ node,
33
+ messageId: "noConvolutedLogicalExpression",
34
+ fix(fixer) {
35
+ const text = `${identifierName} ? (${leftConsequentText} ${op} ${leftAlternateText}) : ${rightConsequentText}`;
36
+ return fixer.replaceText(node, text);
37
+ }
38
+ });
39
+ return;
40
+ }
41
+ if (right.test.type === AST_NODE_TYPES.Identifier && left.test.name === right.test.name) {
42
+ context.report({
43
+ node,
44
+ messageId: "noConvolutedLogicalExpression",
45
+ fix(fixer) {
46
+ const text = `${identifierName} ? (${leftConsequentText} ${op} ${rightConsequentText}) : ${leftAlternateText}`;
47
+ return fixer.replaceText(node, text);
48
+ }
49
+ });
50
+ return;
51
+ }
52
+ if (right.test.type === AST_NODE_TYPES.Identifier && node.operator === "||") {
53
+ const rightIdentifierName = right.test.name;
54
+ context.report({
55
+ node,
56
+ messageId: "noConvolutedLogicalExpression",
57
+ fix(fixer) {
58
+ const text = `${identifierName} && ${leftConsequentText} ? ${leftConsequentText} : ${rightIdentifierName} ? ${rightConsequentText} : ${leftAlternateText}`;
59
+ return fixer.replaceText(node, text);
60
+ }
61
+ });
62
+ }
63
+ }
64
+ return { LogicalExpression(node) {
65
+ if (node.left.type === AST_NODE_TYPES.Identifier && node.right.type === AST_NODE_TYPES.Identifier) {
66
+ if (node.left.name !== node.right.name) return;
67
+ const identifierName = node.left.name;
68
+ context.report({
69
+ node,
70
+ messageId: "noConvolutedLogicalExpression",
71
+ fix(fixer) {
72
+ return fixer.replaceText(node, identifierName);
73
+ }
74
+ });
75
+ return;
76
+ }
77
+ if (node.left.type === AST_NODE_TYPES.Identifier && node.right.type === AST_NODE_TYPES.LogicalExpression) {
78
+ const isDisjunctionWithConjunction = node.operator === "||" && node.right.operator === "&&";
79
+ const isConjunctionWithDisjunction = node.operator === "&&" && node.right.operator === "||";
80
+ if ((isDisjunctionWithConjunction || isConjunctionWithDisjunction) && node.right.left.type === AST_NODE_TYPES.Identifier && node.left.name === node.right.left.name) {
81
+ const identifierName = node.left.name;
82
+ context.report({
83
+ node,
84
+ messageId: "noConvolutedLogicalExpression",
85
+ fix(fixer) {
86
+ return fixer.replaceText(node, identifierName);
87
+ }
88
+ });
89
+ }
90
+ return;
91
+ }
92
+ if (node.left.type === AST_NODE_TYPES.LogicalExpression && node.right.type === AST_NODE_TYPES.LogicalExpression) {
93
+ if (node.left.operator === node.right.operator && node.left.left.type === AST_NODE_TYPES.Identifier && node.right.left.type === AST_NODE_TYPES.Identifier && node.left.left.name === node.right.left.name) {
94
+ const identifierName = node.left.left.name;
95
+ const leftText = context.sourceCode.getText(node.left.right);
96
+ const rightText = context.sourceCode.getText(node.right.right);
97
+ const op = node.operator;
98
+ const text = `${identifierName} ${node.left.operator} (${leftText} ${op} ${rightText})`;
99
+ context.report({
100
+ node,
101
+ messageId: "noConvolutedLogicalExpression",
102
+ fix(fixer) {
103
+ return fixer.replaceText(node, text);
104
+ }
105
+ });
106
+ }
107
+ return;
108
+ }
109
+ if (node.left.type === AST_NODE_TYPES.ConditionalExpression && node.right.type === AST_NODE_TYPES.ConditionalExpression) checkDisjunctionOfTernaryExpressions(node, node.left, node.right);
110
+ } };
111
+ }
112
+ });
113
+ function isNegatedIdentifier(node, identifierName) {
114
+ if (node.type !== AST_NODE_TYPES.UnaryExpression) return false;
115
+ if (node.operator !== "!") return false;
116
+ if (node.argument.type !== AST_NODE_TYPES.Identifier) return false;
117
+ return node.argument.name === identifierName;
118
+ }
119
+ function isNullishLiteral(node) {
120
+ if (node.type === AST_NODE_TYPES.Literal && node.value === null) return true;
121
+ if (node.type === AST_NODE_TYPES.Identifier && node.name === "undefined") return true;
122
+ return false;
123
+ }
124
+
125
+ //#endregion
126
+ export { no_convoluted_logical_expressions_default as default };
@@ -1,7 +1,7 @@
1
1
  import { WyrmPluginDocs } from "../utils/createRule.mjs";
2
- import * as _typescript_eslint_utils_ts_eslint3 from "@typescript-eslint/utils/ts-eslint";
2
+ import * as _typescript_eslint_utils_ts_eslint5 from "@typescript-eslint/utils/ts-eslint";
3
3
 
4
4
  //#region lib/rules/no-duplicated-return.d.ts
5
- declare const _default: _typescript_eslint_utils_ts_eslint3.RuleModule<"noDuplicatedReturn", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint3.RuleListener>;
5
+ declare const _default: _typescript_eslint_utils_ts_eslint5.RuleModule<"noDuplicatedReturn", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint5.RuleListener>;
6
6
  //#endregion
7
7
  export { _default };
@@ -1,6 +1,7 @@
1
1
  import { createRule } from "../utils/createRule.mjs";
2
+ import { compareTokens } from "../utils/compareTokens.mjs";
2
3
  import path from "node:path";
3
- import { AST_NODE_TYPES, AST_TOKEN_TYPES } from "@typescript-eslint/utils";
4
+ import { AST_NODE_TYPES } from "@typescript-eslint/utils";
4
5
 
5
6
  //#region lib/rules/no-duplicated-return.ts
6
7
  const { name } = path.parse(import.meta.filename);
@@ -56,20 +57,6 @@ var no_duplicated_return_default = createRule({
56
57
  };
57
58
  }
58
59
  });
59
- function compareTokens(tokensA, tokensB) {
60
- const [a, ...restA] = tokensA;
61
- const [b, ...restB] = tokensB;
62
- if (a === void 0 && b === void 0) return true;
63
- if (a === void 0) return false;
64
- if (b === void 0) return false;
65
- if (!areTokensEqual(a, b)) return false;
66
- return compareTokens(restA, restB);
67
- }
68
- function areTokensEqual(a, b) {
69
- if (a.type !== b.type) return false;
70
- if (a.type === AST_TOKEN_TYPES.String) return a.value.slice(1, -1) === b.value.slice(1, -1);
71
- return a.value === b.value;
72
- }
73
60
  function normalizeStatements(stmts) {
74
61
  return stmts.flatMap((stmt) => {
75
62
  if (stmt.type === AST_NODE_TYPES.ReturnStatement && stmt.argument === null) return [];