eslint-plugin-wyrm 0.0.10 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/README.md +114 -58
- package/bin/wyrm.mjs +3 -0
- package/dist/_virtual/_rolldown/runtime.mjs +14 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +23 -0
- package/dist/configs/index.d.mts +2 -1
- package/dist/configs/index.mjs +6 -6
- package/dist/index.mjs +1 -4
- package/dist/plugin.mjs +1 -3
- package/dist/rules/array-from-array.d.mts +9 -0
- package/dist/rules/array-from-array.mjs +56 -0
- package/dist/rules/as-unknown-as.d.mts +9 -0
- package/dist/rules/as-unknown-as.mjs +30 -0
- package/dist/rules/await-promise-resolve.d.mts +9 -0
- package/dist/rules/await-promise-resolve.mjs +41 -0
- package/dist/rules/boolean-coalescing.d.mts +9 -0
- package/dist/rules/boolean-coalescing.mjs +141 -0
- package/dist/rules/comment-duplicate-leading-space.d.mts +9 -0
- package/dist/rules/comment-duplicate-leading-space.mjs +34 -0
- package/dist/rules/conditional-boolean.d.mts +9 -0
- package/dist/rules/conditional-boolean.mjs +70 -0
- package/dist/rules/constant-boolean-cast.d.mts +9 -0
- package/dist/rules/constant-boolean-cast.mjs +203 -0
- package/dist/rules/de-morgan.d.mts +2 -2
- package/dist/rules/de-morgan.mjs +1 -3
- package/dist/rules/discarded-expression-statement.d.mts +14 -0
- package/dist/rules/discarded-expression-statement.mjs +243 -0
- package/dist/rules/distribute-boolean-casts.d.mts +2 -2
- package/dist/rules/distribute-boolean-casts.mjs +3 -3
- package/dist/rules/duplicate-destructuring.d.mts +2 -2
- package/dist/rules/duplicate-destructuring.mjs +1 -3
- package/dist/rules/duplicate-object-spread.d.mts +9 -0
- package/dist/rules/duplicate-object-spread.mjs +44 -0
- package/dist/rules/e.d.mts +11 -0
- package/dist/rules/e.mjs +87 -0
- package/dist/rules/empty-for.d.mts +9 -0
- package/dist/rules/empty-for.mjs +34 -0
- package/dist/rules/enum-member.d.mts +9 -0
- package/dist/rules/enum-member.mjs +51 -0
- package/dist/rules/eqeq-null.d.mts +9 -0
- package/dist/rules/eqeq-null.mjs +101 -0
- package/dist/rules/exact-string-regex.d.mts +9 -0
- package/dist/rules/exact-string-regex.mjs +83 -0
- package/dist/rules/export-using.d.mts +9 -0
- package/dist/rules/export-using.mjs +58 -0
- package/dist/rules/generic-constructor-with-hook.d.mts +11 -0
- package/dist/rules/generic-constructor-with-hook.mjs +103 -0
- package/dist/rules/idiomatic-cast.mjs +7 -10
- package/dist/rules/index.d.mts +112 -57
- package/dist/rules/index.mjs +113 -5
- package/dist/rules/inferable-type-predicate.d.mts +9 -0
- package/dist/rules/inferable-type-predicate.mjs +100 -0
- package/dist/rules/inner-as-const.d.mts +9 -0
- package/dist/rules/inner-as-const.mjs +70 -0
- package/dist/rules/jsx-tostring.d.mts +9 -0
- package/dist/rules/jsx-tostring.mjs +120 -0
- package/dist/rules/literal-destructuring.d.mts +9 -0
- package/dist/rules/literal-destructuring.mjs +102 -0
- package/dist/rules/named-export-with-side-effects.d.mts +11 -0
- package/dist/rules/named-export-with-side-effects.mjs +72 -0
- package/dist/rules/nested-reduce.d.mts +9 -0
- package/dist/rules/nested-reduce.mjs +46 -0
- package/dist/rules/nested-try-catch.d.mts +9 -0
- package/dist/rules/nested-try-catch.mjs +37 -0
- package/dist/rules/no-commented-out-comment.d.mts +9 -0
- package/dist/rules/no-commented-out-comment.mjs +31 -0
- package/dist/rules/no-constant-template-expression.d.mts +3 -4
- package/dist/rules/no-constant-template-expression.mjs +12 -9
- package/dist/rules/no-constructed-error-cause.d.mts +9 -0
- package/dist/rules/no-constructed-error-cause.mjs +75 -0
- package/dist/rules/no-convoluted-boolean-expressions.d.mts +9 -0
- package/dist/rules/no-convoluted-boolean-expressions.mjs +130 -0
- package/dist/rules/no-convoluted-logical-expressions.d.mts +2 -2
- package/dist/rules/no-convoluted-logical-expressions.mjs +1 -3
- package/dist/rules/no-custom-url-parsing.d.mts +2 -3
- package/dist/rules/no-custom-url-parsing.mjs +1 -3
- package/dist/rules/no-disallowed-warning-comments.d.mts +2 -2
- package/dist/rules/no-disallowed-warning-comments.mjs +1 -3
- package/dist/rules/no-duplicated-return.d.mts +2 -2
- package/dist/rules/no-duplicated-return.mjs +2 -3
- package/dist/rules/no-else-break.d.mts +2 -2
- package/dist/rules/no-else-break.mjs +3 -5
- package/dist/rules/no-else-continue.d.mts +2 -2
- package/dist/rules/no-else-continue.mjs +3 -5
- package/dist/rules/no-else-never.d.mts +9 -0
- package/dist/rules/no-else-never.mjs +75 -0
- package/dist/rules/no-else-return.d.mts +2 -3
- package/dist/rules/no-else-return.mjs +4 -5
- package/dist/rules/no-else-throw.d.mts +2 -2
- package/dist/rules/no-else-throw.mjs +3 -5
- package/dist/rules/no-empty-attribute.d.mts +3 -3
- package/dist/rules/no-empty-attribute.mjs +1 -3
- package/dist/rules/no-empty-comment.d.mts +3 -3
- package/dist/rules/no-empty-comment.mjs +1 -3
- package/dist/rules/no-empty-jsx-expression.d.mts +2 -2
- package/dist/rules/no-empty-jsx-expression.mjs +1 -3
- package/dist/rules/no-empty-literal-iteration.d.mts +2 -2
- package/dist/rules/no-empty-literal-iteration.mjs +1 -3
- package/dist/rules/no-extra-false-fallback.d.mts +2 -3
- package/dist/rules/no-extra-false-fallback.mjs +1 -3
- package/dist/rules/no-extra-nested-boolean-cast.d.mts +2 -3
- package/dist/rules/no-extra-nested-boolean-cast.mjs +2 -3
- package/dist/rules/no-first-last.d.mts +2 -2
- package/dist/rules/no-first-last.mjs +2 -5
- package/dist/rules/no-float-length-check.d.mts +2 -2
- package/dist/rules/no-float-length-check.mjs +1 -3
- package/dist/rules/no-huge-try-block.d.mts +3 -3
- package/dist/rules/no-huge-try-block.mjs +1 -3
- package/dist/rules/no-huge-useeffect.d.mts +11 -0
- package/dist/rules/no-huge-useeffect.mjs +52 -0
- package/dist/rules/no-if-length-for.d.mts +9 -0
- package/dist/rules/no-if-length-for.mjs +91 -0
- package/dist/rules/no-inline-jsdoc-tag.d.mts +3 -3
- package/dist/rules/no-inline-jsdoc-tag.mjs +1 -3
- package/dist/rules/no-invalid-date-literal.d.mts +2 -2
- package/dist/rules/no-invalid-date-literal.mjs +42 -19
- package/dist/rules/no-jsx-statement.d.mts +2 -2
- package/dist/rules/no-jsx-statement.mjs +1 -3
- package/dist/rules/no-lax-array-type.d.mts +9 -0
- package/dist/rules/no-lax-array-type.mjs +129 -0
- package/dist/rules/no-lax-return-type.d.mts +9 -0
- package/dist/rules/no-lax-return-type.mjs +138 -0
- package/dist/rules/no-mutable-literal-fill.d.mts +2 -3
- package/dist/rules/no-mutable-literal-fill.mjs +1 -3
- package/dist/rules/no-nullish-ternary.d.mts +9 -0
- package/dist/rules/no-nullish-ternary.mjs +121 -0
- package/dist/rules/no-numbered-comments.d.mts +2 -2
- package/dist/rules/no-numbered-comments.mjs +1 -3
- package/dist/rules/no-obvious-any.mjs +35 -27
- package/dist/rules/no-optional-type-guard-param.d.mts +2 -3
- package/dist/rules/no-optional-type-guard-param.mjs +1 -3
- package/dist/rules/no-out-of-order-comments.d.mts +2 -2
- package/dist/rules/no-out-of-order-comments.mjs +4 -8
- package/dist/rules/no-possibly-nullish-equality.d.mts +0 -1
- package/dist/rules/no-possibly-nullish-equality.mjs +6 -13
- package/dist/rules/no-redundant-function-declaration.d.mts +2 -2
- package/dist/rules/no-redundant-function-declaration.mjs +1 -3
- package/dist/rules/no-return-to-void.mjs +2 -4
- package/dist/rules/no-self-object-assign.d.mts +2 -2
- package/dist/rules/no-self-object-assign.mjs +1 -3
- package/dist/rules/no-sloppy-length-check.d.mts +2 -3
- package/dist/rules/no-sloppy-length-check.mjs +35 -37
- package/dist/rules/no-suspicious-jsx-semicolon.d.mts +2 -3
- package/dist/rules/no-suspicious-jsx-semicolon.mjs +2 -4
- package/dist/rules/no-ternary-return.d.mts +3 -4
- package/dist/rules/no-ternary-return.mjs +1 -3
- package/dist/rules/no-type-guard.d.mts +9 -0
- package/dist/rules/no-type-guard.mjs +36 -0
- package/dist/rules/no-unassigned-todo.d.mts +2 -2
- package/dist/rules/no-unassigned-todo.mjs +1 -3
- package/dist/rules/no-unbound-catch-error.d.mts +2 -2
- package/dist/rules/no-unbound-catch-error.mjs +1 -3
- package/dist/rules/no-unused-mutually-referential.d.mts +9 -0
- package/dist/rules/no-unused-mutually-referential.mjs +215 -0
- package/dist/rules/no-unused-param-read.d.mts +2 -2
- package/dist/rules/no-unused-param-read.mjs +1 -3
- package/dist/rules/no-useless-computed-key.d.mts +2 -2
- package/dist/rules/no-useless-computed-key.mjs +1 -3
- package/dist/rules/no-useless-iife.d.mts +2 -2
- package/dist/rules/no-useless-iife.mjs +2 -3
- package/dist/rules/no-useless-logical-fallback.d.mts +0 -1
- package/dist/rules/no-useless-logical-fallback.mjs +32 -24
- package/dist/rules/no-useless-return-undefined.mjs +11 -11
- package/dist/rules/no-useless-ts-check.d.mts +9 -0
- package/dist/rules/no-useless-ts-check.mjs +34 -0
- package/dist/rules/no-useless-use-strict.d.mts +2 -2
- package/dist/rules/no-useless-use-strict.mjs +1 -3
- package/dist/rules/no-useless-usememo.d.mts +2 -2
- package/dist/rules/no-useless-usememo.mjs +8 -6
- package/dist/rules/no-whitespace-property.d.mts +2 -2
- package/dist/rules/no-whitespace-property.mjs +1 -3
- package/dist/rules/nullish-object-spread.d.mts +9 -0
- package/dist/rules/nullish-object-spread.mjs +38 -0
- package/dist/rules/optional-call-expression.d.mts +2 -2
- package/dist/rules/optional-call-expression.mjs +20 -3
- package/dist/rules/prefer-array-from.d.mts +9 -0
- package/dist/rules/prefer-array-from.mjs +87 -0
- package/dist/rules/prefer-catch-method.d.mts +2 -2
- package/dist/rules/prefer-catch-method.mjs +9 -12
- package/dist/rules/prefer-early-return.d.mts +2 -2
- package/dist/rules/prefer-early-return.mjs +23 -20
- package/dist/rules/prefer-eqeq-null.d.mts +9 -0
- package/dist/rules/prefer-eqeq-null.mjs +122 -0
- package/dist/rules/prefer-finally.d.mts +9 -0
- package/dist/rules/prefer-finally.mjs +129 -0
- package/dist/rules/prefer-getorinsert.d.mts +9 -0
- package/dist/rules/prefer-getorinsert.mjs +180 -0
- package/dist/rules/prefer-has.d.mts +9 -0
- package/dist/rules/prefer-has.mjs +69 -0
- package/dist/rules/prefer-in.d.mts +9 -0
- package/dist/rules/prefer-in.mjs +81 -0
- package/dist/rules/prefer-object-keys-values.d.mts +9 -0
- package/dist/rules/prefer-object-keys-values.mjs +78 -0
- package/dist/rules/prefer-repeat.d.mts +2 -2
- package/dist/rules/prefer-repeat.mjs +1 -5
- package/dist/rules/prefer-satisfies.d.mts +9 -0
- package/dist/rules/prefer-satisfies.mjs +86 -0
- package/dist/rules/prefer-string-join.d.mts +9 -0
- package/dist/rules/prefer-string-join.mjs +67 -0
- package/dist/rules/primitive-valueof.mjs +6 -8
- package/dist/rules/slim-try.d.mts +9 -0
- package/dist/rules/slim-try.mjs +150 -0
- package/dist/rules/styled-button-has-type.d.mts +9 -0
- package/dist/rules/styled-button-has-type.mjs +82 -0
- package/dist/rules/styled-transient-props.d.mts +9 -0
- package/dist/rules/styled-transient-props.mjs +52 -0
- package/dist/rules/suspicious-map-length.d.mts +2 -2
- package/dist/rules/suspicious-map-length.mjs +1 -3
- package/dist/rules/template-tostring.d.mts +9 -0
- package/dist/rules/template-tostring.mjs +48 -0
- package/dist/rules/unsafe-asserted-chain.d.mts +0 -1
- package/dist/rules/unsafe-asserted-chain.mjs +5 -8
- package/dist/rules/unused-object-assign.d.mts +2 -2
- package/dist/rules/unused-object-assign.mjs +1 -3
- package/dist/rules/unused-object-freeze.d.mts +9 -0
- package/dist/rules/unused-object-freeze.mjs +37 -0
- package/dist/rules/useless-as-const.d.mts +9 -0
- package/dist/rules/useless-as-const.mjs +59 -0
- package/dist/rules/useless-assign.d.mts +11 -0
- package/dist/rules/useless-assign.mjs +69 -0
- package/dist/rules/useless-conditional-assign.d.mts +9 -0
- package/dist/rules/useless-conditional-assign.mjs +58 -0
- package/dist/rules/useless-intermediary-variable.mjs +18 -21
- package/dist/rules/useless-mock.d.mts +9 -0
- package/dist/rules/useless-mock.mjs +180 -0
- package/dist/rules/useless-required.d.mts +9 -0
- package/dist/rules/useless-required.mjs +257 -0
- package/dist/utils/compareTokens.mjs +1 -3
- package/dist/utils/createRule.mjs +1 -3
- package/dist/utils/negateExpression.mjs +1 -3
- package/dist/utils/option.mjs +5 -2
- package/package.json +30 -23
- package/dist/_virtual/rolldown_runtime.mjs +0 -20
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createRule } from "../utils/createRule.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
4
|
+
//#region lib/rules/named-export-with-side-effects.ts
|
|
5
|
+
const { name } = path.parse(import.meta.filename);
|
|
6
|
+
const DEFAULT_STRICT = false;
|
|
7
|
+
var named_export_with_side_effects_default = createRule({
|
|
8
|
+
name,
|
|
9
|
+
meta: {
|
|
10
|
+
type: "problem",
|
|
11
|
+
docs: {
|
|
12
|
+
description: "Forbid named exports in files with side effects",
|
|
13
|
+
recommended: true
|
|
14
|
+
},
|
|
15
|
+
schema: [{
|
|
16
|
+
type: "object",
|
|
17
|
+
additionalProperties: false,
|
|
18
|
+
properties: { strict: {
|
|
19
|
+
type: "boolean",
|
|
20
|
+
description: `Whether to consider call expressions as possible side effects. Default: \`${DEFAULT_STRICT}\``
|
|
21
|
+
} }
|
|
22
|
+
}],
|
|
23
|
+
messages: { namedExportWithSideEffects: "When exports from this file are imported, this might also be executed. Make sure this is expected." }
|
|
24
|
+
},
|
|
25
|
+
defaultOptions: [{ strict: DEFAULT_STRICT }],
|
|
26
|
+
create(context, [options]) {
|
|
27
|
+
return { Program(node) {
|
|
28
|
+
let hasNamedExports = false;
|
|
29
|
+
const sideEffects = [];
|
|
30
|
+
for (const stmt of node.body) {
|
|
31
|
+
if (stmt.type === AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
32
|
+
hasNamedExports = true;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (isSideEffect(stmt, options.strict)) sideEffects.push(stmt);
|
|
36
|
+
}
|
|
37
|
+
if (!hasNamedExports) return;
|
|
38
|
+
for (const sideEffect of sideEffects) context.report({
|
|
39
|
+
node: sideEffect,
|
|
40
|
+
messageId: "namedExportWithSideEffects"
|
|
41
|
+
});
|
|
42
|
+
} };
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
function isSideEffect(stmt, strict) {
|
|
46
|
+
switch (stmt.type) {
|
|
47
|
+
case AST_NODE_TYPES.BreakStatement:
|
|
48
|
+
case AST_NODE_TYPES.ContinueStatement:
|
|
49
|
+
case AST_NODE_TYPES.DebuggerStatement:
|
|
50
|
+
case AST_NODE_TYPES.DoWhileStatement:
|
|
51
|
+
case AST_NODE_TYPES.SwitchStatement:
|
|
52
|
+
case AST_NODE_TYPES.ForStatement:
|
|
53
|
+
case AST_NODE_TYPES.ForInStatement:
|
|
54
|
+
case AST_NODE_TYPES.ForOfStatement:
|
|
55
|
+
case AST_NODE_TYPES.ThrowStatement:
|
|
56
|
+
case AST_NODE_TYPES.TryStatement:
|
|
57
|
+
case AST_NODE_TYPES.WhileStatement: return true;
|
|
58
|
+
case AST_NODE_TYPES.BlockStatement: return stmt.body.some((s) => isSideEffect(s, strict));
|
|
59
|
+
case AST_NODE_TYPES.IfStatement:
|
|
60
|
+
if (stmt.alternate && isSideEffect(stmt.alternate, strict)) return true;
|
|
61
|
+
return isSideEffect(stmt.consequent, strict);
|
|
62
|
+
case AST_NODE_TYPES.ExpressionStatement: switch (stmt.expression.type) {
|
|
63
|
+
case AST_NODE_TYPES.AwaitExpression:
|
|
64
|
+
case AST_NODE_TYPES.UpdateExpression: return true;
|
|
65
|
+
case AST_NODE_TYPES.CallExpression: return strict;
|
|
66
|
+
default: return false;
|
|
67
|
+
}
|
|
68
|
+
default: return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { named_export_with_side_effects_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
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/nested-reduce.d.ts
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noNestedReduce", [], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createRule } from "../utils/createRule.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
4
|
+
//#region lib/rules/nested-reduce.ts
|
|
5
|
+
const { name } = path.parse(import.meta.filename);
|
|
6
|
+
var nested_reduce_default = createRule({
|
|
7
|
+
name,
|
|
8
|
+
meta: {
|
|
9
|
+
type: "suggestion",
|
|
10
|
+
docs: {
|
|
11
|
+
description: "Forbid nested `reduce` calls",
|
|
12
|
+
strict: true
|
|
13
|
+
},
|
|
14
|
+
schema: [],
|
|
15
|
+
messages: { noNestedReduce: "Refactor to avoid nesting `reduce` calls." }
|
|
16
|
+
},
|
|
17
|
+
defaultOptions: [],
|
|
18
|
+
create(context) {
|
|
19
|
+
return { CallExpression(node) {
|
|
20
|
+
if (!isReduceCall(node)) return;
|
|
21
|
+
if (!isInsideReduceCall(node)) return;
|
|
22
|
+
context.report({
|
|
23
|
+
node: node.callee,
|
|
24
|
+
messageId: "noNestedReduce"
|
|
25
|
+
});
|
|
26
|
+
} };
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
function isReduceCall(expr) {
|
|
30
|
+
if (expr.callee.type !== AST_NODE_TYPES.MemberExpression) return false;
|
|
31
|
+
if (expr.callee.property.type !== AST_NODE_TYPES.Identifier) return false;
|
|
32
|
+
return expr.callee.property.name === "reduce";
|
|
33
|
+
}
|
|
34
|
+
function isInsideReduceCall(node) {
|
|
35
|
+
if (!node.parent) return false;
|
|
36
|
+
switch (node.parent.type) {
|
|
37
|
+
case AST_NODE_TYPES.FunctionDeclaration: return false;
|
|
38
|
+
case AST_NODE_TYPES.CallExpression:
|
|
39
|
+
if (isReduceCall(node.parent)) return true;
|
|
40
|
+
break;
|
|
41
|
+
default: break;
|
|
42
|
+
}
|
|
43
|
+
return isInsideReduceCall(node.parent);
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { nested_reduce_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
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/nested-try-catch.d.ts
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noNestedTryCatch", [], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createRule } from "../utils/createRule.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
4
|
+
//#region lib/rules/nested-try-catch.ts
|
|
5
|
+
const { name } = path.parse(import.meta.filename);
|
|
6
|
+
var nested_try_catch_default = createRule({
|
|
7
|
+
name,
|
|
8
|
+
meta: {
|
|
9
|
+
type: "suggestion",
|
|
10
|
+
docs: {
|
|
11
|
+
description: "Forbid nested try/catch statements",
|
|
12
|
+
strict: true
|
|
13
|
+
},
|
|
14
|
+
schema: [],
|
|
15
|
+
messages: { noNestedTryCatch: "Refactor to avoid nesting try/catch statements." }
|
|
16
|
+
},
|
|
17
|
+
defaultOptions: [],
|
|
18
|
+
create(context) {
|
|
19
|
+
return { TryStatement(node) {
|
|
20
|
+
if (node.parent.type !== AST_NODE_TYPES.BlockStatement) return;
|
|
21
|
+
switch (node.parent.parent.type) {
|
|
22
|
+
case AST_NODE_TYPES.TryStatement:
|
|
23
|
+
case AST_NODE_TYPES.CatchClause: {
|
|
24
|
+
const token = context.sourceCode.getFirstToken(node);
|
|
25
|
+
context.report({
|
|
26
|
+
node: token ?? node,
|
|
27
|
+
messageId: "noNestedTryCatch"
|
|
28
|
+
});
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
default: break;
|
|
32
|
+
}
|
|
33
|
+
} };
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
//#endregion
|
|
37
|
+
export { nested_try_catch_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
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/no-commented-out-comment.d.ts
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"commentedOutComment", [], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _default };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createRule } from "../utils/createRule.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
//#region lib/rules/no-commented-out-comment.ts
|
|
4
|
+
const { name } = path.parse(import.meta.filename);
|
|
5
|
+
var no_commented_out_comment_default = createRule({
|
|
6
|
+
name,
|
|
7
|
+
meta: {
|
|
8
|
+
type: "problem",
|
|
9
|
+
docs: {
|
|
10
|
+
description: "Forbid commented out comments",
|
|
11
|
+
recommended: true
|
|
12
|
+
},
|
|
13
|
+
schema: [],
|
|
14
|
+
messages: { commentedOutComment: "This looks like a commented out comment. Make sure this is expected." }
|
|
15
|
+
},
|
|
16
|
+
defaultOptions: [],
|
|
17
|
+
create(context) {
|
|
18
|
+
if (typeof context.sourceCode.getAllComments === "undefined") return {};
|
|
19
|
+
const comments = context.sourceCode.getAllComments();
|
|
20
|
+
for (const comment of comments) checkComment(comment);
|
|
21
|
+
return {};
|
|
22
|
+
function checkComment(comment) {
|
|
23
|
+
if (comment.value.trim().startsWith("//") || comment.value.trim().startsWith("/*")) context.report({
|
|
24
|
+
node: comment,
|
|
25
|
+
messageId: "commentedOutComment"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
export { no_commented_out_comment_default as default };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-constant-template-expression.d.ts
|
|
5
|
-
|
|
6
|
-
declare const _default: TSESLint.RuleModule<"noConstantTemplateExpression" | "replaceByString", [{
|
|
5
|
+
declare const _default: ESLintUtils.RuleModule<"noConstantTemplateExpression" | "replaceByString", [{
|
|
7
6
|
minAllowedLength: number;
|
|
8
|
-
}], WyrmPluginDocs,
|
|
7
|
+
}], WyrmPluginDocs, ESLintUtils.RuleListener> & {
|
|
9
8
|
name: string;
|
|
10
9
|
};
|
|
11
10
|
//#endregion
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createRule } from "../utils/createRule.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { ASTUtils, AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
4
|
-
import * as ts from "typescript";
|
|
5
|
-
|
|
3
|
+
import { ASTUtils, AST_NODE_TYPES, ESLintUtils, TSESLint } from "@typescript-eslint/utils";
|
|
4
|
+
import * as ts$1 from "typescript";
|
|
6
5
|
//#region lib/rules/no-constant-template-expression.ts
|
|
7
6
|
/**
|
|
8
7
|
* @fileoverview
|
|
@@ -55,6 +54,8 @@ var no_constant_template_expression_default = createRule({
|
|
|
55
54
|
if (references.length > 2) return;
|
|
56
55
|
const def = defs.at(-1);
|
|
57
56
|
if (def?.parent?.type === AST_NODE_TYPES.VariableDeclaration && def.parent.parent.type === AST_NODE_TYPES.ExportNamedDeclaration) return;
|
|
57
|
+
if (def?.type !== TSESLint.Scope.DefinitionType.Variable) return;
|
|
58
|
+
if (isNonAlphabeticStringLiteral(def.node)) return;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
const services = ESLintUtils.getParserServices(context);
|
|
@@ -63,7 +64,7 @@ var no_constant_template_expression_default = createRule({
|
|
|
63
64
|
if (value === null) return;
|
|
64
65
|
if (value.length >= options.minAllowedLength) return;
|
|
65
66
|
const sym = services.getSymbolAtLocation(expr);
|
|
66
|
-
if (sym && sym.getFlags() & ts.SymbolFlags.EnumMember && !quasis.some((quasi) => quasi.value.cooked)) return;
|
|
67
|
+
if (sym && sym.getFlags() & ts$1.SymbolFlags.EnumMember && !quasis.some((quasi) => quasi.value.cooked)) return;
|
|
67
68
|
context.report({
|
|
68
69
|
node: expr,
|
|
69
70
|
messageId: "noConstantTemplateExpression",
|
|
@@ -77,7 +78,7 @@ var no_constant_template_expression_default = createRule({
|
|
|
77
78
|
const nextQuasi = quasis.find((quasi) => quasi.range[0] >= identEnd);
|
|
78
79
|
/* v8 ignore if -- @preserve */
|
|
79
80
|
if (!previousQuasi || !nextQuasi) {
|
|
80
|
-
console.error("No previous/next quasi found. This should never happen.");
|
|
81
|
+
console.error("[wyrm] No previous/next quasi found. This should never happen.");
|
|
81
82
|
return;
|
|
82
83
|
}
|
|
83
84
|
const start = previousQuasi.range[1];
|
|
@@ -90,7 +91,8 @@ var no_constant_template_expression_default = createRule({
|
|
|
90
91
|
}
|
|
91
92
|
return { TemplateLiteral(node) {
|
|
92
93
|
const { expressions, quasis } = node;
|
|
93
|
-
if (quasis.some((quasi) => quasi.value.cooked
|
|
94
|
+
if (quasis.some((quasi) => quasi.value.cooked?.includes(" "))) return;
|
|
95
|
+
if (node.parent.type === AST_NODE_TYPES.TaggedTemplateExpression) return;
|
|
94
96
|
const scope = context.sourceCode.getScope(node);
|
|
95
97
|
for (const expr of expressions) checkExpression(expr, quasis, scope);
|
|
96
98
|
} };
|
|
@@ -98,11 +100,12 @@ var no_constant_template_expression_default = createRule({
|
|
|
98
100
|
});
|
|
99
101
|
function getLiteralValue(type, checker) {
|
|
100
102
|
if (type.isStringLiteral()) return type.value;
|
|
101
|
-
if (type.isNumberLiteral()) return type.value.toString();
|
|
102
103
|
if (type === checker.getTrueType()) return "true";
|
|
103
104
|
if (type === checker.getFalseType()) return "false";
|
|
104
105
|
return null;
|
|
105
106
|
}
|
|
106
|
-
|
|
107
|
+
function isNonAlphabeticStringLiteral(node) {
|
|
108
|
+
return node.init?.type === AST_NODE_TYPES.Literal && typeof node.init.value === "string" && /[^a-zA-Z]/u.test(node.init.value);
|
|
109
|
+
}
|
|
107
110
|
//#endregion
|
|
108
|
-
export { no_constant_template_expression_default as default };
|
|
111
|
+
export { no_constant_template_expression_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
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/no-constructed-error-cause.d.ts
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noConstructedErrorCause", [], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _default };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createRule } from "../utils/createRule.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
4
|
+
//#region lib/rules/no-constructed-error-cause.ts
|
|
5
|
+
/**
|
|
6
|
+
* @fileoverview
|
|
7
|
+
*
|
|
8
|
+
* The `Error.cause` property is used to wrap a previously caught error in a new instantiated error:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* try {
|
|
12
|
+
* // ...
|
|
13
|
+
* } catch (err) {
|
|
14
|
+
* throw Error('New error message', { cause: err });
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* But sometimes it can also be used as a way to store additional information on `Error` objects:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* throw Error('Division by zero', { cause: { code: 'division_by_zero' } });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* This second pattern is what this rule forbids. Custom errors should be used instead:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* class ZeroDivisionError extends Error {
|
|
28
|
+
* public override message = 'Division by zero';
|
|
29
|
+
* public code = 'division_by_zero';
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* throw new ZeroDivisionError();
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
const { name } = path.parse(import.meta.filename);
|
|
36
|
+
var no_constructed_error_cause_default = createRule({
|
|
37
|
+
name,
|
|
38
|
+
meta: {
|
|
39
|
+
type: "suggestion",
|
|
40
|
+
docs: {
|
|
41
|
+
description: "Forbid using `Error.cause` with constructed objects",
|
|
42
|
+
strict: true
|
|
43
|
+
},
|
|
44
|
+
schema: [],
|
|
45
|
+
messages: { noConstructedErrorCause: "Error.cause should be used to wrap a caught error, not to include new information" }
|
|
46
|
+
},
|
|
47
|
+
defaultOptions: [],
|
|
48
|
+
create(context) {
|
|
49
|
+
return {
|
|
50
|
+
NewExpression: checkInstantiation,
|
|
51
|
+
CallExpression: checkInstantiation
|
|
52
|
+
};
|
|
53
|
+
function checkInstantiation(node) {
|
|
54
|
+
if (node.callee.type !== AST_NODE_TYPES.Identifier) return;
|
|
55
|
+
if (node.callee.name !== "Error") return;
|
|
56
|
+
const [, options] = node.arguments;
|
|
57
|
+
if (!options) return;
|
|
58
|
+
if (options.type !== AST_NODE_TYPES.ObjectExpression) return;
|
|
59
|
+
const cause = options.properties.filter((prop) => prop.type === AST_NODE_TYPES.Property).find(({ key }) => key.type === AST_NODE_TYPES.Identifier && key.name === "cause")?.value;
|
|
60
|
+
if (!cause) return;
|
|
61
|
+
switch (cause.type) {
|
|
62
|
+
case AST_NODE_TYPES.CallExpression:
|
|
63
|
+
case AST_NODE_TYPES.ObjectExpression:
|
|
64
|
+
case AST_NODE_TYPES.NewExpression: break;
|
|
65
|
+
default: return;
|
|
66
|
+
}
|
|
67
|
+
context.report({
|
|
68
|
+
node,
|
|
69
|
+
messageId: "noConstructedErrorCause"
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
//#endregion
|
|
75
|
+
export { no_constructed_error_cause_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
3
|
+
|
|
4
|
+
//#region lib/rules/no-convoluted-boolean-expressions.d.ts
|
|
5
|
+
declare const _default: ESLintUtils.RuleModule<"noConvolutedLogicalExpression", [], WyrmPluginDocs, ESLintUtils.RuleListener> & {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _default };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createRule } from "../utils/createRule.mjs";
|
|
2
|
+
import { None, Some, getFirstOption } from "../utils/option.mjs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
5
|
+
import * as ts$1 from "typescript";
|
|
6
|
+
//#region lib/rules/no-convoluted-boolean-expressions.ts
|
|
7
|
+
const { name } = path.parse(import.meta.filename);
|
|
8
|
+
var no_convoluted_boolean_expressions_default = createRule({
|
|
9
|
+
name,
|
|
10
|
+
meta: {
|
|
11
|
+
type: "problem",
|
|
12
|
+
docs: {
|
|
13
|
+
description: "Forbid simplifiable logical expressions with boolean types",
|
|
14
|
+
recommended: true,
|
|
15
|
+
requiresTypeChecking: true
|
|
16
|
+
},
|
|
17
|
+
fixable: "code",
|
|
18
|
+
schema: [],
|
|
19
|
+
messages: { noConvolutedLogicalExpression: "This logical expression can be simplified" }
|
|
20
|
+
},
|
|
21
|
+
defaultOptions: [],
|
|
22
|
+
create(context) {
|
|
23
|
+
let services;
|
|
24
|
+
function getServices() {
|
|
25
|
+
services ??= ESLintUtils.getParserServices(context);
|
|
26
|
+
return services;
|
|
27
|
+
}
|
|
28
|
+
return { LogicalExpression(node) {
|
|
29
|
+
if (node.operator === "&&") {
|
|
30
|
+
const maybeXor = getFirstOption([getConvolutedXor(node, node.left, node.right), getConvolutedXor(node, node.right, node.left)]);
|
|
31
|
+
if (!maybeXor.some) return;
|
|
32
|
+
const [a, b] = maybeXor.value;
|
|
33
|
+
if (!(getServices().getTypeAtLocation(a).flags & ts$1.TypeFlags.BooleanLike)) return;
|
|
34
|
+
if (!(getServices().getTypeAtLocation(b).flags & ts$1.TypeFlags.BooleanLike)) return;
|
|
35
|
+
context.report({
|
|
36
|
+
node,
|
|
37
|
+
messageId: "noConvolutedLogicalExpression",
|
|
38
|
+
fix(fixer) {
|
|
39
|
+
return fixer.replaceText(node, `${a.name} !== ${b.name}`);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (node.operator === "||") {
|
|
45
|
+
const maybeOr = getFirstOption([getConvolutedOr(node, node.left, node.right), getConvolutedOr(node, node.right, node.left)]);
|
|
46
|
+
if (!maybeOr.some) return;
|
|
47
|
+
const [a, b] = maybeOr.value;
|
|
48
|
+
if (!(getServices().getTypeAtLocation(a).flags & ts$1.TypeFlags.BooleanLike)) return;
|
|
49
|
+
if (!(getServices().getTypeAtLocation(b).flags & ts$1.TypeFlags.BooleanLike)) return;
|
|
50
|
+
context.report({
|
|
51
|
+
node,
|
|
52
|
+
messageId: "noConvolutedLogicalExpression",
|
|
53
|
+
fix(fixer) {
|
|
54
|
+
return fixer.replaceText(node, `${a.name} || ${b.name}`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
} };
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
function getConvolutedXor(expr, left, right) {
|
|
62
|
+
if (expr.operator !== "&&") return None;
|
|
63
|
+
const maybeOr = getOr(left);
|
|
64
|
+
const maybeNand = getNand(right);
|
|
65
|
+
if (!maybeOr.some) return None;
|
|
66
|
+
if (!maybeNand.some) return None;
|
|
67
|
+
const [maybeOrA, maybeOrB] = maybeOr.value;
|
|
68
|
+
const [maybeNandA, maybeNandB] = maybeNand.value;
|
|
69
|
+
if (maybeOrA.name === maybeNandA.name && maybeOrB.name === maybeNandB.name) return Some([maybeOrA, maybeOrB]);
|
|
70
|
+
if (maybeOrA.name === maybeNandB.name && maybeOrB.name === maybeNandA.name) return Some([maybeOrA, maybeOrB]);
|
|
71
|
+
return None;
|
|
72
|
+
}
|
|
73
|
+
function getOr(expr) {
|
|
74
|
+
if (expr.type !== AST_NODE_TYPES.LogicalExpression) return None;
|
|
75
|
+
if (expr.operator !== "||") return None;
|
|
76
|
+
if (expr.left.type !== AST_NODE_TYPES.Identifier) return None;
|
|
77
|
+
if (expr.right.type !== AST_NODE_TYPES.Identifier) return None;
|
|
78
|
+
return Some([expr.left, expr.right]);
|
|
79
|
+
}
|
|
80
|
+
function getNand(expr) {
|
|
81
|
+
if (expr.type === AST_NODE_TYPES.UnaryExpression) {
|
|
82
|
+
if (expr.operator !== "!") return None;
|
|
83
|
+
return getAnd(expr.argument);
|
|
84
|
+
}
|
|
85
|
+
if (expr.type === AST_NODE_TYPES.LogicalExpression) return getFirstOption([getOrNot(expr, expr.left, expr.right), getOrNot(expr, expr.right, expr.left)]);
|
|
86
|
+
return None;
|
|
87
|
+
}
|
|
88
|
+
function getOrNot(expr, left, right) {
|
|
89
|
+
if (expr.operator !== "||") return None;
|
|
90
|
+
const maybeNotA = getNot(left);
|
|
91
|
+
const maybeNotB = getNot(right);
|
|
92
|
+
if (!maybeNotA.some) return None;
|
|
93
|
+
if (!maybeNotB.some) return None;
|
|
94
|
+
if (maybeNotA.value.type !== AST_NODE_TYPES.Identifier) return None;
|
|
95
|
+
if (maybeNotB.value.type !== AST_NODE_TYPES.Identifier) return None;
|
|
96
|
+
return Some([maybeNotA.value, maybeNotB.value]);
|
|
97
|
+
}
|
|
98
|
+
function getAnd(expr) {
|
|
99
|
+
if (expr.type !== AST_NODE_TYPES.LogicalExpression) return None;
|
|
100
|
+
if (expr.operator !== "&&") return None;
|
|
101
|
+
if (expr.left.type !== AST_NODE_TYPES.Identifier) return None;
|
|
102
|
+
if (expr.right.type !== AST_NODE_TYPES.Identifier) return None;
|
|
103
|
+
return Some([expr.left, expr.right]);
|
|
104
|
+
}
|
|
105
|
+
function getNot(expr) {
|
|
106
|
+
if (expr.type !== AST_NODE_TYPES.UnaryExpression) return None;
|
|
107
|
+
if (expr.operator !== "!") return None;
|
|
108
|
+
return Some(expr.argument);
|
|
109
|
+
}
|
|
110
|
+
function getConvolutedOr(expr, left, right) {
|
|
111
|
+
if (expr.operator !== "||") return None;
|
|
112
|
+
const maybeIneq = getIneq(left);
|
|
113
|
+
const maybeAnd = getAnd(right);
|
|
114
|
+
if (!maybeIneq.some) return None;
|
|
115
|
+
if (!maybeAnd.some) return None;
|
|
116
|
+
const [maybeIneqA, maybeIneqB] = maybeIneq.value;
|
|
117
|
+
const [maybeAndA, maybeAndB] = maybeAnd.value;
|
|
118
|
+
if (maybeIneqA.name === maybeAndA.name && maybeIneqB.name === maybeAndB.name) return Some([maybeIneqA, maybeIneqB]);
|
|
119
|
+
if (maybeIneqA.name === maybeAndB.name && maybeIneqB.name === maybeAndA.name) return Some([maybeIneqA, maybeIneqB]);
|
|
120
|
+
return None;
|
|
121
|
+
}
|
|
122
|
+
function getIneq(expr) {
|
|
123
|
+
if (expr.type !== AST_NODE_TYPES.BinaryExpression) return None;
|
|
124
|
+
if (expr.operator !== "!==" && expr.operator !== "!=") return None;
|
|
125
|
+
if (expr.left.type !== AST_NODE_TYPES.Identifier) return None;
|
|
126
|
+
if (expr.right.type !== AST_NODE_TYPES.Identifier) return None;
|
|
127
|
+
return Some([expr.left, expr.right]);
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { no_convoluted_boolean_expressions_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-convoluted-logical-expressions.d.ts
|
|
5
|
-
declare const _default:
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noConvolutedLogicalExpression", [], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
6
6
|
name: string;
|
|
7
7
|
};
|
|
8
8
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
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
|
-
|
|
5
4
|
//#region lib/rules/no-convoluted-logical-expressions.ts
|
|
6
5
|
const { name } = path.parse(import.meta.filename);
|
|
7
6
|
var no_convoluted_logical_expressions_default = createRule({
|
|
@@ -193,6 +192,5 @@ function isNullishLiteral(node) {
|
|
|
193
192
|
if (node.type === AST_NODE_TYPES.Identifier && node.name === "undefined") return true;
|
|
194
193
|
return false;
|
|
195
194
|
}
|
|
196
|
-
|
|
197
195
|
//#endregion
|
|
198
|
-
export { no_convoluted_logical_expressions_default as default };
|
|
196
|
+
export { no_convoluted_logical_expressions_default as default };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-custom-url-parsing.d.ts
|
|
5
|
-
|
|
6
|
-
declare const _default: _typescript_eslint_utils_ts_eslint7.RuleModule<"noCustomUrlParsing", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint7.RuleListener> & {
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noCustomUrlParsing", [], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
7
6
|
name: string;
|
|
8
7
|
};
|
|
9
8
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
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
|
-
|
|
5
4
|
//#region lib/rules/no-custom-url-parsing.ts
|
|
6
5
|
/**
|
|
7
6
|
* @fileoverview
|
|
@@ -55,6 +54,5 @@ var no_custom_url_parsing_default = createRule({
|
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
56
|
});
|
|
58
|
-
|
|
59
57
|
//#endregion
|
|
60
|
-
export { no_custom_url_parsing_default as default };
|
|
58
|
+
export { no_custom_url_parsing_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-disallowed-warning-comments.d.ts
|
|
5
|
-
declare const _default:
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noDisallowedWarningComment", [], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
6
6
|
name: string;
|
|
7
7
|
};
|
|
8
8
|
//#endregion
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createRule } from "../utils/createRule.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
|
|
4
3
|
//#region lib/rules/no-disallowed-warning-comments.ts
|
|
5
4
|
const { name } = path.parse(import.meta.filename);
|
|
6
5
|
var no_disallowed_warning_comments_default = createRule({
|
|
@@ -81,6 +80,5 @@ function isBadTodo(line) {
|
|
|
81
80
|
function startsWith(line, keywords) {
|
|
82
81
|
return keywords.some((keyword) => line.toLowerCase() === keyword.toLowerCase() || suffixes.some((suffix) => startsWithCaseInsensitive(line, `${keyword}${suffix}`)));
|
|
83
82
|
}
|
|
84
|
-
|
|
85
83
|
//#endregion
|
|
86
|
-
export { no_disallowed_warning_comments_default as default };
|
|
84
|
+
export { no_disallowed_warning_comments_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-duplicated-return.d.ts
|
|
5
|
-
declare const _default:
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noDuplicatedReturn", [], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
6
6
|
name: string;
|
|
7
7
|
};
|
|
8
8
|
//#endregion
|
|
@@ -2,7 +2,6 @@ import { createRule } from "../utils/createRule.mjs";
|
|
|
2
2
|
import { compareTokens } from "../utils/compareTokens.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
5
|
-
|
|
6
5
|
//#region lib/rules/no-duplicated-return.ts
|
|
7
6
|
const { name } = path.parse(import.meta.filename);
|
|
8
7
|
var no_duplicated_return_default = createRule({
|
|
@@ -76,6 +75,7 @@ function alwaysReturns(stmt) {
|
|
|
76
75
|
case AST_NODE_TYPES.IfStatement:
|
|
77
76
|
if (stmt.alternate && !alwaysReturns(stmt.alternate)) return false;
|
|
78
77
|
return alwaysReturns(stmt.consequent);
|
|
78
|
+
case AST_NODE_TYPES.SwitchStatement: return stmt.cases.flatMap((c) => c.consequent).every((c) => alwaysReturns(c));
|
|
79
79
|
case AST_NODE_TYPES.ForInStatement:
|
|
80
80
|
case AST_NODE_TYPES.ForOfStatement:
|
|
81
81
|
case AST_NODE_TYPES.ForStatement:
|
|
@@ -88,6 +88,5 @@ function alwaysReturns(stmt) {
|
|
|
88
88
|
default: return false;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
|
|
92
91
|
//#endregion
|
|
93
|
-
export { no_duplicated_return_default as default };
|
|
92
|
+
export { no_duplicated_return_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-else-break.d.ts
|
|
5
|
-
declare const _default:
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noElseBreak", [], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
6
6
|
name: string;
|
|
7
7
|
};
|
|
8
8
|
//#endregion
|