eslint-plugin-wyrm 0.0.6 → 0.0.8

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 (75) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +27 -17
  3. package/dist/configs/{index.js → index.mjs} +3 -3
  4. package/dist/{index.d.ts → index.d.mts} +2 -2
  5. package/dist/index.mjs +12 -0
  6. package/dist/{plugin.js → plugin.mjs} +1 -1
  7. package/dist/rules/distribute-boolean-casts.d.mts +7 -0
  8. package/dist/rules/distribute-boolean-casts.mjs +91 -0
  9. package/dist/rules/index.d.mts +31 -0
  10. package/dist/rules/index.mjs +56 -0
  11. package/dist/rules/{no-constant-template-expression.d.ts → no-constant-template-expression.d.mts} +1 -1
  12. package/dist/rules/{no-constant-template-expression.js → no-constant-template-expression.mjs} +29 -7
  13. package/dist/rules/no-duplicated-return.d.mts +7 -0
  14. package/dist/rules/no-duplicated-return.mjs +96 -0
  15. package/dist/rules/no-else-break.d.mts +7 -0
  16. package/dist/rules/{no-else-break.js → no-else-break.mjs} +2 -1
  17. package/dist/rules/no-else-continue.d.mts +7 -0
  18. package/dist/rules/{no-else-continue.js → no-else-continue.mjs} +2 -1
  19. package/dist/rules/no-else-throw.d.mts +7 -0
  20. package/dist/rules/{no-else-throw.js → no-else-throw.mjs} +2 -1
  21. package/dist/rules/no-empty-comment.d.mts +9 -0
  22. package/dist/rules/{no-empty-comment.js → no-empty-comment.mjs} +7 -7
  23. package/dist/rules/no-empty-jsx-expression.d.mts +7 -0
  24. package/dist/rules/{no-empty-jsx-expression.js → no-empty-jsx-expression.mjs} +2 -1
  25. package/dist/rules/no-extra-false-fallback.d.mts +8 -0
  26. package/dist/rules/no-extra-false-fallback.mjs +170 -0
  27. package/dist/rules/{no-extra-nested-boolean-cast.d.ts → no-extra-nested-boolean-cast.d.mts} +1 -1
  28. package/dist/rules/{no-extra-nested-boolean-cast.js → no-extra-nested-boolean-cast.mjs} +24 -1
  29. package/dist/rules/{no-invalid-date-literal.d.ts → no-invalid-date-literal.d.mts} +1 -1
  30. package/dist/rules/{no-invalid-date-literal.js → no-invalid-date-literal.mjs} +3 -1
  31. package/dist/rules/no-jsx-statement.d.mts +7 -0
  32. package/dist/rules/{no-jsx-statement.js → no-jsx-statement.mjs} +3 -2
  33. package/dist/rules/no-optional-type-guard-param.d.mts +7 -0
  34. package/dist/rules/no-optional-type-guard-param.mjs +43 -0
  35. package/dist/rules/no-return-to-void.d.mts +7 -0
  36. package/dist/rules/no-return-to-void.mjs +87 -0
  37. package/dist/rules/no-suspicious-jsx-semicolon.d.mts +8 -0
  38. package/dist/rules/{no-suspicious-jsx-semicolon.js → no-suspicious-jsx-semicolon.mjs} +7 -2
  39. package/dist/rules/no-ternary-return.d.mts +10 -0
  40. package/dist/rules/{no-ternary-return.js → no-ternary-return.mjs} +10 -3
  41. package/dist/rules/no-useless-iife.d.mts +7 -0
  42. package/dist/rules/{no-useless-iife.js → no-useless-iife.mjs} +1 -1
  43. package/dist/rules/no-useless-logical-fallback.d.mts +8 -0
  44. package/dist/rules/no-useless-logical-fallback.mjs +255 -0
  45. package/dist/rules/no-useless-return-undefined.d.mts +7 -0
  46. package/dist/rules/no-useless-return-undefined.mjs +105 -0
  47. package/dist/rules/no-whitespace-property.d.mts +7 -0
  48. package/dist/rules/no-whitespace-property.mjs +42 -0
  49. package/dist/rules/prefer-catch-method.d.mts +7 -0
  50. package/dist/rules/prefer-catch-method.mjs +132 -0
  51. package/dist/rules/prefer-early-return.d.mts +7 -0
  52. package/dist/rules/prefer-early-return.mjs +121 -0
  53. package/dist/rules/prefer-repeat.d.mts +7 -0
  54. package/dist/rules/{prefer-repeat.js → prefer-repeat.mjs} +8 -5
  55. package/dist/rules/{unsafe-asserted-chain.d.ts → unsafe-asserted-chain.d.mts} +1 -1
  56. package/dist/rules/{unsafe-asserted-chain.js → unsafe-asserted-chain.mjs} +23 -7
  57. package/package.json +35 -22
  58. package/dist/index.js +0 -12
  59. package/dist/rules/index.d.ts +0 -21
  60. package/dist/rules/index.js +0 -36
  61. package/dist/rules/no-else-break.d.ts +0 -7
  62. package/dist/rules/no-else-continue.d.ts +0 -7
  63. package/dist/rules/no-else-throw.d.ts +0 -7
  64. package/dist/rules/no-empty-comment.d.ts +0 -9
  65. package/dist/rules/no-empty-jsx-expression.d.ts +0 -7
  66. package/dist/rules/no-jsx-statement.d.ts +0 -7
  67. package/dist/rules/no-suspicious-jsx-semicolon.d.ts +0 -8
  68. package/dist/rules/no-ternary-return.d.ts +0 -9
  69. package/dist/rules/no-useless-iife.d.ts +0 -7
  70. package/dist/rules/prefer-repeat.d.ts +0 -7
  71. /package/dist/_virtual/{rolldown_runtime.js → rolldown_runtime.mjs} +0 -0
  72. /package/dist/configs/{index.d.ts → index.d.mts} +0 -0
  73. /package/dist/utils/{createRule.d.ts → createRule.d.mts} +0 -0
  74. /package/dist/utils/{createRule.js → createRule.mjs} +0 -0
  75. /package/dist/utils/{option.js → option.mjs} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [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
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * add no-duplicated-return & prefer-early-return ([41372c9](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/41372c9d1d147e9597259b22bc4fe29d8f6873e1))
9
+ * add no-extra-false-fallback ([f2e2bcd](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/f2e2bcd9f5aae66535f159c2d6fb1ca51ba3176f))
10
+ * add no-optional-type-guard-param ([6b3d9a1](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/6b3d9a1be37da3e4104de462bcf27dc1147741db))
11
+ * add no-return-to-void & no-useless-return-undefined ([5b5da17](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/5b5da17a778bf23c4b29bd44ddbea7d3919c9d0e))
12
+ * add no-useless-logical-fallback ([129eaea](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/129eaea5ec6db9b07cf3478fd42f7d766ada2e82))
13
+ * add no-whitespace-property ([6aab31a](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/6aab31a2e61e6b68bad909420ea845aee281e184))
14
+ * improve no-duplicated-return ([60ed1d8](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/60ed1d8e09154d3e1fd45bd409bfbdef644857ac))
15
+ * improve no-useless-logical-fallback ([c770119](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/c7701199ee0486494a8a5b688540725113aca17c))
16
+ * improve rules ([68cb444](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/68cb4442a9436b39fe739ea5cdfe85ba2b6ed897))
17
+
18
+ ## [0.0.7](https://github.com/mchevestrier/eslint-plugin-wyrm/compare/eslint-plugin-wyrm-v0.0.6...eslint-plugin-wyrm-v0.0.7) (2025-11-05)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * add distribute-boolean-casts ([a6a7a1d](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/a6a7a1d34fe2dca977bd98fb27337797ce1b1200))
24
+ * add prefer-catch-method ([fb1b614](https://github.com/mchevestrier/eslint-plugin-wyrm/commit/fb1b614f2a2e53c8e2ca197b706f458cbe73ba4a))
25
+
3
26
  ## [0.0.6](https://github.com/mchevestrier/eslint-plugin-wyrm/compare/eslint-plugin-wyrm-v0.0.5...eslint-plugin-wyrm-v0.0.6) (2025-11-04)
4
27
 
5
28
 
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/eslint-plugin-wyrm.svg?color=7f52af&labelColor=26272b)](https://www.npmjs.com/package/eslint-plugin-wyrm)
4
4
  [![GitHub release](https://img.shields.io/github/v/release/mchevestrier/eslint-plugin-wyrm?color=7f52af&labelColor=26272b)](https://github.com/mchevestrier/eslint-plugin-wyrm/releases/latest)
5
- [![GitHub License](https://img.shields.io/badge/license-MIT-232428.svg?color=7f52af&labelColor=26272b)](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/main/LICENSE.md)
5
+ [![GitHub License](https://img.shields.io/badge/license-MIT-232428.svg?color=7f52af&labelColor=26272b)](https://github.com/mchevestrier/eslint-plugin-wyrm/blob/master/LICENSE.md)
6
6
 
7
7
  ## Installation
8
8
 
@@ -49,21 +49,31 @@ 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
- | [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 | ☑️ | | 💡 | 💭 |
55
- | [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 | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
56
- | [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 | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
57
- | [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 | 🟩 ✅ 🟪 ☑️ | 🔧 | | |
58
- | [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 | 🟪 ☑️ | | | |
59
- | [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 | 🟩 ✅ 🟪 ☑️ | | | |
60
- | [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 | 🟪 ☑️ | | | |
61
- | [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 | 🟩 ✅ 🟪 ☑️ | | | |
62
- | [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 | 🟩 🟪 ☑️ | | | |
63
- | [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 | 🟩 🟪 ☑️ | | | |
64
- | [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 | 🟪 ☑️ | 🔧 | | |
65
- | [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 | 🟩 ✅ 🟪 ☑️ | | 💡 | |
66
- | [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` | 🟩 ✅ 🟪 ☑️ | | 💡 | |
67
- | [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-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 | ☑️ | | | 💭 |
68
78
 
69
79
  <!-- end auto-generated rules list -->
@@ -1,6 +1,6 @@
1
- import { __export } from "../_virtual/rolldown_runtime.js";
2
- import { rules_exports } from "../rules/index.js";
3
- import { plugin } from "../plugin.js";
1
+ import { __export } from "../_virtual/rolldown_runtime.mjs";
2
+ import { rules_exports } from "../rules/index.mjs";
3
+ import { plugin } from "../plugin.mjs";
4
4
 
5
5
  //#region lib/configs/index.ts
6
6
  var configs_exports = /* @__PURE__ */ __export({
@@ -1,5 +1,5 @@
1
- import { index_d_exports } from "./configs/index.js";
2
- import { index_d_exports as index_d_exports$1 } from "./rules/index.js";
1
+ import { index_d_exports } from "./configs/index.mjs";
2
+ import { index_d_exports as index_d_exports$1 } from "./rules/index.mjs";
3
3
 
4
4
  //#region lib/index.d.ts
5
5
  interface CompatibleConfig {
package/dist/index.mjs ADDED
@@ -0,0 +1,12 @@
1
+ import { rules_exports } from "./rules/index.mjs";
2
+ import { configs_exports } from "./configs/index.mjs";
3
+
4
+ //#region lib/index.ts
5
+ const plugin = {
6
+ rules: rules_exports,
7
+ configs: configs_exports
8
+ };
9
+ var lib_default = plugin;
10
+
11
+ //#endregion
12
+ export { lib_default as default };
@@ -1,4 +1,4 @@
1
- import { rules_exports } from "./rules/index.js";
1
+ import { rules_exports } from "./rules/index.mjs";
2
2
  import { createRequire } from "node:module";
3
3
 
4
4
  //#region lib/plugin.ts
@@ -0,0 +1,7 @@
1
+ import { WyrmPluginDocs } from "../utils/createRule.mjs";
2
+ import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
3
+
4
+ //#region lib/rules/distribute-boolean-casts.d.ts
5
+ declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"distributeBooleanCast", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener>;
6
+ //#endregion
7
+ export { _default };
@@ -0,0 +1,91 @@
1
+ import { createRule } from "../utils/createRule.mjs";
2
+ import { None, Some } from "../utils/option.mjs";
3
+ import path from "node:path";
4
+ import { AST_NODE_TYPES } from "@typescript-eslint/utils";
5
+
6
+ //#region lib/rules/distribute-boolean-casts.ts
7
+ const { name } = path.parse(import.meta.filename);
8
+ var distribute_boolean_casts_default = createRule({
9
+ name,
10
+ meta: {
11
+ type: "suggestion",
12
+ docs: {
13
+ description: "Enforce that boolean casts are distributed over logical expressions",
14
+ recommended: true
15
+ },
16
+ fixable: "code",
17
+ schema: [],
18
+ messages: { distributeBooleanCast: "Distribute this boolean cast over logical expressions" }
19
+ },
20
+ defaultOptions: [],
21
+ create(context) {
22
+ return { LogicalExpression(node) {
23
+ if (node.operator === "??") return;
24
+ const parentCast = getParentBooleanCast(node);
25
+ if (!parentCast.some) return;
26
+ context.report({
27
+ node,
28
+ messageId: "distributeBooleanCast",
29
+ fix(fixer) {
30
+ const left = maybeWrapInBooleanCast(node.left);
31
+ const right = maybeWrapInBooleanCast(node.right);
32
+ const newText = `(${left} ${node.operator} ${right})`;
33
+ return fixer.replaceText(parentCast.value, newText);
34
+ }
35
+ });
36
+ } };
37
+ function getTextWithPreviousComments(node) {
38
+ const txt = context.sourceCode.getText(node);
39
+ const prev = context.sourceCode.getTokenBefore(node);
40
+ /* v8 ignore if -- @preserve */
41
+ if (!prev) return txt;
42
+ const previousComments = context.sourceCode.getAllComments().filter((comment) => comment.range[0] >= prev.range[1] && comment.range[1] <= node.range[0]);
43
+ if (!previousComments.length) return txt;
44
+ return `\n${previousComments.map((comment) => context.sourceCode.getText(comment)).join("\n")}\n${txt}`;
45
+ }
46
+ function maybeWrapInBooleanCast(expr) {
47
+ const txt = getTextWithPreviousComments(expr);
48
+ if (isBooleanLike(expr)) return txt;
49
+ return `!!(${txt})`;
50
+ }
51
+ }
52
+ });
53
+ function isBooleanLike(expr) {
54
+ if (expr.type === AST_NODE_TYPES.UnaryExpression) return expr.operator === "!";
55
+ if (expr.type === AST_NODE_TYPES.BinaryExpression) switch (expr.operator) {
56
+ case "&&": return true;
57
+ case "||": return true;
58
+ case "!=":
59
+ case "!==":
60
+ case "==":
61
+ case "===":
62
+ case "<":
63
+ case "<=":
64
+ case ">":
65
+ case ">=":
66
+ case "in":
67
+ case "instanceof": return true;
68
+ default: return false;
69
+ }
70
+ if (expr.type === AST_NODE_TYPES.Literal) return typeof expr.value === "boolean";
71
+ return false;
72
+ }
73
+ function getParentBooleanCast(node) {
74
+ if (node.parent.type === AST_NODE_TYPES.UnaryExpression && isDoubleNegation(node.parent)) return Some(node.parent.parent);
75
+ if (node.parent.type === AST_NODE_TYPES.CallExpression && isBooleanCall(node.parent)) return Some(node.parent);
76
+ return None;
77
+ }
78
+ function isDoubleNegation(node) {
79
+ if (node.operator !== "!") return false;
80
+ if (node.parent.type !== AST_NODE_TYPES.UnaryExpression) return false;
81
+ if (node.parent.operator !== "!") return false;
82
+ return true;
83
+ }
84
+ function isBooleanCall(node) {
85
+ if (node.callee.type !== AST_NODE_TYPES.Identifier) return false;
86
+ if (node.callee.name !== "Boolean") return false;
87
+ return true;
88
+ }
89
+
90
+ //#endregion
91
+ export { distribute_boolean_casts_default as default };
@@ -0,0 +1,31 @@
1
+ import { _default } from "./distribute-boolean-casts.mjs";
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";
25
+
26
+ //#region lib/rules/index.d.ts
27
+ 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" };
29
+ }
30
+ //#endregion
31
+ export { index_d_exports };
@@ -0,0 +1,56 @@
1
+ import { __export } from "../_virtual/rolldown_runtime.mjs";
2
+ import distribute_boolean_casts_default from "./distribute-boolean-casts.mjs";
3
+ import no_constant_template_expression_default from "./no-constant-template-expression.mjs";
4
+ import no_duplicated_return_default from "./no-duplicated-return.mjs";
5
+ import no_else_break_default from "./no-else-break.mjs";
6
+ import no_else_continue_default from "./no-else-continue.mjs";
7
+ import no_else_throw_default from "./no-else-throw.mjs";
8
+ import no_empty_comment_default from "./no-empty-comment.mjs";
9
+ import no_empty_jsx_expression_default from "./no-empty-jsx-expression.mjs";
10
+ import no_extra_false_fallback_default from "./no-extra-false-fallback.mjs";
11
+ import no_extra_nested_boolean_cast_default from "./no-extra-nested-boolean-cast.mjs";
12
+ import no_invalid_date_literal_default from "./no-invalid-date-literal.mjs";
13
+ import no_jsx_statement_default from "./no-jsx-statement.mjs";
14
+ import no_optional_type_guard_param_default from "./no-optional-type-guard-param.mjs";
15
+ import no_return_to_void_default from "./no-return-to-void.mjs";
16
+ import no_suspicious_jsx_semicolon_default from "./no-suspicious-jsx-semicolon.mjs";
17
+ import no_ternary_return_default from "./no-ternary-return.mjs";
18
+ import no_useless_iife_default from "./no-useless-iife.mjs";
19
+ import no_useless_logical_fallback_default from "./no-useless-logical-fallback.mjs";
20
+ import no_useless_return_undefined_default from "./no-useless-return-undefined.mjs";
21
+ import no_whitespace_property_default from "./no-whitespace-property.mjs";
22
+ import prefer_catch_method_default from "./prefer-catch-method.mjs";
23
+ import prefer_early_return_default from "./prefer-early-return.mjs";
24
+ import prefer_repeat_default from "./prefer-repeat.mjs";
25
+ import unsafe_asserted_chain_default from "./unsafe-asserted-chain.mjs";
26
+
27
+ //#region lib/rules/index.ts
28
+ var rules_exports = /* @__PURE__ */ __export({
29
+ "distribute-boolean-casts": () => distribute_boolean_casts_default,
30
+ "no-constant-template-expression": () => no_constant_template_expression_default,
31
+ "no-duplicated-return": () => no_duplicated_return_default,
32
+ "no-else-break": () => no_else_break_default,
33
+ "no-else-continue": () => no_else_continue_default,
34
+ "no-else-throw": () => no_else_throw_default,
35
+ "no-empty-comment": () => no_empty_comment_default,
36
+ "no-empty-jsx-expression": () => no_empty_jsx_expression_default,
37
+ "no-extra-false-fallback": () => no_extra_false_fallback_default,
38
+ "no-extra-nested-boolean-cast": () => no_extra_nested_boolean_cast_default,
39
+ "no-invalid-date-literal": () => no_invalid_date_literal_default,
40
+ "no-jsx-statement": () => no_jsx_statement_default,
41
+ "no-optional-type-guard-param": () => no_optional_type_guard_param_default,
42
+ "no-return-to-void": () => no_return_to_void_default,
43
+ "no-suspicious-jsx-semicolon": () => no_suspicious_jsx_semicolon_default,
44
+ "no-ternary-return": () => no_ternary_return_default,
45
+ "no-useless-iife": () => no_useless_iife_default,
46
+ "no-useless-logical-fallback": () => no_useless_logical_fallback_default,
47
+ "no-useless-return-undefined": () => no_useless_return_undefined_default,
48
+ "no-whitespace-property": () => no_whitespace_property_default,
49
+ "prefer-catch-method": () => prefer_catch_method_default,
50
+ "prefer-early-return": () => prefer_early_return_default,
51
+ "prefer-repeat": () => prefer_repeat_default,
52
+ "unsafe-asserted-chain": () => unsafe_asserted_chain_default
53
+ });
54
+
55
+ //#endregion
56
+ export { rules_exports };
@@ -1,4 +1,4 @@
1
- import { WyrmPluginDocs } from "../utils/createRule.js";
1
+ import { WyrmPluginDocs } from "../utils/createRule.mjs";
2
2
  import { ESLintUtils } from "@typescript-eslint/utils";
3
3
 
4
4
  //#region lib/rules/no-constant-template-expression.d.ts
@@ -1,8 +1,25 @@
1
- import { createRule } from "../utils/createRule.js";
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
4
 
5
5
  //#region lib/rules/no-constant-template-expression.ts
6
+ /**
7
+ * @fileoverview
8
+ *
9
+ * It is sometimes clearer to inline interpolated expressions when their values are constant:
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const foo = 'foobar';
14
+ * const str = `${foo}_baz`;
15
+ * // This would be clearer as:
16
+ * const str = 'foobar_baz';
17
+ * ```
18
+ *
19
+ * By default, this rule allows constant values when they take up at least 10 characters.
20
+ * This can be configured with the `minAllowedLength` option.
21
+ *
22
+ */
6
23
  const { name } = path.parse(import.meta.filename);
7
24
  const DEFAULT_MIN_ALLOWED_LENGTH = 10;
8
25
  var no_constant_template_expression_default = createRule({
@@ -30,8 +47,6 @@ var no_constant_template_expression_default = createRule({
30
47
  defaultOptions: [{ minAllowedLength: DEFAULT_MIN_ALLOWED_LENGTH }],
31
48
  create(context, [options]) {
32
49
  return { TemplateLiteral(node) {
33
- const services = ESLintUtils.getParserServices(context);
34
- const checker = services.program.getTypeChecker();
35
50
  const { expressions, quasis } = node;
36
51
  if (quasis.some((quasi) => quasi.value.cooked.includes(" "))) return;
37
52
  const scope = context.sourceCode.getScope(node);
@@ -45,6 +60,8 @@ var no_constant_template_expression_default = createRule({
45
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;
46
61
  }
47
62
  }
63
+ const services = ESLintUtils.getParserServices(context);
64
+ const checker = services.program.getTypeChecker();
48
65
  const value = getLiteralValue(services.getTypeAtLocation(expr), checker);
49
66
  if (value === null) continue;
50
67
  if (value.length >= options.minAllowedLength) return;
@@ -55,14 +72,19 @@ var no_constant_template_expression_default = createRule({
55
72
  suggest: [{
56
73
  messageId: "replaceByString",
57
74
  data: { value },
58
- fix(fixer) {
75
+ *fix(fixer) {
59
76
  const [identStart, identEnd] = expr.range;
60
77
  const previousQuasi = quasis.toReversed().find((quasi) => quasi.range[1] <= identStart);
61
78
  const nextQuasi = quasis.find((quasi) => quasi.range[0] >= identEnd);
62
- const start = previousQuasi?.range[1] ?? node.range[0];
63
- const end = nextQuasi?.range[0] ?? node.range[1];
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];
64
86
  const range = [start - 2, end + 1];
65
- return fixer.replaceTextRange(range, value);
87
+ yield fixer.replaceTextRange(range, value);
66
88
  }
67
89
  }]
68
90
  });
@@ -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-duplicated-return.d.ts
5
+ declare const _default: _typescript_eslint_utils_ts_eslint3.RuleModule<"noDuplicatedReturn", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint3.RuleListener>;
6
+ //#endregion
7
+ export { _default };
@@ -0,0 +1,96 @@
1
+ import { createRule } from "../utils/createRule.mjs";
2
+ import path from "node:path";
3
+ import { AST_NODE_TYPES, AST_TOKEN_TYPES } from "@typescript-eslint/utils";
4
+
5
+ //#region lib/rules/no-duplicated-return.ts
6
+ const { name } = path.parse(import.meta.filename);
7
+ var no_duplicated_return_default = createRule({
8
+ name,
9
+ meta: {
10
+ type: "suggestion",
11
+ docs: {
12
+ description: "Forbid duplicated branches with early returns",
13
+ recommended: true
14
+ },
15
+ schema: [],
16
+ messages: { noDuplicatedReturn: "Both branches do the same thing" }
17
+ },
18
+ defaultOptions: [],
19
+ create(context) {
20
+ function getTokensForStatements(stmts) {
21
+ return normalizeStatements(stmts).flatMap((stmt) => context.sourceCode.getTokens(stmt));
22
+ }
23
+ function compareStatementLists(a, b) {
24
+ return compareTokens(getTokensForStatements(a), getTokensForStatements(b));
25
+ }
26
+ function compareStatements(a, b) {
27
+ return compareStatementLists(getStatements(a), getStatements(b));
28
+ }
29
+ function checkStatements(ifStatement, subsequentStatements) {
30
+ if (ifStatement.alternate) return;
31
+ if (!alwaysReturns(ifStatement.consequent)) return;
32
+ if (!compareStatements(ifStatement.consequent, subsequentStatements)) return;
33
+ context.report({
34
+ node: ifStatement,
35
+ messageId: "noDuplicatedReturn"
36
+ });
37
+ const lastStatement = subsequentStatements.at(-1);
38
+ /* v8 ignore else -- @preserve */
39
+ if (lastStatement) context.report({
40
+ node: lastStatement,
41
+ messageId: "noDuplicatedReturn"
42
+ });
43
+ }
44
+ function checkBody(node) {
45
+ if (node.body.type !== AST_NODE_TYPES.BlockStatement) return;
46
+ const { body } = node.body;
47
+ for (const stmt of body) {
48
+ if (stmt.type !== AST_NODE_TYPES.IfStatement) continue;
49
+ checkStatements(stmt, body.slice(body.indexOf(stmt) + 1));
50
+ }
51
+ }
52
+ return {
53
+ FunctionDeclaration: checkBody,
54
+ FunctionExpression: checkBody,
55
+ ArrowFunctionExpression: checkBody
56
+ };
57
+ }
58
+ });
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
+ function normalizeStatements(stmts) {
74
+ return stmts.flatMap((stmt) => {
75
+ if (stmt.type === AST_NODE_TYPES.ReturnStatement && stmt.argument === null) return [];
76
+ return [stmt];
77
+ });
78
+ }
79
+ function getStatements(stmt) {
80
+ if (Array.isArray(stmt)) return stmt;
81
+ if (stmt.type === AST_NODE_TYPES.BlockStatement) return stmt.body;
82
+ return [stmt];
83
+ }
84
+ function alwaysReturns(stmt) {
85
+ if (stmt == null) return true;
86
+ if (stmt.type === AST_NODE_TYPES.ReturnStatement) return true;
87
+ if (stmt.type === AST_NODE_TYPES.BlockStatement) return stmt.body.some((s) => alwaysReturns(s));
88
+ if (stmt.type === AST_NODE_TYPES.IfStatement) return alwaysReturns(stmt.consequent) && alwaysReturns(stmt.alternate);
89
+ if (stmt.type !== AST_NODE_TYPES.TryStatement) return false;
90
+ if (!stmt.finalizer) return alwaysReturns(stmt.block) && alwaysReturns(stmt.handler?.body);
91
+ if (alwaysReturns(stmt.finalizer)) return true;
92
+ return alwaysReturns(stmt.block) && alwaysReturns(stmt.handler?.body);
93
+ }
94
+
95
+ //#endregion
96
+ export { no_duplicated_return_default as default };
@@ -0,0 +1,7 @@
1
+ import { WyrmPluginDocs } from "../utils/createRule.mjs";
2
+ import * as _typescript_eslint_utils_ts_eslint5 from "@typescript-eslint/utils/ts-eslint";
3
+
4
+ //#region lib/rules/no-else-break.d.ts
5
+ declare const _default: _typescript_eslint_utils_ts_eslint5.RuleModule<"noElseBreak", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint5.RuleListener>;
6
+ //#endregion
7
+ export { _default };
@@ -1,4 +1,4 @@
1
- import { createRule } from "../utils/createRule.js";
1
+ import { createRule } from "../utils/createRule.mjs";
2
2
  import path from "node:path";
3
3
  import { AST_NODE_TYPES } from "@typescript-eslint/utils";
4
4
 
@@ -28,6 +28,7 @@ var no_else_break_default = createRule({
28
28
  messageId: "noElseBreak",
29
29
  *fix(fixer) {
30
30
  const firstToken = context.sourceCode.getTokenBefore(alternate);
31
+ /* v8 ignore else -- @preserve */
31
32
  if (firstToken) yield fixer.remove(firstToken);
32
33
  yield fixer.remove(alternate);
33
34
  if (alternate.type === AST_NODE_TYPES.BlockStatement) {
@@ -0,0 +1,7 @@
1
+ import { WyrmPluginDocs } from "../utils/createRule.mjs";
2
+ import * as _typescript_eslint_utils_ts_eslint7 from "@typescript-eslint/utils/ts-eslint";
3
+
4
+ //#region lib/rules/no-else-continue.d.ts
5
+ declare const _default: _typescript_eslint_utils_ts_eslint7.RuleModule<"noElseContinue", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint7.RuleListener>;
6
+ //#endregion
7
+ export { _default };
@@ -1,4 +1,4 @@
1
- import { createRule } from "../utils/createRule.js";
1
+ import { createRule } from "../utils/createRule.mjs";
2
2
  import path from "node:path";
3
3
  import { AST_NODE_TYPES } from "@typescript-eslint/utils";
4
4
 
@@ -28,6 +28,7 @@ var no_else_continue_default = createRule({
28
28
  messageId: "noElseContinue",
29
29
  *fix(fixer) {
30
30
  const firstToken = context.sourceCode.getTokenBefore(alternate);
31
+ /* v8 ignore else -- @preserve */
31
32
  if (firstToken) yield fixer.remove(firstToken);
32
33
  yield fixer.remove(alternate);
33
34
  if (alternate.type === AST_NODE_TYPES.BlockStatement) {
@@ -0,0 +1,7 @@
1
+ import { WyrmPluginDocs } from "../utils/createRule.mjs";
2
+ import * as _typescript_eslint_utils_ts_eslint1 from "@typescript-eslint/utils/ts-eslint";
3
+
4
+ //#region lib/rules/no-else-throw.d.ts
5
+ declare const _default: _typescript_eslint_utils_ts_eslint1.RuleModule<"noElseThrow", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint1.RuleListener>;
6
+ //#endregion
7
+ export { _default };
@@ -1,4 +1,4 @@
1
- import { createRule } from "../utils/createRule.js";
1
+ import { createRule } from "../utils/createRule.mjs";
2
2
  import path from "node:path";
3
3
  import { AST_NODE_TYPES } from "@typescript-eslint/utils";
4
4
 
@@ -28,6 +28,7 @@ var no_else_throw_default = createRule({
28
28
  messageId: "noElseThrow",
29
29
  *fix(fixer) {
30
30
  const firstToken = context.sourceCode.getTokenBefore(alternate);
31
+ /* v8 ignore else -- @preserve */
31
32
  if (firstToken) yield fixer.remove(firstToken);
32
33
  yield fixer.remove(alternate);
33
34
  if (alternate.type === AST_NODE_TYPES.BlockStatement) {
@@ -0,0 +1,9 @@
1
+ import { WyrmPluginDocs } from "../utils/createRule.mjs";
2
+ import * as _typescript_eslint_utils_ts_eslint13 from "@typescript-eslint/utils/ts-eslint";
3
+
4
+ //#region lib/rules/no-empty-comment.d.ts
5
+ declare const _default: _typescript_eslint_utils_ts_eslint13.RuleModule<"noEmptyComment", [{
6
+ allowPadding: boolean;
7
+ }], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint13.RuleListener>;
8
+ //#endregion
9
+ export { _default };