eslint-plugin-wyrm 0.0.11 → 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 +53 -0
- package/README.md +114 -78
- package/bin/wyrm.mjs +3 -0
- package/dist/_virtual/_rolldown/runtime.mjs +7 -13
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +23 -0
- package/dist/configs/index.mjs +1 -3
- package/dist/index.mjs +1 -3
- 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 +3 -3
- package/dist/rules/e.mjs +4 -3
- 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 +2 -2
- package/dist/rules/exact-string-regex.mjs +1 -3
- package/dist/rules/export-using.mjs +1 -3
- package/dist/rules/generic-constructor-with-hook.d.mts +3 -3
- package/dist/rules/generic-constructor-with-hook.mjs +1 -3
- package/dist/rules/idiomatic-cast.mjs +6 -8
- package/dist/rules/index.d.mts +112 -77
- package/dist/rules/index.mjs +71 -3
- 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 +3 -3
- package/dist/rules/named-export-with-side-effects.mjs +1 -3
- 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 +2 -2
- package/dist/rules/no-commented-out-comment.mjs +1 -3
- package/dist/rules/no-constant-template-expression.mjs +9 -6
- package/dist/rules/no-constructed-error-cause.d.mts +2 -2
- package/dist/rules/no-constructed-error-cause.mjs +1 -3
- 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 -2
- 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 +1 -3
- package/dist/rules/no-else-break.d.mts +2 -2
- package/dist/rules/no-else-break.mjs +1 -3
- package/dist/rules/no-else-continue.d.mts +2 -2
- package/dist/rules/no-else-continue.mjs +1 -3
- 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 -2
- package/dist/rules/no-else-return.mjs +1 -3
- package/dist/rules/no-else-throw.d.mts +2 -2
- package/dist/rules/no-else-throw.mjs +1 -3
- 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 -2
- package/dist/rules/no-extra-false-fallback.mjs +1 -3
- package/dist/rules/no-extra-nested-boolean-cast.d.mts +2 -2
- 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 -4
- 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 +3 -3
- package/dist/rules/no-huge-useeffect.mjs +1 -3
- package/dist/rules/no-if-length-for.d.mts +2 -2
- package/dist/rules/no-if-length-for.mjs +1 -3
- 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 +1 -3
- 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.mjs +7 -9
- package/dist/rules/no-lax-return-type.mjs +7 -8
- package/dist/rules/no-mutable-literal-fill.d.mts +2 -2
- 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 +9 -12
- package/dist/rules/no-optional-type-guard-param.d.mts +2 -2
- 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 +3 -8
- package/dist/rules/no-possibly-nullish-equality.mjs +6 -12
- 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 +1 -3
- 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 -2
- package/dist/rules/no-sloppy-length-check.mjs +25 -27
- package/dist/rules/no-suspicious-jsx-semicolon.d.mts +2 -2
- package/dist/rules/no-suspicious-jsx-semicolon.mjs +2 -4
- package/dist/rules/no-ternary-return.d.mts +3 -3
- 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.mjs +10 -15
- 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.mjs +7 -12
- package/dist/rules/no-useless-return-undefined.mjs +1 -3
- package/dist/rules/no-useless-ts-check.d.mts +2 -2
- package/dist/rules/no-useless-ts-check.mjs +1 -3
- 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 +1 -3
- 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 +2 -2
- package/dist/rules/nullish-object-spread.mjs +7 -6
- package/dist/rules/optional-call-expression.d.mts +2 -2
- package/dist/rules/optional-call-expression.mjs +1 -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 +2 -3
- package/dist/rules/prefer-early-return.d.mts +2 -2
- package/dist/rules/prefer-early-return.mjs +1 -3
- 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 +2 -2
- package/dist/rules/prefer-finally.mjs +1 -3
- package/dist/rules/prefer-getorinsert.d.mts +2 -2
- package/dist/rules/prefer-getorinsert.mjs +1 -3
- package/dist/rules/prefer-has.d.mts +2 -2
- package/dist/rules/prefer-has.mjs +1 -3
- 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 +2 -2
- package/dist/rules/prefer-object-keys-values.mjs +1 -3
- package/dist/rules/prefer-repeat.d.mts +2 -2
- package/dist/rules/prefer-repeat.mjs +1 -3
- 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 +2 -2
- package/dist/rules/slim-try.mjs +9 -11
- 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.mjs +5 -7
- 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 +1 -3
- package/dist/rules/useless-mock.d.mts +9 -0
- package/dist/rules/useless-mock.mjs +180 -0
- package/dist/rules/useless-required.mjs +10 -12
- 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 +1 -2
- package/package.json +29 -23
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createRule } from "../utils/createRule.mjs";
|
|
2
|
-
import { None, Some } from "../utils/option.mjs";
|
|
3
2
|
import { compareTokens } from "../utils/compareTokens.mjs";
|
|
3
|
+
import { None, Some } from "../utils/option.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
6
|
-
|
|
7
6
|
//#region lib/rules/no-first-last.ts
|
|
8
7
|
const { name } = path.parse(import.meta.filename);
|
|
9
8
|
var no_first_last_default = createRule({
|
|
@@ -165,6 +164,5 @@ var no_first_last_default = createRule({
|
|
|
165
164
|
};
|
|
166
165
|
}
|
|
167
166
|
});
|
|
168
|
-
|
|
169
167
|
//#endregion
|
|
170
|
-
export { no_first_last_default as default };
|
|
168
|
+
export { no_first_last_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-float-length-check.d.ts
|
|
5
|
-
declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"noFloatLengthCheck", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noFloatLengthCheck", [], 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-float-length-check.ts
|
|
6
5
|
const { name } = path.parse(import.meta.filename);
|
|
7
6
|
var no_float_length_check_default = createRule({
|
|
@@ -36,6 +35,5 @@ var no_float_length_check_default = createRule({
|
|
|
36
35
|
} };
|
|
37
36
|
}
|
|
38
37
|
});
|
|
39
|
-
|
|
40
38
|
//#endregion
|
|
41
|
-
export { no_float_length_check_default as default };
|
|
39
|
+
export { no_float_length_check_default as default };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-huge-try-block.d.ts
|
|
5
|
-
declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"noHugeTryBlock" | "noHugeCatchBlock" | "noHugeFinallyBlock", [{
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noHugeTryBlock" | "noHugeCatchBlock" | "noHugeFinallyBlock", [{
|
|
6
6
|
maxTryLines: number;
|
|
7
7
|
maxCatchLines: number;
|
|
8
8
|
maxFinallyLines: number;
|
|
9
|
-
}], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
9
|
+
}], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
10
10
|
name: string;
|
|
11
11
|
};
|
|
12
12
|
//#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-huge-try-block.ts
|
|
5
4
|
const { name } = path.parse(import.meta.filename);
|
|
6
5
|
const DEFAULT_MAX_TRY_LINES = 20;
|
|
@@ -66,6 +65,5 @@ var no_huge_try_block_default = createRule({
|
|
|
66
65
|
} };
|
|
67
66
|
}
|
|
68
67
|
});
|
|
69
|
-
|
|
70
68
|
//#endregion
|
|
71
|
-
export { no_huge_try_block_default as default };
|
|
69
|
+
export { no_huge_try_block_default as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-huge-useeffect.d.ts
|
|
5
|
-
declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"noHugeUseEffect", [{
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noHugeUseEffect", [{
|
|
6
6
|
maxNbLines: number;
|
|
7
|
-
}], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
7
|
+
}], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
8
8
|
name: string;
|
|
9
9
|
};
|
|
10
10
|
//#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-huge-useeffect.ts
|
|
6
5
|
const { name } = path.parse(import.meta.filename);
|
|
7
6
|
const DEFAULT_MAX_LINES = 20;
|
|
@@ -49,6 +48,5 @@ function isUseEffect(node) {
|
|
|
49
48
|
if (node.callee.property.name !== hookName) return false;
|
|
50
49
|
return true;
|
|
51
50
|
}
|
|
52
|
-
|
|
53
51
|
//#endregion
|
|
54
|
-
export { no_huge_useeffect_default as default };
|
|
52
|
+
export { no_huge_useeffect_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-if-length-for.d.ts
|
|
5
|
-
declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"noIfLengthFor", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noIfLengthFor", [], 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 { None, Option, Some, getFirstOption } from "../utils/option.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-if-length-for.ts
|
|
7
6
|
const { name } = path.parse(import.meta.filename);
|
|
8
7
|
var no_if_length_for_default = createRule({
|
|
@@ -88,6 +87,5 @@ function getUniqueStatement(stmt) {
|
|
|
88
87
|
if (stmt.body.length !== 1) return None;
|
|
89
88
|
return Option.fromUndef(stmt.body[0]);
|
|
90
89
|
}
|
|
91
|
-
|
|
92
90
|
//#endregion
|
|
93
|
-
export { no_if_length_for_default as default };
|
|
91
|
+
export { no_if_length_for_default as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-inline-jsdoc-tag.d.ts
|
|
5
|
-
declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"noInlineJsDocTags", [{
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noInlineJsDocTags", [{
|
|
6
6
|
tags: string[];
|
|
7
|
-
}], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
7
|
+
}], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
8
8
|
name: string;
|
|
9
9
|
};
|
|
10
10
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createRule } from "../utils/createRule.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { AST_TOKEN_TYPES } from "@typescript-eslint/utils";
|
|
4
|
-
|
|
5
4
|
//#region lib/rules/no-inline-jsdoc-tag.ts
|
|
6
5
|
const { name } = path.parse(import.meta.filename);
|
|
7
6
|
const DEFAULT_ADDITIONAL_JSDOC_TAGS = [];
|
|
@@ -150,6 +149,5 @@ function getJsDocTags() {
|
|
|
150
149
|
"yields"
|
|
151
150
|
];
|
|
152
151
|
}
|
|
153
|
-
|
|
154
152
|
//#endregion
|
|
155
|
-
export { no_inline_jsdoc_tag_default as default };
|
|
153
|
+
export { no_inline_jsdoc_tag_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-invalid-date-literal.d.ts
|
|
5
|
-
declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"noInvalidDateLiteral", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noInvalidDateLiteral", [], 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-invalid-date-literal.ts
|
|
6
5
|
const { name } = path.parse(import.meta.filename);
|
|
7
6
|
var no_invalid_date_literal_default = createRule({
|
|
@@ -90,6 +89,5 @@ function isValidDateLiteral(literal) {
|
|
|
90
89
|
const value = new Date(literal).valueOf();
|
|
91
90
|
return !Number.isNaN(value);
|
|
92
91
|
}
|
|
93
|
-
|
|
94
92
|
//#endregion
|
|
95
|
-
export { no_invalid_date_literal_default as default };
|
|
93
|
+
export { no_invalid_date_literal_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-jsx-statement.d.ts
|
|
5
|
-
declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"noJsxExpressionStatement", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noJsxExpressionStatement", [], 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-jsx-statement.ts
|
|
6
5
|
const { name } = path.parse(import.meta.filename);
|
|
7
6
|
var no_jsx_statement_default = createRule({
|
|
@@ -26,6 +25,5 @@ var no_jsx_statement_default = createRule({
|
|
|
26
25
|
} };
|
|
27
26
|
}
|
|
28
27
|
});
|
|
29
|
-
|
|
30
28
|
//#endregion
|
|
31
|
-
export { no_jsx_statement_default as default };
|
|
29
|
+
export { no_jsx_statement_default as default };
|
|
@@ -1,8 +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";
|
|
5
|
-
|
|
4
|
+
import * as ts$1 from "typescript";
|
|
6
5
|
//#region lib/rules/no-lax-array-type.ts
|
|
7
6
|
const { name } = path.parse(import.meta.filename);
|
|
8
7
|
var no_lax_array_type_default = createRule({
|
|
@@ -96,15 +95,15 @@ function getArrayElementsTypeNodes(arrayTypeNode) {
|
|
|
96
95
|
return getUnionTypeNodes(innerTypeNode);
|
|
97
96
|
}
|
|
98
97
|
function getUnionTypeNodes(type) {
|
|
99
|
-
if (ts.isParenthesizedTypeNode(type)) return getUnionTypeNodes(type.type);
|
|
100
|
-
if (ts.isUnionTypeNode(type)) return [...type.types];
|
|
98
|
+
if (ts$1.isParenthesizedTypeNode(type)) return getUnionTypeNodes(type.type);
|
|
99
|
+
if (ts$1.isUnionTypeNode(type)) return [...type.types];
|
|
101
100
|
return [];
|
|
102
101
|
}
|
|
103
102
|
/** Extract the inner type node from an Array type node */
|
|
104
103
|
function getArrayTypeNode(arrayTypeNode) {
|
|
105
|
-
if (ts.isArrayTypeNode(arrayTypeNode)) return arrayTypeNode.elementType;
|
|
106
|
-
if (!ts.isTypeReferenceNode(arrayTypeNode)) return null;
|
|
107
|
-
if (!ts.isIdentifier(arrayTypeNode.typeName)) return null;
|
|
104
|
+
if (ts$1.isArrayTypeNode(arrayTypeNode)) return arrayTypeNode.elementType;
|
|
105
|
+
if (!ts$1.isTypeReferenceNode(arrayTypeNode)) return null;
|
|
106
|
+
if (!ts$1.isIdentifier(arrayTypeNode.typeName)) return null;
|
|
108
107
|
if (arrayTypeNode.typeName.escapedText.toString() !== "Array") return null;
|
|
109
108
|
const [typeArgNode] = arrayTypeNode.typeArguments ?? [];
|
|
110
109
|
if (!typeArgNode) return null;
|
|
@@ -126,6 +125,5 @@ function isPossiblyMutatingReference(ref, id) {
|
|
|
126
125
|
"unshift"
|
|
127
126
|
].includes(ref.identifier.parent.property.name);
|
|
128
127
|
}
|
|
129
|
-
|
|
130
128
|
//#endregion
|
|
131
|
-
export { no_lax_array_type_default as default };
|
|
129
|
+
export { no_lax_array_type_default as default };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createRule } from "../utils/createRule.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
4
|
-
import * as ts from "typescript";
|
|
5
|
-
|
|
4
|
+
import * as ts$1 from "typescript";
|
|
6
5
|
//#region lib/rules/no-lax-return-type.ts
|
|
7
6
|
const { name } = path.parse(import.meta.filename);
|
|
8
7
|
var no_lax_return_type_default = createRule({
|
|
@@ -53,7 +52,7 @@ var no_lax_return_type_default = createRule({
|
|
|
53
52
|
}
|
|
54
53
|
function checkReturnTypeNode(returnTypeNode, inferredReturnTypes) {
|
|
55
54
|
const returnType = getChecker().getTypeFromTypeNode(returnTypeNode);
|
|
56
|
-
if (returnType.flags & ts.TypeFlags.Conditional) return;
|
|
55
|
+
if (returnType.flags & ts$1.TypeFlags.Conditional) return;
|
|
57
56
|
if (inferredReturnTypes.some((inferredReturnType) => isAssignableTo(inferredReturnType, returnType))) return;
|
|
58
57
|
const estreeNode = getServices().tsNodeToESTreeNodeMap.get(returnTypeNode);
|
|
59
58
|
const typeAsString = returnTypeNode.getText();
|
|
@@ -82,6 +81,7 @@ var no_lax_return_type_default = createRule({
|
|
|
82
81
|
}
|
|
83
82
|
function checkFunction(node) {
|
|
84
83
|
if (!node.returnType) return;
|
|
84
|
+
if (node.generator) return;
|
|
85
85
|
if (node.parent.type === AST_NODE_TYPES.MethodDefinition) return;
|
|
86
86
|
const inferredReturnTypes = inferAllReturnTypes(node.body, node.async);
|
|
87
87
|
if (!inferredReturnTypes.length) return;
|
|
@@ -102,7 +102,7 @@ function getUnionTypeNodes(type, async) {
|
|
|
102
102
|
if (!promiseTypeNode) return [];
|
|
103
103
|
return getUnionTypeNodes(promiseTypeNode, false);
|
|
104
104
|
}
|
|
105
|
-
if (ts.isUnionTypeNode(type)) return [...type.types];
|
|
105
|
+
if (ts$1.isUnionTypeNode(type)) return [...type.types];
|
|
106
106
|
return [type];
|
|
107
107
|
}
|
|
108
108
|
function getAllReturnStatements(stmt) {
|
|
@@ -127,13 +127,12 @@ function getAllReturnStatements(stmt) {
|
|
|
127
127
|
}
|
|
128
128
|
/** Extract the inner type node from a Promise type node */
|
|
129
129
|
function getPromiseTypeNode(returnTypeNode) {
|
|
130
|
-
if (!ts.isTypeReferenceNode(returnTypeNode)) return null;
|
|
131
|
-
if (!ts.isIdentifier(returnTypeNode.typeName)) return null;
|
|
130
|
+
if (!ts$1.isTypeReferenceNode(returnTypeNode)) return null;
|
|
131
|
+
if (!ts$1.isIdentifier(returnTypeNode.typeName)) return null;
|
|
132
132
|
if (returnTypeNode.typeName.escapedText.toString() !== "Promise") return null;
|
|
133
133
|
const [typeArgNode] = returnTypeNode.typeArguments ?? [];
|
|
134
134
|
if (!typeArgNode) return null;
|
|
135
135
|
return typeArgNode;
|
|
136
136
|
}
|
|
137
|
-
|
|
138
137
|
//#endregion
|
|
139
|
-
export { no_lax_return_type_default as default };
|
|
138
|
+
export { no_lax_return_type_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-mutable-literal-fill.d.ts
|
|
5
|
-
declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"noMutableLiteralFill", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noMutableLiteralFill", [], 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-mutable-literal-fill.ts
|
|
6
5
|
/**
|
|
7
6
|
* @fileoverview
|
|
@@ -61,6 +60,5 @@ function isMutableLiteral(expr) {
|
|
|
61
60
|
default: return false;
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
|
-
|
|
65
63
|
//#endregion
|
|
66
|
-
export { no_mutable_literal_fill_default as default };
|
|
64
|
+
export { no_mutable_literal_fill_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-nullish-ternary.d.ts
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noNullishTernary", [], WyrmPluginDocs, _$_typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { _default };
|
|
@@ -0,0 +1,121 @@
|
|
|
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 } from "@typescript-eslint/utils";
|
|
5
|
+
//#region lib/rules/no-nullish-ternary.ts
|
|
6
|
+
const { name } = path.parse(import.meta.filename);
|
|
7
|
+
var no_nullish_ternary_default = createRule({
|
|
8
|
+
name,
|
|
9
|
+
meta: {
|
|
10
|
+
type: "suggestion",
|
|
11
|
+
docs: {
|
|
12
|
+
description: "Forbid ternary conditions that can be replaced by optional chains",
|
|
13
|
+
recommended: true
|
|
14
|
+
},
|
|
15
|
+
fixable: "code",
|
|
16
|
+
schema: [],
|
|
17
|
+
messages: { noNullishTernary: "Replace this ternary condition by optional chaining" }
|
|
18
|
+
},
|
|
19
|
+
defaultOptions: [],
|
|
20
|
+
create(context) {
|
|
21
|
+
return { ConditionalExpression(node) {
|
|
22
|
+
const maybeTestResult = analyzeTest(node.test);
|
|
23
|
+
if (!maybeTestResult.some) return;
|
|
24
|
+
const testResult = maybeTestResult.value;
|
|
25
|
+
switch (testResult.kind) {
|
|
26
|
+
case TestKind.TRUTHY:
|
|
27
|
+
checkTernary(testResult.ident, node.consequent, node.alternate);
|
|
28
|
+
break;
|
|
29
|
+
case TestKind.FALSY:
|
|
30
|
+
checkTernary(testResult.ident, node.alternate, node.consequent);
|
|
31
|
+
break;
|
|
32
|
+
default: {
|
|
33
|
+
const check = testResult.kind;
|
|
34
|
+
console.error(`[wyrm] Unexpected test kind: ${check}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function checkTernary(ident, consequent, alternate) {
|
|
38
|
+
if (!isUndefinedLiteral(alternate)) return;
|
|
39
|
+
if (consequent.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
40
|
+
if (consequent.object.type !== AST_NODE_TYPES.Identifier) return;
|
|
41
|
+
if (consequent.object.name !== ident.name) return;
|
|
42
|
+
context.report({
|
|
43
|
+
node,
|
|
44
|
+
messageId: "noNullishTernary",
|
|
45
|
+
fix(fixer) {
|
|
46
|
+
const objTxt = context.sourceCode.getText(consequent.object);
|
|
47
|
+
const propTxt = context.sourceCode.getText(consequent.property);
|
|
48
|
+
const txt = consequent.computed ? `${objTxt}?.[${propTxt}]` : `${objTxt}?.${propTxt}`;
|
|
49
|
+
return fixer.replaceText(node, txt);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
} };
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
function isUndefinedLiteral(node) {
|
|
57
|
+
return node.type === AST_NODE_TYPES.Identifier && node.name === "undefined";
|
|
58
|
+
}
|
|
59
|
+
var TestKind = /* @__PURE__ */ function(TestKind) {
|
|
60
|
+
TestKind["TRUTHY"] = "TRUTHY";
|
|
61
|
+
TestKind["FALSY"] = "FALSY";
|
|
62
|
+
return TestKind;
|
|
63
|
+
}(TestKind || {});
|
|
64
|
+
function analyzeTest(test) {
|
|
65
|
+
switch (test.type) {
|
|
66
|
+
case AST_NODE_TYPES.Identifier: return Some({
|
|
67
|
+
kind: TestKind.TRUTHY,
|
|
68
|
+
ident: test
|
|
69
|
+
});
|
|
70
|
+
case AST_NODE_TYPES.BinaryExpression: return getFirstOption([analyzeEqualityCheck(test, test.left, test.right), analyzeEqualityCheck(test, test.right, test.left)]);
|
|
71
|
+
case AST_NODE_TYPES.UnaryExpression:
|
|
72
|
+
if (test.operator !== "!") return None;
|
|
73
|
+
if (test.argument.type === AST_NODE_TYPES.Identifier) return Some({
|
|
74
|
+
kind: TestKind.FALSY,
|
|
75
|
+
ident: test.argument
|
|
76
|
+
});
|
|
77
|
+
return None;
|
|
78
|
+
default: return None;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function analyzeEqualityCheck(node, left, right) {
|
|
82
|
+
switch (node.operator) {
|
|
83
|
+
case "!=":
|
|
84
|
+
case "!==": {
|
|
85
|
+
const kind = TestKind.TRUTHY;
|
|
86
|
+
if (left.type === AST_NODE_TYPES.Identifier && right.type === AST_NODE_TYPES.Literal && right.value === null) return Some({
|
|
87
|
+
ident: left,
|
|
88
|
+
kind
|
|
89
|
+
});
|
|
90
|
+
if (left.type === AST_NODE_TYPES.Identifier && right.type === AST_NODE_TYPES.Identifier && right.name === "undefined") return Some({
|
|
91
|
+
ident: left,
|
|
92
|
+
kind
|
|
93
|
+
});
|
|
94
|
+
if (left.type === AST_NODE_TYPES.UnaryExpression && left.operator === "typeof" && right.type === AST_NODE_TYPES.Literal && right.value === "undefined" && left.argument.type === AST_NODE_TYPES.Identifier) return Some({
|
|
95
|
+
ident: left.argument,
|
|
96
|
+
kind
|
|
97
|
+
});
|
|
98
|
+
return None;
|
|
99
|
+
}
|
|
100
|
+
case "==":
|
|
101
|
+
case "===": {
|
|
102
|
+
const kind = TestKind.FALSY;
|
|
103
|
+
if (left.type === AST_NODE_TYPES.Identifier && right.type === AST_NODE_TYPES.Literal && right.value === null) return Some({
|
|
104
|
+
ident: left,
|
|
105
|
+
kind
|
|
106
|
+
});
|
|
107
|
+
if (left.type === AST_NODE_TYPES.Identifier && right.type === AST_NODE_TYPES.Identifier && right.name === "undefined") return Some({
|
|
108
|
+
ident: left,
|
|
109
|
+
kind
|
|
110
|
+
});
|
|
111
|
+
if (left.type === AST_NODE_TYPES.UnaryExpression && left.operator === "typeof" && right.type === AST_NODE_TYPES.Literal && right.value === "undefined" && left.argument.type === AST_NODE_TYPES.Identifier) return Some({
|
|
112
|
+
ident: left.argument,
|
|
113
|
+
kind
|
|
114
|
+
});
|
|
115
|
+
return None;
|
|
116
|
+
}
|
|
117
|
+
default: return None;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { no_nullish_ternary_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-numbered-comments.d.ts
|
|
5
|
-
declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"noNumberedComment", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noNumberedComment", [], 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-numbered-comments.ts
|
|
5
4
|
const { name } = path.parse(import.meta.filename);
|
|
6
5
|
var no_numbered_comments_default = createRule({
|
|
@@ -31,6 +30,5 @@ var no_numbered_comments_default = createRule({
|
|
|
31
30
|
function isNumberedComment(comment) {
|
|
32
31
|
return /^\d+\. /u.test(comment.value.trim());
|
|
33
32
|
}
|
|
34
|
-
|
|
35
33
|
//#endregion
|
|
36
|
-
export { no_numbered_comments_default as default };
|
|
34
|
+
export { no_numbered_comments_default as default };
|
|
@@ -1,8 +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";
|
|
5
|
-
|
|
4
|
+
import * as ts$1 from "typescript";
|
|
6
5
|
//#region lib/rules/no-obvious-any.ts
|
|
7
6
|
const { name } = path.parse(import.meta.filename);
|
|
8
7
|
var no_obvious_any_default = createRule({
|
|
@@ -73,7 +72,7 @@ var no_obvious_any_default = createRule({
|
|
|
73
72
|
const services = ESLintUtils.getParserServices(context);
|
|
74
73
|
const checker = services.program.getTypeChecker();
|
|
75
74
|
const types = args.map((arg) => services.getTypeAtLocation(arg));
|
|
76
|
-
if (types.some((t) => t.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Never))) return null;
|
|
75
|
+
if (types.some((t) => t.flags & (ts$1.TypeFlags.Any | ts$1.TypeFlags.Unknown | ts$1.TypeFlags.Never))) return null;
|
|
77
76
|
const typesAsStrings = types.map((widened) => checker.getBaseTypeOfLiteralType(widened)).map((widened) => checker.typeToString(widened));
|
|
78
77
|
return [...new Set(typesAsStrings)].join(" | ");
|
|
79
78
|
}
|
|
@@ -96,7 +95,7 @@ var no_obvious_any_default = createRule({
|
|
|
96
95
|
return;
|
|
97
96
|
}
|
|
98
97
|
const type = ESLintUtils.getParserServices(context).getTypeAtLocation(node.init);
|
|
99
|
-
if (type.flags & ts.TypeFlags.NumberLike) {
|
|
98
|
+
if (type.flags & ts$1.TypeFlags.NumberLike) {
|
|
100
99
|
const inferredType = "number";
|
|
101
100
|
context.report({
|
|
102
101
|
node,
|
|
@@ -108,7 +107,7 @@ var no_obvious_any_default = createRule({
|
|
|
108
107
|
});
|
|
109
108
|
return;
|
|
110
109
|
}
|
|
111
|
-
if (type.flags & ts.TypeFlags.StringLike) {
|
|
110
|
+
if (type.flags & ts$1.TypeFlags.StringLike) {
|
|
112
111
|
const inferredType = "string";
|
|
113
112
|
context.report({
|
|
114
113
|
node,
|
|
@@ -120,7 +119,7 @@ var no_obvious_any_default = createRule({
|
|
|
120
119
|
});
|
|
121
120
|
return;
|
|
122
121
|
}
|
|
123
|
-
if (type.flags & ts.TypeFlags.BooleanLike) {
|
|
122
|
+
if (type.flags & ts$1.TypeFlags.BooleanLike) {
|
|
124
123
|
const inferredType = "boolean";
|
|
125
124
|
context.report({
|
|
126
125
|
node,
|
|
@@ -147,13 +146,11 @@ function getFunctionName(node) {
|
|
|
147
146
|
if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) return null;
|
|
148
147
|
if (node.parent.id.type !== AST_NODE_TYPES.Identifier) return null;
|
|
149
148
|
return node.parent.id;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
console.error(`[wyrm] Unexpected node type: ${
|
|
149
|
+
/* v8 ignore next -- @preserve */
|
|
150
|
+
default:
|
|
151
|
+
console.error(`[wyrm] Unexpected node type: ${nodeType}`);
|
|
153
152
|
return null;
|
|
154
|
-
}
|
|
155
153
|
}
|
|
156
154
|
}
|
|
157
|
-
|
|
158
155
|
//#endregion
|
|
159
|
-
export { no_obvious_any_default as default };
|
|
156
|
+
export { no_obvious_any_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-optional-type-guard-param.d.ts
|
|
5
|
-
declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"optionalTypeGuardParam", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"optionalTypeGuardParam", [], 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-optional-type-guard-param.ts
|
|
6
5
|
/**
|
|
7
6
|
* @fileoverview
|
|
@@ -67,6 +66,5 @@ var no_optional_type_guard_param_default = createRule({
|
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
68
|
});
|
|
70
|
-
|
|
71
69
|
//#endregion
|
|
72
|
-
export { no_optional_type_guard_param_default as default };
|
|
70
|
+
export { no_optional_type_guard_param_default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WyrmPluginDocs } from "../utils/createRule.mjs";
|
|
2
|
-
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
2
|
+
import * as _$_typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
4
|
//#region lib/rules/no-out-of-order-comments.d.ts
|
|
5
|
-
declare const _default: _typescript_eslint_utils_ts_eslint0.RuleModule<"noOutOfOrderComments", [], WyrmPluginDocs, _typescript_eslint_utils_ts_eslint0.RuleListener> & {
|
|
5
|
+
declare const _default: _$_typescript_eslint_utils_ts_eslint0.RuleModule<"noOutOfOrderComments", [], 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 { None, Some } from "../utils/option.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
|
|
5
4
|
//#region lib/rules/no-out-of-order-comments.ts
|
|
6
5
|
const { name } = path.parse(import.meta.filename);
|
|
7
6
|
var no_out_of_order_comments_default = createRule({
|
|
@@ -37,16 +36,12 @@ var no_out_of_order_comments_default = createRule({
|
|
|
37
36
|
}
|
|
38
37
|
});
|
|
39
38
|
function getCommentNumber(comment) {
|
|
40
|
-
const plainBulletPointResult = /^(?<number>\d+)[.:] /u.exec(comment.value.trim());
|
|
41
|
-
const prefixResult = /^\w+ (?<number>\d+)[.:] /u.exec(comment.value.trim());
|
|
42
|
-
if (!plainBulletPointResult && !prefixResult) return None;
|
|
39
|
+
const plainBulletPointResult = /^(?<number>\d+)\s*[.:)-] /u.exec(comment.value.trim());
|
|
40
|
+
const prefixResult = /^\w+ (?<number>\d+)\s*[.:)-] /u.exec(comment.value.trim());
|
|
43
41
|
const capture = plainBulletPointResult?.groups?.["number"] ?? prefixResult?.groups?.["number"];
|
|
44
|
-
/* v8 ignore if -- @preserve */
|
|
45
|
-
if (capture === void 0) return None;
|
|
46
42
|
const n = Number(capture);
|
|
47
43
|
if (!Number.isFinite(n)) return None;
|
|
48
44
|
return Some(n);
|
|
49
45
|
}
|
|
50
|
-
|
|
51
46
|
//#endregion
|
|
52
|
-
export { no_out_of_order_comments_default as default };
|
|
47
|
+
export { no_out_of_order_comments_default as default };
|