eslint-plugin-etc-misc 1.1.4 → 1.1.6
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/dist/_internal/casing.js +1 -1
- package/dist/_internal/casing.js.map +1 -1
- package/dist/_internal/create-external-rule.d.ts +2 -1
- package/dist/_internal/create-external-rule.d.ts.map +1 -1
- package/dist/_internal/create-external-rule.js +56 -7
- package/dist/_internal/create-external-rule.js.map +1 -1
- package/dist/_internal/get-core-rule.d.ts +1 -5
- package/dist/_internal/get-core-rule.d.ts.map +1 -1
- package/dist/_internal/get-core-rule.js.map +1 -1
- package/dist/_internal/identifier-blocks.js +3 -3
- package/dist/_internal/import-patterns.d.ts.map +1 -1
- package/dist/_internal/import-patterns.js +6 -5
- package/dist/_internal/import-patterns.js.map +1 -1
- package/dist/_internal/rule-creator.d.ts +7 -7
- package/dist/_internal/rule-creator.d.ts.map +1 -1
- package/dist/_internal/rule-creator.js +2 -1
- package/dist/_internal/rule-creator.js.map +1 -1
- package/dist/_internal/symbol-usage.d.ts.map +1 -1
- package/dist/_internal/symbol-usage.js +15 -14
- package/dist/_internal/symbol-usage.js.map +1 -1
- package/dist/_internal/syntax-selectors.js +1 -1
- package/dist/_internal/syntax-selectors.js.map +1 -1
- package/dist/configs/all-strict.d.ts +2 -2
- package/dist/configs/all-strict.d.ts.map +1 -1
- package/dist/configs/all-strict.js +9 -6
- package/dist/configs/all-strict.js.map +1 -1
- package/dist/configs/all.d.ts +2 -2
- package/dist/configs/all.d.ts.map +1 -1
- package/dist/configs/all.js +9 -3
- package/dist/configs/all.js.map +1 -1
- package/dist/configs/strict-type-checked.d.ts +2 -2
- package/dist/configs/strict-type-checked.d.ts.map +1 -1
- package/dist/configs/strict-type-checked.js +5 -4
- package/dist/configs/strict-type-checked.js.map +1 -1
- package/dist/configs/strict.d.ts +2 -2
- package/dist/configs/strict.d.ts.map +1 -1
- package/dist/configs/strict.js +6 -1
- package/dist/configs/strict.js.map +1 -1
- package/dist/configs.d.ts +7 -6
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/plugin.cjs +633 -540
- package/dist/plugin.cjs.map +3 -3
- package/dist/plugin.d.cts +2 -2
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/rules/class-match-filename.js +3 -3
- package/dist/rules/class-match-filename.js.map +1 -1
- package/dist/rules/comment-spacing.d.ts.map +1 -1
- package/dist/rules/comment-spacing.js +6 -3
- package/dist/rules/comment-spacing.js.map +1 -1
- package/dist/rules/consistent-empty-lines.js +1 -1
- package/dist/rules/consistent-import.d.ts.map +1 -1
- package/dist/rules/consistent-import.js +4 -3
- package/dist/rules/consistent-import.js.map +1 -1
- package/dist/rules/consistent-optional-props.d.ts.map +1 -1
- package/dist/rules/consistent-optional-props.js +3 -2
- package/dist/rules/consistent-optional-props.js.map +1 -1
- package/dist/rules/export-matching-filename-only.d.ts.map +1 -1
- package/dist/rules/export-matching-filename-only.js +13 -14
- package/dist/rules/export-matching-filename-only.js.map +1 -1
- package/dist/rules/match-filename.d.ts.map +1 -1
- package/dist/rules/match-filename.js +4 -3
- package/dist/rules/match-filename.js.map +1 -1
- package/dist/rules/no-assign-mutated-array.d.ts.map +1 -1
- package/dist/rules/no-assign-mutated-array.js +14 -14
- package/dist/rules/no-assign-mutated-array.js.map +1 -1
- package/dist/rules/no-commented-out-code.d.ts.map +1 -1
- package/dist/rules/no-commented-out-code.js +15 -13
- package/dist/rules/no-commented-out-code.js.map +1 -1
- package/dist/rules/no-const-enum.d.ts.map +1 -1
- package/dist/rules/no-const-enum.js +2 -1
- package/dist/rules/no-const-enum.js.map +1 -1
- package/dist/rules/no-expression-empty-lines.js +1 -1
- package/dist/rules/no-foreach.d.ts.map +1 -1
- package/dist/rules/no-foreach.js +2 -2
- package/dist/rules/no-foreach.js.map +1 -1
- package/dist/rules/no-function-declare-after-return.d.ts.map +1 -1
- package/dist/rules/no-function-declare-after-return.js +17 -12
- package/dist/rules/no-function-declare-after-return.js.map +1 -1
- package/dist/rules/no-implicit-any-catch.d.ts.map +1 -1
- package/dist/rules/no-implicit-any-catch.js +8 -7
- package/dist/rules/no-implicit-any-catch.js.map +1 -1
- package/dist/rules/no-misused-generics.d.ts.map +1 -1
- package/dist/rules/no-misused-generics.js +0 -1
- package/dist/rules/no-misused-generics.js.map +1 -1
- package/dist/rules/no-param-reassign.d.ts.map +1 -1
- package/dist/rules/no-param-reassign.js +9 -9
- package/dist/rules/no-param-reassign.js.map +1 -1
- package/dist/rules/no-self-import.js +11 -11
- package/dist/rules/no-self-import.js.map +1 -1
- package/dist/rules/no-shadow.d.ts.map +1 -1
- package/dist/rules/no-shadow.js +2 -1
- package/dist/rules/no-shadow.js.map +1 -1
- package/dist/rules/no-single-line-comment.d.ts.map +1 -1
- package/dist/rules/no-single-line-comment.js +3 -2
- package/dist/rules/no-single-line-comment.js.map +1 -1
- package/dist/rules/no-unnecessary-as-const.d.ts.map +1 -1
- package/dist/rules/no-unnecessary-as-const.js +4 -3
- package/dist/rules/no-unnecessary-as-const.js.map +1 -1
- package/dist/rules/no-unnecessary-break.d.ts.map +1 -1
- package/dist/rules/no-unnecessary-break.js +4 -2
- package/dist/rules/no-unnecessary-break.js.map +1 -1
- package/dist/rules/no-unnecessary-template-literal.d.ts.map +1 -1
- package/dist/rules/no-unnecessary-template-literal.js +3 -2
- package/dist/rules/no-unnecessary-template-literal.js.map +1 -1
- package/dist/rules/no-use-extend-native.d.ts.map +1 -1
- package/dist/rules/no-use-extend-native.js +23 -19
- package/dist/rules/no-use-extend-native.js.map +1 -1
- package/dist/rules/no-vulnerable.d.ts.map +1 -1
- package/dist/rules/no-vulnerable.js +14 -23
- package/dist/rules/no-vulnerable.js.map +1 -1
- package/dist/rules/only-export-name.d.ts.map +1 -1
- package/dist/rules/only-export-name.js +7 -8
- package/dist/rules/only-export-name.js.map +1 -1
- package/dist/rules/prefer-includes.js +2 -2
- package/dist/rules/prefer-includes.js.map +1 -1
- package/dist/rules/prefer-interface.d.ts.map +1 -1
- package/dist/rules/prefer-interface.js +6 -5
- package/dist/rules/prefer-interface.js.map +1 -1
- package/dist/rules/require-jsdoc.d.ts.map +1 -1
- package/dist/rules/require-jsdoc.js +8 -7
- package/dist/rules/require-jsdoc.js.map +1 -1
- package/dist/rules/sort-array.d.ts.map +1 -1
- package/dist/rules/sort-array.js +2 -1
- package/dist/rules/sort-array.js.map +1 -1
- package/dist/rules/sort-class-members.d.ts.map +1 -1
- package/dist/rules/sort-class-members.js +6 -4
- package/dist/rules/sort-class-members.js.map +1 -1
- package/dist/rules/sort-export-specifiers.d.ts.map +1 -1
- package/dist/rules/sort-export-specifiers.js +3 -4
- package/dist/rules/sort-export-specifiers.js.map +1 -1
- package/dist/rules/sort-keys.d.ts.map +1 -1
- package/dist/rules/sort-keys.js +4 -3
- package/dist/rules/sort-keys.js.map +1 -1
- package/dist/rules/switch-case-spacing.d.ts.map +1 -1
- package/dist/rules/switch-case-spacing.js +3 -2
- package/dist/rules/switch-case-spacing.js.map +1 -1
- package/dist/rules/template-literal-format.js +2 -2
- package/dist/rules/throw-error.d.ts.map +1 -1
- package/dist/rules/throw-error.js +7 -10
- package/dist/rules/throw-error.js.map +1 -1
- package/dist/rules/throw-new-error.js +2 -2
- package/dist/rules/throw-new-error.js.map +1 -1
- package/dist/rules/typescript-array-callback-return-type.d.ts.map +1 -1
- package/dist/rules/typescript-array-callback-return-type.js +5 -5
- package/dist/rules/typescript-array-callback-return-type.js.map +1 -1
- package/dist/rules/typescript-class-methods-use-this.d.ts.map +1 -1
- package/dist/rules/typescript-class-methods-use-this.js +4 -2
- package/dist/rules/typescript-class-methods-use-this.js.map +1 -1
- package/dist/rules/typescript-no-boolean-literal-type.d.ts.map +1 -1
- package/dist/rules/typescript-no-boolean-literal-type.js +2 -1
- package/dist/rules/typescript-no-boolean-literal-type.js.map +1 -1
- package/dist/rules/typescript-no-never.d.ts.map +1 -1
- package/dist/rules/typescript-no-never.js +3 -3
- package/dist/rules/typescript-no-never.js.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-const.d.ts.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-const.js +18 -23
- package/dist/rules/typescript-no-redundant-undefined-const.js.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-default-parameter.d.ts.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-default-parameter.js +35 -36
- package/dist/rules/typescript-no-redundant-undefined-default-parameter.js.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-let.d.ts.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-let.js +17 -15
- package/dist/rules/typescript-no-redundant-undefined-let.js.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-optional.d.ts.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-optional.js +3 -2
- package/dist/rules/typescript-no-redundant-undefined-optional.js.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-promise-return-type.d.ts.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-promise-return-type.js +25 -24
- package/dist/rules/typescript-no-redundant-undefined-promise-return-type.js.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-readonly-property.d.ts.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-readonly-property.js +17 -15
- package/dist/rules/typescript-no-redundant-undefined-readonly-property.js.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-return-type.d.ts.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-return-type.js +24 -22
- package/dist/rules/typescript-no-redundant-undefined-return-type.js.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-var.d.ts.map +1 -1
- package/dist/rules/typescript-no-redundant-undefined-var.js +17 -15
- package/dist/rules/typescript-no-redundant-undefined-var.js.map +1 -1
- package/dist/rules/typescript-no-restricted-syntax.d.ts +4 -3
- package/dist/rules/typescript-no-restricted-syntax.d.ts.map +1 -1
- package/dist/rules/typescript-no-restricted-syntax.js +8 -4
- package/dist/rules/typescript-no-restricted-syntax.js.map +1 -1
- package/dist/rules/typescript-no-unsafe-object-assignment.d.ts +4 -3
- package/dist/rules/typescript-no-unsafe-object-assignment.d.ts.map +1 -1
- package/dist/rules/typescript-no-unsafe-object-assignment.js +8 -4
- package/dist/rules/typescript-no-unsafe-object-assignment.js.map +1 -1
- package/dist/rules/typescript-prefer-enum.d.ts.map +1 -1
- package/dist/rules/typescript-prefer-enum.js +15 -16
- package/dist/rules/typescript-prefer-enum.js.map +1 -1
- package/dist/rules/typescript-prefer-named-tuple-members.d.ts.map +1 -1
- package/dist/rules/typescript-prefer-named-tuple-members.js +10 -10
- package/dist/rules/typescript-prefer-named-tuple-members.js.map +1 -1
- package/dist/rules/typescript-prefer-readonly-array-parameter.d.ts.map +1 -1
- package/dist/rules/typescript-prefer-readonly-array-parameter.js +25 -22
- package/dist/rules/typescript-prefer-readonly-array-parameter.js.map +1 -1
- package/dist/rules/typescript-prefer-readonly-array.d.ts.map +1 -1
- package/dist/rules/typescript-prefer-readonly-array.js +5 -4
- package/dist/rules/typescript-prefer-readonly-array.js.map +1 -1
- package/dist/rules/typescript-prefer-readonly-index-signature.d.ts.map +1 -1
- package/dist/rules/typescript-prefer-readonly-index-signature.js +3 -1
- package/dist/rules/typescript-prefer-readonly-index-signature.js.map +1 -1
- package/dist/rules/typescript-prefer-readonly-map.d.ts.map +1 -1
- package/dist/rules/typescript-prefer-readonly-map.js +2 -1
- package/dist/rules/typescript-prefer-readonly-map.js.map +1 -1
- package/dist/rules/typescript-prefer-readonly-property.d.ts.map +1 -1
- package/dist/rules/typescript-prefer-readonly-property.js +6 -5
- package/dist/rules/typescript-prefer-readonly-property.js.map +1 -1
- package/dist/rules/typescript-prefer-readonly-record.d.ts.map +1 -1
- package/dist/rules/typescript-prefer-readonly-record.js +8 -6
- package/dist/rules/typescript-prefer-readonly-record.js.map +1 -1
- package/dist/rules/typescript-prefer-readonly-set.d.ts.map +1 -1
- package/dist/rules/typescript-prefer-readonly-set.js +2 -1
- package/dist/rules/typescript-prefer-readonly-set.js.map +1 -1
- package/dist/rules/typescript-require-prop-type-annotation.d.ts.map +1 -1
- package/dist/rules/typescript-require-prop-type-annotation.js +3 -2
- package/dist/rules/typescript-require-prop-type-annotation.js.map +1 -1
- package/dist/rules/typescript-require-readonly-array-property-type.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-array-property-type.js +11 -11
- package/dist/rules/typescript-require-readonly-array-property-type.js.map +1 -1
- package/dist/rules/typescript-require-readonly-array-return-type.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-array-return-type.js +19 -16
- package/dist/rules/typescript-require-readonly-array-return-type.js.map +1 -1
- package/dist/rules/typescript-require-readonly-array-type-alias.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-array-type-alias.js +9 -6
- package/dist/rules/typescript-require-readonly-array-type-alias.js.map +1 -1
- package/dist/rules/typescript-require-readonly-map-parameter-type.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-map-parameter-type.js +23 -20
- package/dist/rules/typescript-require-readonly-map-parameter-type.js.map +1 -1
- package/dist/rules/typescript-require-readonly-map-property-type.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-map-property-type.js +9 -9
- package/dist/rules/typescript-require-readonly-map-property-type.js.map +1 -1
- package/dist/rules/typescript-require-readonly-map-return-type.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-map-return-type.js +17 -14
- package/dist/rules/typescript-require-readonly-map-return-type.js.map +1 -1
- package/dist/rules/typescript-require-readonly-map-type-alias.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-map-type-alias.js +7 -4
- package/dist/rules/typescript-require-readonly-map-type-alias.js.map +1 -1
- package/dist/rules/typescript-require-readonly-record-parameter-type.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-record-parameter-type.js +26 -23
- package/dist/rules/typescript-require-readonly-record-parameter-type.js.map +1 -1
- package/dist/rules/typescript-require-readonly-record-property-type.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-record-property-type.js +12 -12
- package/dist/rules/typescript-require-readonly-record-property-type.js.map +1 -1
- package/dist/rules/typescript-require-readonly-record-return-type.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-record-return-type.js +20 -17
- package/dist/rules/typescript-require-readonly-record-return-type.js.map +1 -1
- package/dist/rules/typescript-require-readonly-record-type-alias.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-record-type-alias.js +10 -7
- package/dist/rules/typescript-require-readonly-record-type-alias.js.map +1 -1
- package/dist/rules/typescript-require-readonly-set-parameter-type.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-set-parameter-type.js +23 -20
- package/dist/rules/typescript-require-readonly-set-parameter-type.js.map +1 -1
- package/dist/rules/typescript-require-readonly-set-property-type.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-set-property-type.js +9 -9
- package/dist/rules/typescript-require-readonly-set-property-type.js.map +1 -1
- package/dist/rules/typescript-require-readonly-set-return-type.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-set-return-type.js +17 -14
- package/dist/rules/typescript-require-readonly-set-return-type.js.map +1 -1
- package/dist/rules/typescript-require-readonly-set-type-alias.d.ts.map +1 -1
- package/dist/rules/typescript-require-readonly-set-type-alias.js +7 -4
- package/dist/rules/typescript-require-readonly-set-type-alias.js.map +1 -1
- package/dist/rules/typescript-require-this-void.d.ts.map +1 -1
- package/dist/rules/typescript-require-this-void.js +3 -2
- package/dist/rules/typescript-require-this-void.js.map +1 -1
- package/dist/rules/underscore-internal.d.ts.map +1 -1
- package/dist/rules/underscore-internal.js +10 -12
- package/dist/rules/underscore-internal.js.map +1 -1
- package/dist/rules/unused-internal-properties.js +2 -2
- package/dist/rules/unused-internal-properties.js.map +1 -1
- package/dist/rules/uppercase-iife.js +2 -2
- package/dist/rules/uppercase-iife.js.map +1 -1
- package/dist/rules/words.js +2 -2
- package/dist/rules/words.js.map +1 -1
- package/dist/rules.d.ts +2 -1
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +269 -268
- package/dist/rules.js.map +1 -1
- package/docs/docusaurus/package.json +1 -1
- package/docs/docusaurus/src/components/GitHubStats.jsx +7 -1
- package/docs/docusaurus/src/pages/index.jsx +5 -0
- package/docs/docusaurus/typedoc-plugins/hashToBangLinksCore.mjs +1 -1
- package/docs/docusaurus/typedoc-plugins/prefixDocLinksCore.mjs +4 -5
- package/package.json +37 -39
package/dist/plugin.cjs
CHANGED
|
@@ -42,10 +42,10 @@ var pluginMeta = {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
// dist/configs/all-strict.js
|
|
45
|
-
var
|
|
45
|
+
var import_ts_extras71 = require("ts-extras");
|
|
46
46
|
|
|
47
47
|
// dist/rules.js
|
|
48
|
-
var
|
|
48
|
+
var import_ts_extras70 = require("ts-extras");
|
|
49
49
|
|
|
50
50
|
// dist/_internal/rule-catalog.js
|
|
51
51
|
var toCatalogNumericPart = (catalogIndex) => `${catalogIndex}`.padStart(3, "0");
|
|
@@ -92,6 +92,45 @@ var import_eslint_plugin = __toESM(require("@typescript-eslint/eslint-plugin"),
|
|
|
92
92
|
var import_ts_extras = require("ts-extras");
|
|
93
93
|
var isObjectRecord = (value) => typeof value === "object" && value !== null;
|
|
94
94
|
var hasCreateFunction = (value) => isObjectRecord(value) && typeof value["create"] === "function";
|
|
95
|
+
var isRuleMetaDocs = (value) => isObjectRecord(value) && typeof value["description"] === "string";
|
|
96
|
+
var getNormalizedMetaType = (value) => {
|
|
97
|
+
if (value === "layout" || value === "problem" || value === "suggestion") {
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
return "problem";
|
|
101
|
+
};
|
|
102
|
+
var getNormalizedMetaMessages = (value) => {
|
|
103
|
+
if (!isObjectRecord(value)) {
|
|
104
|
+
return {};
|
|
105
|
+
}
|
|
106
|
+
let normalizedMessages = {};
|
|
107
|
+
for (const [key, message] of (0, import_ts_extras.objectEntries)(value)) {
|
|
108
|
+
if (typeof message !== "string") {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
normalizedMessages = {
|
|
112
|
+
...normalizedMessages,
|
|
113
|
+
[key]: message
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return normalizedMessages;
|
|
117
|
+
};
|
|
118
|
+
var isJsonSchemaLike = (value) => {
|
|
119
|
+
if (!isObjectRecord(value)) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return (0, import_ts_extras.keyIn)(value, "allOf") || (0, import_ts_extras.keyIn)(value, "anyOf") || (0, import_ts_extras.keyIn)(value, "oneOf") || (0, import_ts_extras.keyIn)(value, "properties") || (0, import_ts_extras.keyIn)(value, "type");
|
|
123
|
+
};
|
|
124
|
+
var isJsonSchemaArray = (value) => Array.isArray(value) && value.every((entry) => isJsonSchemaLike(entry));
|
|
125
|
+
var getNormalizedMetaSchema = (value) => {
|
|
126
|
+
if (isJsonSchemaArray(value)) {
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
if (isJsonSchemaLike(value)) {
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
return [];
|
|
133
|
+
};
|
|
95
134
|
var createLegacyContextCompat = (context) => new Proxy(context, {
|
|
96
135
|
get: (target, property, receiver) => {
|
|
97
136
|
if (property === "getSourceCode") {
|
|
@@ -109,11 +148,11 @@ var createLegacyContextCompat = (context) => new Proxy(context, {
|
|
|
109
148
|
return Reflect.get(target, property, receiver);
|
|
110
149
|
}
|
|
111
150
|
});
|
|
112
|
-
var getExternalRuleFromPlugin = (
|
|
113
|
-
if (!isObjectRecord(
|
|
151
|
+
var getExternalRuleFromPlugin = (plugin3, ruleName, pluginName) => {
|
|
152
|
+
if (!isObjectRecord(plugin3) || !isObjectRecord(plugin3["rules"])) {
|
|
114
153
|
throw new TypeError(`Plugin "${pluginName}" does not expose a valid rules map.`);
|
|
115
154
|
}
|
|
116
|
-
const rules2 =
|
|
155
|
+
const rules2 = plugin3["rules"];
|
|
117
156
|
if (!(0, import_ts_extras.objectHasOwn)(rules2, ruleName)) {
|
|
118
157
|
throw new Error(`Rule "${ruleName}" was not found in plugin "${pluginName}".`);
|
|
119
158
|
}
|
|
@@ -124,19 +163,25 @@ var adaptExternalRule = (externalRule4, docsUrl) => {
|
|
|
124
163
|
throw new TypeError("External rule module does not expose create().");
|
|
125
164
|
}
|
|
126
165
|
const externalRuleRecord = externalRule4;
|
|
127
|
-
const
|
|
128
|
-
const externalDocs =
|
|
166
|
+
const externalMetaRecord = isObjectRecord(externalRuleRecord["meta"]) ? externalRuleRecord["meta"] : {};
|
|
167
|
+
const externalDocs = isRuleMetaDocs(externalMetaRecord["docs"]) ? externalMetaRecord["docs"] : {
|
|
168
|
+
description: "External rule re-exported by eslint-plugin-etc-misc."
|
|
169
|
+
};
|
|
129
170
|
const create = (context) => externalRule4.create(createLegacyContextCompat(context));
|
|
171
|
+
const externalRuleModule = (0, import_ts_extras.safeCastTo)(externalRuleRecord);
|
|
130
172
|
return {
|
|
131
|
-
...
|
|
173
|
+
...externalRuleModule,
|
|
132
174
|
create,
|
|
133
175
|
defaultOptions: Array.isArray(externalRuleRecord["defaultOptions"]) ? (0, import_ts_extras.safeCastTo)(externalRuleRecord["defaultOptions"]) : [],
|
|
134
176
|
meta: {
|
|
135
|
-
...
|
|
177
|
+
...externalMetaRecord,
|
|
136
178
|
docs: {
|
|
137
179
|
...externalDocs,
|
|
138
180
|
url: docsUrl
|
|
139
|
-
}
|
|
181
|
+
},
|
|
182
|
+
messages: getNormalizedMetaMessages(externalMetaRecord["messages"]),
|
|
183
|
+
schema: getNormalizedMetaSchema(externalMetaRecord["schema"]),
|
|
184
|
+
type: getNormalizedMetaType(externalMetaRecord["type"])
|
|
140
185
|
}
|
|
141
186
|
};
|
|
142
187
|
};
|
|
@@ -191,19 +236,20 @@ var deprecatedRule = withDeprecatedRuleLifecycle(rule, {
|
|
|
191
236
|
var array_type_default = deprecatedRule;
|
|
192
237
|
|
|
193
238
|
// dist/rules/class-match-filename.js
|
|
194
|
-
var import_node_path = require("node:path");
|
|
239
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
195
240
|
|
|
196
241
|
// dist/_internal/rule-creator.js
|
|
197
242
|
var import_utils = require("@typescript-eslint/utils");
|
|
198
|
-
var
|
|
243
|
+
var createRuleCreator = import_utils.ESLintUtils.RuleCreator;
|
|
244
|
+
var ruleCreator = createRuleCreator((name) => {
|
|
199
245
|
const docsPathName = name.replaceAll("/", "-");
|
|
200
246
|
return `https://nick2bad4u.github.io/eslint-plugin-etc-misc/docs/rules/${docsPathName}`;
|
|
201
247
|
});
|
|
202
248
|
|
|
203
249
|
// dist/rules/class-match-filename.js
|
|
204
250
|
var getFileStem = (filePath) => {
|
|
205
|
-
const extension =
|
|
206
|
-
return
|
|
251
|
+
const extension = import_node_path.default.extname(filePath);
|
|
252
|
+
return import_node_path.default.basename(filePath, extension);
|
|
207
253
|
};
|
|
208
254
|
var rule2 = ruleCreator({
|
|
209
255
|
create: (context) => ({
|
|
@@ -247,13 +293,14 @@ var rule2 = ruleCreator({
|
|
|
247
293
|
var class_match_filename_default = rule2;
|
|
248
294
|
|
|
249
295
|
// dist/rules/comment-spacing.js
|
|
296
|
+
var import_utils2 = require("@typescript-eslint/utils");
|
|
250
297
|
var import_ts_extras3 = require("ts-extras");
|
|
251
|
-
var isEslintDirectiveComment = (comment) => comment.type ===
|
|
298
|
+
var isEslintDirectiveComment = (comment) => comment.type === import_utils2.AST_TOKEN_TYPES.Block && comment.value.trimStart().startsWith("eslint-");
|
|
252
299
|
var expectedBlankLines = (comment) => {
|
|
253
|
-
if (comment.type ===
|
|
300
|
+
if (comment.type === import_utils2.AST_TOKEN_TYPES.Line || isEslintDirectiveComment(comment)) {
|
|
254
301
|
return 0;
|
|
255
302
|
}
|
|
256
|
-
return /\r\n|\n/
|
|
303
|
+
return /\r\n|\n/v.test(comment.value) ? 1 : 0;
|
|
257
304
|
};
|
|
258
305
|
var buildFix = (sourceCode, comment, nextNode, expected) => (fixer) => {
|
|
259
306
|
const textBetween = sourceCode.text.slice(comment.range[1], (0, import_ts_extras3.arrayFirst)(nextNode.range));
|
|
@@ -308,7 +355,7 @@ var comment_spacing_default = rule3;
|
|
|
308
355
|
|
|
309
356
|
// dist/rules/consistent-empty-lines.js
|
|
310
357
|
var import_ts_extras4 = require("ts-extras");
|
|
311
|
-
var splitLines = (sourceText) => (0, import_ts_extras4.stringSplit)(sourceText.replaceAll(/\r\n?/
|
|
358
|
+
var splitLines = (sourceText) => (0, import_ts_extras4.stringSplit)(sourceText.replaceAll(/\r\n?/gv, "\n"), "\n");
|
|
312
359
|
var collapseEmptyLines = (sourceText) => {
|
|
313
360
|
const lines = splitLines(sourceText);
|
|
314
361
|
let output = [];
|
|
@@ -415,9 +462,9 @@ var import_ts_extras6 = require("ts-extras");
|
|
|
415
462
|
|
|
416
463
|
// dist/_internal/identifier-blocks.js
|
|
417
464
|
var import_ts_extras5 = require("ts-extras");
|
|
418
|
-
var camelCaseBoundaryPattern = /(?<=[\da-z])(?=[A-Z])/
|
|
419
|
-
var nonAlphanumericPattern = /[^0-9A-Za-z]+/
|
|
420
|
-
var whitespacePattern = /\s+/
|
|
465
|
+
var camelCaseBoundaryPattern = /(?<=[\da-z])(?=[A-Z])/gv;
|
|
466
|
+
var nonAlphanumericPattern = /[^0-9A-Za-z]+/gv;
|
|
467
|
+
var whitespacePattern = /\s+/gv;
|
|
421
468
|
var splitIdentifierBlocks = (value) => {
|
|
422
469
|
const normalized = value.replaceAll(camelCaseBoundaryPattern, " ").replaceAll(nonAlphanumericPattern, " ").trim();
|
|
423
470
|
if (normalized.length === 0) {
|
|
@@ -452,7 +499,7 @@ var filenameStem = (filePath) => {
|
|
|
452
499
|
const normalizedPath = filePath.replaceAll("\\", "/");
|
|
453
500
|
const pathSegments = (0, import_ts_extras6.stringSplit)(normalizedPath, "/");
|
|
454
501
|
const lastPathSegment = (0, import_ts_extras6.arrayAt)(pathSegments, -1) ?? filePath;
|
|
455
|
-
return lastPathSegment.replace(/\.[
|
|
502
|
+
return lastPathSegment.replace(/\.[^.\/]+$/v, "");
|
|
456
503
|
};
|
|
457
504
|
|
|
458
505
|
// dist/rules/consistent-filename.js
|
|
@@ -534,14 +581,15 @@ var deprecatedRule2 = withDeprecatedRuleLifecycle(rule6, {
|
|
|
534
581
|
var consistent_filename_default = deprecatedRule2;
|
|
535
582
|
|
|
536
583
|
// dist/rules/consistent-import.js
|
|
584
|
+
var import_utils3 = require("@typescript-eslint/utils");
|
|
537
585
|
var import_ts_extras8 = require("ts-extras");
|
|
538
586
|
var styleFromImport = (node) => {
|
|
539
587
|
if (node.specifiers.length === 0) {
|
|
540
588
|
return "side-effect";
|
|
541
589
|
}
|
|
542
|
-
const hasDefault = node.specifiers.some((specifier) => specifier.type ===
|
|
543
|
-
const hasNamed = node.specifiers.some((specifier) => specifier.type ===
|
|
544
|
-
const hasNamespace = node.specifiers.some((specifier) => specifier.type ===
|
|
590
|
+
const hasDefault = node.specifiers.some((specifier) => specifier.type === import_utils3.AST_NODE_TYPES.ImportDefaultSpecifier);
|
|
591
|
+
const hasNamed = node.specifiers.some((specifier) => specifier.type === import_utils3.AST_NODE_TYPES.ImportSpecifier);
|
|
592
|
+
const hasNamespace = node.specifiers.some((specifier) => specifier.type === import_utils3.AST_NODE_TYPES.ImportNamespaceSpecifier);
|
|
545
593
|
if (hasNamespace) {
|
|
546
594
|
return "namespace";
|
|
547
595
|
}
|
|
@@ -622,6 +670,7 @@ var rule7 = ruleCreator({
|
|
|
622
670
|
var consistent_import_default = rule7;
|
|
623
671
|
|
|
624
672
|
// dist/rules/consistent-optional-props.js
|
|
673
|
+
var import_utils4 = require("@typescript-eslint/utils");
|
|
625
674
|
var import_ts_extras9 = require("ts-extras");
|
|
626
675
|
var selector2 = (0, import_ts_extras9.arrayJoin)([
|
|
627
676
|
"TSPropertySignature[optional=true] > TSTypeAnnotation > TSUnionType",
|
|
@@ -630,7 +679,7 @@ var selector2 = (0, import_ts_extras9.arrayJoin)([
|
|
|
630
679
|
var buildOptionalUnionFixText = (sourceCode, unionType) => {
|
|
631
680
|
let nonUndefinedTypeTexts = [];
|
|
632
681
|
for (const typeNode of unionType.types) {
|
|
633
|
-
if (typeNode.type ===
|
|
682
|
+
if (typeNode.type === import_utils4.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
634
683
|
continue;
|
|
635
684
|
}
|
|
636
685
|
nonUndefinedTypeTexts = [
|
|
@@ -648,7 +697,7 @@ var rule8 = ruleCreator({
|
|
|
648
697
|
const sourceCode = context.sourceCode;
|
|
649
698
|
return {
|
|
650
699
|
[selector2]: (node) => {
|
|
651
|
-
if (node.type !==
|
|
700
|
+
if (node.type !== import_utils4.AST_NODE_TYPES.TSUnionType) {
|
|
652
701
|
return;
|
|
653
702
|
}
|
|
654
703
|
const fixedTypeText = buildOptionalUnionFixText(sourceCode, node);
|
|
@@ -783,20 +832,21 @@ var default_case_default = rule11;
|
|
|
783
832
|
var import_ts_extras11 = require("ts-extras");
|
|
784
833
|
|
|
785
834
|
// dist/_internal/import-patterns.js
|
|
835
|
+
var import_utils5 = require("@typescript-eslint/utils");
|
|
786
836
|
var import_minimatch = require("minimatch");
|
|
787
837
|
var matchesAnyPattern = (value, patterns) => patterns.some((pattern) => (0, import_minimatch.minimatch)(value, pattern, {
|
|
788
838
|
dot: true,
|
|
789
839
|
nocase: false
|
|
790
840
|
}));
|
|
791
841
|
var getImportSourceText = (node) => {
|
|
792
|
-
if (node.type ===
|
|
842
|
+
if (node.type === import_utils5.AST_NODE_TYPES.ExportAllDeclaration || node.type === import_utils5.AST_NODE_TYPES.ImportDeclaration) {
|
|
793
843
|
return node.source.value;
|
|
794
844
|
}
|
|
795
|
-
if (node.type ===
|
|
845
|
+
if (node.type === import_utils5.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
796
846
|
return node.source?.value;
|
|
797
847
|
}
|
|
798
|
-
if (node.type ===
|
|
799
|
-
return node.source.type ===
|
|
848
|
+
if (node.type === import_utils5.AST_NODE_TYPES.ImportExpression) {
|
|
849
|
+
return node.source.type === import_utils5.AST_NODE_TYPES.Literal && typeof node.source.value === "string" ? node.source.value : void 0;
|
|
800
850
|
}
|
|
801
851
|
return void 0;
|
|
802
852
|
};
|
|
@@ -880,24 +930,25 @@ var rule12 = createImportPatternRule({
|
|
|
880
930
|
var disallow_import_default = rule12;
|
|
881
931
|
|
|
882
932
|
// dist/rules/export-matching-filename-only.js
|
|
883
|
-
var
|
|
933
|
+
var import_utils6 = require("@typescript-eslint/utils");
|
|
934
|
+
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
884
935
|
var import_ts_extras12 = require("ts-extras");
|
|
885
936
|
var exportedNamesFromDeclaration = (node) => {
|
|
886
937
|
if (node.specifiers.length > 0) {
|
|
887
|
-
return node.specifiers.
|
|
938
|
+
return node.specifiers.flatMap((specifier) => specifier.exported.type === import_utils6.AST_NODE_TYPES.Identifier ? [specifier.exported.name] : []);
|
|
888
939
|
}
|
|
889
|
-
if (node.declaration?.type ===
|
|
940
|
+
if (node.declaration?.type === import_utils6.AST_NODE_TYPES.ClassDeclaration || node.declaration?.type === import_utils6.AST_NODE_TYPES.FunctionDeclaration) {
|
|
890
941
|
return node.declaration.id === null ? [] : [node.declaration.id.name];
|
|
891
942
|
}
|
|
892
943
|
return [];
|
|
893
944
|
};
|
|
894
945
|
var rule13 = ruleCreator({
|
|
895
946
|
create: (context, [options]) => {
|
|
896
|
-
let
|
|
947
|
+
let namedExports = [];
|
|
897
948
|
return {
|
|
898
949
|
ExportDefaultDeclaration: (node) => {
|
|
899
|
-
|
|
900
|
-
...
|
|
950
|
+
namedExports = [
|
|
951
|
+
...namedExports,
|
|
901
952
|
{
|
|
902
953
|
name: "default",
|
|
903
954
|
node
|
|
@@ -906,20 +957,20 @@ var rule13 = ruleCreator({
|
|
|
906
957
|
},
|
|
907
958
|
ExportNamedDeclaration: (node) => {
|
|
908
959
|
for (const name of exportedNamesFromDeclaration(node)) {
|
|
909
|
-
|
|
960
|
+
namedExports = [...namedExports, { name, node }];
|
|
910
961
|
}
|
|
911
962
|
},
|
|
912
963
|
"Program:exit": () => {
|
|
913
964
|
if (context.filename === "<input>") {
|
|
914
965
|
return;
|
|
915
966
|
}
|
|
916
|
-
const stem = filenameStem(
|
|
967
|
+
const stem = filenameStem(import_node_path2.default.resolve(context.filename));
|
|
917
968
|
const expected = toCasing(stem, options.format ?? "PascalCase");
|
|
918
|
-
const matching =
|
|
919
|
-
if ((0, import_ts_extras12.isEmpty)(matching) ||
|
|
969
|
+
const matching = namedExports.filter((entry) => entry.name === expected);
|
|
970
|
+
if ((0, import_ts_extras12.isEmpty)(matching) || namedExports.length <= 1) {
|
|
920
971
|
return;
|
|
921
972
|
}
|
|
922
|
-
for (const entry of
|
|
973
|
+
for (const entry of namedExports) {
|
|
923
974
|
if (entry.name === expected) {
|
|
924
975
|
continue;
|
|
925
976
|
}
|
|
@@ -973,7 +1024,8 @@ var rule13 = ruleCreator({
|
|
|
973
1024
|
var export_matching_filename_only_default = rule13;
|
|
974
1025
|
|
|
975
1026
|
// dist/rules/match-filename.js
|
|
976
|
-
var
|
|
1027
|
+
var import_utils7 = require("@typescript-eslint/utils");
|
|
1028
|
+
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
977
1029
|
var import_ts_extras13 = require("ts-extras");
|
|
978
1030
|
var defaultSelectors = [
|
|
979
1031
|
"ClassDeclaration > Identifier.id",
|
|
@@ -998,10 +1050,10 @@ var rule14 = ruleCreator({
|
|
|
998
1050
|
listeners = {
|
|
999
1051
|
...listeners,
|
|
1000
1052
|
[selector25]: (node) => {
|
|
1001
|
-
if (context.filename === "<input>" || node.type !==
|
|
1053
|
+
if (context.filename === "<input>" || node.type !== import_utils7.AST_NODE_TYPES.Identifier) {
|
|
1002
1054
|
return;
|
|
1003
1055
|
}
|
|
1004
|
-
const stem = filenameStem(
|
|
1056
|
+
const stem = filenameStem(import_node_path3.default.resolve(context.filename));
|
|
1005
1057
|
const expected = `${options.prefix ?? ""}${toCasing(node.name, options.format ?? "kebab-case")}${options.suffix ?? ""}`;
|
|
1006
1058
|
const matches = stem === expected;
|
|
1007
1059
|
if (options.match ?? true ? matches : !matches) {
|
|
@@ -1127,7 +1179,7 @@ var max_identifier_blocks_default = rule15;
|
|
|
1127
1179
|
|
|
1128
1180
|
// dist/rules/no-assign-mutated-array.js
|
|
1129
1181
|
var import_type_utils = require("@typescript-eslint/type-utils");
|
|
1130
|
-
var
|
|
1182
|
+
var import_utils8 = require("@typescript-eslint/utils");
|
|
1131
1183
|
var import_ts_extras15 = require("ts-extras");
|
|
1132
1184
|
var readonlyArrayTypeNames = /* @__PURE__ */ new Set(["ReadonlyArray"]);
|
|
1133
1185
|
var isArrayLikeType = (typeChecker, type) => {
|
|
@@ -1145,54 +1197,54 @@ var creatorMethodNames = /* @__PURE__ */ new Set([
|
|
|
1145
1197
|
"values"
|
|
1146
1198
|
]);
|
|
1147
1199
|
var isArrayFactoryCallee = (callee) => {
|
|
1148
|
-
if (callee.type ===
|
|
1200
|
+
if (callee.type === import_utils8.AST_NODE_TYPES.Identifier) {
|
|
1149
1201
|
return callee.name === "Array";
|
|
1150
1202
|
}
|
|
1151
|
-
if (callee.type ===
|
|
1203
|
+
if (callee.type === import_utils8.AST_NODE_TYPES.MemberExpression && callee.object.type === import_utils8.AST_NODE_TYPES.Identifier && callee.object.name === "Array" && callee.property.type === import_utils8.AST_NODE_TYPES.Identifier) {
|
|
1152
1204
|
return callee.property.name === "from" || callee.property.name === "of";
|
|
1153
1205
|
}
|
|
1154
1206
|
return false;
|
|
1155
1207
|
};
|
|
1156
1208
|
var isNewArray = (node) => {
|
|
1157
|
-
if (node.type ===
|
|
1209
|
+
if (node.type === import_utils8.AST_NODE_TYPES.ArrayExpression) {
|
|
1158
1210
|
return true;
|
|
1159
1211
|
}
|
|
1160
|
-
if (node.type ===
|
|
1212
|
+
if (node.type === import_utils8.AST_NODE_TYPES.CallExpression) {
|
|
1161
1213
|
return isArrayFactoryCallee(node.callee);
|
|
1162
1214
|
}
|
|
1163
1215
|
return false;
|
|
1164
1216
|
};
|
|
1165
1217
|
var mutatesReferencedArray = (callExpression) => {
|
|
1166
|
-
if (callExpression.callee.type !==
|
|
1218
|
+
if (callExpression.callee.type !== import_utils8.AST_NODE_TYPES.MemberExpression) {
|
|
1167
1219
|
return true;
|
|
1168
1220
|
}
|
|
1169
1221
|
const { object, property } = callExpression.callee;
|
|
1170
|
-
if (property.type ===
|
|
1222
|
+
if (property.type === import_utils8.AST_NODE_TYPES.Identifier && (0, import_ts_extras15.setHas)(creatorMethodNames, property.name)) {
|
|
1171
1223
|
return false;
|
|
1172
1224
|
}
|
|
1173
1225
|
if (isNewArray(object)) {
|
|
1174
1226
|
return false;
|
|
1175
1227
|
}
|
|
1176
|
-
if (object.type ===
|
|
1228
|
+
if (object.type === import_utils8.AST_NODE_TYPES.CallExpression) {
|
|
1177
1229
|
return mutatesReferencedArray(object);
|
|
1178
1230
|
}
|
|
1179
1231
|
return true;
|
|
1180
1232
|
};
|
|
1181
1233
|
var rule16 = ruleCreator({
|
|
1182
1234
|
create: (context) => {
|
|
1183
|
-
const parserServices =
|
|
1235
|
+
const parserServices = import_utils8.ESLintUtils.getParserServices(context);
|
|
1184
1236
|
const typeChecker = parserServices.program.getTypeChecker();
|
|
1185
1237
|
return {
|
|
1186
1238
|
"CallExpression[callee.type='MemberExpression'][callee.property.type='Identifier'][callee.property.name=/^(?:fill|reverse|sort)$/]": (callExpression) => {
|
|
1187
1239
|
const { callee } = callExpression;
|
|
1188
|
-
if (callee.type !==
|
|
1240
|
+
if (callee.type !== import_utils8.AST_NODE_TYPES.MemberExpression) {
|
|
1189
1241
|
return;
|
|
1190
1242
|
}
|
|
1191
1243
|
const { property } = callee;
|
|
1192
|
-
if (property.type !==
|
|
1244
|
+
if (property.type !== import_utils8.AST_NODE_TYPES.Identifier) {
|
|
1193
1245
|
return;
|
|
1194
1246
|
}
|
|
1195
|
-
if (callExpression.parent
|
|
1247
|
+
if (callExpression.parent.type === import_utils8.AST_NODE_TYPES.ExpressionStatement) {
|
|
1196
1248
|
return;
|
|
1197
1249
|
}
|
|
1198
1250
|
const objectType = (0, import_type_utils.getConstrainedTypeAtLocation)(parserServices, callee.object);
|
|
@@ -1279,6 +1331,7 @@ var no_chain_coalescence_mixture_default = rule19;
|
|
|
1279
1331
|
|
|
1280
1332
|
// dist/rules/no-commented-out-code.js
|
|
1281
1333
|
var import_parser = __toESM(require("@typescript-eslint/parser"), 1);
|
|
1334
|
+
var import_utils9 = require("@typescript-eslint/utils");
|
|
1282
1335
|
var import_ts_extras16 = require("ts-extras");
|
|
1283
1336
|
var parserOptions = {
|
|
1284
1337
|
ecmaVersion: "latest",
|
|
@@ -1320,7 +1373,7 @@ var toCommentBlocks = (comments) => {
|
|
|
1320
1373
|
let blocks = [];
|
|
1321
1374
|
let previousLineComment = null;
|
|
1322
1375
|
for (const comment of comments) {
|
|
1323
|
-
if (comment.type ===
|
|
1376
|
+
if (comment.type === import_utils9.AST_TOKEN_TYPES.Block) {
|
|
1324
1377
|
blocks = [
|
|
1325
1378
|
...blocks,
|
|
1326
1379
|
{
|
|
@@ -1356,10 +1409,10 @@ ${comment.value}`,
|
|
|
1356
1409
|
return blocks;
|
|
1357
1410
|
};
|
|
1358
1411
|
var isExpressionOrIdentifierOrLiteral = (node) => {
|
|
1359
|
-
if (node.type ===
|
|
1412
|
+
if (node.type === import_utils9.AST_NODE_TYPES.Identifier || node.type === import_utils9.AST_NODE_TYPES.Literal) {
|
|
1360
1413
|
return true;
|
|
1361
1414
|
}
|
|
1362
|
-
if (node.type !==
|
|
1415
|
+
if (node.type !== import_utils9.AST_NODE_TYPES.BinaryExpression) {
|
|
1363
1416
|
return false;
|
|
1364
1417
|
}
|
|
1365
1418
|
return isExpressionOrIdentifierOrLiteral(node.left) && isExpressionOrIdentifierOrLiteral(node.right);
|
|
@@ -1368,37 +1421,37 @@ var isTrivialProgram = (program) => {
|
|
|
1368
1421
|
if (program.body.length === 0) {
|
|
1369
1422
|
return true;
|
|
1370
1423
|
}
|
|
1371
|
-
if (program.body.length === 1 && (0, import_ts_extras16.arrayFirst)(program.body)?.type ===
|
|
1424
|
+
if (program.body.length === 1 && (0, import_ts_extras16.arrayFirst)(program.body)?.type === import_utils9.AST_NODE_TYPES.LabeledStatement) {
|
|
1372
1425
|
return true;
|
|
1373
1426
|
}
|
|
1374
|
-
return program.body.every((statement) => statement.type ===
|
|
1427
|
+
return program.body.every((statement) => statement.type === import_utils9.AST_NODE_TYPES.ExpressionStatement && isExpressionOrIdentifierOrLiteral(statement.expression));
|
|
1375
1428
|
};
|
|
1376
1429
|
var getWrappedContent = (content, node) => {
|
|
1377
1430
|
if (node === null) {
|
|
1378
1431
|
return void 0;
|
|
1379
1432
|
}
|
|
1380
|
-
if (node.type ===
|
|
1433
|
+
if (node.type === import_utils9.AST_NODE_TYPES.ArrayExpression) {
|
|
1381
1434
|
return `const wrapper = [${content}]`;
|
|
1382
1435
|
}
|
|
1383
|
-
if (node.type ===
|
|
1436
|
+
if (node.type === import_utils9.AST_NODE_TYPES.ClassBody) {
|
|
1384
1437
|
return `class Wrapper { ${content} }`;
|
|
1385
1438
|
}
|
|
1386
|
-
if (node.type ===
|
|
1439
|
+
if (node.type === import_utils9.AST_NODE_TYPES.FunctionDeclaration) {
|
|
1387
1440
|
return `function wrapper(${content}) {}`;
|
|
1388
1441
|
}
|
|
1389
|
-
if (node.type ===
|
|
1442
|
+
if (node.type === import_utils9.AST_NODE_TYPES.ImportDeclaration) {
|
|
1390
1443
|
return `import { ${content} } from "wrapper"`;
|
|
1391
1444
|
}
|
|
1392
|
-
if (node.type ===
|
|
1445
|
+
if (node.type === import_utils9.AST_NODE_TYPES.ObjectExpression) {
|
|
1393
1446
|
return `const wrapper = { ${content} }`;
|
|
1394
1447
|
}
|
|
1395
|
-
if (node.type ===
|
|
1448
|
+
if (node.type === import_utils9.AST_NODE_TYPES.SwitchStatement) {
|
|
1396
1449
|
return `switch (wrapper) { ${content} }`;
|
|
1397
1450
|
}
|
|
1398
|
-
if (node.type ===
|
|
1451
|
+
if (node.type === import_utils9.AST_NODE_TYPES.TSInterfaceBody) {
|
|
1399
1452
|
return `interface Wrapper { ${content} }`;
|
|
1400
1453
|
}
|
|
1401
|
-
if (node.type ===
|
|
1454
|
+
if (node.type === import_utils9.AST_NODE_TYPES.TSTypeLiteral) {
|
|
1402
1455
|
return `type Wrapper = { ${content} }`;
|
|
1403
1456
|
}
|
|
1404
1457
|
return void 0;
|
|
@@ -1479,9 +1532,10 @@ var deprecatedRule4 = withDeprecatedRuleLifecycle(rule20, {
|
|
|
1479
1532
|
var no_commented_out_code_default = deprecatedRule4;
|
|
1480
1533
|
|
|
1481
1534
|
// dist/rules/no-const-enum.js
|
|
1535
|
+
var import_utils10 = require("@typescript-eslint/utils");
|
|
1482
1536
|
var import_ts_extras17 = require("ts-extras");
|
|
1483
1537
|
var defaultOptions2 = [{}];
|
|
1484
|
-
var isExportedEnumDeclaration = (node) => node.parent
|
|
1538
|
+
var isExportedEnumDeclaration = (node) => node.parent.type === import_utils10.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
1485
1539
|
var getConstToken = (sourceCode, node) => sourceCode.getFirstToken(node, {
|
|
1486
1540
|
filter: (token) => token.value === "const"
|
|
1487
1541
|
}) ?? void 0;
|
|
@@ -1561,7 +1615,7 @@ var rule21 = ruleCreator({
|
|
|
1561
1615
|
var no_const_enum_default = rule21;
|
|
1562
1616
|
|
|
1563
1617
|
// dist/rules/no-deprecated.js
|
|
1564
|
-
var
|
|
1618
|
+
var import_utils12 = require("@typescript-eslint/utils");
|
|
1565
1619
|
var import_ts_extras20 = require("ts-extras");
|
|
1566
1620
|
|
|
1567
1621
|
// dist/_internal/ignore-patterns.js
|
|
@@ -1593,20 +1647,21 @@ var compileIgnorePatterns = (ignored) => {
|
|
|
1593
1647
|
|
|
1594
1648
|
// dist/_internal/symbol-usage.js
|
|
1595
1649
|
var import_type_utils2 = require("@typescript-eslint/type-utils");
|
|
1650
|
+
var import_utils11 = require("@typescript-eslint/utils");
|
|
1596
1651
|
var import_ts_extras19 = require("ts-extras");
|
|
1597
|
-
var isImportOrExportSpecifier = (parent) => parent?.type ===
|
|
1652
|
+
var isImportOrExportSpecifier = (parent) => parent?.type === import_utils11.AST_NODE_TYPES.ExportSpecifier || parent?.type === import_utils11.AST_NODE_TYPES.ImportDefaultSpecifier || parent?.type === import_utils11.AST_NODE_TYPES.ImportNamespaceSpecifier || parent?.type === import_utils11.AST_NODE_TYPES.ImportSpecifier;
|
|
1598
1653
|
var isDeclarationIdentifier = (node) => {
|
|
1599
1654
|
const { parent } = node;
|
|
1600
|
-
if (
|
|
1655
|
+
if (!(0, import_ts_extras19.isDefined)(parent)) {
|
|
1601
1656
|
return false;
|
|
1602
1657
|
}
|
|
1603
|
-
if (parent.type ===
|
|
1658
|
+
if (parent.type === import_utils11.AST_NODE_TYPES.TSInterfaceDeclaration || parent.type === import_utils11.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
1604
1659
|
return parent.id === node;
|
|
1605
1660
|
}
|
|
1606
|
-
if (parent.type ===
|
|
1661
|
+
if (parent.type === import_utils11.AST_NODE_TYPES.ClassDeclaration || parent.type === import_utils11.AST_NODE_TYPES.FunctionDeclaration || parent.type === import_utils11.AST_NODE_TYPES.TSDeclareFunction || parent.type === import_utils11.AST_NODE_TYPES.TSEnumDeclaration) {
|
|
1607
1662
|
return parent.id === node;
|
|
1608
1663
|
}
|
|
1609
|
-
if (parent.type ===
|
|
1664
|
+
if (parent.type === import_utils11.AST_NODE_TYPES.VariableDeclarator) {
|
|
1610
1665
|
return parent.id === node;
|
|
1611
1666
|
}
|
|
1612
1667
|
return false;
|
|
@@ -1616,10 +1671,10 @@ var normalizeTagComment = (text) => {
|
|
|
1616
1671
|
return void 0;
|
|
1617
1672
|
}
|
|
1618
1673
|
if (typeof text === "string") {
|
|
1619
|
-
const normalized2 = text.trim().replaceAll(/\s+/
|
|
1674
|
+
const normalized2 = text.trim().replaceAll(/\s+/gv, " ");
|
|
1620
1675
|
return normalized2.length > 0 ? normalized2 : void 0;
|
|
1621
1676
|
}
|
|
1622
|
-
const normalized = (0, import_ts_extras19.arrayJoin)(text.map((part) => part.text), "").replaceAll(/\s+/
|
|
1677
|
+
const normalized = (0, import_ts_extras19.arrayJoin)(text.map((part) => part.text), "").replaceAll(/\s+/gv, " ").trim();
|
|
1623
1678
|
return normalized.length > 0 ? normalized : void 0;
|
|
1624
1679
|
};
|
|
1625
1680
|
var isUnknownRecord = (value) => typeof value === "object" && value !== null;
|
|
@@ -1654,7 +1709,7 @@ var defaultOptions3 = [{}];
|
|
|
1654
1709
|
var rule22 = ruleCreator({
|
|
1655
1710
|
create: (context) => {
|
|
1656
1711
|
const [{ ignored = {} } = {}] = context.options;
|
|
1657
|
-
const parserServices =
|
|
1712
|
+
const parserServices = import_utils12.ESLintUtils.getParserServices(context);
|
|
1658
1713
|
const typeChecker = parserServices.program.getTypeChecker();
|
|
1659
1714
|
const compiledIgnorePatterns = compileIgnorePatterns(ignored);
|
|
1660
1715
|
const ignorePatterns = compiledIgnorePatterns.patterns;
|
|
@@ -1804,7 +1859,7 @@ var no_enum_default = rule23;
|
|
|
1804
1859
|
|
|
1805
1860
|
// dist/rules/no-expression-empty-lines.js
|
|
1806
1861
|
var import_ts_extras21 = require("ts-extras");
|
|
1807
|
-
var splitLines2 = (sourceText) => (0, import_ts_extras21.stringSplit)(sourceText.replaceAll(/\r\n?/
|
|
1862
|
+
var splitLines2 = (sourceText) => (0, import_ts_extras21.stringSplit)(sourceText.replaceAll(/\r\n?/gv, "\n"), "\n");
|
|
1808
1863
|
var hasBlankLine = (text) => splitLines2(text).some((line) => line.trim().length === 0);
|
|
1809
1864
|
var normalizeExpressionSource = (sourceText) => {
|
|
1810
1865
|
const lines = splitLines2(sourceText).map((line) => line.trimEnd());
|
|
@@ -1852,7 +1907,7 @@ var no_expression_empty_lines_default = rule24;
|
|
|
1852
1907
|
|
|
1853
1908
|
// dist/rules/no-foreach.js
|
|
1854
1909
|
var import_type_utils3 = require("@typescript-eslint/type-utils");
|
|
1855
|
-
var
|
|
1910
|
+
var import_utils13 = require("@typescript-eslint/utils");
|
|
1856
1911
|
var import_ts_extras22 = require("ts-extras");
|
|
1857
1912
|
var defaultOptions4 = [{}];
|
|
1858
1913
|
var defaultTypes = [
|
|
@@ -1882,14 +1937,14 @@ var matchesConfiguredCollectionType = (typeChecker, type, configuredTypeNames) =
|
|
|
1882
1937
|
};
|
|
1883
1938
|
var rule25 = ruleCreator({
|
|
1884
1939
|
create: (context) => {
|
|
1885
|
-
const parserServices =
|
|
1940
|
+
const parserServices = import_utils13.ESLintUtils.getParserServices(context);
|
|
1886
1941
|
const typeChecker = parserServices.program.getTypeChecker();
|
|
1887
1942
|
const [{ types = defaultTypes } = {}] = context.options;
|
|
1888
1943
|
const configuredTypeNames = getConfiguredTypeNames(types);
|
|
1889
1944
|
return {
|
|
1890
1945
|
"CallExpression[callee.type='MemberExpression'][callee.property.type='Identifier'][callee.property.name='forEach']": (callExpression) => {
|
|
1891
1946
|
const { callee } = callExpression;
|
|
1892
|
-
if (callee.type !==
|
|
1947
|
+
if (callee.type !== import_utils13.AST_NODE_TYPES.MemberExpression) {
|
|
1893
1948
|
return;
|
|
1894
1949
|
}
|
|
1895
1950
|
const objectType = (0, import_type_utils3.getConstrainedTypeAtLocation)(parserServices, callee.object);
|
|
@@ -1942,25 +1997,26 @@ var rule25 = ruleCreator({
|
|
|
1942
1997
|
var no_foreach_default = rule25;
|
|
1943
1998
|
|
|
1944
1999
|
// dist/rules/no-function-declare-after-return.js
|
|
2000
|
+
var import_utils14 = require("@typescript-eslint/utils");
|
|
1945
2001
|
var import_ts_extras23 = require("ts-extras");
|
|
1946
|
-
var isStatementList = (node) => node.type ===
|
|
2002
|
+
var isStatementList = (node) => node.type === import_utils14.AST_NODE_TYPES.BlockStatement || node.type === import_utils14.AST_NODE_TYPES.Program;
|
|
1947
2003
|
var getLineStartIndex = (sourceText, index) => sourceText.lastIndexOf("\n", index - 1) + 1;
|
|
1948
2004
|
var getSafeFixRangeStart = (sourceCode, node) => {
|
|
1949
|
-
const declarationStart = (0, import_ts_extras23.arrayFirst)(node.range)
|
|
2005
|
+
const declarationStart = (0, import_ts_extras23.arrayFirst)(node.range);
|
|
1950
2006
|
const tokenBeforeDeclaration = sourceCode.getTokenBefore(node);
|
|
1951
|
-
const tokenBeforeEnd = tokenBeforeDeclaration === null ? 0 : (0, import_ts_extras23.arrayLast)(tokenBeforeDeclaration.range)
|
|
1952
|
-
const commentsBeforeDeclaration = sourceCode.getCommentsBefore(node).filter((comment) => (
|
|
2007
|
+
const tokenBeforeEnd = tokenBeforeDeclaration === null ? 0 : (0, import_ts_extras23.arrayLast)(tokenBeforeDeclaration.range);
|
|
2008
|
+
const commentsBeforeDeclaration = sourceCode.getCommentsBefore(node).filter((comment) => (0, import_ts_extras23.arrayFirst)(comment.range) >= tokenBeforeEnd && (0, import_ts_extras23.arrayLast)(comment.range) <= declarationStart);
|
|
1953
2009
|
const firstLeadingComment = (0, import_ts_extras23.arrayFirst)(commentsBeforeDeclaration);
|
|
1954
|
-
const firstMovableNodeStart = firstLeadingComment === void 0 ? declarationStart : (0, import_ts_extras23.arrayFirst)(firstLeadingComment.range)
|
|
2010
|
+
const firstMovableNodeStart = firstLeadingComment === void 0 ? declarationStart : (0, import_ts_extras23.arrayFirst)(firstLeadingComment.range);
|
|
1955
2011
|
return getLineStartIndex(sourceCode.text, firstMovableNodeStart);
|
|
1956
2012
|
};
|
|
1957
2013
|
var getSafeFixRangeEnd = (sourceCode, node) => {
|
|
1958
|
-
const declarationEnd = (0, import_ts_extras23.arrayLast)(node.range)
|
|
2014
|
+
const declarationEnd = (0, import_ts_extras23.arrayLast)(node.range);
|
|
1959
2015
|
const tokenAfterDeclaration = sourceCode.getTokenAfter(node);
|
|
1960
2016
|
if (tokenAfterDeclaration === null) {
|
|
1961
2017
|
return declarationEnd;
|
|
1962
2018
|
}
|
|
1963
|
-
return getLineStartIndex(sourceCode.text, (0, import_ts_extras23.arrayFirst)(tokenAfterDeclaration.range)
|
|
2019
|
+
return getLineStartIndex(sourceCode.text, (0, import_ts_extras23.arrayFirst)(tokenAfterDeclaration.range));
|
|
1964
2020
|
};
|
|
1965
2021
|
var rule26 = ruleCreator({
|
|
1966
2022
|
create: (context) => ({
|
|
@@ -1973,18 +2029,18 @@ var rule26 = ruleCreator({
|
|
|
1973
2029
|
const returnIndex = siblings.indexOf(node);
|
|
1974
2030
|
for (let i = returnIndex + 1; i < siblings.length; i++) {
|
|
1975
2031
|
const sibling = siblings[i];
|
|
1976
|
-
if (sibling?.type !==
|
|
2032
|
+
if (sibling?.type !== import_utils14.AST_NODE_TYPES.FunctionDeclaration) {
|
|
1977
2033
|
continue;
|
|
1978
2034
|
}
|
|
1979
2035
|
const functionDeclaration = sibling;
|
|
1980
2036
|
const returnStatement = node;
|
|
1981
2037
|
context.report({
|
|
1982
2038
|
data: {
|
|
1983
|
-
name: functionDeclaration.id
|
|
2039
|
+
name: functionDeclaration.id.name
|
|
1984
2040
|
},
|
|
1985
2041
|
fix(fixer) {
|
|
1986
2042
|
const sourceCode = context.sourceCode;
|
|
1987
|
-
const declarationEnd = (0, import_ts_extras23.arrayLast)(functionDeclaration.range)
|
|
2043
|
+
const declarationEnd = (0, import_ts_extras23.arrayLast)(functionDeclaration.range);
|
|
1988
2044
|
const fixRangeStart = getSafeFixRangeStart(sourceCode, functionDeclaration);
|
|
1989
2045
|
const fixRangeEnd = getSafeFixRangeEnd(sourceCode, functionDeclaration);
|
|
1990
2046
|
const functionAndLeadingCommentsText = sourceCode.text.slice(fixRangeStart, declarationEnd);
|
|
@@ -1992,7 +2048,10 @@ var rule26 = ruleCreator({
|
|
|
1992
2048
|
return null;
|
|
1993
2049
|
}
|
|
1994
2050
|
const returnToken = sourceCode.getFirstToken(returnStatement);
|
|
1995
|
-
|
|
2051
|
+
if (returnToken === null) {
|
|
2052
|
+
return null;
|
|
2053
|
+
}
|
|
2054
|
+
const indentationEnd = (0, import_ts_extras23.arrayFirst)(returnToken.range);
|
|
1996
2055
|
const returnLineStart = getLineStartIndex(sourceCode.text, indentationEnd);
|
|
1997
2056
|
return [
|
|
1998
2057
|
fixer.insertTextBeforeRange([returnLineStart, returnLineStart], `${functionAndLeadingCommentsText}
|
|
@@ -2029,12 +2088,12 @@ var no_function_declare_after_return_default = rule26;
|
|
|
2029
2088
|
|
|
2030
2089
|
// dist/rules/no-implicit-any-catch.js
|
|
2031
2090
|
var import_type_utils4 = require("@typescript-eslint/type-utils");
|
|
2032
|
-
var
|
|
2091
|
+
var import_utils15 = require("@typescript-eslint/utils");
|
|
2033
2092
|
var import_ts_extras24 = require("ts-extras");
|
|
2034
2093
|
var defaultOptions5 = [{}];
|
|
2035
2094
|
var isPromiseRejectionCall = (callExpression, parserServices, program) => {
|
|
2036
2095
|
const { callee } = callExpression;
|
|
2037
|
-
if (callee.type !==
|
|
2096
|
+
if (callee.type !== import_utils15.AST_NODE_TYPES.MemberExpression || callee.object.type === import_utils15.AST_NODE_TYPES.Super) {
|
|
2038
2097
|
return false;
|
|
2039
2098
|
}
|
|
2040
2099
|
const objectType = (0, import_type_utils4.getConstrainedTypeAtLocation)(parserServices, callee.object);
|
|
@@ -2060,15 +2119,15 @@ var annotateImplicitParamFixes = (fixer, sourceCode, parameter) => {
|
|
|
2060
2119
|
};
|
|
2061
2120
|
var rule27 = ruleCreator({
|
|
2062
2121
|
create: (context) => {
|
|
2063
|
-
const parserServices =
|
|
2122
|
+
const parserServices = import_utils15.ESLintUtils.getParserServices(context);
|
|
2064
2123
|
const sourceCode = context.sourceCode;
|
|
2065
2124
|
const [{ allowExplicitAny = false } = {}] = context.options;
|
|
2066
2125
|
const checkRejectionCallback = (callExpression, callback) => {
|
|
2067
|
-
if (callback.type !==
|
|
2126
|
+
if (callback.type !== import_utils15.AST_NODE_TYPES.ArrowFunctionExpression && callback.type !== import_utils15.AST_NODE_TYPES.FunctionExpression) {
|
|
2068
2127
|
return;
|
|
2069
2128
|
}
|
|
2070
2129
|
const [parameter] = callback.params;
|
|
2071
|
-
if (parameter?.type !==
|
|
2130
|
+
if (parameter?.type !== import_utils15.AST_NODE_TYPES.Identifier) {
|
|
2072
2131
|
return;
|
|
2073
2132
|
}
|
|
2074
2133
|
if (!isPromiseRejectionCall(callExpression, parserServices, parserServices.program)) {
|
|
@@ -2090,10 +2149,10 @@ var rule27 = ruleCreator({
|
|
|
2090
2149
|
}
|
|
2091
2150
|
const { typeAnnotation } = parameter;
|
|
2092
2151
|
const annotationType = typeAnnotation.typeAnnotation.type;
|
|
2093
|
-
if (annotationType ===
|
|
2152
|
+
if (annotationType === import_utils15.AST_NODE_TYPES.TSUnknownKeyword) {
|
|
2094
2153
|
return;
|
|
2095
2154
|
}
|
|
2096
|
-
if (annotationType ===
|
|
2155
|
+
if (annotationType === import_utils15.AST_NODE_TYPES.TSAnyKeyword) {
|
|
2097
2156
|
if (allowExplicitAny) {
|
|
2098
2157
|
return;
|
|
2099
2158
|
}
|
|
@@ -2197,13 +2256,13 @@ var rule29 = createImportPatternRule({
|
|
|
2197
2256
|
var no_internal_modules_default = rule29;
|
|
2198
2257
|
|
|
2199
2258
|
// dist/rules/no-internal.js
|
|
2200
|
-
var
|
|
2259
|
+
var import_utils16 = require("@typescript-eslint/utils");
|
|
2201
2260
|
var import_ts_extras25 = require("ts-extras");
|
|
2202
2261
|
var defaultOptions6 = [{}];
|
|
2203
2262
|
var rule30 = ruleCreator({
|
|
2204
2263
|
create: (context) => {
|
|
2205
2264
|
const [{ ignored = {} } = {}] = context.options;
|
|
2206
|
-
const parserServices =
|
|
2265
|
+
const parserServices = import_utils16.ESLintUtils.getParserServices(context);
|
|
2207
2266
|
const typeChecker = parserServices.program.getTypeChecker();
|
|
2208
2267
|
const compiledIgnorePatterns = compileIgnorePatterns(ignored);
|
|
2209
2268
|
const ignorePatterns = compiledIgnorePatterns.patterns;
|
|
@@ -2342,7 +2401,7 @@ var rule31 = ruleCreator({
|
|
|
2342
2401
|
var no_language_mixing_default = rule31;
|
|
2343
2402
|
|
|
2344
2403
|
// dist/rules/no-misused-generics.js
|
|
2345
|
-
var
|
|
2404
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
2346
2405
|
var import_ts_extras27 = require("ts-extras");
|
|
2347
2406
|
var tsutils = __toESM(require("tsutils"), 1);
|
|
2348
2407
|
var getVariableUses = (usageMap, identifier) => usageMap.get(identifier)?.uses ?? [];
|
|
@@ -2414,7 +2473,7 @@ var analyzeTypeParameterUses = (uses, signature, typeParameters) => {
|
|
|
2414
2473
|
};
|
|
2415
2474
|
var rule32 = ruleCreator({
|
|
2416
2475
|
create: (context) => {
|
|
2417
|
-
const parserServices =
|
|
2476
|
+
const parserServices = import_utils17.ESLintUtils.getParserServices(context);
|
|
2418
2477
|
let usageMap = null;
|
|
2419
2478
|
const checkTypeParameters = (typeParameters, signature) => {
|
|
2420
2479
|
usageMap ??= tsutils.collectVariableUsage(signature.getSourceFile());
|
|
@@ -2435,7 +2494,7 @@ var rule32 = ruleCreator({
|
|
|
2435
2494
|
});
|
|
2436
2495
|
continue;
|
|
2437
2496
|
}
|
|
2438
|
-
if (!usageAnalysis.usedInReturnOrExtends &&
|
|
2497
|
+
if (!usageAnalysis.usedInReturnOrExtends && !isConstrainedByAnotherTypeParameter(typeParameter, typeParameters, usageMap)) {
|
|
2439
2498
|
context.report({
|
|
2440
2499
|
data: {
|
|
2441
2500
|
name: typeParameter.name.text,
|
|
@@ -2563,9 +2622,10 @@ var rule35 = createImportPatternRule({
|
|
|
2563
2622
|
var no_nodejs_modules_default = rule35;
|
|
2564
2623
|
|
|
2565
2624
|
// dist/rules/no-param-reassign.js
|
|
2625
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
2566
2626
|
var import_ts_extras29 = require("ts-extras");
|
|
2567
2627
|
var getAssignmentTargetIdentifier = (node) => {
|
|
2568
|
-
if (node.left.type ===
|
|
2628
|
+
if (node.left.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
2569
2629
|
return node.left;
|
|
2570
2630
|
}
|
|
2571
2631
|
return void 0;
|
|
@@ -2581,7 +2641,7 @@ var getScopeVariable = (sourceCode, identifier) => {
|
|
|
2581
2641
|
}
|
|
2582
2642
|
return void 0;
|
|
2583
2643
|
};
|
|
2584
|
-
var isParameterVariable = (variable) => variable?.defs.some((definition) => definition.type ===
|
|
2644
|
+
var isParameterVariable = (variable) => variable?.defs.some((definition) => definition.type === import_utils18.TSESLint.Scope.DefinitionType.Parameter) ?? false;
|
|
2585
2645
|
var isInFirstFunctionExpressionStatement = (sourceCode, node) => {
|
|
2586
2646
|
const ancestors = sourceCode.getAncestors(node);
|
|
2587
2647
|
let enclosingFunction = null;
|
|
@@ -2590,16 +2650,16 @@ var isInFirstFunctionExpressionStatement = (sourceCode, node) => {
|
|
|
2590
2650
|
if (ancestor === void 0) {
|
|
2591
2651
|
continue;
|
|
2592
2652
|
}
|
|
2593
|
-
if (ancestor.type ===
|
|
2653
|
+
if (ancestor.type === import_utils18.AST_NODE_TYPES.ArrowFunctionExpression || ancestor.type === import_utils18.AST_NODE_TYPES.FunctionDeclaration || ancestor.type === import_utils18.AST_NODE_TYPES.FunctionExpression) {
|
|
2594
2654
|
enclosingFunction = ancestor;
|
|
2595
2655
|
break;
|
|
2596
2656
|
}
|
|
2597
2657
|
}
|
|
2598
|
-
if (enclosingFunction?.body.type !==
|
|
2658
|
+
if (enclosingFunction?.body.type !== import_utils18.AST_NODE_TYPES.BlockStatement) {
|
|
2599
2659
|
return false;
|
|
2600
2660
|
}
|
|
2601
2661
|
const [firstStatement] = enclosingFunction.body.body;
|
|
2602
|
-
if (firstStatement?.type !==
|
|
2662
|
+
if (firstStatement?.type !== import_utils18.AST_NODE_TYPES.ExpressionStatement) {
|
|
2603
2663
|
return false;
|
|
2604
2664
|
}
|
|
2605
2665
|
return (0, import_ts_extras29.arrayFirst)(node.range) >= (0, import_ts_extras29.arrayFirst)(firstStatement.range) && node.range[1] <= firstStatement.range[1];
|
|
@@ -2629,7 +2689,7 @@ var rule36 = ruleCreator({
|
|
|
2629
2689
|
reportIfParameterReassignment(identifier);
|
|
2630
2690
|
},
|
|
2631
2691
|
UpdateExpression: (node) => {
|
|
2632
|
-
if (node.argument.type !==
|
|
2692
|
+
if (node.argument.type !== import_utils18.AST_NODE_TYPES.Identifier) {
|
|
2633
2693
|
return;
|
|
2634
2694
|
}
|
|
2635
2695
|
reportIfParameterReassignment(node.argument);
|
|
@@ -2696,7 +2756,7 @@ var import_ts_extras31 = require("ts-extras");
|
|
|
2696
2756
|
|
|
2697
2757
|
// dist/_internal/syntax-selectors.js
|
|
2698
2758
|
var import_ts_extras30 = require("ts-extras");
|
|
2699
|
-
var isSelectorObject = (value) => typeof value === "object" &&
|
|
2759
|
+
var isSelectorObject = (value) => typeof value === "object" && (0, import_ts_extras30.keyIn)(value, "selector");
|
|
2700
2760
|
var normalizeSyntaxSelector = (selector25) => {
|
|
2701
2761
|
if (isSelectorObject(selector25)) {
|
|
2702
2762
|
if (!(0, import_ts_extras30.isDefined)(selector25.message)) {
|
|
@@ -2848,31 +2908,31 @@ var deprecatedRule9 = withDeprecatedRuleLifecycle(rule39, {
|
|
|
2848
2908
|
var no_secret_default = deprecatedRule9;
|
|
2849
2909
|
|
|
2850
2910
|
// dist/rules/no-self-import.js
|
|
2851
|
-
var import_node_path4 = require("node:path");
|
|
2911
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
2852
2912
|
var import_ts_extras32 = require("ts-extras");
|
|
2853
2913
|
var importFileSuffixes = [
|
|
2854
2914
|
"",
|
|
2855
|
-
".ts",
|
|
2856
|
-
".tsx",
|
|
2857
|
-
".js",
|
|
2858
|
-
".mjs",
|
|
2859
2915
|
".cjs",
|
|
2860
2916
|
".d.ts",
|
|
2861
|
-
"
|
|
2862
|
-
"
|
|
2917
|
+
".js",
|
|
2918
|
+
".mjs",
|
|
2919
|
+
".ts",
|
|
2920
|
+
".tsx",
|
|
2921
|
+
"/index.cjs",
|
|
2863
2922
|
"/index.js",
|
|
2864
2923
|
"/index.mjs",
|
|
2865
|
-
"/index.
|
|
2924
|
+
"/index.ts",
|
|
2925
|
+
"/index.tsx"
|
|
2866
2926
|
];
|
|
2867
|
-
var toResolvedCandidates = (baseDirectory, importSource) => importFileSuffixes.map((suffix) =>
|
|
2927
|
+
var toResolvedCandidates = (baseDirectory, importSource) => importFileSuffixes.map((suffix) => import_node_path4.default.resolve(baseDirectory, `${importSource}${suffix}`));
|
|
2868
2928
|
var rule40 = ruleCreator({
|
|
2869
2929
|
create: (context) => {
|
|
2870
2930
|
const currentFilePath = context.filename;
|
|
2871
2931
|
if (currentFilePath === "<input>") {
|
|
2872
2932
|
return {};
|
|
2873
2933
|
}
|
|
2874
|
-
const normalizedCurrentFilePath =
|
|
2875
|
-
const currentFileDirectory =
|
|
2934
|
+
const normalizedCurrentFilePath = import_node_path4.default.resolve(currentFilePath);
|
|
2935
|
+
const currentFileDirectory = import_node_path4.default.dirname(normalizedCurrentFilePath);
|
|
2876
2936
|
return {
|
|
2877
2937
|
"ImportDeclaration, ExportNamedDeclaration[source], ExportAllDeclaration, ImportExpression": (node) => {
|
|
2878
2938
|
const sourceText = getImportSourceFromNode(node);
|
|
@@ -2926,7 +2986,8 @@ var deprecatedRule10 = withDeprecatedRuleLifecycle(rule40, {
|
|
|
2926
2986
|
var no_self_import_default = deprecatedRule10;
|
|
2927
2987
|
|
|
2928
2988
|
// dist/rules/no-shadow.js
|
|
2929
|
-
var
|
|
2989
|
+
var import_utils19 = require("@typescript-eslint/utils");
|
|
2990
|
+
var shouldIgnoreVariable = (variable) => variable.defs.some((definition) => definition.node.type === import_utils19.AST_NODE_TYPES.TSEnumDeclaration || definition.type.includes("Enum"));
|
|
2930
2991
|
var findShadowedVariable = (scope, variableName) => {
|
|
2931
2992
|
let upperScope = scope.upper;
|
|
2932
2993
|
while (upperScope !== null) {
|
|
@@ -3015,7 +3076,8 @@ var rule42 = createImportPatternRule({
|
|
|
3015
3076
|
var no_sibling_import_default = rule42;
|
|
3016
3077
|
|
|
3017
3078
|
// dist/rules/no-single-line-comment.js
|
|
3018
|
-
var
|
|
3079
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
3080
|
+
var directiveCommentPattern = /^(?:eslint(?:-|$)|global\s|exported\s|ts-(?:check|expect-error|ignore|nocheck))/v;
|
|
3019
3081
|
var isDirectiveComment = (commentText2) => directiveCommentPattern.test(commentText2.trimStart());
|
|
3020
3082
|
var createConvertToBlockSuggestionFix = (commentValue, commentRange) => {
|
|
3021
3083
|
if (commentValue.includes("*/")) {
|
|
@@ -3029,7 +3091,7 @@ var rule43 = ruleCreator({
|
|
|
3029
3091
|
return {
|
|
3030
3092
|
Program: () => {
|
|
3031
3093
|
for (const comment of context.sourceCode.getAllComments()) {
|
|
3032
|
-
if (comment.type !==
|
|
3094
|
+
if (comment.type !== import_utils20.AST_TOKEN_TYPES.Line) {
|
|
3033
3095
|
continue;
|
|
3034
3096
|
}
|
|
3035
3097
|
if (allowDirectiveComments && isDirectiveComment(comment.value)) {
|
|
@@ -3187,9 +3249,10 @@ var rule45 = ruleCreator({
|
|
|
3187
3249
|
var no_underscore_export_default = rule45;
|
|
3188
3250
|
|
|
3189
3251
|
// dist/rules/no-unnecessary-as-const.js
|
|
3252
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
3190
3253
|
var disallowedSelector7 = "VariableDeclarator > TSAsExpression[expression.properties.length=0] > TSTypeReference > Identifier[name='const'], VariableDeclarator[id.typeAnnotation] > TSAsExpression > TSTypeReference > Identifier[name='const']";
|
|
3191
3254
|
var getAsConstExpression = (node) => {
|
|
3192
|
-
if (node.type !==
|
|
3255
|
+
if (node.type !== import_utils21.AST_NODE_TYPES.Identifier || node.parent.type !== import_utils21.AST_NODE_TYPES.TSTypeReference || node.parent.parent.type !== import_utils21.AST_NODE_TYPES.TSAsExpression) {
|
|
3193
3256
|
return void 0;
|
|
3194
3257
|
}
|
|
3195
3258
|
return node.parent.parent;
|
|
@@ -3234,6 +3297,7 @@ var rule46 = ruleCreator({
|
|
|
3234
3297
|
var no_unnecessary_as_const_default = rule46;
|
|
3235
3298
|
|
|
3236
3299
|
// dist/rules/no-unnecessary-break.js
|
|
3300
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
3237
3301
|
var import_ts_extras34 = require("ts-extras");
|
|
3238
3302
|
var disallowedSelector8 = "SwitchCase:last-child > BreakStatement.consequent";
|
|
3239
3303
|
var createTrailingBreakRemovalFix = (sourceCode, node) => {
|
|
@@ -3245,7 +3309,7 @@ var createTrailingBreakRemovalFix = (sourceCode, node) => {
|
|
|
3245
3309
|
return (fixer) => fixer.remove(node);
|
|
3246
3310
|
}
|
|
3247
3311
|
const leadingText = sourceCode.text.slice(previousToken.range[1], (0, import_ts_extras34.arrayFirst)(node.range));
|
|
3248
|
-
const leadingWhitespaceLength = /^[\t ]*/
|
|
3312
|
+
const leadingWhitespaceLength = /^[\t ]*/v.exec(leadingText)?.[0].length ?? 0;
|
|
3249
3313
|
return (fixer) => fixer.removeRange([
|
|
3250
3314
|
(0, import_ts_extras34.arrayFirst)(node.range) - leadingWhitespaceLength,
|
|
3251
3315
|
node.range[1]
|
|
@@ -3256,7 +3320,7 @@ var rule47 = ruleCreator({
|
|
|
3256
3320
|
const sourceCode = context.sourceCode;
|
|
3257
3321
|
return {
|
|
3258
3322
|
[disallowedSelector8]: (node) => {
|
|
3259
|
-
if (node.type !==
|
|
3323
|
+
if (node.type !== import_utils22.AST_NODE_TYPES.BreakStatement || node.label !== null) {
|
|
3260
3324
|
return;
|
|
3261
3325
|
}
|
|
3262
3326
|
const fix = createTrailingBreakRemovalFix(sourceCode, node);
|
|
@@ -3357,13 +3421,14 @@ var rule48 = ruleCreator({
|
|
|
3357
3421
|
var no_unnecessary_initialization_default = rule48;
|
|
3358
3422
|
|
|
3359
3423
|
// dist/rules/no-unnecessary-template-literal.js
|
|
3424
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
3360
3425
|
var import_ts_extras36 = require("ts-extras");
|
|
3361
3426
|
var selector3 = "TemplateLiteral[expressions.length=0] > TemplateElement";
|
|
3362
3427
|
var toSafeStringLiteralText = (templateLiteral) => JSON.stringify((0, import_ts_extras36.arrayFirst)(templateLiteral.quasis)?.value.cooked ?? (0, import_ts_extras36.arrayFirst)(templateLiteral.quasis)?.value.raw ?? "");
|
|
3363
3428
|
var rule49 = ruleCreator({
|
|
3364
3429
|
create: (context) => ({
|
|
3365
3430
|
[selector3]: (node) => {
|
|
3366
|
-
const templateLiteral = node.type ===
|
|
3431
|
+
const templateLiteral = node.type === import_utils23.AST_NODE_TYPES.TemplateElement && node.parent.type === import_utils23.AST_NODE_TYPES.TemplateLiteral ? node.parent : void 0;
|
|
3367
3432
|
if (templateLiteral === void 0) {
|
|
3368
3433
|
return;
|
|
3369
3434
|
}
|
|
@@ -3417,6 +3482,7 @@ var deprecatedRule12 = withDeprecatedRuleLifecycle(rule50, {
|
|
|
3417
3482
|
var no_unused_disable_default = deprecatedRule12;
|
|
3418
3483
|
|
|
3419
3484
|
// dist/rules/no-use-extend-native.js
|
|
3485
|
+
var import_utils24 = require("@typescript-eslint/utils");
|
|
3420
3486
|
var import_ts_extras37 = require("ts-extras");
|
|
3421
3487
|
var nativeTypeDefinitions = [
|
|
3422
3488
|
{
|
|
@@ -3504,6 +3570,7 @@ var nativeTypeDefinitions = [
|
|
|
3504
3570
|
}
|
|
3505
3571
|
];
|
|
3506
3572
|
var nativeTypeNameSet = new Set(nativeTypeDefinitions.map((definition) => definition.name));
|
|
3573
|
+
var nativeTypeNameLookup = nativeTypeNameSet;
|
|
3507
3574
|
function buildNativeTypeInfoByName(definitions) {
|
|
3508
3575
|
return new Map(definitions.map((definition) => [
|
|
3509
3576
|
definition.name,
|
|
@@ -3515,8 +3582,8 @@ function buildNativeTypeInfoByName(definitions) {
|
|
|
3515
3582
|
function collectPropertyKinds(definition) {
|
|
3516
3583
|
const propertyKinds = /* @__PURE__ */ new Map();
|
|
3517
3584
|
const descriptorSources = [
|
|
3518
|
-
definition.
|
|
3519
|
-
definition.
|
|
3585
|
+
definition.constructorRef,
|
|
3586
|
+
definition.prototypeRef
|
|
3520
3587
|
];
|
|
3521
3588
|
for (const descriptorSource of descriptorSources) {
|
|
3522
3589
|
if (!(0, import_ts_extras37.isDefined)(descriptorSource)) {
|
|
@@ -3542,38 +3609,38 @@ function collectPropertyKinds(definition) {
|
|
|
3542
3609
|
return propertyKinds;
|
|
3543
3610
|
}
|
|
3544
3611
|
function unwrapExpression(node) {
|
|
3545
|
-
if (node.type ===
|
|
3612
|
+
if (node.type === import_utils24.AST_NODE_TYPES.TSAsExpression || node.type === import_utils24.AST_NODE_TYPES.TSTypeAssertion) {
|
|
3546
3613
|
return unwrapExpression(node.expression);
|
|
3547
3614
|
}
|
|
3548
|
-
if (node.type ===
|
|
3615
|
+
if (node.type === import_utils24.AST_NODE_TYPES.ChainExpression) {
|
|
3549
3616
|
return unwrapExpression(node.expression);
|
|
3550
3617
|
}
|
|
3551
3618
|
return node;
|
|
3552
3619
|
}
|
|
3553
3620
|
var inferNativeType = (rawExpression) => {
|
|
3554
3621
|
const expression = unwrapExpression(rawExpression);
|
|
3555
|
-
if (expression.type ===
|
|
3622
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.ArrayExpression) {
|
|
3556
3623
|
return "Array";
|
|
3557
3624
|
}
|
|
3558
|
-
if (expression.type ===
|
|
3625
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.ObjectExpression) {
|
|
3559
3626
|
return "Object";
|
|
3560
3627
|
}
|
|
3561
|
-
if (expression.type ===
|
|
3628
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.TemplateLiteral) {
|
|
3562
3629
|
return "String";
|
|
3563
3630
|
}
|
|
3564
|
-
if (expression.type ===
|
|
3631
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.Literal) {
|
|
3565
3632
|
return inferNativeTypeFromLiteral(expression);
|
|
3566
3633
|
}
|
|
3567
|
-
if (expression.type ===
|
|
3634
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.Identifier && isNativeTypeName(expression.name)) {
|
|
3568
3635
|
return expression.name;
|
|
3569
3636
|
}
|
|
3570
|
-
if (expression.type ===
|
|
3637
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.BinaryExpression) {
|
|
3571
3638
|
return inferNativeTypeFromBinaryExpression(expression);
|
|
3572
3639
|
}
|
|
3573
|
-
if (expression.type ===
|
|
3640
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.MemberExpression) {
|
|
3574
3641
|
return inferNativeTypeFromMemberExpression(expression);
|
|
3575
3642
|
}
|
|
3576
|
-
if (expression.type ===
|
|
3643
|
+
if (expression.type === import_utils24.AST_NODE_TYPES.NewExpression) {
|
|
3577
3644
|
return inferNativeTypeFromNewExpression(expression);
|
|
3578
3645
|
}
|
|
3579
3646
|
return null;
|
|
@@ -3611,13 +3678,13 @@ function inferNativeTypeFromLiteral(expression) {
|
|
|
3611
3678
|
return null;
|
|
3612
3679
|
}
|
|
3613
3680
|
function inferNativeTypeFromMemberExpression(expression) {
|
|
3614
|
-
if (expression.computed || expression.property.type !==
|
|
3681
|
+
if (expression.computed || expression.property.type !== import_utils24.AST_NODE_TYPES.Identifier || expression.property.name !== "prototype" || expression.object.type !== import_utils24.AST_NODE_TYPES.Identifier || !isNativeTypeName(expression.object.name)) {
|
|
3615
3682
|
return null;
|
|
3616
3683
|
}
|
|
3617
3684
|
return expression.object.name;
|
|
3618
3685
|
}
|
|
3619
3686
|
function inferNativeTypeFromNewExpression(expression) {
|
|
3620
|
-
if (expression.callee.type !==
|
|
3687
|
+
if (expression.callee.type !== import_utils24.AST_NODE_TYPES.Identifier || !isNativeTypeName(expression.callee.name)) {
|
|
3621
3688
|
return null;
|
|
3622
3689
|
}
|
|
3623
3690
|
return expression.callee.name;
|
|
@@ -3632,17 +3699,17 @@ function getMemberKind(descriptor) {
|
|
|
3632
3699
|
return "data";
|
|
3633
3700
|
}
|
|
3634
3701
|
var getStaticMemberPropertyName = (node) => {
|
|
3635
|
-
if (node.computed || node.property.type !==
|
|
3702
|
+
if (node.computed || node.property.type !== import_utils24.AST_NODE_TYPES.Identifier) {
|
|
3636
3703
|
return null;
|
|
3637
3704
|
}
|
|
3638
3705
|
return node.property.name;
|
|
3639
3706
|
};
|
|
3640
3707
|
var isCallUsage = (node) => {
|
|
3641
3708
|
const parent = node.parent;
|
|
3642
|
-
return parent.type ===
|
|
3709
|
+
return parent.type === import_utils24.AST_NODE_TYPES.CallExpression && parent.callee === node;
|
|
3643
3710
|
};
|
|
3644
3711
|
var nativeTypeInfoByName = buildNativeTypeInfoByName(nativeTypeDefinitions);
|
|
3645
|
-
var isNativeTypeName = (value) => (0, import_ts_extras37.setHas)(
|
|
3712
|
+
var isNativeTypeName = (value) => (0, import_ts_extras37.setHas)(nativeTypeNameLookup, value);
|
|
3646
3713
|
var rule51 = ruleCreator({
|
|
3647
3714
|
create: (context) => ({
|
|
3648
3715
|
MemberExpression: (node) => {
|
|
@@ -3745,12 +3812,12 @@ var deprecatedRule14 = withDeprecatedRuleLifecycle(rule53, {
|
|
|
3745
3812
|
var no_value_tostring_default = deprecatedRule14;
|
|
3746
3813
|
|
|
3747
3814
|
// dist/rules/no-vulnerable.js
|
|
3748
|
-
var
|
|
3815
|
+
var import_utils25 = require("@typescript-eslint/utils");
|
|
3749
3816
|
var import_node_module = require("node:module");
|
|
3750
|
-
var import_node_path5 = require("node:path");
|
|
3817
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
3751
3818
|
var import_recheck = require("recheck");
|
|
3752
3819
|
var import_ts_extras38 = require("ts-extras");
|
|
3753
|
-
var requireFromWorkingDirectory = (0, import_node_module.createRequire)(
|
|
3820
|
+
var requireFromWorkingDirectory = (0, import_node_module.createRequire)(import_node_path5.default.join(process.cwd(), "package.json"));
|
|
3754
3821
|
var isUnknownRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3755
3822
|
var isModuleNotFoundError = (error) => {
|
|
3756
3823
|
if (!isUnknownRecord2(error)) {
|
|
@@ -3769,18 +3836,11 @@ var createRequireFromPluginPackage = () => {
|
|
|
3769
3836
|
}
|
|
3770
3837
|
};
|
|
3771
3838
|
var requireFromPluginPackage = createRequireFromPluginPackage();
|
|
3772
|
-
var
|
|
3773
|
-
try {
|
|
3774
|
-
return (0, import_node_fs.statSync)(filePath).isFile();
|
|
3775
|
-
} catch {
|
|
3776
|
-
return false;
|
|
3777
|
-
}
|
|
3778
|
-
};
|
|
3779
|
-
var shouldOverrideRuntimePath = (currentPath) => !(0, import_ts_extras38.isDefined)(currentPath) || !isExistingFile(currentPath) || (0, import_node_path5.basename)(currentPath).toLowerCase() === "package.json";
|
|
3839
|
+
var shouldOverrideRuntimePath = (currentPath) => !(0, import_ts_extras38.isDefined)(currentPath) || import_node_path5.default.basename(currentPath).toLowerCase() === "package.json";
|
|
3780
3840
|
var resolvePackageSiblingFile = (packageJsonSpecifier, siblingFileName) => {
|
|
3781
3841
|
try {
|
|
3782
3842
|
const packageJsonPath = requireFromPluginPackage.resolve(packageJsonSpecifier);
|
|
3783
|
-
return
|
|
3843
|
+
return import_node_path5.default.join(import_node_path5.default.dirname(packageJsonPath), siblingFileName);
|
|
3784
3844
|
} catch (error) {
|
|
3785
3845
|
if (isModuleNotFoundError(error)) {
|
|
3786
3846
|
return null;
|
|
@@ -3817,10 +3877,10 @@ var getRecheckEnvironmentOverrides = () => {
|
|
|
3817
3877
|
return {};
|
|
3818
3878
|
}
|
|
3819
3879
|
const overrides = {};
|
|
3820
|
-
if (recheckJarPath !== null &&
|
|
3880
|
+
if (recheckJarPath !== null && shouldOverrideRuntimePath(getRecheckEnvironmentValue("RECHECK_JAR"))) {
|
|
3821
3881
|
overrides.RECHECK_JAR = recheckJarPath;
|
|
3822
3882
|
}
|
|
3823
|
-
if (recheckWindowsBinaryPath !== null &&
|
|
3883
|
+
if (recheckWindowsBinaryPath !== null && shouldOverrideRuntimePath(getRecheckEnvironmentValue("RECHECK_BIN"))) {
|
|
3824
3884
|
overrides.RECHECK_BIN = recheckWindowsBinaryPath;
|
|
3825
3885
|
}
|
|
3826
3886
|
return overrides;
|
|
@@ -3851,17 +3911,17 @@ var withRecheckEnvironmentOverrides = (callback) => {
|
|
|
3851
3911
|
};
|
|
3852
3912
|
var runRecheck = (source, flags, parameters) => withRecheckEnvironmentOverrides(() => (0, import_recheck.checkSync)(source, flags, parameters));
|
|
3853
3913
|
var getStaticStringValue = (node) => {
|
|
3854
|
-
if (node.type ===
|
|
3914
|
+
if (node.type === import_utils25.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
3855
3915
|
return node.value;
|
|
3856
3916
|
}
|
|
3857
|
-
if (node.type ===
|
|
3917
|
+
if (node.type === import_utils25.AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0 && node.quasis.length === 1) {
|
|
3858
3918
|
return (0, import_ts_extras38.arrayFirst)(node.quasis)?.value.cooked ?? null;
|
|
3859
3919
|
}
|
|
3860
3920
|
return null;
|
|
3861
3921
|
};
|
|
3862
|
-
var isNonSpreadArgument = (argument) => argument.type !==
|
|
3922
|
+
var isNonSpreadArgument = (argument) => argument.type !== import_utils25.AST_NODE_TYPES.SpreadElement;
|
|
3863
3923
|
var isRegExpConstructorCall = (node) => {
|
|
3864
|
-
if (node.callee.type !==
|
|
3924
|
+
if (node.callee.type !== import_utils25.AST_NODE_TYPES.Identifier || node.callee.name !== "RegExp") {
|
|
3865
3925
|
return false;
|
|
3866
3926
|
}
|
|
3867
3927
|
if (node.arguments.length === 0 || node.arguments.length > 2) {
|
|
@@ -3879,7 +3939,7 @@ var isRegExpConstructorCall = (node) => {
|
|
|
3879
3939
|
if (flagsArgument === void 0) {
|
|
3880
3940
|
return true;
|
|
3881
3941
|
}
|
|
3882
|
-
if (flagsArgument.type ===
|
|
3942
|
+
if (flagsArgument.type === import_utils25.AST_NODE_TYPES.SpreadElement) {
|
|
3883
3943
|
return false;
|
|
3884
3944
|
}
|
|
3885
3945
|
return (0, import_ts_extras38.isDefined)(getStaticStringValue(flagsArgument));
|
|
@@ -4114,11 +4174,12 @@ var rule56 = ruleCreator({
|
|
|
4114
4174
|
var object_format_default = rule56;
|
|
4115
4175
|
|
|
4116
4176
|
// dist/rules/only-export-name.js
|
|
4177
|
+
var import_utils26 = require("@typescript-eslint/utils");
|
|
4117
4178
|
var import_ts_extras39 = require("ts-extras");
|
|
4118
4179
|
var getExportedNames = (node) => {
|
|
4119
4180
|
if (node.specifiers.length > 0) {
|
|
4120
|
-
return node.specifiers.
|
|
4121
|
-
if (specifier.exported.type ===
|
|
4181
|
+
return node.specifiers.flatMap((specifier) => {
|
|
4182
|
+
if (specifier.exported.type === import_utils26.AST_NODE_TYPES.Identifier) {
|
|
4122
4183
|
return [specifier.exported.name];
|
|
4123
4184
|
}
|
|
4124
4185
|
return [];
|
|
@@ -4128,13 +4189,13 @@ var getExportedNames = (node) => {
|
|
|
4128
4189
|
if (declaration === null) {
|
|
4129
4190
|
return [];
|
|
4130
4191
|
}
|
|
4131
|
-
if (declaration.type ===
|
|
4192
|
+
if (declaration.type === import_utils26.AST_NODE_TYPES.FunctionDeclaration || declaration.type === import_utils26.AST_NODE_TYPES.ClassDeclaration) {
|
|
4132
4193
|
return declaration.id === null ? [] : [declaration.id.name];
|
|
4133
4194
|
}
|
|
4134
|
-
if (declaration.type ===
|
|
4195
|
+
if (declaration.type === import_utils26.AST_NODE_TYPES.VariableDeclaration) {
|
|
4135
4196
|
let names = [];
|
|
4136
4197
|
for (const declarator of declaration.declarations) {
|
|
4137
|
-
if (declarator.id.type ===
|
|
4198
|
+
if (declarator.id.type === import_utils26.AST_NODE_TYPES.Identifier) {
|
|
4138
4199
|
names = [...names, declarator.id.name];
|
|
4139
4200
|
}
|
|
4140
4201
|
}
|
|
@@ -4298,12 +4359,12 @@ var prefer_includes_default = deprecatedRule15;
|
|
|
4298
4359
|
|
|
4299
4360
|
// dist/rules/prefer-interface.js
|
|
4300
4361
|
var import_type_utils5 = require("@typescript-eslint/type-utils");
|
|
4301
|
-
var
|
|
4362
|
+
var import_utils27 = require("@typescript-eslint/utils");
|
|
4302
4363
|
var import_ts_extras40 = require("ts-extras");
|
|
4303
4364
|
var tsutils2 = __toESM(require("tsutils"), 1);
|
|
4304
4365
|
var defaultOptions8 = [{}];
|
|
4305
|
-
var isExportedTypeAlias = (typeAliasDeclaration) => typeAliasDeclaration.parent
|
|
4306
|
-
var getTypeAliasDeclarationParent = (node) => node?.type ===
|
|
4366
|
+
var isExportedTypeAlias = (typeAliasDeclaration) => typeAliasDeclaration.parent.type === import_utils27.AST_NODE_TYPES.ExportNamedDeclaration && typeAliasDeclaration.parent.declaration === typeAliasDeclaration;
|
|
4367
|
+
var getTypeAliasDeclarationParent = (node) => node?.type === import_utils27.AST_NODE_TYPES.TSTypeAliasDeclaration ? node : void 0;
|
|
4307
4368
|
var formatTypeParameters = (sourceCode, typeParameters) => typeParameters === void 0 ? "" : sourceCode.getText(typeParameters);
|
|
4308
4369
|
var createTypeLiteralFixText = (sourceCode, typeAliasDeclaration, typeLiteralNode) => {
|
|
4309
4370
|
const aliasTypeParameters = formatTypeParameters(sourceCode, typeAliasDeclaration.typeParameters);
|
|
@@ -4328,11 +4389,11 @@ var canSafelyConvertIntersection = (intersectionTypeNode, parserServices) => {
|
|
|
4328
4389
|
let literals = [];
|
|
4329
4390
|
let references = [];
|
|
4330
4391
|
for (const intersectionMember of intersectionTypeNode.types) {
|
|
4331
|
-
if (intersectionMember.type ===
|
|
4392
|
+
if (intersectionMember.type === import_utils27.AST_NODE_TYPES.TSTypeLiteral) {
|
|
4332
4393
|
literals = [...literals, intersectionMember];
|
|
4333
4394
|
continue;
|
|
4334
4395
|
}
|
|
4335
|
-
if (intersectionMember.type ===
|
|
4396
|
+
if (intersectionMember.type === import_utils27.AST_NODE_TYPES.TSTypeReference) {
|
|
4336
4397
|
references = [...references, intersectionMember];
|
|
4337
4398
|
continue;
|
|
4338
4399
|
}
|
|
@@ -4371,7 +4432,7 @@ var rule61 = ruleCreator({
|
|
|
4371
4432
|
create: (context) => {
|
|
4372
4433
|
const [{ allowIntersection = true, allowLocal = false } = {}] = context.options;
|
|
4373
4434
|
const sourceCode = context.sourceCode;
|
|
4374
|
-
const parserServices =
|
|
4435
|
+
const parserServices = import_utils27.ESLintUtils.getParserServices(context, true);
|
|
4375
4436
|
const typedParserServices = hasFullTypeInformation(parserServices) ? parserServices : void 0;
|
|
4376
4437
|
const shouldSkipForAllowLocal = (typeAliasDeclaration) => allowLocal && !isExportedTypeAlias(typeAliasDeclaration);
|
|
4377
4438
|
return {
|
|
@@ -4581,6 +4642,7 @@ var rule64 = ruleCreator({
|
|
|
4581
4642
|
var prefer_only_export_default = rule64;
|
|
4582
4643
|
|
|
4583
4644
|
// dist/rules/require-jsdoc.js
|
|
4645
|
+
var import_utils28 = require("@typescript-eslint/utils");
|
|
4584
4646
|
var import_ts_extras41 = require("ts-extras");
|
|
4585
4647
|
var defaultKinds = [
|
|
4586
4648
|
"arrow-function",
|
|
@@ -4592,7 +4654,7 @@ var defaultKinds = [
|
|
|
4592
4654
|
var hasJSDocComment = (sourceCode, node) => {
|
|
4593
4655
|
const comments = sourceCode.getCommentsBefore(node);
|
|
4594
4656
|
const comment = (0, import_ts_extras41.arrayLast)(comments);
|
|
4595
|
-
return comment?.type ===
|
|
4657
|
+
return comment?.type === import_utils28.AST_TOKEN_TYPES.Block && comment.value.startsWith("*");
|
|
4596
4658
|
};
|
|
4597
4659
|
var reportMissingJSDoc = (context, node) => {
|
|
4598
4660
|
if (hasJSDocComment(context.sourceCode, node)) {
|
|
@@ -4620,7 +4682,7 @@ var rule65 = ruleCreator({
|
|
|
4620
4682
|
reportMissingJSDoc(context, node);
|
|
4621
4683
|
},
|
|
4622
4684
|
MethodDefinition: (node) => {
|
|
4623
|
-
if (!(0, import_ts_extras41.setHas)(kinds, "method") || node.kind === "constructor" || node.key.type !==
|
|
4685
|
+
if (!(0, import_ts_extras41.setHas)(kinds, "method") || node.kind === "constructor" || node.key.type !== import_utils28.AST_NODE_TYPES.Identifier) {
|
|
4624
4686
|
return;
|
|
4625
4687
|
}
|
|
4626
4688
|
reportMissingJSDoc(context, node);
|
|
@@ -4629,12 +4691,12 @@ var rule65 = ruleCreator({
|
|
|
4629
4691
|
if (!(0, import_ts_extras41.setHas)(kinds, "type")) {
|
|
4630
4692
|
return;
|
|
4631
4693
|
}
|
|
4632
|
-
if (node.type ===
|
|
4694
|
+
if (node.type === import_utils28.AST_NODE_TYPES.TSInterfaceDeclaration || node.type === import_utils28.AST_NODE_TYPES.TSTypeAliasDeclaration) {
|
|
4633
4695
|
reportMissingJSDoc(context, node);
|
|
4634
4696
|
}
|
|
4635
4697
|
},
|
|
4636
4698
|
VariableDeclarator: (node) => {
|
|
4637
|
-
if (!(0, import_ts_extras41.setHas)(kinds, "arrow-function") || node.id.type !==
|
|
4699
|
+
if (!(0, import_ts_extras41.setHas)(kinds, "arrow-function") || node.id.type !== import_utils28.AST_NODE_TYPES.Identifier || node.init?.type !== import_utils28.AST_NODE_TYPES.ArrowFunctionExpression || node.parent.kind !== "const") {
|
|
4638
4700
|
return;
|
|
4639
4701
|
}
|
|
4640
4702
|
reportMissingJSDoc(context, node.parent);
|
|
@@ -4828,9 +4890,10 @@ var rule67 = ruleCreator({
|
|
|
4828
4890
|
var restrict_identifier_characters_default = rule67;
|
|
4829
4891
|
|
|
4830
4892
|
// dist/rules/sort-array.js
|
|
4893
|
+
var import_utils29 = require("@typescript-eslint/utils");
|
|
4831
4894
|
var import_ts_extras43 = require("ts-extras");
|
|
4832
4895
|
var getSortableValue = (element) => {
|
|
4833
|
-
if (element.type ===
|
|
4896
|
+
if (element.type === import_utils29.AST_NODE_TYPES.Literal) {
|
|
4834
4897
|
return String(element.value);
|
|
4835
4898
|
}
|
|
4836
4899
|
return void 0;
|
|
@@ -4926,12 +4989,13 @@ var rule69 = ruleCreator({
|
|
|
4926
4989
|
var sort_call_signature_default = rule69;
|
|
4927
4990
|
|
|
4928
4991
|
// dist/rules/sort-class-members.js
|
|
4992
|
+
var import_utils30 = require("@typescript-eslint/utils");
|
|
4929
4993
|
var import_ts_extras44 = require("ts-extras");
|
|
4930
4994
|
var memberName = (member) => {
|
|
4931
|
-
if (member.key.type ===
|
|
4995
|
+
if (member.key.type === import_utils30.AST_NODE_TYPES.Identifier) {
|
|
4932
4996
|
return member.key.name;
|
|
4933
4997
|
}
|
|
4934
|
-
if (member.key.type ===
|
|
4998
|
+
if (member.key.type === import_utils30.AST_NODE_TYPES.Literal && typeof member.key.value === "string") {
|
|
4935
4999
|
return member.key.value;
|
|
4936
5000
|
}
|
|
4937
5001
|
return void 0;
|
|
@@ -4941,7 +5005,7 @@ var rule70 = ruleCreator({
|
|
|
4941
5005
|
ClassBody: (node) => {
|
|
4942
5006
|
let members = [];
|
|
4943
5007
|
for (const member of node.body) {
|
|
4944
|
-
if (member.type ===
|
|
5008
|
+
if (member.type === import_utils30.AST_NODE_TYPES.PropertyDefinition || member.type === import_utils30.AST_NODE_TYPES.MethodDefinition) {
|
|
4945
5009
|
members = [...members, member];
|
|
4946
5010
|
}
|
|
4947
5011
|
}
|
|
@@ -5038,8 +5102,9 @@ var rule71 = ruleCreator({
|
|
|
5038
5102
|
var sort_construct_signature_default = rule71;
|
|
5039
5103
|
|
|
5040
5104
|
// dist/rules/sort-export-specifiers.js
|
|
5105
|
+
var import_utils31 = require("@typescript-eslint/utils");
|
|
5041
5106
|
var import_ts_extras45 = require("ts-extras");
|
|
5042
|
-
var toName = (specifier) => specifier.exported.type ===
|
|
5107
|
+
var toName = (specifier) => specifier.exported.type === import_utils31.AST_NODE_TYPES.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
5043
5108
|
var buildFix3 = (fixer, node, sourceCode, sorted) => {
|
|
5044
5109
|
const startRange = (0, import_ts_extras45.arrayFirst)(node.specifiers)?.range ?? node.range;
|
|
5045
5110
|
const endRange = (0, import_ts_extras45.arrayLast)(node.specifiers)?.range ?? node.range;
|
|
@@ -5050,9 +5115,7 @@ var rule72 = ruleCreator({
|
|
|
5050
5115
|
ExportNamedDeclaration: (node) => {
|
|
5051
5116
|
let exportSpecifiers = [];
|
|
5052
5117
|
for (const specifier of node.specifiers) {
|
|
5053
|
-
|
|
5054
|
-
exportSpecifiers = [...exportSpecifiers, specifier];
|
|
5055
|
-
}
|
|
5118
|
+
exportSpecifiers = [...exportSpecifiers, specifier];
|
|
5056
5119
|
}
|
|
5057
5120
|
if (exportSpecifiers.length < 2) {
|
|
5058
5121
|
return;
|
|
@@ -5091,12 +5154,13 @@ var rule72 = ruleCreator({
|
|
|
5091
5154
|
var sort_export_specifiers_default = rule72;
|
|
5092
5155
|
|
|
5093
5156
|
// dist/rules/sort-keys.js
|
|
5157
|
+
var import_utils32 = require("@typescript-eslint/utils");
|
|
5094
5158
|
var import_ts_extras46 = require("ts-extras");
|
|
5095
5159
|
var keyName = (property) => {
|
|
5096
|
-
if (property.key.type ===
|
|
5160
|
+
if (property.key.type === import_utils32.AST_NODE_TYPES.Identifier) {
|
|
5097
5161
|
return property.key.name;
|
|
5098
5162
|
}
|
|
5099
|
-
if (property.key.type ===
|
|
5163
|
+
if (property.key.type === import_utils32.AST_NODE_TYPES.Literal && typeof property.key.value === "string") {
|
|
5100
5164
|
return property.key.value;
|
|
5101
5165
|
}
|
|
5102
5166
|
return void 0;
|
|
@@ -5115,7 +5179,7 @@ var rule73 = ruleCreator({
|
|
|
5115
5179
|
ObjectExpression: (node) => {
|
|
5116
5180
|
let properties = [];
|
|
5117
5181
|
for (const property of node.properties) {
|
|
5118
|
-
if (property.type ===
|
|
5182
|
+
if (property.type === import_utils32.AST_NODE_TYPES.Property && property.kind === "init" && !property.computed) {
|
|
5119
5183
|
properties = [...properties, property];
|
|
5120
5184
|
}
|
|
5121
5185
|
}
|
|
@@ -5217,6 +5281,7 @@ var rule74 = ruleCreator({
|
|
|
5217
5281
|
var sort_top_comments_default = rule74;
|
|
5218
5282
|
|
|
5219
5283
|
// dist/rules/switch-case-spacing.js
|
|
5284
|
+
var import_utils33 = require("@typescript-eslint/utils");
|
|
5220
5285
|
var import_ts_extras48 = require("ts-extras");
|
|
5221
5286
|
var isValidCaseBody = (node) => {
|
|
5222
5287
|
if (node.consequent.length === 0) {
|
|
@@ -5228,8 +5293,8 @@ var isValidCaseBody = (node) => {
|
|
|
5228
5293
|
return true;
|
|
5229
5294
|
}
|
|
5230
5295
|
const startsOnFollowingLine = firstStatement.loc.start.line > node.loc.start.line;
|
|
5231
|
-
const startsWithBlock = firstStatement.type ===
|
|
5232
|
-
const endsWithBreak = lastStatement.type ===
|
|
5296
|
+
const startsWithBlock = firstStatement.type === import_utils33.AST_NODE_TYPES.BlockStatement;
|
|
5297
|
+
const endsWithBreak = lastStatement.type === import_utils33.AST_NODE_TYPES.BreakStatement || startsWithBlock;
|
|
5233
5298
|
return (startsOnFollowingLine || startsWithBlock) && endsWithBreak;
|
|
5234
5299
|
};
|
|
5235
5300
|
var rule75 = ruleCreator({
|
|
@@ -5289,9 +5354,9 @@ var hasExpectedBoundaryNewlines = (node) => {
|
|
|
5289
5354
|
return first.startsWith("\n") && last.endsWith("\n");
|
|
5290
5355
|
};
|
|
5291
5356
|
var normalizeTemplate = (sourceText) => {
|
|
5292
|
-
const lines = (0, import_ts_extras49.stringSplit)(sourceText.replaceAll(/\r\n?/
|
|
5357
|
+
const lines = (0, import_ts_extras49.stringSplit)(sourceText.replaceAll(/\r\n?/gv, "\n"), "\n");
|
|
5293
5358
|
const contentLines = lines.slice(1, -1);
|
|
5294
|
-
const indents = contentLines.filter((line) => line.trim().length > 0).map((line) => /^\s*/
|
|
5359
|
+
const indents = contentLines.filter((line) => line.trim().length > 0).map((line) => /^\s*/v.exec(line)?.[0].length ?? 0);
|
|
5295
5360
|
const minIndent = (0, import_ts_extras49.isEmpty)(indents) ? 0 : Math.min(...indents);
|
|
5296
5361
|
const normalizedContent = (0, import_ts_extras49.arrayJoin)(contentLines.map((line) => line.length >= minIndent ? line.slice(minIndent) : line).map((line) => ` ${line}`), "\n");
|
|
5297
5362
|
const lastLine = (0, import_ts_extras49.arrayLast)(lines) ?? "";
|
|
@@ -5341,22 +5406,22 @@ var template_literal_format_default = rule76;
|
|
|
5341
5406
|
|
|
5342
5407
|
// dist/rules/throw-error.js
|
|
5343
5408
|
var import_type_utils6 = require("@typescript-eslint/type-utils");
|
|
5344
|
-
var
|
|
5409
|
+
var import_utils34 = require("@typescript-eslint/utils");
|
|
5345
5410
|
var import_ts_extras50 = require("ts-extras");
|
|
5346
5411
|
var tsutils3 = __toESM(require("tsutils"), 1);
|
|
5347
5412
|
var isAllowedThrowableVariant = (type, program) => (0, import_type_utils6.isTypeAnyType)(type) || (0, import_type_utils6.isTypeUnknownType)(type) || (0, import_type_utils6.isErrorLike)(program, type);
|
|
5348
5413
|
var couldBeAllowedThrowableType = (type, program) => tsutils3.unionTypeParts(type).every((typeVariant) => isAllowedThrowableVariant(typeVariant, program));
|
|
5349
5414
|
var couldBePromiseConstructorType = (type, program) => tsutils3.unionTypeParts(type).some((typeVariant) => (0, import_type_utils6.isBuiltinSymbolLike)(program, typeVariant, "PromiseConstructor"));
|
|
5350
|
-
var isPromiseIdentifier = (node) => node.type ===
|
|
5415
|
+
var isPromiseIdentifier = (node) => node.type === import_utils34.AST_NODE_TYPES.Identifier && node.name === "Promise";
|
|
5351
5416
|
var createWrapLiteralInErrorSuggestionFix = (sourceCode, node) => {
|
|
5352
|
-
if (node.type !==
|
|
5417
|
+
if (node.type !== import_utils34.AST_NODE_TYPES.Literal) {
|
|
5353
5418
|
return void 0;
|
|
5354
5419
|
}
|
|
5355
5420
|
return (fixer) => fixer.replaceText(node, `new Error(${sourceCode.getText(node)})`);
|
|
5356
5421
|
};
|
|
5357
5422
|
var rule77 = ruleCreator({
|
|
5358
5423
|
create: (context) => {
|
|
5359
|
-
const parserServices =
|
|
5424
|
+
const parserServices = import_utils34.ESLintUtils.getParserServices(context);
|
|
5360
5425
|
const sourceCode = context.sourceCode;
|
|
5361
5426
|
const { program } = parserServices;
|
|
5362
5427
|
const reportIfNonErrorLike = (node, usage) => {
|
|
@@ -5389,7 +5454,7 @@ var rule77 = ruleCreator({
|
|
|
5389
5454
|
return {
|
|
5390
5455
|
"CallExpression[callee.type='MemberExpression'][callee.property.type='Identifier'][callee.property.name='reject']": (callExpression) => {
|
|
5391
5456
|
const { callee } = callExpression;
|
|
5392
|
-
if (callee.type !==
|
|
5457
|
+
if (callee.type !== import_utils34.AST_NODE_TYPES.MemberExpression || callee.object.type === import_utils34.AST_NODE_TYPES.Super) {
|
|
5393
5458
|
return;
|
|
5394
5459
|
}
|
|
5395
5460
|
const objectType = (0, import_type_utils6.getConstrainedTypeAtLocation)(parserServices, callee.object);
|
|
@@ -5400,7 +5465,7 @@ var rule77 = ruleCreator({
|
|
|
5400
5465
|
},
|
|
5401
5466
|
"NewExpression[callee.type='Identifier'][callee.name='Promise'] > ArrowFunctionExpression, NewExpression[callee.type='Identifier'][callee.name='Promise'] > FunctionExpression": (callback) => {
|
|
5402
5467
|
const rejectParameter = callback.params[1];
|
|
5403
|
-
if (rejectParameter?.type !==
|
|
5468
|
+
if (rejectParameter?.type !== import_utils34.AST_NODE_TYPES.Identifier) {
|
|
5404
5469
|
return;
|
|
5405
5470
|
}
|
|
5406
5471
|
const rejectVariable = (0, import_ts_extras50.arrayFirst)(context.sourceCode.getDeclaredVariables(callback).filter((declaredVariable) => declaredVariable.name === rejectParameter.name));
|
|
@@ -5410,16 +5475,13 @@ var rule77 = ruleCreator({
|
|
|
5410
5475
|
for (const reference of rejectVariable.references) {
|
|
5411
5476
|
const { identifier } = reference;
|
|
5412
5477
|
const parent = identifier.parent;
|
|
5413
|
-
if (parent
|
|
5478
|
+
if (parent.type === import_utils34.AST_NODE_TYPES.CallExpression && parent.callee === identifier) {
|
|
5414
5479
|
checkRejectionCall(parent);
|
|
5415
5480
|
}
|
|
5416
5481
|
}
|
|
5417
5482
|
},
|
|
5418
5483
|
ThrowStatement: (throwStatement) => {
|
|
5419
5484
|
const { argument } = throwStatement;
|
|
5420
|
-
if (argument === null) {
|
|
5421
|
-
return;
|
|
5422
|
-
}
|
|
5423
5485
|
reportIfNonErrorLike(argument, "Throwing");
|
|
5424
5486
|
}
|
|
5425
5487
|
};
|
|
@@ -5469,7 +5531,7 @@ var throw_new_error_default = deprecatedRule21;
|
|
|
5469
5531
|
|
|
5470
5532
|
// dist/rules/typescript-array-callback-return-type.js
|
|
5471
5533
|
var import_type_utils7 = require("@typescript-eslint/type-utils");
|
|
5472
|
-
var
|
|
5534
|
+
var import_utils35 = require("@typescript-eslint/utils");
|
|
5473
5535
|
var import_ts_extras51 = require("ts-extras");
|
|
5474
5536
|
var arrayCallbackMethodNames = /* @__PURE__ */ new Set([
|
|
5475
5537
|
"every",
|
|
@@ -5491,19 +5553,19 @@ var isArrayLikeType2 = (typeChecker, type) => {
|
|
|
5491
5553
|
var isFirstCallbackArgument = (callExpression, callback) => (0, import_ts_extras51.arrayFirst)(callExpression.arguments) === callback;
|
|
5492
5554
|
var rule79 = ruleCreator({
|
|
5493
5555
|
create: (context) => {
|
|
5494
|
-
const parserServices =
|
|
5556
|
+
const parserServices = import_utils35.ESLintUtils.getParserServices(context);
|
|
5495
5557
|
const typeChecker = parserServices.program.getTypeChecker();
|
|
5496
5558
|
return {
|
|
5497
5559
|
[callbackSelector]: (callback) => {
|
|
5498
5560
|
const parentNode = callback.parent;
|
|
5499
|
-
if (parentNode
|
|
5561
|
+
if (parentNode.type !== import_utils35.AST_NODE_TYPES.CallExpression) {
|
|
5500
5562
|
return;
|
|
5501
5563
|
}
|
|
5502
5564
|
if (!isFirstCallbackArgument(parentNode, callback)) {
|
|
5503
5565
|
return;
|
|
5504
5566
|
}
|
|
5505
5567
|
const { callee } = parentNode;
|
|
5506
|
-
if (callee.type !==
|
|
5568
|
+
if (callee.type !== import_utils35.AST_NODE_TYPES.MemberExpression || callee.object.type === import_utils35.AST_NODE_TYPES.Super || callee.property.type !== import_utils35.AST_NODE_TYPES.Identifier || !(0, import_ts_extras51.setHas)(arrayCallbackMethodNames, callee.property.name)) {
|
|
5507
5569
|
return;
|
|
5508
5570
|
}
|
|
5509
5571
|
const objectType = (0, import_type_utils7.getConstrainedTypeAtLocation)(parserServices, callee.object);
|
|
@@ -5539,6 +5601,7 @@ var rule79 = ruleCreator({
|
|
|
5539
5601
|
var typescript_array_callback_return_type_default = rule79;
|
|
5540
5602
|
|
|
5541
5603
|
// dist/rules/typescript-class-methods-use-this.js
|
|
5604
|
+
var import_utils36 = require("@typescript-eslint/utils");
|
|
5542
5605
|
var import_ts_extras52 = require("ts-extras");
|
|
5543
5606
|
var isNode = (value) => typeof value === "object" && value !== null && (0, import_ts_extras52.objectHasOwn)(value, "type");
|
|
5544
5607
|
var collectNodeChildren = (node) => {
|
|
@@ -5570,7 +5633,7 @@ var containsThisExpression = (root) => {
|
|
|
5570
5633
|
if (node === void 0) {
|
|
5571
5634
|
continue;
|
|
5572
5635
|
}
|
|
5573
|
-
if (node.type ===
|
|
5636
|
+
if (node.type === import_utils36.AST_NODE_TYPES.ThisExpression) {
|
|
5574
5637
|
return true;
|
|
5575
5638
|
}
|
|
5576
5639
|
stack = [...stack, ...collectNodeChildren(node)];
|
|
@@ -5579,7 +5642,7 @@ var containsThisExpression = (root) => {
|
|
|
5579
5642
|
};
|
|
5580
5643
|
var hasThisParameter = (node) => {
|
|
5581
5644
|
const [firstParameter] = node.value.params;
|
|
5582
|
-
return firstParameter?.type ===
|
|
5645
|
+
return firstParameter?.type === import_utils36.AST_NODE_TYPES.Identifier && firstParameter.name === "this";
|
|
5583
5646
|
};
|
|
5584
5647
|
var usesThisExpression = (node) => node.value.body === null ? false : containsThisExpression(node.value.body);
|
|
5585
5648
|
var shouldSkipMethod = (node) => node.kind !== "method" || node.static || node.value.body === null || hasThisParameter(node) || usesThisExpression(node);
|
|
@@ -5741,6 +5804,7 @@ var deprecatedRule23 = withDeprecatedRuleLifecycle(rule83, {
|
|
|
5741
5804
|
var typescript_exhaustive_switch_default = deprecatedRule23;
|
|
5742
5805
|
|
|
5743
5806
|
// dist/rules/typescript-no-boolean-literal-type.js
|
|
5807
|
+
var import_utils37 = require("@typescript-eslint/utils");
|
|
5744
5808
|
var import_ts_extras53 = require("ts-extras");
|
|
5745
5809
|
var selector8 = (0, import_ts_extras53.arrayJoin)([
|
|
5746
5810
|
"TSPropertySignature[optional=true] > TSTypeAnnotation > TSLiteralType > Literal[value=true]",
|
|
@@ -5749,7 +5813,7 @@ var selector8 = (0, import_ts_extras53.arrayJoin)([
|
|
|
5749
5813
|
var rule84 = ruleCreator({
|
|
5750
5814
|
create: (context) => ({
|
|
5751
5815
|
[selector8]: (node) => {
|
|
5752
|
-
if (node.type !==
|
|
5816
|
+
if (node.type !== import_utils37.AST_NODE_TYPES.Literal) {
|
|
5753
5817
|
return;
|
|
5754
5818
|
}
|
|
5755
5819
|
context.report({
|
|
@@ -5973,11 +6037,11 @@ var typescript_no_multi_type_tuples_default = rule89;
|
|
|
5973
6037
|
|
|
5974
6038
|
// dist/rules/typescript-no-never.js
|
|
5975
6039
|
var import_type_utils8 = require("@typescript-eslint/type-utils");
|
|
5976
|
-
var
|
|
5977
|
-
var isTypeAliasNeverIdentifier = (node) => node.parent.type ===
|
|
6040
|
+
var import_utils38 = require("@typescript-eslint/utils");
|
|
6041
|
+
var isTypeAliasNeverIdentifier = (node) => node.parent.type === import_utils38.AST_NODE_TYPES.TSTypeAliasDeclaration && node.parent.id === node && node.parent.typeAnnotation.type === import_utils38.AST_NODE_TYPES.TSNeverKeyword;
|
|
5978
6042
|
var rule90 = ruleCreator({
|
|
5979
6043
|
create: (context) => {
|
|
5980
|
-
const parserServices =
|
|
6044
|
+
const parserServices = import_utils38.ESLintUtils.getParserServices(context);
|
|
5981
6045
|
return {
|
|
5982
6046
|
Identifier: (node) => {
|
|
5983
6047
|
if (isTypeAliasNeverIdentifier(node)) {
|
|
@@ -6016,11 +6080,12 @@ var rule90 = ruleCreator({
|
|
|
6016
6080
|
var typescript_no_never_default = rule90;
|
|
6017
6081
|
|
|
6018
6082
|
// dist/rules/typescript-no-redundant-undefined-const.js
|
|
6083
|
+
var import_utils39 = require("@typescript-eslint/utils");
|
|
6019
6084
|
var import_ts_extras55 = require("ts-extras");
|
|
6020
6085
|
var buildFixedTypeText = (sourceCode, unionType) => {
|
|
6021
6086
|
let nonUndefinedTypeTexts = [];
|
|
6022
6087
|
for (const typeNode of unionType.types) {
|
|
6023
|
-
if (typeNode.type ===
|
|
6088
|
+
if (typeNode.type === import_utils39.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
6024
6089
|
continue;
|
|
6025
6090
|
}
|
|
6026
6091
|
nonUndefinedTypeTexts = [
|
|
@@ -6033,42 +6098,37 @@ var buildFixedTypeText = (sourceCode, unionType) => {
|
|
|
6033
6098
|
}
|
|
6034
6099
|
return (0, import_ts_extras55.arrayJoin)(nonUndefinedTypeTexts, " | ");
|
|
6035
6100
|
};
|
|
6036
|
-
var getTypeAnnotationFromDeclarator = (declarator) =>
|
|
6037
|
-
if (declarator.id.type === "Identifier" || declarator.id.type === "ArrayPattern" || declarator.id.type === "ObjectPattern") {
|
|
6038
|
-
return declarator.id.typeAnnotation;
|
|
6039
|
-
}
|
|
6040
|
-
return void 0;
|
|
6041
|
-
};
|
|
6101
|
+
var getTypeAnnotationFromDeclarator = (declarator) => declarator.id.typeAnnotation;
|
|
6042
6102
|
var unwrapExpression2 = (expression) => {
|
|
6043
|
-
if (expression.type ===
|
|
6103
|
+
if (expression.type === import_utils39.AST_NODE_TYPES.TSAsExpression || expression.type === import_utils39.AST_NODE_TYPES.TSSatisfiesExpression || expression.type === import_utils39.AST_NODE_TYPES.TSNonNullExpression || expression.type === import_utils39.AST_NODE_TYPES.TSTypeAssertion) {
|
|
6044
6104
|
return unwrapExpression2(expression.expression);
|
|
6045
6105
|
}
|
|
6046
6106
|
return expression;
|
|
6047
6107
|
};
|
|
6048
6108
|
var isDefinitelyDefinedExpression = (expression) => {
|
|
6049
6109
|
const unwrappedExpression = unwrapExpression2(expression);
|
|
6050
|
-
if (unwrappedExpression.type ===
|
|
6110
|
+
if (unwrappedExpression.type === import_utils39.AST_NODE_TYPES.ArrayExpression) {
|
|
6051
6111
|
return true;
|
|
6052
6112
|
}
|
|
6053
|
-
if (unwrappedExpression.type ===
|
|
6113
|
+
if (unwrappedExpression.type === import_utils39.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
6054
6114
|
return true;
|
|
6055
6115
|
}
|
|
6056
|
-
if (unwrappedExpression.type ===
|
|
6116
|
+
if (unwrappedExpression.type === import_utils39.AST_NODE_TYPES.ClassExpression) {
|
|
6057
6117
|
return true;
|
|
6058
6118
|
}
|
|
6059
|
-
if (unwrappedExpression.type ===
|
|
6119
|
+
if (unwrappedExpression.type === import_utils39.AST_NODE_TYPES.FunctionExpression) {
|
|
6060
6120
|
return true;
|
|
6061
6121
|
}
|
|
6062
|
-
if (unwrappedExpression.type ===
|
|
6122
|
+
if (unwrappedExpression.type === import_utils39.AST_NODE_TYPES.Literal) {
|
|
6063
6123
|
return true;
|
|
6064
6124
|
}
|
|
6065
|
-
if (unwrappedExpression.type ===
|
|
6125
|
+
if (unwrappedExpression.type === import_utils39.AST_NODE_TYPES.NewExpression) {
|
|
6066
6126
|
return true;
|
|
6067
6127
|
}
|
|
6068
|
-
if (unwrappedExpression.type ===
|
|
6128
|
+
if (unwrappedExpression.type === import_utils39.AST_NODE_TYPES.ObjectExpression) {
|
|
6069
6129
|
return true;
|
|
6070
6130
|
}
|
|
6071
|
-
if (unwrappedExpression.type ===
|
|
6131
|
+
if (unwrappedExpression.type === import_utils39.AST_NODE_TYPES.TemplateLiteral) {
|
|
6072
6132
|
return true;
|
|
6073
6133
|
}
|
|
6074
6134
|
return false;
|
|
@@ -6078,7 +6138,7 @@ var rule91 = ruleCreator({
|
|
|
6078
6138
|
const sourceCode = context.sourceCode;
|
|
6079
6139
|
return {
|
|
6080
6140
|
'VariableDeclaration[kind="const"] > VariableDeclarator': (node) => {
|
|
6081
|
-
if (node.type !==
|
|
6141
|
+
if (node.type !== import_utils39.AST_NODE_TYPES.VariableDeclarator) {
|
|
6082
6142
|
return;
|
|
6083
6143
|
}
|
|
6084
6144
|
if (node.init === null) {
|
|
@@ -6091,7 +6151,7 @@ var rule91 = ruleCreator({
|
|
|
6091
6151
|
if (typeAnnotation === void 0) {
|
|
6092
6152
|
return;
|
|
6093
6153
|
}
|
|
6094
|
-
if (typeAnnotation.typeAnnotation.type !==
|
|
6154
|
+
if (typeAnnotation.typeAnnotation.type !== import_utils39.AST_NODE_TYPES.TSUnionType) {
|
|
6095
6155
|
return;
|
|
6096
6156
|
}
|
|
6097
6157
|
const fixedTypeText = buildFixedTypeText(sourceCode, typeAnnotation.typeAnnotation);
|
|
@@ -6136,65 +6196,61 @@ var rule91 = ruleCreator({
|
|
|
6136
6196
|
var typescript_no_redundant_undefined_const_default = rule91;
|
|
6137
6197
|
|
|
6138
6198
|
// dist/rules/typescript-no-redundant-undefined-default-parameter.js
|
|
6199
|
+
var import_utils40 = require("@typescript-eslint/utils");
|
|
6139
6200
|
var import_ts_extras56 = require("ts-extras");
|
|
6140
6201
|
var functionLikeNodeSelector = ":matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSConstructorType, TSDeclareFunction, TSEmptyBodyFunctionExpression, TSFunctionType, TSMethodSignature)";
|
|
6141
6202
|
var getParametersFromFunctionLikeNode = (node) => {
|
|
6142
|
-
if (node.type ===
|
|
6203
|
+
if (node.type === import_utils40.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils40.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils40.AST_NODE_TYPES.FunctionExpression || node.type === import_utils40.AST_NODE_TYPES.TSCallSignatureDeclaration || node.type === import_utils40.AST_NODE_TYPES.TSConstructSignatureDeclaration || node.type === import_utils40.AST_NODE_TYPES.TSConstructorType || node.type === import_utils40.AST_NODE_TYPES.TSDeclareFunction || node.type === import_utils40.AST_NODE_TYPES.TSEmptyBodyFunctionExpression || node.type === import_utils40.AST_NODE_TYPES.TSFunctionType || node.type === import_utils40.AST_NODE_TYPES.TSMethodSignature) {
|
|
6143
6204
|
return node.params;
|
|
6144
6205
|
}
|
|
6145
6206
|
return void 0;
|
|
6146
6207
|
};
|
|
6147
6208
|
var getAssignmentPatternFromPattern = (pattern) => {
|
|
6148
|
-
if (pattern.type ===
|
|
6209
|
+
if (pattern.type === import_utils40.AST_NODE_TYPES.AssignmentPattern) {
|
|
6149
6210
|
return pattern;
|
|
6150
6211
|
}
|
|
6151
|
-
if (pattern.type ===
|
|
6212
|
+
if (pattern.type === import_utils40.AST_NODE_TYPES.RestElement) {
|
|
6152
6213
|
return void 0;
|
|
6153
6214
|
}
|
|
6154
6215
|
return void 0;
|
|
6155
6216
|
};
|
|
6156
6217
|
var getAssignmentPatternFromParameter = (parameter) => {
|
|
6157
|
-
if (parameter.type ===
|
|
6218
|
+
if (parameter.type === import_utils40.AST_NODE_TYPES.TSParameterProperty) {
|
|
6158
6219
|
return getAssignmentPatternFromPattern(parameter.parameter);
|
|
6159
6220
|
}
|
|
6160
6221
|
return getAssignmentPatternFromPattern(parameter);
|
|
6161
6222
|
};
|
|
6162
|
-
var getTypeAnnotationFromAssignmentPattern = (assignmentPattern) =>
|
|
6163
|
-
if (assignmentPattern.left.type !== "ArrayPattern" && assignmentPattern.left.type !== "Identifier" && assignmentPattern.left.type !== "ObjectPattern") {
|
|
6164
|
-
return void 0;
|
|
6165
|
-
}
|
|
6166
|
-
return assignmentPattern.left.typeAnnotation;
|
|
6167
|
-
};
|
|
6223
|
+
var getTypeAnnotationFromAssignmentPattern = (assignmentPattern) => assignmentPattern.left.typeAnnotation;
|
|
6168
6224
|
var unwrapExpression3 = (expression) => {
|
|
6169
|
-
if (expression.type ===
|
|
6225
|
+
if (expression.type === import_utils40.AST_NODE_TYPES.TSAsExpression || expression.type === import_utils40.AST_NODE_TYPES.TSSatisfiesExpression || expression.type === import_utils40.AST_NODE_TYPES.TSNonNullExpression || expression.type === import_utils40.AST_NODE_TYPES.TSTypeAssertion) {
|
|
6170
6226
|
return unwrapExpression3(expression.expression);
|
|
6171
6227
|
}
|
|
6172
6228
|
return expression;
|
|
6173
6229
|
};
|
|
6174
6230
|
var isDefinitelyDefinedExpression2 = (expression) => {
|
|
6175
6231
|
const unwrappedExpression = unwrapExpression3(expression);
|
|
6176
|
-
if (unwrappedExpression.type ===
|
|
6232
|
+
if (unwrappedExpression.type === import_utils40.AST_NODE_TYPES.ArrayExpression) {
|
|
6177
6233
|
return true;
|
|
6178
6234
|
}
|
|
6179
|
-
if (unwrappedExpression.type ===
|
|
6235
|
+
if (unwrappedExpression.type === import_utils40.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
6180
6236
|
return true;
|
|
6181
6237
|
}
|
|
6182
|
-
if (unwrappedExpression.type ===
|
|
6238
|
+
if (unwrappedExpression.type === import_utils40.AST_NODE_TYPES.ClassExpression) {
|
|
6183
6239
|
return true;
|
|
6184
6240
|
}
|
|
6185
|
-
if (unwrappedExpression.type ===
|
|
6241
|
+
if (unwrappedExpression.type === import_utils40.AST_NODE_TYPES.FunctionExpression) {
|
|
6186
6242
|
return true;
|
|
6187
6243
|
}
|
|
6188
|
-
if (unwrappedExpression.type ===
|
|
6244
|
+
if (unwrappedExpression.type === import_utils40.AST_NODE_TYPES.Literal) {
|
|
6189
6245
|
return true;
|
|
6190
6246
|
}
|
|
6191
|
-
if (unwrappedExpression.type ===
|
|
6247
|
+
if (unwrappedExpression.type === import_utils40.AST_NODE_TYPES.NewExpression) {
|
|
6192
6248
|
return true;
|
|
6193
6249
|
}
|
|
6194
|
-
if (unwrappedExpression.type ===
|
|
6250
|
+
if (unwrappedExpression.type === import_utils40.AST_NODE_TYPES.ObjectExpression) {
|
|
6195
6251
|
return true;
|
|
6196
6252
|
}
|
|
6197
|
-
if (unwrappedExpression.type ===
|
|
6253
|
+
if (unwrappedExpression.type === import_utils40.AST_NODE_TYPES.TemplateLiteral) {
|
|
6198
6254
|
return true;
|
|
6199
6255
|
}
|
|
6200
6256
|
return false;
|
|
@@ -6202,7 +6258,7 @@ var isDefinitelyDefinedExpression2 = (expression) => {
|
|
|
6202
6258
|
var buildFixedTypeText2 = (sourceCode, unionType) => {
|
|
6203
6259
|
let nonUndefinedTypeTexts = [];
|
|
6204
6260
|
for (const typeNode of unionType.types) {
|
|
6205
|
-
if (typeNode.type ===
|
|
6261
|
+
if (typeNode.type === import_utils40.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
6206
6262
|
continue;
|
|
6207
6263
|
}
|
|
6208
6264
|
nonUndefinedTypeTexts = [
|
|
@@ -6215,6 +6271,10 @@ var buildFixedTypeText2 = (sourceCode, unionType) => {
|
|
|
6215
6271
|
}
|
|
6216
6272
|
return (0, import_ts_extras56.arrayJoin)(nonUndefinedTypeTexts, " | ");
|
|
6217
6273
|
};
|
|
6274
|
+
var createReplaceTypeFix = (targetNode, replacementText) => (fixer) => {
|
|
6275
|
+
const [start, end] = targetNode.range;
|
|
6276
|
+
return fixer.replaceTextRange([start, end], replacementText);
|
|
6277
|
+
};
|
|
6218
6278
|
var rule92 = ruleCreator({
|
|
6219
6279
|
create: (context) => {
|
|
6220
6280
|
const sourceCode = context.sourceCode;
|
|
@@ -6236,14 +6296,14 @@ var rule92 = ruleCreator({
|
|
|
6236
6296
|
if (typeAnnotation === void 0) {
|
|
6237
6297
|
continue;
|
|
6238
6298
|
}
|
|
6239
|
-
if (typeAnnotation.typeAnnotation.type !==
|
|
6299
|
+
if (typeAnnotation.typeAnnotation.type !== import_utils40.AST_NODE_TYPES.TSUnionType) {
|
|
6240
6300
|
continue;
|
|
6241
6301
|
}
|
|
6242
6302
|
const fixedTypeText = buildFixedTypeText2(sourceCode, typeAnnotation.typeAnnotation);
|
|
6243
6303
|
if (!(0, import_ts_extras56.isDefined)(fixedTypeText)) {
|
|
6244
6304
|
continue;
|
|
6245
6305
|
}
|
|
6246
|
-
const fix = (
|
|
6306
|
+
const fix = createReplaceTypeFix(typeAnnotation.typeAnnotation, fixedTypeText);
|
|
6247
6307
|
context.report({
|
|
6248
6308
|
fix,
|
|
6249
6309
|
messageId: "forbidden",
|
|
@@ -6282,11 +6342,12 @@ var rule92 = ruleCreator({
|
|
|
6282
6342
|
var typescript_no_redundant_undefined_default_parameter_default = rule92;
|
|
6283
6343
|
|
|
6284
6344
|
// dist/rules/typescript-no-redundant-undefined-let.js
|
|
6345
|
+
var import_utils41 = require("@typescript-eslint/utils");
|
|
6285
6346
|
var import_ts_extras57 = require("ts-extras");
|
|
6286
6347
|
var buildFixedTypeText3 = (sourceCode, unionType) => {
|
|
6287
6348
|
let nonUndefinedTypeTexts = [];
|
|
6288
6349
|
for (const typeNode of unionType.types) {
|
|
6289
|
-
if (typeNode.type ===
|
|
6350
|
+
if (typeNode.type === import_utils41.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
6290
6351
|
continue;
|
|
6291
6352
|
}
|
|
6292
6353
|
nonUndefinedTypeTexts = [
|
|
@@ -6300,35 +6361,35 @@ var buildFixedTypeText3 = (sourceCode, unionType) => {
|
|
|
6300
6361
|
return (0, import_ts_extras57.arrayJoin)(nonUndefinedTypeTexts, " | ");
|
|
6301
6362
|
};
|
|
6302
6363
|
var unwrapExpression4 = (expression) => {
|
|
6303
|
-
if (expression.type ===
|
|
6364
|
+
if (expression.type === import_utils41.AST_NODE_TYPES.TSAsExpression || expression.type === import_utils41.AST_NODE_TYPES.TSSatisfiesExpression || expression.type === import_utils41.AST_NODE_TYPES.TSNonNullExpression || expression.type === import_utils41.AST_NODE_TYPES.TSTypeAssertion) {
|
|
6304
6365
|
return unwrapExpression4(expression.expression);
|
|
6305
6366
|
}
|
|
6306
6367
|
return expression;
|
|
6307
6368
|
};
|
|
6308
6369
|
var isDefinitelyDefinedExpression3 = (expression) => {
|
|
6309
6370
|
const unwrappedExpression = unwrapExpression4(expression);
|
|
6310
|
-
if (unwrappedExpression.type ===
|
|
6371
|
+
if (unwrappedExpression.type === import_utils41.AST_NODE_TYPES.ArrayExpression) {
|
|
6311
6372
|
return true;
|
|
6312
6373
|
}
|
|
6313
|
-
if (unwrappedExpression.type ===
|
|
6374
|
+
if (unwrappedExpression.type === import_utils41.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
6314
6375
|
return true;
|
|
6315
6376
|
}
|
|
6316
|
-
if (unwrappedExpression.type ===
|
|
6377
|
+
if (unwrappedExpression.type === import_utils41.AST_NODE_TYPES.ClassExpression) {
|
|
6317
6378
|
return true;
|
|
6318
6379
|
}
|
|
6319
|
-
if (unwrappedExpression.type ===
|
|
6380
|
+
if (unwrappedExpression.type === import_utils41.AST_NODE_TYPES.FunctionExpression) {
|
|
6320
6381
|
return true;
|
|
6321
6382
|
}
|
|
6322
|
-
if (unwrappedExpression.type ===
|
|
6383
|
+
if (unwrappedExpression.type === import_utils41.AST_NODE_TYPES.Literal) {
|
|
6323
6384
|
return true;
|
|
6324
6385
|
}
|
|
6325
|
-
if (unwrappedExpression.type ===
|
|
6386
|
+
if (unwrappedExpression.type === import_utils41.AST_NODE_TYPES.NewExpression) {
|
|
6326
6387
|
return true;
|
|
6327
6388
|
}
|
|
6328
|
-
if (unwrappedExpression.type ===
|
|
6389
|
+
if (unwrappedExpression.type === import_utils41.AST_NODE_TYPES.ObjectExpression) {
|
|
6329
6390
|
return true;
|
|
6330
6391
|
}
|
|
6331
|
-
if (unwrappedExpression.type ===
|
|
6392
|
+
if (unwrappedExpression.type === import_utils41.AST_NODE_TYPES.TemplateLiteral) {
|
|
6332
6393
|
return true;
|
|
6333
6394
|
}
|
|
6334
6395
|
return false;
|
|
@@ -6356,14 +6417,14 @@ var rule93 = ruleCreator({
|
|
|
6356
6417
|
return;
|
|
6357
6418
|
}
|
|
6358
6419
|
const id = node.id;
|
|
6359
|
-
if (id.type !==
|
|
6420
|
+
if (id.type !== import_utils41.AST_NODE_TYPES.Identifier) {
|
|
6360
6421
|
return;
|
|
6361
6422
|
}
|
|
6362
6423
|
const typeAnnotation = id.typeAnnotation;
|
|
6363
6424
|
if (typeAnnotation === void 0) {
|
|
6364
6425
|
return;
|
|
6365
6426
|
}
|
|
6366
|
-
if (typeAnnotation.typeAnnotation.type !==
|
|
6427
|
+
if (typeAnnotation.typeAnnotation.type !== import_utils41.AST_NODE_TYPES.TSUnionType) {
|
|
6367
6428
|
return;
|
|
6368
6429
|
}
|
|
6369
6430
|
const fixedTypeText = buildFixedTypeText3(sourceCode, typeAnnotation.typeAnnotation);
|
|
@@ -6408,6 +6469,7 @@ var rule93 = ruleCreator({
|
|
|
6408
6469
|
var typescript_no_redundant_undefined_let_default = rule93;
|
|
6409
6470
|
|
|
6410
6471
|
// dist/rules/typescript-no-redundant-undefined-optional.js
|
|
6472
|
+
var import_utils42 = require("@typescript-eslint/utils");
|
|
6411
6473
|
var import_ts_extras58 = require("ts-extras");
|
|
6412
6474
|
var selector14 = (0, import_ts_extras58.arrayJoin)([
|
|
6413
6475
|
"Identifier[optional=true] > TSTypeAnnotation > TSUnionType",
|
|
@@ -6417,7 +6479,7 @@ var selector14 = (0, import_ts_extras58.arrayJoin)([
|
|
|
6417
6479
|
var buildFixedTypeText4 = (sourceCode, unionType) => {
|
|
6418
6480
|
let nonUndefinedTypeTexts = [];
|
|
6419
6481
|
for (const typeNode of unionType.types) {
|
|
6420
|
-
if (typeNode.type ===
|
|
6482
|
+
if (typeNode.type === import_utils42.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
6421
6483
|
continue;
|
|
6422
6484
|
}
|
|
6423
6485
|
nonUndefinedTypeTexts = [
|
|
@@ -6435,7 +6497,7 @@ var rule94 = ruleCreator({
|
|
|
6435
6497
|
const sourceCode = context.sourceCode;
|
|
6436
6498
|
return {
|
|
6437
6499
|
[selector14]: (node) => {
|
|
6438
|
-
if (node.type !==
|
|
6500
|
+
if (node.type !== import_utils42.AST_NODE_TYPES.TSUnionType) {
|
|
6439
6501
|
return;
|
|
6440
6502
|
}
|
|
6441
6503
|
const fixedTypeText = buildFixedTypeText4(sourceCode, node);
|
|
@@ -6480,11 +6542,12 @@ var rule94 = ruleCreator({
|
|
|
6480
6542
|
var typescript_no_redundant_undefined_optional_default = rule94;
|
|
6481
6543
|
|
|
6482
6544
|
// dist/rules/typescript-no-redundant-undefined-promise-return-type.js
|
|
6545
|
+
var import_utils43 = require("@typescript-eslint/utils");
|
|
6483
6546
|
var import_ts_extras59 = require("ts-extras");
|
|
6484
6547
|
var buildFixedTypeText5 = (sourceCode, unionType) => {
|
|
6485
6548
|
let nonUndefinedTypeTexts = [];
|
|
6486
6549
|
for (const typeNode of unionType.types) {
|
|
6487
|
-
if (typeNode.type ===
|
|
6550
|
+
if (typeNode.type === import_utils43.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
6488
6551
|
continue;
|
|
6489
6552
|
}
|
|
6490
6553
|
nonUndefinedTypeTexts = [
|
|
@@ -6498,52 +6561,52 @@ var buildFixedTypeText5 = (sourceCode, unionType) => {
|
|
|
6498
6561
|
return (0, import_ts_extras59.arrayJoin)(nonUndefinedTypeTexts, " | ");
|
|
6499
6562
|
};
|
|
6500
6563
|
var unwrapExpression5 = (expression) => {
|
|
6501
|
-
if (expression.type ===
|
|
6564
|
+
if (expression.type === import_utils43.AST_NODE_TYPES.TSAsExpression || expression.type === import_utils43.AST_NODE_TYPES.TSSatisfiesExpression || expression.type === import_utils43.AST_NODE_TYPES.TSNonNullExpression || expression.type === import_utils43.AST_NODE_TYPES.TSTypeAssertion) {
|
|
6502
6565
|
return unwrapExpression5(expression.expression);
|
|
6503
6566
|
}
|
|
6504
6567
|
return expression;
|
|
6505
6568
|
};
|
|
6506
6569
|
var isDefinitelyDefinedExpression4 = (expression) => {
|
|
6507
6570
|
const unwrappedExpression = unwrapExpression5(expression);
|
|
6508
|
-
if (unwrappedExpression.type ===
|
|
6571
|
+
if (unwrappedExpression.type === import_utils43.AST_NODE_TYPES.ArrayExpression) {
|
|
6509
6572
|
return true;
|
|
6510
6573
|
}
|
|
6511
|
-
if (unwrappedExpression.type ===
|
|
6574
|
+
if (unwrappedExpression.type === import_utils43.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
6512
6575
|
return true;
|
|
6513
6576
|
}
|
|
6514
|
-
if (unwrappedExpression.type ===
|
|
6577
|
+
if (unwrappedExpression.type === import_utils43.AST_NODE_TYPES.ClassExpression) {
|
|
6515
6578
|
return true;
|
|
6516
6579
|
}
|
|
6517
|
-
if (unwrappedExpression.type ===
|
|
6580
|
+
if (unwrappedExpression.type === import_utils43.AST_NODE_TYPES.ConditionalExpression) {
|
|
6518
6581
|
return isDefinitelyDefinedExpression4(unwrappedExpression.consequent) && isDefinitelyDefinedExpression4(unwrappedExpression.alternate);
|
|
6519
6582
|
}
|
|
6520
|
-
if (unwrappedExpression.type ===
|
|
6583
|
+
if (unwrappedExpression.type === import_utils43.AST_NODE_TYPES.FunctionExpression) {
|
|
6521
6584
|
return true;
|
|
6522
6585
|
}
|
|
6523
|
-
if (unwrappedExpression.type ===
|
|
6586
|
+
if (unwrappedExpression.type === import_utils43.AST_NODE_TYPES.Literal) {
|
|
6524
6587
|
return true;
|
|
6525
6588
|
}
|
|
6526
|
-
if (unwrappedExpression.type ===
|
|
6589
|
+
if (unwrappedExpression.type === import_utils43.AST_NODE_TYPES.LogicalExpression && unwrappedExpression.operator === "??") {
|
|
6527
6590
|
return isDefinitelyDefinedExpression4(unwrappedExpression.right);
|
|
6528
6591
|
}
|
|
6529
|
-
if (unwrappedExpression.type ===
|
|
6592
|
+
if (unwrappedExpression.type === import_utils43.AST_NODE_TYPES.NewExpression) {
|
|
6530
6593
|
return true;
|
|
6531
6594
|
}
|
|
6532
|
-
if (unwrappedExpression.type ===
|
|
6595
|
+
if (unwrappedExpression.type === import_utils43.AST_NODE_TYPES.ObjectExpression) {
|
|
6533
6596
|
return true;
|
|
6534
6597
|
}
|
|
6535
|
-
if (unwrappedExpression.type ===
|
|
6598
|
+
if (unwrappedExpression.type === import_utils43.AST_NODE_TYPES.SequenceExpression) {
|
|
6536
6599
|
const lastExpression = (0, import_ts_extras59.arrayAt)(unwrappedExpression.expressions, -1);
|
|
6537
6600
|
return lastExpression !== void 0 && isDefinitelyDefinedExpression4(lastExpression);
|
|
6538
6601
|
}
|
|
6539
|
-
if (unwrappedExpression.type ===
|
|
6602
|
+
if (unwrappedExpression.type === import_utils43.AST_NODE_TYPES.TemplateLiteral) {
|
|
6540
6603
|
return true;
|
|
6541
6604
|
}
|
|
6542
6605
|
return false;
|
|
6543
6606
|
};
|
|
6544
6607
|
var hasDefinitelyDefinedReturnValue = (node) => {
|
|
6545
6608
|
const body = node.body;
|
|
6546
|
-
if (body.type !==
|
|
6609
|
+
if (body.type !== import_utils43.AST_NODE_TYPES.BlockStatement) {
|
|
6547
6610
|
return isDefinitelyDefinedExpression4(body);
|
|
6548
6611
|
}
|
|
6549
6612
|
if (body.body.length !== 1) {
|
|
@@ -6553,7 +6616,7 @@ var hasDefinitelyDefinedReturnValue = (node) => {
|
|
|
6553
6616
|
if (statement === void 0) {
|
|
6554
6617
|
return false;
|
|
6555
6618
|
}
|
|
6556
|
-
if (statement.type !==
|
|
6619
|
+
if (statement.type !== import_utils43.AST_NODE_TYPES.ReturnStatement) {
|
|
6557
6620
|
return false;
|
|
6558
6621
|
}
|
|
6559
6622
|
if (statement.argument === null) {
|
|
@@ -6563,10 +6626,10 @@ var hasDefinitelyDefinedReturnValue = (node) => {
|
|
|
6563
6626
|
};
|
|
6564
6627
|
var getPromiseValueUnionType = (returnType) => {
|
|
6565
6628
|
const annotation = returnType.typeAnnotation;
|
|
6566
|
-
if (annotation.type !==
|
|
6629
|
+
if (annotation.type !== import_utils43.AST_NODE_TYPES.TSTypeReference) {
|
|
6567
6630
|
return void 0;
|
|
6568
6631
|
}
|
|
6569
|
-
if (annotation.typeName.type !==
|
|
6632
|
+
if (annotation.typeName.type !== import_utils43.AST_NODE_TYPES.Identifier) {
|
|
6570
6633
|
return void 0;
|
|
6571
6634
|
}
|
|
6572
6635
|
if (annotation.typeName.name !== "Promise") {
|
|
@@ -6580,7 +6643,7 @@ var getPromiseValueUnionType = (returnType) => {
|
|
|
6580
6643
|
if (promiseValueType === void 0) {
|
|
6581
6644
|
return void 0;
|
|
6582
6645
|
}
|
|
6583
|
-
if (promiseValueType.type !==
|
|
6646
|
+
if (promiseValueType.type !== import_utils43.AST_NODE_TYPES.TSUnionType) {
|
|
6584
6647
|
return void 0;
|
|
6585
6648
|
}
|
|
6586
6649
|
return promiseValueType;
|
|
@@ -6590,7 +6653,7 @@ var rule95 = ruleCreator({
|
|
|
6590
6653
|
const sourceCode = context.sourceCode;
|
|
6591
6654
|
return {
|
|
6592
6655
|
":matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression)[async=true]": (node) => {
|
|
6593
|
-
if (node.type !==
|
|
6656
|
+
if (node.type !== import_utils43.AST_NODE_TYPES.ArrowFunctionExpression && node.type !== import_utils43.AST_NODE_TYPES.FunctionDeclaration && node.type !== import_utils43.AST_NODE_TYPES.FunctionExpression) {
|
|
6594
6657
|
return;
|
|
6595
6658
|
}
|
|
6596
6659
|
const returnType = node.returnType;
|
|
@@ -6646,11 +6709,12 @@ var rule95 = ruleCreator({
|
|
|
6646
6709
|
var typescript_no_redundant_undefined_promise_return_type_default = rule95;
|
|
6647
6710
|
|
|
6648
6711
|
// dist/rules/typescript-no-redundant-undefined-readonly-property.js
|
|
6712
|
+
var import_utils44 = require("@typescript-eslint/utils");
|
|
6649
6713
|
var import_ts_extras60 = require("ts-extras");
|
|
6650
6714
|
var buildFixedTypeText6 = (sourceCode, unionType) => {
|
|
6651
6715
|
let nonUndefinedTypeTexts = [];
|
|
6652
6716
|
for (const typeNode of unionType.types) {
|
|
6653
|
-
if (typeNode.type ===
|
|
6717
|
+
if (typeNode.type === import_utils44.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
6654
6718
|
continue;
|
|
6655
6719
|
}
|
|
6656
6720
|
nonUndefinedTypeTexts = [
|
|
@@ -6664,35 +6728,35 @@ var buildFixedTypeText6 = (sourceCode, unionType) => {
|
|
|
6664
6728
|
return (0, import_ts_extras60.arrayJoin)(nonUndefinedTypeTexts, " | ");
|
|
6665
6729
|
};
|
|
6666
6730
|
var unwrapExpression6 = (expression) => {
|
|
6667
|
-
if (expression.type ===
|
|
6731
|
+
if (expression.type === import_utils44.AST_NODE_TYPES.TSAsExpression || expression.type === import_utils44.AST_NODE_TYPES.TSSatisfiesExpression || expression.type === import_utils44.AST_NODE_TYPES.TSNonNullExpression || expression.type === import_utils44.AST_NODE_TYPES.TSTypeAssertion) {
|
|
6668
6732
|
return unwrapExpression6(expression.expression);
|
|
6669
6733
|
}
|
|
6670
6734
|
return expression;
|
|
6671
6735
|
};
|
|
6672
6736
|
var isDefinitelyDefinedExpression5 = (expression) => {
|
|
6673
6737
|
const unwrappedExpression = unwrapExpression6(expression);
|
|
6674
|
-
if (unwrappedExpression.type ===
|
|
6738
|
+
if (unwrappedExpression.type === import_utils44.AST_NODE_TYPES.ArrayExpression) {
|
|
6675
6739
|
return true;
|
|
6676
6740
|
}
|
|
6677
|
-
if (unwrappedExpression.type ===
|
|
6741
|
+
if (unwrappedExpression.type === import_utils44.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
6678
6742
|
return true;
|
|
6679
6743
|
}
|
|
6680
|
-
if (unwrappedExpression.type ===
|
|
6744
|
+
if (unwrappedExpression.type === import_utils44.AST_NODE_TYPES.ClassExpression) {
|
|
6681
6745
|
return true;
|
|
6682
6746
|
}
|
|
6683
|
-
if (unwrappedExpression.type ===
|
|
6747
|
+
if (unwrappedExpression.type === import_utils44.AST_NODE_TYPES.FunctionExpression) {
|
|
6684
6748
|
return true;
|
|
6685
6749
|
}
|
|
6686
|
-
if (unwrappedExpression.type ===
|
|
6750
|
+
if (unwrappedExpression.type === import_utils44.AST_NODE_TYPES.Literal) {
|
|
6687
6751
|
return true;
|
|
6688
6752
|
}
|
|
6689
|
-
if (unwrappedExpression.type ===
|
|
6753
|
+
if (unwrappedExpression.type === import_utils44.AST_NODE_TYPES.NewExpression) {
|
|
6690
6754
|
return true;
|
|
6691
6755
|
}
|
|
6692
|
-
if (unwrappedExpression.type ===
|
|
6756
|
+
if (unwrappedExpression.type === import_utils44.AST_NODE_TYPES.ObjectExpression) {
|
|
6693
6757
|
return true;
|
|
6694
6758
|
}
|
|
6695
|
-
if (unwrappedExpression.type ===
|
|
6759
|
+
if (unwrappedExpression.type === import_utils44.AST_NODE_TYPES.TemplateLiteral) {
|
|
6696
6760
|
return true;
|
|
6697
6761
|
}
|
|
6698
6762
|
return false;
|
|
@@ -6702,7 +6766,7 @@ var rule96 = ruleCreator({
|
|
|
6702
6766
|
const sourceCode = context.sourceCode;
|
|
6703
6767
|
return {
|
|
6704
6768
|
"PropertyDefinition[readonly=true][optional!=true]": (node) => {
|
|
6705
|
-
if (node.type !==
|
|
6769
|
+
if (node.type !== import_utils44.AST_NODE_TYPES.PropertyDefinition) {
|
|
6706
6770
|
return;
|
|
6707
6771
|
}
|
|
6708
6772
|
if (node.declare) {
|
|
@@ -6718,7 +6782,7 @@ var rule96 = ruleCreator({
|
|
|
6718
6782
|
if (typeAnnotation === void 0) {
|
|
6719
6783
|
return;
|
|
6720
6784
|
}
|
|
6721
|
-
if (typeAnnotation.typeAnnotation.type !==
|
|
6785
|
+
if (typeAnnotation.typeAnnotation.type !== import_utils44.AST_NODE_TYPES.TSUnionType) {
|
|
6722
6786
|
return;
|
|
6723
6787
|
}
|
|
6724
6788
|
const fixedTypeText = buildFixedTypeText6(sourceCode, typeAnnotation.typeAnnotation);
|
|
@@ -6763,11 +6827,12 @@ var rule96 = ruleCreator({
|
|
|
6763
6827
|
var typescript_no_redundant_undefined_readonly_property_default = rule96;
|
|
6764
6828
|
|
|
6765
6829
|
// dist/rules/typescript-no-redundant-undefined-return-type.js
|
|
6830
|
+
var import_utils45 = require("@typescript-eslint/utils");
|
|
6766
6831
|
var import_ts_extras61 = require("ts-extras");
|
|
6767
6832
|
var buildFixedTypeText7 = (sourceCode, unionType) => {
|
|
6768
6833
|
let nonUndefinedTypeTexts = [];
|
|
6769
6834
|
for (const typeNode of unionType.types) {
|
|
6770
|
-
if (typeNode.type ===
|
|
6835
|
+
if (typeNode.type === import_utils45.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
6771
6836
|
continue;
|
|
6772
6837
|
}
|
|
6773
6838
|
nonUndefinedTypeTexts = [
|
|
@@ -6781,52 +6846,52 @@ var buildFixedTypeText7 = (sourceCode, unionType) => {
|
|
|
6781
6846
|
return (0, import_ts_extras61.arrayJoin)(nonUndefinedTypeTexts, " | ");
|
|
6782
6847
|
};
|
|
6783
6848
|
var unwrapExpression7 = (expression) => {
|
|
6784
|
-
if (expression.type ===
|
|
6849
|
+
if (expression.type === import_utils45.AST_NODE_TYPES.TSAsExpression || expression.type === import_utils45.AST_NODE_TYPES.TSSatisfiesExpression || expression.type === import_utils45.AST_NODE_TYPES.TSNonNullExpression || expression.type === import_utils45.AST_NODE_TYPES.TSTypeAssertion) {
|
|
6785
6850
|
return unwrapExpression7(expression.expression);
|
|
6786
6851
|
}
|
|
6787
6852
|
return expression;
|
|
6788
6853
|
};
|
|
6789
6854
|
var isDefinitelyDefinedExpression6 = (expression) => {
|
|
6790
6855
|
const unwrappedExpression = unwrapExpression7(expression);
|
|
6791
|
-
if (unwrappedExpression.type ===
|
|
6856
|
+
if (unwrappedExpression.type === import_utils45.AST_NODE_TYPES.ArrayExpression) {
|
|
6792
6857
|
return true;
|
|
6793
6858
|
}
|
|
6794
|
-
if (unwrappedExpression.type ===
|
|
6859
|
+
if (unwrappedExpression.type === import_utils45.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
6795
6860
|
return true;
|
|
6796
6861
|
}
|
|
6797
|
-
if (unwrappedExpression.type ===
|
|
6862
|
+
if (unwrappedExpression.type === import_utils45.AST_NODE_TYPES.ClassExpression) {
|
|
6798
6863
|
return true;
|
|
6799
6864
|
}
|
|
6800
|
-
if (unwrappedExpression.type ===
|
|
6865
|
+
if (unwrappedExpression.type === import_utils45.AST_NODE_TYPES.ConditionalExpression) {
|
|
6801
6866
|
return isDefinitelyDefinedExpression6(unwrappedExpression.consequent) && isDefinitelyDefinedExpression6(unwrappedExpression.alternate);
|
|
6802
6867
|
}
|
|
6803
|
-
if (unwrappedExpression.type ===
|
|
6868
|
+
if (unwrappedExpression.type === import_utils45.AST_NODE_TYPES.FunctionExpression) {
|
|
6804
6869
|
return true;
|
|
6805
6870
|
}
|
|
6806
|
-
if (unwrappedExpression.type ===
|
|
6871
|
+
if (unwrappedExpression.type === import_utils45.AST_NODE_TYPES.Literal) {
|
|
6807
6872
|
return true;
|
|
6808
6873
|
}
|
|
6809
|
-
if (unwrappedExpression.type ===
|
|
6874
|
+
if (unwrappedExpression.type === import_utils45.AST_NODE_TYPES.LogicalExpression && unwrappedExpression.operator === "??") {
|
|
6810
6875
|
return isDefinitelyDefinedExpression6(unwrappedExpression.right);
|
|
6811
6876
|
}
|
|
6812
|
-
if (unwrappedExpression.type ===
|
|
6877
|
+
if (unwrappedExpression.type === import_utils45.AST_NODE_TYPES.NewExpression) {
|
|
6813
6878
|
return true;
|
|
6814
6879
|
}
|
|
6815
|
-
if (unwrappedExpression.type ===
|
|
6880
|
+
if (unwrappedExpression.type === import_utils45.AST_NODE_TYPES.ObjectExpression) {
|
|
6816
6881
|
return true;
|
|
6817
6882
|
}
|
|
6818
|
-
if (unwrappedExpression.type ===
|
|
6883
|
+
if (unwrappedExpression.type === import_utils45.AST_NODE_TYPES.SequenceExpression) {
|
|
6819
6884
|
const lastExpression = (0, import_ts_extras61.arrayAt)(unwrappedExpression.expressions, -1);
|
|
6820
6885
|
return lastExpression !== void 0 && isDefinitelyDefinedExpression6(lastExpression);
|
|
6821
6886
|
}
|
|
6822
|
-
if (unwrappedExpression.type ===
|
|
6887
|
+
if (unwrappedExpression.type === import_utils45.AST_NODE_TYPES.TemplateLiteral) {
|
|
6823
6888
|
return true;
|
|
6824
6889
|
}
|
|
6825
6890
|
return false;
|
|
6826
6891
|
};
|
|
6827
6892
|
var hasDefinitelyDefinedReturnValue2 = (node) => {
|
|
6828
6893
|
const body = node.body;
|
|
6829
|
-
if (body.type !==
|
|
6894
|
+
if (body.type !== import_utils45.AST_NODE_TYPES.BlockStatement) {
|
|
6830
6895
|
return isDefinitelyDefinedExpression6(body);
|
|
6831
6896
|
}
|
|
6832
6897
|
if (body.body.length !== 1) {
|
|
@@ -6836,7 +6901,7 @@ var hasDefinitelyDefinedReturnValue2 = (node) => {
|
|
|
6836
6901
|
if (statement === void 0) {
|
|
6837
6902
|
return false;
|
|
6838
6903
|
}
|
|
6839
|
-
if (statement.type !==
|
|
6904
|
+
if (statement.type !== import_utils45.AST_NODE_TYPES.ReturnStatement) {
|
|
6840
6905
|
return false;
|
|
6841
6906
|
}
|
|
6842
6907
|
if (statement.argument === null) {
|
|
@@ -6849,14 +6914,14 @@ var rule97 = ruleCreator({
|
|
|
6849
6914
|
const sourceCode = context.sourceCode;
|
|
6850
6915
|
return {
|
|
6851
6916
|
":matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression)": (node) => {
|
|
6852
|
-
if (node.type !==
|
|
6917
|
+
if (node.type !== import_utils45.AST_NODE_TYPES.ArrowFunctionExpression && node.type !== import_utils45.AST_NODE_TYPES.FunctionDeclaration && node.type !== import_utils45.AST_NODE_TYPES.FunctionExpression) {
|
|
6853
6918
|
return;
|
|
6854
6919
|
}
|
|
6855
6920
|
const returnType = node.returnType;
|
|
6856
6921
|
if (returnType === void 0) {
|
|
6857
6922
|
return;
|
|
6858
6923
|
}
|
|
6859
|
-
if (returnType.typeAnnotation.type !==
|
|
6924
|
+
if (returnType.typeAnnotation.type !== import_utils45.AST_NODE_TYPES.TSUnionType) {
|
|
6860
6925
|
return;
|
|
6861
6926
|
}
|
|
6862
6927
|
if (!hasDefinitelyDefinedReturnValue2(node)) {
|
|
@@ -6904,11 +6969,12 @@ var rule97 = ruleCreator({
|
|
|
6904
6969
|
var typescript_no_redundant_undefined_return_type_default = rule97;
|
|
6905
6970
|
|
|
6906
6971
|
// dist/rules/typescript-no-redundant-undefined-var.js
|
|
6972
|
+
var import_utils46 = require("@typescript-eslint/utils");
|
|
6907
6973
|
var import_ts_extras62 = require("ts-extras");
|
|
6908
6974
|
var buildFixedTypeText8 = (sourceCode, unionType) => {
|
|
6909
6975
|
let nonUndefinedTypeTexts = [];
|
|
6910
6976
|
for (const typeNode of unionType.types) {
|
|
6911
|
-
if (typeNode.type ===
|
|
6977
|
+
if (typeNode.type === import_utils46.AST_NODE_TYPES.TSUndefinedKeyword) {
|
|
6912
6978
|
continue;
|
|
6913
6979
|
}
|
|
6914
6980
|
nonUndefinedTypeTexts = [
|
|
@@ -6922,35 +6988,35 @@ var buildFixedTypeText8 = (sourceCode, unionType) => {
|
|
|
6922
6988
|
return (0, import_ts_extras62.arrayJoin)(nonUndefinedTypeTexts, " | ");
|
|
6923
6989
|
};
|
|
6924
6990
|
var unwrapExpression8 = (expression) => {
|
|
6925
|
-
if (expression.type ===
|
|
6991
|
+
if (expression.type === import_utils46.AST_NODE_TYPES.TSAsExpression || expression.type === import_utils46.AST_NODE_TYPES.TSSatisfiesExpression || expression.type === import_utils46.AST_NODE_TYPES.TSNonNullExpression || expression.type === import_utils46.AST_NODE_TYPES.TSTypeAssertion) {
|
|
6926
6992
|
return unwrapExpression8(expression.expression);
|
|
6927
6993
|
}
|
|
6928
6994
|
return expression;
|
|
6929
6995
|
};
|
|
6930
6996
|
var isDefinitelyDefinedExpression7 = (expression) => {
|
|
6931
6997
|
const unwrappedExpression = unwrapExpression8(expression);
|
|
6932
|
-
if (unwrappedExpression.type ===
|
|
6998
|
+
if (unwrappedExpression.type === import_utils46.AST_NODE_TYPES.ArrayExpression) {
|
|
6933
6999
|
return true;
|
|
6934
7000
|
}
|
|
6935
|
-
if (unwrappedExpression.type ===
|
|
7001
|
+
if (unwrappedExpression.type === import_utils46.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
6936
7002
|
return true;
|
|
6937
7003
|
}
|
|
6938
|
-
if (unwrappedExpression.type ===
|
|
7004
|
+
if (unwrappedExpression.type === import_utils46.AST_NODE_TYPES.ClassExpression) {
|
|
6939
7005
|
return true;
|
|
6940
7006
|
}
|
|
6941
|
-
if (unwrappedExpression.type ===
|
|
7007
|
+
if (unwrappedExpression.type === import_utils46.AST_NODE_TYPES.FunctionExpression) {
|
|
6942
7008
|
return true;
|
|
6943
7009
|
}
|
|
6944
|
-
if (unwrappedExpression.type ===
|
|
7010
|
+
if (unwrappedExpression.type === import_utils46.AST_NODE_TYPES.Literal) {
|
|
6945
7011
|
return true;
|
|
6946
7012
|
}
|
|
6947
|
-
if (unwrappedExpression.type ===
|
|
7013
|
+
if (unwrappedExpression.type === import_utils46.AST_NODE_TYPES.NewExpression) {
|
|
6948
7014
|
return true;
|
|
6949
7015
|
}
|
|
6950
|
-
if (unwrappedExpression.type ===
|
|
7016
|
+
if (unwrappedExpression.type === import_utils46.AST_NODE_TYPES.ObjectExpression) {
|
|
6951
7017
|
return true;
|
|
6952
7018
|
}
|
|
6953
|
-
if (unwrappedExpression.type ===
|
|
7019
|
+
if (unwrappedExpression.type === import_utils46.AST_NODE_TYPES.TemplateLiteral) {
|
|
6954
7020
|
return true;
|
|
6955
7021
|
}
|
|
6956
7022
|
return false;
|
|
@@ -6978,14 +7044,14 @@ var rule98 = ruleCreator({
|
|
|
6978
7044
|
return;
|
|
6979
7045
|
}
|
|
6980
7046
|
const id = node.id;
|
|
6981
|
-
if (id.type !==
|
|
7047
|
+
if (id.type !== import_utils46.AST_NODE_TYPES.Identifier) {
|
|
6982
7048
|
return;
|
|
6983
7049
|
}
|
|
6984
7050
|
const typeAnnotation = id.typeAnnotation;
|
|
6985
7051
|
if (typeAnnotation === void 0) {
|
|
6986
7052
|
return;
|
|
6987
7053
|
}
|
|
6988
|
-
if (typeAnnotation.typeAnnotation.type !==
|
|
7054
|
+
if (typeAnnotation.typeAnnotation.type !== import_utils46.AST_NODE_TYPES.TSUnionType) {
|
|
6989
7055
|
return;
|
|
6990
7056
|
}
|
|
6991
7057
|
const fixedTypeText = buildFixedTypeText8(sourceCode, typeAnnotation.typeAnnotation);
|
|
@@ -7030,21 +7096,25 @@ var rule98 = ruleCreator({
|
|
|
7030
7096
|
var typescript_no_redundant_undefined_var_default = rule98;
|
|
7031
7097
|
|
|
7032
7098
|
// dist/rules/typescript-no-restricted-syntax.js
|
|
7099
|
+
var import_ts_extras63 = require("ts-extras");
|
|
7100
|
+
var noRestrictedSyntaxRule = no_restricted_syntax_default;
|
|
7101
|
+
var baseDocs = noRestrictedSyntaxRule.meta.docs;
|
|
7102
|
+
(0, import_ts_extras63.assertDefined)(baseDocs);
|
|
7033
7103
|
var typescriptNoRestrictedSyntaxRule = {
|
|
7034
|
-
...
|
|
7104
|
+
...noRestrictedSyntaxRule,
|
|
7035
7105
|
meta: {
|
|
7036
7106
|
deprecated: true,
|
|
7037
|
-
...
|
|
7107
|
+
...noRestrictedSyntaxRule.meta,
|
|
7038
7108
|
docs: {
|
|
7109
|
+
...baseDocs,
|
|
7039
7110
|
deprecated: true,
|
|
7040
7111
|
frozen: true,
|
|
7041
7112
|
recommended: false,
|
|
7042
|
-
...no_restricted_syntax_default.meta.docs,
|
|
7043
7113
|
url: "https://nick2bad4u.github.io/eslint-plugin-etc-misc/docs/rules/typescript-no-restricted-syntax"
|
|
7044
7114
|
}
|
|
7045
7115
|
}
|
|
7046
7116
|
};
|
|
7047
|
-
var
|
|
7117
|
+
var rule99 = withDeprecatedRuleLifecycle(typescriptNoRestrictedSyntaxRule, {
|
|
7048
7118
|
message: "Deprecated in favor of @typescript-eslint/no-restricted-syntax.",
|
|
7049
7119
|
replacedBy: [
|
|
7050
7120
|
createReplacementRuleInfo({
|
|
@@ -7060,15 +7130,15 @@ var deprecatedRule26 = withDeprecatedRuleLifecycle(typescriptNoRestrictedSyntaxR
|
|
|
7060
7130
|
],
|
|
7061
7131
|
ruleId: "typescript/no-restricted-syntax"
|
|
7062
7132
|
});
|
|
7063
|
-
var typescript_no_restricted_syntax_default =
|
|
7133
|
+
var typescript_no_restricted_syntax_default = rule99;
|
|
7064
7134
|
|
|
7065
7135
|
// dist/rules/typescript-no-unsafe-object-assign.js
|
|
7066
7136
|
var import_type_utils9 = require("@typescript-eslint/type-utils");
|
|
7067
|
-
var
|
|
7137
|
+
var import_utils47 = require("@typescript-eslint/utils");
|
|
7068
7138
|
var tsutils4 = __toESM(require("tsutils"), 1);
|
|
7069
|
-
var
|
|
7139
|
+
var rule100 = ruleCreator({
|
|
7070
7140
|
create: (context) => {
|
|
7071
|
-
const parserServices =
|
|
7141
|
+
const parserServices = import_utils47.ESLintUtils.getParserServices(context);
|
|
7072
7142
|
const checker = parserServices.program.getTypeChecker();
|
|
7073
7143
|
const hasReadonlyProperty = (type) => type.getProperties().some((property) => tsutils4.isPropertyReadonlyInType(type, property.getEscapedName(), checker));
|
|
7074
7144
|
return {
|
|
@@ -7107,24 +7177,28 @@ var rule99 = ruleCreator({
|
|
|
7107
7177
|
},
|
|
7108
7178
|
name: "typescript/no-unsafe-object-assign"
|
|
7109
7179
|
});
|
|
7110
|
-
var typescript_no_unsafe_object_assign_default =
|
|
7180
|
+
var typescript_no_unsafe_object_assign_default = rule100;
|
|
7111
7181
|
|
|
7112
7182
|
// dist/rules/typescript-no-unsafe-object-assignment.js
|
|
7113
|
-
var
|
|
7114
|
-
|
|
7183
|
+
var import_ts_extras64 = require("ts-extras");
|
|
7184
|
+
var coreNoUnsafeObjectAssignRule = typescript_no_unsafe_object_assign_default;
|
|
7185
|
+
var baseDocs2 = coreNoUnsafeObjectAssignRule.meta.docs;
|
|
7186
|
+
(0, import_ts_extras64.assertDefined)(baseDocs2);
|
|
7187
|
+
var typescriptNoUnsafeObjectAssignmentRule = {
|
|
7188
|
+
...coreNoUnsafeObjectAssignRule,
|
|
7115
7189
|
meta: {
|
|
7116
7190
|
deprecated: false,
|
|
7117
|
-
...
|
|
7191
|
+
...coreNoUnsafeObjectAssignRule.meta,
|
|
7118
7192
|
docs: {
|
|
7193
|
+
...baseDocs2,
|
|
7119
7194
|
deprecated: false,
|
|
7120
7195
|
frozen: false,
|
|
7121
7196
|
recommended: false,
|
|
7122
|
-
...typescript_no_unsafe_object_assign_default.meta.docs,
|
|
7123
7197
|
url: "https://nick2bad4u.github.io/eslint-plugin-etc-misc/docs/rules/typescript-no-unsafe-object-assignment"
|
|
7124
7198
|
}
|
|
7125
7199
|
}
|
|
7126
7200
|
};
|
|
7127
|
-
var typescript_no_unsafe_object_assignment_default =
|
|
7201
|
+
var typescript_no_unsafe_object_assignment_default = typescriptNoUnsafeObjectAssignmentRule;
|
|
7128
7202
|
|
|
7129
7203
|
// dist/rules/typescript-prefer-array-type-alias.js
|
|
7130
7204
|
var selector15 = String.raw`TSTypeAliasDeclaration > Identifier.id:matches([parent.typeAnnotation.type='TSArrayType'], [parent.typeAnnotation.type='TSTupleType']):not([name=/^(?:[A-Z][a-z\d]*)+(?:Array|s)$/u])`;
|
|
@@ -7190,8 +7264,8 @@ var typescript_prefer_class_method_default = rule102;
|
|
|
7190
7264
|
|
|
7191
7265
|
// dist/rules/typescript-prefer-enum.js
|
|
7192
7266
|
var import_type_utils10 = require("@typescript-eslint/type-utils");
|
|
7193
|
-
var
|
|
7194
|
-
var
|
|
7267
|
+
var import_utils48 = require("@typescript-eslint/utils");
|
|
7268
|
+
var import_ts_extras65 = require("ts-extras");
|
|
7195
7269
|
var tsutils5 = __toESM(require("tsutils"), 1);
|
|
7196
7270
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
7197
7271
|
var isEnumLikeOrUndefinedType = (checker, type) => {
|
|
@@ -7209,10 +7283,10 @@ var isEnumLikeOrUndefinedType = (checker, type) => {
|
|
|
7209
7283
|
}
|
|
7210
7284
|
return hasEnumLike;
|
|
7211
7285
|
};
|
|
7212
|
-
var isStringLiteral = (node) => node.type ===
|
|
7286
|
+
var isStringLiteral = (node) => node.type === import_utils48.AST_NODE_TYPES.Literal && typeof node.value === "string";
|
|
7213
7287
|
var rule103 = ruleCreator({
|
|
7214
7288
|
create: (context) => {
|
|
7215
|
-
const parserServices =
|
|
7289
|
+
const parserServices = import_utils48.ESLintUtils.getParserServices(context);
|
|
7216
7290
|
const checker = parserServices.program.getTypeChecker();
|
|
7217
7291
|
return {
|
|
7218
7292
|
BinaryExpression: (node) => {
|
|
@@ -7220,16 +7294,11 @@ var rule103 = ruleCreator({
|
|
|
7220
7294
|
if (!isEqualityOperator) {
|
|
7221
7295
|
return;
|
|
7222
7296
|
}
|
|
7223
|
-
|
|
7224
|
-
if (isStringLiteral(node.left)) {
|
|
7225
|
-
literalNode = node.left;
|
|
7226
|
-
} else if (isStringLiteral(node.right)) {
|
|
7227
|
-
literalNode = node.right;
|
|
7228
|
-
}
|
|
7229
|
-
const expressionNode = literalNode === node.left ? node.right : node.left;
|
|
7297
|
+
const literalNode = isStringLiteral(node.left) ? node.left : isStringLiteral(node.right) ? node.right : null;
|
|
7230
7298
|
if (literalNode === null) {
|
|
7231
7299
|
return;
|
|
7232
7300
|
}
|
|
7301
|
+
const expressionNode = literalNode === node.left ? node.right : node.left;
|
|
7233
7302
|
const expressionType = (0, import_type_utils10.getConstrainedTypeAtLocation)(parserServices, expressionNode);
|
|
7234
7303
|
if (!isEnumLikeOrUndefinedType(checker, expressionType)) {
|
|
7235
7304
|
return;
|
|
@@ -7245,16 +7314,16 @@ var rule103 = ruleCreator({
|
|
|
7245
7314
|
}
|
|
7246
7315
|
let functionNode = null;
|
|
7247
7316
|
for (const ancestor of context.sourceCode.getAncestors(node)) {
|
|
7248
|
-
if (ancestor.type ===
|
|
7317
|
+
if (ancestor.type === import_utils48.AST_NODE_TYPES.ArrowFunctionExpression || ancestor.type === import_utils48.AST_NODE_TYPES.FunctionDeclaration || ancestor.type === import_utils48.AST_NODE_TYPES.FunctionExpression) {
|
|
7249
7318
|
functionNode = ancestor;
|
|
7250
7319
|
}
|
|
7251
7320
|
}
|
|
7252
7321
|
if (functionNode === null) {
|
|
7253
7322
|
return;
|
|
7254
7323
|
}
|
|
7255
|
-
const signature = (0,
|
|
7256
|
-
const returnType = (0,
|
|
7257
|
-
if (!(0,
|
|
7324
|
+
const signature = (0, import_ts_extras65.arrayFirst)((0, import_type_utils10.getConstrainedTypeAtLocation)(parserServices, functionNode).getCallSignatures());
|
|
7325
|
+
const returnType = (0, import_ts_extras65.isDefined)(signature) ? checker.getReturnTypeOfSignature(signature) : void 0;
|
|
7326
|
+
if (!(0, import_ts_extras65.isDefined)(returnType)) {
|
|
7258
7327
|
return;
|
|
7259
7328
|
}
|
|
7260
7329
|
if (!isEnumLikeOrUndefinedType(checker, returnType)) {
|
|
@@ -7266,12 +7335,12 @@ var rule103 = ruleCreator({
|
|
|
7266
7335
|
});
|
|
7267
7336
|
},
|
|
7268
7337
|
TSTypeAliasDeclaration: (node) => {
|
|
7269
|
-
if (node.typeAnnotation.type !==
|
|
7338
|
+
if (node.typeAnnotation.type !== import_utils48.AST_NODE_TYPES.TSUnionType) {
|
|
7270
7339
|
return;
|
|
7271
7340
|
}
|
|
7272
7341
|
let literalCount = 0;
|
|
7273
7342
|
for (const typeNode of node.typeAnnotation.types) {
|
|
7274
|
-
if (typeNode.type ===
|
|
7343
|
+
if (typeNode.type === import_utils48.AST_NODE_TYPES.TSLiteralType && typeNode.literal.type === import_utils48.AST_NODE_TYPES.Literal && typeof typeNode.literal.value === "string") {
|
|
7275
7344
|
literalCount += 1;
|
|
7276
7345
|
}
|
|
7277
7346
|
}
|
|
@@ -7308,11 +7377,12 @@ var rule103 = ruleCreator({
|
|
|
7308
7377
|
var typescript_prefer_enum_default = rule103;
|
|
7309
7378
|
|
|
7310
7379
|
// dist/rules/typescript-prefer-named-tuple-members.js
|
|
7380
|
+
var import_utils49 = require("@typescript-eslint/utils");
|
|
7311
7381
|
var isUnnamedTupleElement = (tupleElement) => {
|
|
7312
|
-
if (tupleElement.type ===
|
|
7382
|
+
if (tupleElement.type === import_utils49.AST_NODE_TYPES.TSNamedTupleMember) {
|
|
7313
7383
|
return false;
|
|
7314
7384
|
}
|
|
7315
|
-
if (tupleElement.type ===
|
|
7385
|
+
if (tupleElement.type === import_utils49.AST_NODE_TYPES.TSRestType && tupleElement.typeAnnotation.type === import_utils49.AST_NODE_TYPES.TSNamedTupleMember) {
|
|
7316
7386
|
return false;
|
|
7317
7387
|
}
|
|
7318
7388
|
return true;
|
|
@@ -7331,11 +7401,11 @@ var generateUniqueTupleMemberName = (preferredName, usedNames) => {
|
|
|
7331
7401
|
return generatedName;
|
|
7332
7402
|
};
|
|
7333
7403
|
var getTupleMemberReplacementText = (tupleElement, memberName2, sourceCode) => {
|
|
7334
|
-
if (tupleElement.type ===
|
|
7404
|
+
if (tupleElement.type === import_utils49.AST_NODE_TYPES.TSOptionalType) {
|
|
7335
7405
|
return `${memberName2}?: ${sourceCode.getText(tupleElement.typeAnnotation)}`;
|
|
7336
7406
|
}
|
|
7337
|
-
if (tupleElement.type ===
|
|
7338
|
-
if (tupleElement.typeAnnotation.type ===
|
|
7407
|
+
if (tupleElement.type === import_utils49.AST_NODE_TYPES.TSRestType) {
|
|
7408
|
+
if (tupleElement.typeAnnotation.type === import_utils49.AST_NODE_TYPES.TSNamedTupleMember) {
|
|
7339
7409
|
return sourceCode.getText(tupleElement);
|
|
7340
7410
|
}
|
|
7341
7411
|
return `...${memberName2}: ${sourceCode.getText(tupleElement.typeAnnotation)}`;
|
|
@@ -7352,10 +7422,7 @@ var rule104 = ruleCreator({
|
|
|
7352
7422
|
return;
|
|
7353
7423
|
}
|
|
7354
7424
|
const usedNames = new Set(node.elementTypes.flatMap((tupleElement) => {
|
|
7355
|
-
if (tupleElement.type !==
|
|
7356
|
-
return [];
|
|
7357
|
-
}
|
|
7358
|
-
if (tupleElement.label.type !== "Identifier") {
|
|
7425
|
+
if (tupleElement.type !== import_utils49.AST_NODE_TYPES.TSNamedTupleMember) {
|
|
7359
7426
|
return [];
|
|
7360
7427
|
}
|
|
7361
7428
|
return [tupleElement.label.name];
|
|
@@ -7411,23 +7478,24 @@ var rule104 = ruleCreator({
|
|
|
7411
7478
|
var typescript_prefer_named_tuple_members_default = rule104;
|
|
7412
7479
|
|
|
7413
7480
|
// dist/rules/typescript-prefer-readonly-array-parameter.js
|
|
7481
|
+
var import_utils50 = require("@typescript-eslint/utils");
|
|
7414
7482
|
var functionLikeNodeSelector2 = ":matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSConstructorType, TSDeclareFunction, TSEmptyBodyFunctionExpression, TSFunctionType, TSMethodSignature)";
|
|
7415
7483
|
var getParametersFromFunctionLikeNode2 = (node) => {
|
|
7416
|
-
if (node.type ===
|
|
7484
|
+
if (node.type === import_utils50.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils50.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils50.AST_NODE_TYPES.FunctionExpression || node.type === import_utils50.AST_NODE_TYPES.TSCallSignatureDeclaration || node.type === import_utils50.AST_NODE_TYPES.TSConstructSignatureDeclaration || node.type === import_utils50.AST_NODE_TYPES.TSConstructorType || node.type === import_utils50.AST_NODE_TYPES.TSDeclareFunction || node.type === import_utils50.AST_NODE_TYPES.TSEmptyBodyFunctionExpression || node.type === import_utils50.AST_NODE_TYPES.TSFunctionType || node.type === import_utils50.AST_NODE_TYPES.TSMethodSignature) {
|
|
7417
7485
|
return node.params;
|
|
7418
7486
|
}
|
|
7419
7487
|
return void 0;
|
|
7420
7488
|
};
|
|
7421
7489
|
var getTypeAnnotationFromPattern = (pattern) => {
|
|
7422
|
-
if (pattern.type ===
|
|
7490
|
+
if (pattern.type === import_utils50.AST_NODE_TYPES.AssignmentPattern) {
|
|
7423
7491
|
return getTypeAnnotationFromPattern(pattern.left);
|
|
7424
7492
|
}
|
|
7425
|
-
if (pattern.type ===
|
|
7493
|
+
if (pattern.type === import_utils50.AST_NODE_TYPES.RestElement) {
|
|
7426
7494
|
if (pattern.typeAnnotation !== void 0) {
|
|
7427
7495
|
return pattern.typeAnnotation;
|
|
7428
7496
|
}
|
|
7429
7497
|
const argument = pattern.argument;
|
|
7430
|
-
if (argument.type !==
|
|
7498
|
+
if (argument.type !== import_utils50.AST_NODE_TYPES.ArrayPattern && argument.type !== import_utils50.AST_NODE_TYPES.Identifier && argument.type !== import_utils50.AST_NODE_TYPES.ObjectPattern) {
|
|
7431
7499
|
return void 0;
|
|
7432
7500
|
}
|
|
7433
7501
|
return argument.typeAnnotation;
|
|
@@ -7435,20 +7503,20 @@ var getTypeAnnotationFromPattern = (pattern) => {
|
|
|
7435
7503
|
return pattern.typeAnnotation;
|
|
7436
7504
|
};
|
|
7437
7505
|
var getTypeAnnotationFromParameter = (parameter) => {
|
|
7438
|
-
if (parameter.type ===
|
|
7506
|
+
if (parameter.type === import_utils50.AST_NODE_TYPES.TSParameterProperty) {
|
|
7439
7507
|
return getTypeAnnotationFromPattern(parameter.parameter);
|
|
7440
7508
|
}
|
|
7441
7509
|
return getTypeAnnotationFromPattern(parameter);
|
|
7442
7510
|
};
|
|
7443
|
-
var isArrayTypeReference = (node) => node.typeName.type ===
|
|
7511
|
+
var isArrayTypeReference = (node) => node.typeName.type === import_utils50.AST_NODE_TYPES.Identifier && node.typeName.name === "Array";
|
|
7444
7512
|
var collectMutableArrayLikeTypeNodes = (typeNode) => {
|
|
7445
|
-
if (typeNode.type ===
|
|
7513
|
+
if (typeNode.type === import_utils50.AST_NODE_TYPES.TSArrayType || typeNode.type === import_utils50.AST_NODE_TYPES.TSTupleType) {
|
|
7446
7514
|
return [typeNode];
|
|
7447
7515
|
}
|
|
7448
|
-
if (typeNode.type ===
|
|
7516
|
+
if (typeNode.type === import_utils50.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils50.AST_NODE_TYPES.TSUnionType) {
|
|
7449
7517
|
return typeNode.types.flatMap((subTypeNode) => collectMutableArrayLikeTypeNodes(subTypeNode));
|
|
7450
7518
|
}
|
|
7451
|
-
if (typeNode.type ===
|
|
7519
|
+
if (typeNode.type === import_utils50.AST_NODE_TYPES.TSTypeReference) {
|
|
7452
7520
|
if (!isArrayTypeReference(typeNode)) {
|
|
7453
7521
|
return [];
|
|
7454
7522
|
}
|
|
@@ -7457,7 +7525,7 @@ var collectMutableArrayLikeTypeNodes = (typeNode) => {
|
|
|
7457
7525
|
return [];
|
|
7458
7526
|
};
|
|
7459
7527
|
var buildReadonlyArrayLikeFix = (node, sourceCode) => {
|
|
7460
|
-
if (node.type ===
|
|
7528
|
+
if (node.type === import_utils50.AST_NODE_TYPES.Identifier) {
|
|
7461
7529
|
return (fixer) => fixer.replaceText(node, "ReadonlyArray");
|
|
7462
7530
|
}
|
|
7463
7531
|
return (fixer) => fixer.replaceText(node, `readonly ${sourceCode.getText(node)}`);
|
|
@@ -7518,8 +7586,9 @@ var rule105 = ruleCreator({
|
|
|
7518
7586
|
var typescript_prefer_readonly_array_parameter_default = rule105;
|
|
7519
7587
|
|
|
7520
7588
|
// dist/rules/typescript-prefer-readonly-array.js
|
|
7521
|
-
var
|
|
7522
|
-
var
|
|
7589
|
+
var import_utils51 = require("@typescript-eslint/utils");
|
|
7590
|
+
var import_ts_extras66 = require("ts-extras");
|
|
7591
|
+
var selector17 = (0, import_ts_extras66.arrayJoin)([
|
|
7523
7592
|
":not(TSTypeOperator[operator='readonly']) > :matches(TSArrayType, TSTupleType)",
|
|
7524
7593
|
"TSTypeReference > Identifier[name='Array']"
|
|
7525
7594
|
], ", ");
|
|
@@ -7528,10 +7597,10 @@ var rule106 = ruleCreator({
|
|
|
7528
7597
|
const sourceCode = context.sourceCode;
|
|
7529
7598
|
return {
|
|
7530
7599
|
[selector17]: (node) => {
|
|
7531
|
-
if (node.type !==
|
|
7600
|
+
if (node.type !== import_utils51.AST_NODE_TYPES.Identifier && node.type !== import_utils51.AST_NODE_TYPES.TSArrayType && node.type !== import_utils51.AST_NODE_TYPES.TSTupleType) {
|
|
7532
7601
|
return;
|
|
7533
7602
|
}
|
|
7534
|
-
const fix = node.type ===
|
|
7603
|
+
const fix = node.type === import_utils51.AST_NODE_TYPES.Identifier ? (fixer) => fixer.replaceText(node, "ReadonlyArray") : (fixer) => fixer.replaceText(node, `readonly ${sourceCode.getText(node)}`);
|
|
7535
7604
|
context.report({
|
|
7536
7605
|
fix,
|
|
7537
7606
|
messageId: "forbidden",
|
|
@@ -7562,11 +7631,12 @@ var rule106 = ruleCreator({
|
|
|
7562
7631
|
var typescript_prefer_readonly_array_default = rule106;
|
|
7563
7632
|
|
|
7564
7633
|
// dist/rules/typescript-prefer-readonly-index-signature.js
|
|
7634
|
+
var import_utils52 = require("@typescript-eslint/utils");
|
|
7565
7635
|
var selector18 = "TSIndexSignature[readonly!=true]";
|
|
7566
7636
|
var rule107 = ruleCreator({
|
|
7567
7637
|
create: (context) => ({
|
|
7568
7638
|
[selector18]: (node) => {
|
|
7569
|
-
if (node.type !==
|
|
7639
|
+
if (node.type !== import_utils52.AST_NODE_TYPES.TSIndexSignature || node.readonly) {
|
|
7570
7640
|
return;
|
|
7571
7641
|
}
|
|
7572
7642
|
context.report({
|
|
@@ -7598,11 +7668,12 @@ var rule107 = ruleCreator({
|
|
|
7598
7668
|
var typescript_prefer_readonly_index_signature_default = rule107;
|
|
7599
7669
|
|
|
7600
7670
|
// dist/rules/typescript-prefer-readonly-map.js
|
|
7671
|
+
var import_utils53 = require("@typescript-eslint/utils");
|
|
7601
7672
|
var selector19 = "TSTypeReference > Identifier[name='Map']";
|
|
7602
7673
|
var rule108 = ruleCreator({
|
|
7603
7674
|
create: (context) => ({
|
|
7604
7675
|
[selector19]: (node) => {
|
|
7605
|
-
if (node.type !==
|
|
7676
|
+
if (node.type !== import_utils53.AST_NODE_TYPES.Identifier) {
|
|
7606
7677
|
return;
|
|
7607
7678
|
}
|
|
7608
7679
|
context.report({
|
|
@@ -7634,20 +7705,21 @@ var rule108 = ruleCreator({
|
|
|
7634
7705
|
var typescript_prefer_readonly_map_default = rule108;
|
|
7635
7706
|
|
|
7636
7707
|
// dist/rules/typescript-prefer-readonly-property.js
|
|
7637
|
-
var
|
|
7708
|
+
var import_utils54 = require("@typescript-eslint/utils");
|
|
7709
|
+
var import_ts_extras67 = require("ts-extras");
|
|
7638
7710
|
var selector20 = ":matches(PropertyDefinition, TSPropertySignature)[readonly!=true]";
|
|
7639
7711
|
var rule109 = ruleCreator({
|
|
7640
7712
|
create: (context) => ({
|
|
7641
7713
|
[selector20]: (node) => {
|
|
7642
|
-
if (node.type !==
|
|
7714
|
+
if (node.type !== import_utils54.AST_NODE_TYPES.PropertyDefinition && node.type !== import_utils54.AST_NODE_TYPES.TSPropertySignature) {
|
|
7643
7715
|
return;
|
|
7644
7716
|
}
|
|
7645
7717
|
const keyNode = node.key;
|
|
7646
|
-
const fix = keyNode.type ===
|
|
7718
|
+
const fix = keyNode.type === import_utils54.AST_NODE_TYPES.Identifier || keyNode.type === import_utils54.AST_NODE_TYPES.PrivateIdentifier || keyNode.type === import_utils54.AST_NODE_TYPES.Literal ? (fixer) => fixer.insertTextBefore(keyNode, "readonly ") : void 0;
|
|
7647
7719
|
context.report({
|
|
7648
7720
|
messageId: "forbidden",
|
|
7649
7721
|
node,
|
|
7650
|
-
...(0,
|
|
7722
|
+
...(0, import_ts_extras67.isDefined)(fix) ? {
|
|
7651
7723
|
fix,
|
|
7652
7724
|
suggest: [
|
|
7653
7725
|
{
|
|
@@ -7682,23 +7754,24 @@ var rule109 = ruleCreator({
|
|
|
7682
7754
|
var typescript_prefer_readonly_property_default = rule109;
|
|
7683
7755
|
|
|
7684
7756
|
// dist/rules/typescript-prefer-readonly-record.js
|
|
7757
|
+
var import_utils55 = require("@typescript-eslint/utils");
|
|
7685
7758
|
var selector21 = "TSTypeReference > Identifier[name='Record']";
|
|
7686
7759
|
var isReadonlyWrappedRecord = (typeReference) => {
|
|
7687
7760
|
const parent = typeReference.parent;
|
|
7688
|
-
if (parent
|
|
7761
|
+
if (parent.type !== import_utils55.AST_NODE_TYPES.TSTypeParameterInstantiation) {
|
|
7689
7762
|
return false;
|
|
7690
7763
|
}
|
|
7691
7764
|
const maybeReadonlyTypeReference = parent.parent;
|
|
7692
|
-
return maybeReadonlyTypeReference
|
|
7765
|
+
return maybeReadonlyTypeReference.type === import_utils55.AST_NODE_TYPES.TSTypeReference && maybeReadonlyTypeReference.typeName.type === import_utils55.AST_NODE_TYPES.Identifier && maybeReadonlyTypeReference.typeName.name === "Readonly";
|
|
7693
7766
|
};
|
|
7694
7767
|
var rule110 = ruleCreator({
|
|
7695
7768
|
create: (context) => ({
|
|
7696
7769
|
[selector21]: (node) => {
|
|
7697
|
-
if (node.type !==
|
|
7770
|
+
if (node.type !== import_utils55.AST_NODE_TYPES.Identifier) {
|
|
7698
7771
|
return;
|
|
7699
7772
|
}
|
|
7700
7773
|
const typeReference = node.parent;
|
|
7701
|
-
if (typeReference
|
|
7774
|
+
if (typeReference.type !== import_utils55.AST_NODE_TYPES.TSTypeReference || typeReference.typeName.type !== import_utils55.AST_NODE_TYPES.Identifier || typeReference.typeName.name !== "Record" || isReadonlyWrappedRecord(typeReference)) {
|
|
7702
7775
|
return;
|
|
7703
7776
|
}
|
|
7704
7777
|
context.report({
|
|
@@ -7733,11 +7806,12 @@ var rule110 = ruleCreator({
|
|
|
7733
7806
|
var typescript_prefer_readonly_record_default = rule110;
|
|
7734
7807
|
|
|
7735
7808
|
// dist/rules/typescript-prefer-readonly-set.js
|
|
7809
|
+
var import_utils56 = require("@typescript-eslint/utils");
|
|
7736
7810
|
var selector22 = "TSTypeReference > Identifier[name='Set']";
|
|
7737
7811
|
var rule111 = ruleCreator({
|
|
7738
7812
|
create: (context) => ({
|
|
7739
7813
|
[selector22]: (node) => {
|
|
7740
|
-
if (node.type !==
|
|
7814
|
+
if (node.type !== import_utils56.AST_NODE_TYPES.Identifier) {
|
|
7741
7815
|
return;
|
|
7742
7816
|
}
|
|
7743
7817
|
context.report({
|
|
@@ -7769,20 +7843,21 @@ var rule111 = ruleCreator({
|
|
|
7769
7843
|
var typescript_prefer_readonly_set_default = rule111;
|
|
7770
7844
|
|
|
7771
7845
|
// dist/rules/typescript-require-prop-type-annotation.js
|
|
7772
|
-
var
|
|
7846
|
+
var import_utils57 = require("@typescript-eslint/utils");
|
|
7847
|
+
var import_ts_extras68 = require("ts-extras");
|
|
7773
7848
|
var selector23 = "PropertyDefinition[typeAnnotation=undefined][value=null]";
|
|
7774
7849
|
var rule112 = ruleCreator({
|
|
7775
7850
|
create: (context) => ({
|
|
7776
7851
|
[selector23]: (node) => {
|
|
7777
|
-
if (node.type !==
|
|
7852
|
+
if (node.type !== import_utils57.AST_NODE_TYPES.PropertyDefinition) {
|
|
7778
7853
|
return;
|
|
7779
7854
|
}
|
|
7780
|
-
const canProvideSafeSuggestion = !node.computed && node.key.type ===
|
|
7855
|
+
const canProvideSafeSuggestion = !node.computed && node.key.type === import_utils57.AST_NODE_TYPES.Identifier && !node.optional && !node.definite;
|
|
7781
7856
|
const fix = canProvideSafeSuggestion ? (fixer) => fixer.insertTextAfter(node.key, ": unknown") : void 0;
|
|
7782
7857
|
context.report({
|
|
7783
7858
|
messageId: "forbidden",
|
|
7784
7859
|
node,
|
|
7785
|
-
...(0,
|
|
7860
|
+
...(0, import_ts_extras68.isDefined)(fix) ? {
|
|
7786
7861
|
fix,
|
|
7787
7862
|
suggest: [
|
|
7788
7863
|
{
|
|
@@ -7817,15 +7892,16 @@ var rule112 = ruleCreator({
|
|
|
7817
7892
|
var typescript_require_prop_type_annotation_default = rule112;
|
|
7818
7893
|
|
|
7819
7894
|
// dist/rules/typescript-require-readonly-array-property-type.js
|
|
7820
|
-
var
|
|
7895
|
+
var import_utils58 = require("@typescript-eslint/utils");
|
|
7896
|
+
var isArrayTypeReference2 = (node) => node.typeName.type === import_utils58.AST_NODE_TYPES.Identifier && node.typeName.name === "Array";
|
|
7821
7897
|
var collectMutableArrayLikeTypeNodes2 = (typeNode) => {
|
|
7822
|
-
if (typeNode.type ===
|
|
7898
|
+
if (typeNode.type === import_utils58.AST_NODE_TYPES.TSArrayType || typeNode.type === import_utils58.AST_NODE_TYPES.TSTupleType) {
|
|
7823
7899
|
return [typeNode];
|
|
7824
7900
|
}
|
|
7825
|
-
if (typeNode.type ===
|
|
7901
|
+
if (typeNode.type === import_utils58.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils58.AST_NODE_TYPES.TSUnionType) {
|
|
7826
7902
|
return typeNode.types.flatMap((subTypeNode) => collectMutableArrayLikeTypeNodes2(subTypeNode));
|
|
7827
7903
|
}
|
|
7828
|
-
if (typeNode.type ===
|
|
7904
|
+
if (typeNode.type === import_utils58.AST_NODE_TYPES.TSTypeReference) {
|
|
7829
7905
|
if (!isArrayTypeReference2(typeNode)) {
|
|
7830
7906
|
return [];
|
|
7831
7907
|
}
|
|
@@ -7834,21 +7910,18 @@ var collectMutableArrayLikeTypeNodes2 = (typeNode) => {
|
|
|
7834
7910
|
return [];
|
|
7835
7911
|
};
|
|
7836
7912
|
var buildReadonlyArrayLikeFix2 = (node, sourceCode) => {
|
|
7837
|
-
if (node.type ===
|
|
7913
|
+
if (node.type === import_utils58.AST_NODE_TYPES.Identifier) {
|
|
7838
7914
|
return (fixer) => fixer.replaceText(node, "ReadonlyArray");
|
|
7839
7915
|
}
|
|
7840
7916
|
return (fixer) => fixer.replaceText(node, `readonly ${sourceCode.getText(node)}`);
|
|
7841
7917
|
};
|
|
7842
7918
|
var isTopLevelPropertySignature = (node) => {
|
|
7843
7919
|
const parent = node.parent;
|
|
7844
|
-
if (parent
|
|
7920
|
+
if (parent.type === import_utils58.AST_NODE_TYPES.TSInterfaceBody) {
|
|
7845
7921
|
return true;
|
|
7846
7922
|
}
|
|
7847
|
-
if (parent?.type !== "TSTypeLiteral") {
|
|
7848
|
-
return false;
|
|
7849
|
-
}
|
|
7850
7923
|
const maybeTypeAliasDeclaration = parent.parent;
|
|
7851
|
-
return maybeTypeAliasDeclaration
|
|
7924
|
+
return maybeTypeAliasDeclaration.type === import_utils58.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
7852
7925
|
};
|
|
7853
7926
|
var rule113 = ruleCreator({
|
|
7854
7927
|
create: (context) => {
|
|
@@ -7903,22 +7976,23 @@ var rule113 = ruleCreator({
|
|
|
7903
7976
|
var typescript_require_readonly_array_property_type_default = rule113;
|
|
7904
7977
|
|
|
7905
7978
|
// dist/rules/typescript-require-readonly-array-return-type.js
|
|
7979
|
+
var import_utils59 = require("@typescript-eslint/utils");
|
|
7906
7980
|
var functionLikeNodeSelector3 = ":matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSConstructorType, TSDeclareFunction, TSEmptyBodyFunctionExpression, TSFunctionType, TSMethodSignature)";
|
|
7907
7981
|
var getReturnTypeAnnotationFromFunctionLikeNode = (node) => {
|
|
7908
|
-
if (node.type ===
|
|
7982
|
+
if (node.type === import_utils59.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils59.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils59.AST_NODE_TYPES.FunctionExpression || node.type === import_utils59.AST_NODE_TYPES.TSCallSignatureDeclaration || node.type === import_utils59.AST_NODE_TYPES.TSConstructSignatureDeclaration || node.type === import_utils59.AST_NODE_TYPES.TSConstructorType || node.type === import_utils59.AST_NODE_TYPES.TSDeclareFunction || node.type === import_utils59.AST_NODE_TYPES.TSEmptyBodyFunctionExpression || node.type === import_utils59.AST_NODE_TYPES.TSFunctionType || node.type === import_utils59.AST_NODE_TYPES.TSMethodSignature) {
|
|
7909
7983
|
return node.returnType;
|
|
7910
7984
|
}
|
|
7911
7985
|
return void 0;
|
|
7912
7986
|
};
|
|
7913
|
-
var isArrayTypeReference3 = (node) => node.typeName.type ===
|
|
7987
|
+
var isArrayTypeReference3 = (node) => node.typeName.type === import_utils59.AST_NODE_TYPES.Identifier && node.typeName.name === "Array";
|
|
7914
7988
|
var collectMutableArrayLikeTypeNodes3 = (typeNode) => {
|
|
7915
|
-
if (typeNode.type ===
|
|
7989
|
+
if (typeNode.type === import_utils59.AST_NODE_TYPES.TSArrayType || typeNode.type === import_utils59.AST_NODE_TYPES.TSTupleType) {
|
|
7916
7990
|
return [typeNode];
|
|
7917
7991
|
}
|
|
7918
|
-
if (typeNode.type ===
|
|
7992
|
+
if (typeNode.type === import_utils59.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils59.AST_NODE_TYPES.TSUnionType) {
|
|
7919
7993
|
return typeNode.types.flatMap((subTypeNode) => collectMutableArrayLikeTypeNodes3(subTypeNode));
|
|
7920
7994
|
}
|
|
7921
|
-
if (typeNode.type ===
|
|
7995
|
+
if (typeNode.type === import_utils59.AST_NODE_TYPES.TSTypeReference) {
|
|
7922
7996
|
if (!isArrayTypeReference3(typeNode)) {
|
|
7923
7997
|
return [];
|
|
7924
7998
|
}
|
|
@@ -7927,7 +8001,7 @@ var collectMutableArrayLikeTypeNodes3 = (typeNode) => {
|
|
|
7927
8001
|
return [];
|
|
7928
8002
|
};
|
|
7929
8003
|
var buildReadonlyArrayLikeFix3 = (node, sourceCode) => {
|
|
7930
|
-
if (node.type ===
|
|
8004
|
+
if (node.type === import_utils59.AST_NODE_TYPES.Identifier) {
|
|
7931
8005
|
return (fixer) => fixer.replaceText(node, "ReadonlyArray");
|
|
7932
8006
|
}
|
|
7933
8007
|
return (fixer) => fixer.replaceText(node, `readonly ${sourceCode.getText(node)}`);
|
|
@@ -7982,15 +8056,16 @@ var rule114 = ruleCreator({
|
|
|
7982
8056
|
var typescript_require_readonly_array_return_type_default = rule114;
|
|
7983
8057
|
|
|
7984
8058
|
// dist/rules/typescript-require-readonly-array-type-alias.js
|
|
7985
|
-
var
|
|
8059
|
+
var import_utils60 = require("@typescript-eslint/utils");
|
|
8060
|
+
var isArrayTypeReference4 = (node) => node.typeName.type === import_utils60.AST_NODE_TYPES.Identifier && node.typeName.name === "Array";
|
|
7986
8061
|
var collectMutableArrayLikeTypeNodes4 = (typeNode) => {
|
|
7987
|
-
if (typeNode.type ===
|
|
8062
|
+
if (typeNode.type === import_utils60.AST_NODE_TYPES.TSArrayType || typeNode.type === import_utils60.AST_NODE_TYPES.TSTupleType) {
|
|
7988
8063
|
return [typeNode];
|
|
7989
8064
|
}
|
|
7990
|
-
if (typeNode.type ===
|
|
8065
|
+
if (typeNode.type === import_utils60.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils60.AST_NODE_TYPES.TSUnionType) {
|
|
7991
8066
|
return typeNode.types.flatMap((subTypeNode) => collectMutableArrayLikeTypeNodes4(subTypeNode));
|
|
7992
8067
|
}
|
|
7993
|
-
if (typeNode.type ===
|
|
8068
|
+
if (typeNode.type === import_utils60.AST_NODE_TYPES.TSTypeReference) {
|
|
7994
8069
|
if (!isArrayTypeReference4(typeNode)) {
|
|
7995
8070
|
return [];
|
|
7996
8071
|
}
|
|
@@ -7999,7 +8074,7 @@ var collectMutableArrayLikeTypeNodes4 = (typeNode) => {
|
|
|
7999
8074
|
return [];
|
|
8000
8075
|
};
|
|
8001
8076
|
var buildReadonlyArrayLikeFix4 = (node, sourceCode) => {
|
|
8002
|
-
if (node.type ===
|
|
8077
|
+
if (node.type === import_utils60.AST_NODE_TYPES.Identifier) {
|
|
8003
8078
|
return (fixer) => fixer.replaceText(node, "ReadonlyArray");
|
|
8004
8079
|
}
|
|
8005
8080
|
return (fixer) => fixer.replaceText(node, `readonly ${sourceCode.getText(node)}`);
|
|
@@ -8050,23 +8125,24 @@ var rule115 = ruleCreator({
|
|
|
8050
8125
|
var typescript_require_readonly_array_type_alias_default = rule115;
|
|
8051
8126
|
|
|
8052
8127
|
// dist/rules/typescript-require-readonly-map-parameter-type.js
|
|
8128
|
+
var import_utils61 = require("@typescript-eslint/utils");
|
|
8053
8129
|
var functionLikeNodeSelector4 = ":matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSConstructorType, TSDeclareFunction, TSEmptyBodyFunctionExpression, TSFunctionType, TSMethodSignature)";
|
|
8054
8130
|
var getParametersFromFunctionLikeNode3 = (node) => {
|
|
8055
|
-
if (node.type ===
|
|
8131
|
+
if (node.type === import_utils61.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils61.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils61.AST_NODE_TYPES.FunctionExpression || node.type === import_utils61.AST_NODE_TYPES.TSCallSignatureDeclaration || node.type === import_utils61.AST_NODE_TYPES.TSConstructSignatureDeclaration || node.type === import_utils61.AST_NODE_TYPES.TSConstructorType || node.type === import_utils61.AST_NODE_TYPES.TSDeclareFunction || node.type === import_utils61.AST_NODE_TYPES.TSEmptyBodyFunctionExpression || node.type === import_utils61.AST_NODE_TYPES.TSFunctionType || node.type === import_utils61.AST_NODE_TYPES.TSMethodSignature) {
|
|
8056
8132
|
return node.params;
|
|
8057
8133
|
}
|
|
8058
8134
|
return void 0;
|
|
8059
8135
|
};
|
|
8060
8136
|
var getTypeAnnotationFromPattern2 = (pattern) => {
|
|
8061
|
-
if (pattern.type ===
|
|
8137
|
+
if (pattern.type === import_utils61.AST_NODE_TYPES.AssignmentPattern) {
|
|
8062
8138
|
return getTypeAnnotationFromPattern2(pattern.left);
|
|
8063
8139
|
}
|
|
8064
|
-
if (pattern.type ===
|
|
8140
|
+
if (pattern.type === import_utils61.AST_NODE_TYPES.RestElement) {
|
|
8065
8141
|
if (pattern.typeAnnotation !== void 0) {
|
|
8066
8142
|
return pattern.typeAnnotation;
|
|
8067
8143
|
}
|
|
8068
8144
|
const argument = pattern.argument;
|
|
8069
|
-
if (argument.type !==
|
|
8145
|
+
if (argument.type !== import_utils61.AST_NODE_TYPES.ArrayPattern && argument.type !== import_utils61.AST_NODE_TYPES.Identifier && argument.type !== import_utils61.AST_NODE_TYPES.ObjectPattern) {
|
|
8070
8146
|
return void 0;
|
|
8071
8147
|
}
|
|
8072
8148
|
return argument.typeAnnotation;
|
|
@@ -8074,17 +8150,17 @@ var getTypeAnnotationFromPattern2 = (pattern) => {
|
|
|
8074
8150
|
return pattern.typeAnnotation;
|
|
8075
8151
|
};
|
|
8076
8152
|
var getTypeAnnotationFromParameter2 = (parameter) => {
|
|
8077
|
-
if (parameter.type ===
|
|
8153
|
+
if (parameter.type === import_utils61.AST_NODE_TYPES.TSParameterProperty) {
|
|
8078
8154
|
return getTypeAnnotationFromPattern2(parameter.parameter);
|
|
8079
8155
|
}
|
|
8080
8156
|
return getTypeAnnotationFromPattern2(parameter);
|
|
8081
8157
|
};
|
|
8082
|
-
var isMapTypeReference = (node) => node.typeName.type ===
|
|
8158
|
+
var isMapTypeReference = (node) => node.typeName.type === import_utils61.AST_NODE_TYPES.Identifier && node.typeName.name === "Map";
|
|
8083
8159
|
var collectMutableMapTypeNodes = (typeNode) => {
|
|
8084
|
-
if (typeNode.type ===
|
|
8160
|
+
if (typeNode.type === import_utils61.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils61.AST_NODE_TYPES.TSUnionType) {
|
|
8085
8161
|
return typeNode.types.flatMap((subTypeNode) => collectMutableMapTypeNodes(subTypeNode));
|
|
8086
8162
|
}
|
|
8087
|
-
if (typeNode.type !==
|
|
8163
|
+
if (typeNode.type !== import_utils61.AST_NODE_TYPES.TSTypeReference || !isMapTypeReference(typeNode)) {
|
|
8088
8164
|
return [];
|
|
8089
8165
|
}
|
|
8090
8166
|
return [typeNode.typeName];
|
|
@@ -8143,12 +8219,13 @@ var rule116 = ruleCreator({
|
|
|
8143
8219
|
var typescript_require_readonly_map_parameter_type_default = rule116;
|
|
8144
8220
|
|
|
8145
8221
|
// dist/rules/typescript-require-readonly-map-property-type.js
|
|
8146
|
-
var
|
|
8222
|
+
var import_utils62 = require("@typescript-eslint/utils");
|
|
8223
|
+
var isMapTypeReference2 = (node) => node.typeName.type === import_utils62.AST_NODE_TYPES.Identifier && node.typeName.name === "Map";
|
|
8147
8224
|
var collectMutableMapTypeNodes2 = (typeNode) => {
|
|
8148
|
-
if (typeNode.type ===
|
|
8225
|
+
if (typeNode.type === import_utils62.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils62.AST_NODE_TYPES.TSUnionType) {
|
|
8149
8226
|
return typeNode.types.flatMap((subTypeNode) => collectMutableMapTypeNodes2(subTypeNode));
|
|
8150
8227
|
}
|
|
8151
|
-
if (typeNode.type !==
|
|
8228
|
+
if (typeNode.type !== import_utils62.AST_NODE_TYPES.TSTypeReference || !isMapTypeReference2(typeNode)) {
|
|
8152
8229
|
return [];
|
|
8153
8230
|
}
|
|
8154
8231
|
return [typeNode.typeName];
|
|
@@ -8156,14 +8233,11 @@ var collectMutableMapTypeNodes2 = (typeNode) => {
|
|
|
8156
8233
|
var buildReadonlyMapFix2 = (node) => (fixer) => fixer.replaceText(node, "ReadonlyMap");
|
|
8157
8234
|
var isTopLevelPropertySignature2 = (node) => {
|
|
8158
8235
|
const parent = node.parent;
|
|
8159
|
-
if (parent
|
|
8236
|
+
if (parent.type === import_utils62.AST_NODE_TYPES.TSInterfaceBody) {
|
|
8160
8237
|
return true;
|
|
8161
8238
|
}
|
|
8162
|
-
if (parent?.type !== "TSTypeLiteral") {
|
|
8163
|
-
return false;
|
|
8164
|
-
}
|
|
8165
8239
|
const maybeTypeAliasDeclaration = parent.parent;
|
|
8166
|
-
return maybeTypeAliasDeclaration
|
|
8240
|
+
return maybeTypeAliasDeclaration.type === import_utils62.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
8167
8241
|
};
|
|
8168
8242
|
var rule117 = ruleCreator({
|
|
8169
8243
|
create: (context) => ({
|
|
@@ -8215,19 +8289,20 @@ var rule117 = ruleCreator({
|
|
|
8215
8289
|
var typescript_require_readonly_map_property_type_default = rule117;
|
|
8216
8290
|
|
|
8217
8291
|
// dist/rules/typescript-require-readonly-map-return-type.js
|
|
8292
|
+
var import_utils63 = require("@typescript-eslint/utils");
|
|
8218
8293
|
var functionLikeNodeSelector5 = ":matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSConstructorType, TSDeclareFunction, TSEmptyBodyFunctionExpression, TSFunctionType, TSMethodSignature)";
|
|
8219
8294
|
var getReturnTypeAnnotationFromFunctionLikeNode2 = (node) => {
|
|
8220
|
-
if (node.type ===
|
|
8295
|
+
if (node.type === import_utils63.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils63.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils63.AST_NODE_TYPES.FunctionExpression || node.type === import_utils63.AST_NODE_TYPES.TSCallSignatureDeclaration || node.type === import_utils63.AST_NODE_TYPES.TSConstructSignatureDeclaration || node.type === import_utils63.AST_NODE_TYPES.TSConstructorType || node.type === import_utils63.AST_NODE_TYPES.TSDeclareFunction || node.type === import_utils63.AST_NODE_TYPES.TSEmptyBodyFunctionExpression || node.type === import_utils63.AST_NODE_TYPES.TSFunctionType || node.type === import_utils63.AST_NODE_TYPES.TSMethodSignature) {
|
|
8221
8296
|
return node.returnType;
|
|
8222
8297
|
}
|
|
8223
8298
|
return void 0;
|
|
8224
8299
|
};
|
|
8225
|
-
var isMapTypeReference3 = (node) => node.typeName.type ===
|
|
8300
|
+
var isMapTypeReference3 = (node) => node.typeName.type === import_utils63.AST_NODE_TYPES.Identifier && node.typeName.name === "Map";
|
|
8226
8301
|
var collectMutableMapTypeNodes3 = (typeNode) => {
|
|
8227
|
-
if (typeNode.type ===
|
|
8302
|
+
if (typeNode.type === import_utils63.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils63.AST_NODE_TYPES.TSUnionType) {
|
|
8228
8303
|
return typeNode.types.flatMap((subTypeNode) => collectMutableMapTypeNodes3(subTypeNode));
|
|
8229
8304
|
}
|
|
8230
|
-
if (typeNode.type !==
|
|
8305
|
+
if (typeNode.type !== import_utils63.AST_NODE_TYPES.TSTypeReference || !isMapTypeReference3(typeNode)) {
|
|
8231
8306
|
return [];
|
|
8232
8307
|
}
|
|
8233
8308
|
return [typeNode.typeName];
|
|
@@ -8280,12 +8355,13 @@ var rule118 = ruleCreator({
|
|
|
8280
8355
|
var typescript_require_readonly_map_return_type_default = rule118;
|
|
8281
8356
|
|
|
8282
8357
|
// dist/rules/typescript-require-readonly-map-type-alias.js
|
|
8283
|
-
var
|
|
8358
|
+
var import_utils64 = require("@typescript-eslint/utils");
|
|
8359
|
+
var isMapTypeReference4 = (node) => node.typeName.type === import_utils64.AST_NODE_TYPES.Identifier && node.typeName.name === "Map";
|
|
8284
8360
|
var collectMutableMapTypeNodes4 = (typeNode) => {
|
|
8285
|
-
if (typeNode.type ===
|
|
8361
|
+
if (typeNode.type === import_utils64.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils64.AST_NODE_TYPES.TSUnionType) {
|
|
8286
8362
|
return typeNode.types.flatMap((subTypeNode) => collectMutableMapTypeNodes4(subTypeNode));
|
|
8287
8363
|
}
|
|
8288
|
-
if (typeNode.type !==
|
|
8364
|
+
if (typeNode.type !== import_utils64.AST_NODE_TYPES.TSTypeReference || !isMapTypeReference4(typeNode)) {
|
|
8289
8365
|
return [];
|
|
8290
8366
|
}
|
|
8291
8367
|
return [typeNode.typeName];
|
|
@@ -8334,23 +8410,24 @@ var rule119 = ruleCreator({
|
|
|
8334
8410
|
var typescript_require_readonly_map_type_alias_default = rule119;
|
|
8335
8411
|
|
|
8336
8412
|
// dist/rules/typescript-require-readonly-record-parameter-type.js
|
|
8413
|
+
var import_utils65 = require("@typescript-eslint/utils");
|
|
8337
8414
|
var functionLikeNodeSelector6 = ":matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSConstructorType, TSDeclareFunction, TSEmptyBodyFunctionExpression, TSFunctionType, TSMethodSignature)";
|
|
8338
8415
|
var getParametersFromFunctionLikeNode4 = (node) => {
|
|
8339
|
-
if (node.type ===
|
|
8416
|
+
if (node.type === import_utils65.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils65.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils65.AST_NODE_TYPES.FunctionExpression || node.type === import_utils65.AST_NODE_TYPES.TSCallSignatureDeclaration || node.type === import_utils65.AST_NODE_TYPES.TSConstructSignatureDeclaration || node.type === import_utils65.AST_NODE_TYPES.TSConstructorType || node.type === import_utils65.AST_NODE_TYPES.TSDeclareFunction || node.type === import_utils65.AST_NODE_TYPES.TSEmptyBodyFunctionExpression || node.type === import_utils65.AST_NODE_TYPES.TSFunctionType || node.type === import_utils65.AST_NODE_TYPES.TSMethodSignature) {
|
|
8340
8417
|
return node.params;
|
|
8341
8418
|
}
|
|
8342
8419
|
return void 0;
|
|
8343
8420
|
};
|
|
8344
8421
|
var getTypeAnnotationFromPattern3 = (pattern) => {
|
|
8345
|
-
if (pattern.type ===
|
|
8422
|
+
if (pattern.type === import_utils65.AST_NODE_TYPES.AssignmentPattern) {
|
|
8346
8423
|
return getTypeAnnotationFromPattern3(pattern.left);
|
|
8347
8424
|
}
|
|
8348
|
-
if (pattern.type ===
|
|
8425
|
+
if (pattern.type === import_utils65.AST_NODE_TYPES.RestElement) {
|
|
8349
8426
|
if (pattern.typeAnnotation !== void 0) {
|
|
8350
8427
|
return pattern.typeAnnotation;
|
|
8351
8428
|
}
|
|
8352
8429
|
const argument = pattern.argument;
|
|
8353
|
-
if (argument.type !==
|
|
8430
|
+
if (argument.type !== import_utils65.AST_NODE_TYPES.ArrayPattern && argument.type !== import_utils65.AST_NODE_TYPES.Identifier && argument.type !== import_utils65.AST_NODE_TYPES.ObjectPattern) {
|
|
8354
8431
|
return void 0;
|
|
8355
8432
|
}
|
|
8356
8433
|
return argument.typeAnnotation;
|
|
@@ -8358,22 +8435,22 @@ var getTypeAnnotationFromPattern3 = (pattern) => {
|
|
|
8358
8435
|
return pattern.typeAnnotation;
|
|
8359
8436
|
};
|
|
8360
8437
|
var getTypeAnnotationFromParameter3 = (parameter) => {
|
|
8361
|
-
if (parameter.type ===
|
|
8438
|
+
if (parameter.type === import_utils65.AST_NODE_TYPES.TSParameterProperty) {
|
|
8362
8439
|
return getTypeAnnotationFromPattern3(parameter.parameter);
|
|
8363
8440
|
}
|
|
8364
8441
|
return getTypeAnnotationFromPattern3(parameter);
|
|
8365
8442
|
};
|
|
8366
|
-
var isRecordTypeReference = (typeNode) => typeNode.type ===
|
|
8443
|
+
var isRecordTypeReference = (typeNode) => typeNode.type === import_utils65.AST_NODE_TYPES.TSTypeReference && typeNode.typeName.type === import_utils65.AST_NODE_TYPES.Identifier && typeNode.typeName.name === "Record";
|
|
8367
8444
|
var isReadonlyWrappedRecord2 = (typeReference) => {
|
|
8368
8445
|
const maybeTypeParameterInstantiation = typeReference.parent;
|
|
8369
|
-
if (maybeTypeParameterInstantiation
|
|
8446
|
+
if (maybeTypeParameterInstantiation.type !== import_utils65.AST_NODE_TYPES.TSTypeParameterInstantiation) {
|
|
8370
8447
|
return false;
|
|
8371
8448
|
}
|
|
8372
8449
|
const maybeReadonlyTypeReference = maybeTypeParameterInstantiation.parent;
|
|
8373
|
-
return maybeReadonlyTypeReference
|
|
8450
|
+
return maybeReadonlyTypeReference.type === import_utils65.AST_NODE_TYPES.TSTypeReference && maybeReadonlyTypeReference.typeName.type === import_utils65.AST_NODE_TYPES.Identifier && maybeReadonlyTypeReference.typeName.name === "Readonly";
|
|
8374
8451
|
};
|
|
8375
8452
|
var collectMutableRecordTypeNodes = (typeNode) => {
|
|
8376
|
-
if (typeNode.type ===
|
|
8453
|
+
if (typeNode.type === import_utils65.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils65.AST_NODE_TYPES.TSUnionType) {
|
|
8377
8454
|
return typeNode.types.flatMap((subTypeNode) => collectMutableRecordTypeNodes(subTypeNode));
|
|
8378
8455
|
}
|
|
8379
8456
|
if (!isRecordTypeReference(typeNode) || isReadonlyWrappedRecord2(typeNode)) {
|
|
@@ -8438,17 +8515,18 @@ var rule120 = ruleCreator({
|
|
|
8438
8515
|
var typescript_require_readonly_record_parameter_type_default = rule120;
|
|
8439
8516
|
|
|
8440
8517
|
// dist/rules/typescript-require-readonly-record-property-type.js
|
|
8441
|
-
var
|
|
8518
|
+
var import_utils66 = require("@typescript-eslint/utils");
|
|
8519
|
+
var isRecordTypeReference2 = (typeNode) => typeNode.type === import_utils66.AST_NODE_TYPES.TSTypeReference && typeNode.typeName.type === import_utils66.AST_NODE_TYPES.Identifier && typeNode.typeName.name === "Record";
|
|
8442
8520
|
var isReadonlyWrappedRecord3 = (typeReference) => {
|
|
8443
8521
|
const maybeTypeParameterInstantiation = typeReference.parent;
|
|
8444
|
-
if (maybeTypeParameterInstantiation
|
|
8522
|
+
if (maybeTypeParameterInstantiation.type !== import_utils66.AST_NODE_TYPES.TSTypeParameterInstantiation) {
|
|
8445
8523
|
return false;
|
|
8446
8524
|
}
|
|
8447
8525
|
const maybeReadonlyTypeReference = maybeTypeParameterInstantiation.parent;
|
|
8448
|
-
return maybeReadonlyTypeReference
|
|
8526
|
+
return maybeReadonlyTypeReference.type === import_utils66.AST_NODE_TYPES.TSTypeReference && maybeReadonlyTypeReference.typeName.type === import_utils66.AST_NODE_TYPES.Identifier && maybeReadonlyTypeReference.typeName.name === "Readonly";
|
|
8449
8527
|
};
|
|
8450
8528
|
var collectMutableRecordTypeNodes2 = (typeNode) => {
|
|
8451
|
-
if (typeNode.type ===
|
|
8529
|
+
if (typeNode.type === import_utils66.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils66.AST_NODE_TYPES.TSUnionType) {
|
|
8452
8530
|
return typeNode.types.flatMap((subTypeNode) => collectMutableRecordTypeNodes2(subTypeNode));
|
|
8453
8531
|
}
|
|
8454
8532
|
if (!isRecordTypeReference2(typeNode) || isReadonlyWrappedRecord3(typeNode)) {
|
|
@@ -8462,14 +8540,11 @@ var buildReadonlyRecordFix2 = (node) => (fixer) => [
|
|
|
8462
8540
|
];
|
|
8463
8541
|
var isTopLevelPropertySignature3 = (node) => {
|
|
8464
8542
|
const parent = node.parent;
|
|
8465
|
-
if (parent
|
|
8543
|
+
if (parent.type === import_utils66.AST_NODE_TYPES.TSInterfaceBody) {
|
|
8466
8544
|
return true;
|
|
8467
8545
|
}
|
|
8468
|
-
if (parent?.type !== "TSTypeLiteral") {
|
|
8469
|
-
return false;
|
|
8470
|
-
}
|
|
8471
8546
|
const maybeTypeAliasDeclaration = parent.parent;
|
|
8472
|
-
return maybeTypeAliasDeclaration
|
|
8547
|
+
return maybeTypeAliasDeclaration.type === import_utils66.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
8473
8548
|
};
|
|
8474
8549
|
var rule121 = ruleCreator({
|
|
8475
8550
|
create: (context) => ({
|
|
@@ -8521,24 +8596,25 @@ var rule121 = ruleCreator({
|
|
|
8521
8596
|
var typescript_require_readonly_record_property_type_default = rule121;
|
|
8522
8597
|
|
|
8523
8598
|
// dist/rules/typescript-require-readonly-record-return-type.js
|
|
8599
|
+
var import_utils67 = require("@typescript-eslint/utils");
|
|
8524
8600
|
var functionLikeNodeSelector7 = ":matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSConstructorType, TSDeclareFunction, TSEmptyBodyFunctionExpression, TSFunctionType, TSMethodSignature)";
|
|
8525
8601
|
var getReturnTypeAnnotationFromFunctionLikeNode3 = (node) => {
|
|
8526
|
-
if (node.type ===
|
|
8602
|
+
if (node.type === import_utils67.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils67.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils67.AST_NODE_TYPES.FunctionExpression || node.type === import_utils67.AST_NODE_TYPES.TSCallSignatureDeclaration || node.type === import_utils67.AST_NODE_TYPES.TSConstructSignatureDeclaration || node.type === import_utils67.AST_NODE_TYPES.TSConstructorType || node.type === import_utils67.AST_NODE_TYPES.TSDeclareFunction || node.type === import_utils67.AST_NODE_TYPES.TSEmptyBodyFunctionExpression || node.type === import_utils67.AST_NODE_TYPES.TSFunctionType || node.type === import_utils67.AST_NODE_TYPES.TSMethodSignature) {
|
|
8527
8603
|
return node.returnType;
|
|
8528
8604
|
}
|
|
8529
8605
|
return void 0;
|
|
8530
8606
|
};
|
|
8531
|
-
var isRecordTypeReference3 = (typeNode) => typeNode.type ===
|
|
8607
|
+
var isRecordTypeReference3 = (typeNode) => typeNode.type === import_utils67.AST_NODE_TYPES.TSTypeReference && typeNode.typeName.type === import_utils67.AST_NODE_TYPES.Identifier && typeNode.typeName.name === "Record";
|
|
8532
8608
|
var isReadonlyWrappedRecord4 = (typeReference) => {
|
|
8533
8609
|
const maybeTypeParameterInstantiation = typeReference.parent;
|
|
8534
|
-
if (maybeTypeParameterInstantiation
|
|
8610
|
+
if (maybeTypeParameterInstantiation.type !== import_utils67.AST_NODE_TYPES.TSTypeParameterInstantiation) {
|
|
8535
8611
|
return false;
|
|
8536
8612
|
}
|
|
8537
8613
|
const maybeReadonlyTypeReference = maybeTypeParameterInstantiation.parent;
|
|
8538
|
-
return maybeReadonlyTypeReference
|
|
8614
|
+
return maybeReadonlyTypeReference.type === import_utils67.AST_NODE_TYPES.TSTypeReference && maybeReadonlyTypeReference.typeName.type === import_utils67.AST_NODE_TYPES.Identifier && maybeReadonlyTypeReference.typeName.name === "Readonly";
|
|
8539
8615
|
};
|
|
8540
8616
|
var collectMutableRecordTypeNodes3 = (typeNode) => {
|
|
8541
|
-
if (typeNode.type ===
|
|
8617
|
+
if (typeNode.type === import_utils67.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils67.AST_NODE_TYPES.TSUnionType) {
|
|
8542
8618
|
return typeNode.types.flatMap((subTypeNode) => collectMutableRecordTypeNodes3(subTypeNode));
|
|
8543
8619
|
}
|
|
8544
8620
|
if (!isRecordTypeReference3(typeNode) || isReadonlyWrappedRecord4(typeNode)) {
|
|
@@ -8597,17 +8673,18 @@ var rule122 = ruleCreator({
|
|
|
8597
8673
|
var typescript_require_readonly_record_return_type_default = rule122;
|
|
8598
8674
|
|
|
8599
8675
|
// dist/rules/typescript-require-readonly-record-type-alias.js
|
|
8600
|
-
var
|
|
8676
|
+
var import_utils68 = require("@typescript-eslint/utils");
|
|
8677
|
+
var isRecordTypeReference4 = (typeNode) => typeNode.type === import_utils68.AST_NODE_TYPES.TSTypeReference && typeNode.typeName.type === import_utils68.AST_NODE_TYPES.Identifier && typeNode.typeName.name === "Record";
|
|
8601
8678
|
var isReadonlyWrappedRecord5 = (typeReference) => {
|
|
8602
8679
|
const maybeTypeParameterInstantiation = typeReference.parent;
|
|
8603
|
-
if (maybeTypeParameterInstantiation
|
|
8680
|
+
if (maybeTypeParameterInstantiation.type !== import_utils68.AST_NODE_TYPES.TSTypeParameterInstantiation) {
|
|
8604
8681
|
return false;
|
|
8605
8682
|
}
|
|
8606
8683
|
const maybeReadonlyTypeReference = maybeTypeParameterInstantiation.parent;
|
|
8607
|
-
return maybeReadonlyTypeReference
|
|
8684
|
+
return maybeReadonlyTypeReference.type === import_utils68.AST_NODE_TYPES.TSTypeReference && maybeReadonlyTypeReference.typeName.type === import_utils68.AST_NODE_TYPES.Identifier && maybeReadonlyTypeReference.typeName.name === "Readonly";
|
|
8608
8685
|
};
|
|
8609
8686
|
var collectMutableRecordTypeNodes4 = (typeNode) => {
|
|
8610
|
-
if (typeNode.type ===
|
|
8687
|
+
if (typeNode.type === import_utils68.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils68.AST_NODE_TYPES.TSUnionType) {
|
|
8611
8688
|
return typeNode.types.flatMap((subTypeNode) => collectMutableRecordTypeNodes4(subTypeNode));
|
|
8612
8689
|
}
|
|
8613
8690
|
if (!isRecordTypeReference4(typeNode) || isReadonlyWrappedRecord5(typeNode)) {
|
|
@@ -8662,23 +8739,24 @@ var rule123 = ruleCreator({
|
|
|
8662
8739
|
var typescript_require_readonly_record_type_alias_default = rule123;
|
|
8663
8740
|
|
|
8664
8741
|
// dist/rules/typescript-require-readonly-set-parameter-type.js
|
|
8742
|
+
var import_utils69 = require("@typescript-eslint/utils");
|
|
8665
8743
|
var functionLikeNodeSelector8 = ":matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSConstructorType, TSDeclareFunction, TSEmptyBodyFunctionExpression, TSFunctionType, TSMethodSignature)";
|
|
8666
8744
|
var getParametersFromFunctionLikeNode5 = (node) => {
|
|
8667
|
-
if (node.type ===
|
|
8745
|
+
if (node.type === import_utils69.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils69.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils69.AST_NODE_TYPES.FunctionExpression || node.type === import_utils69.AST_NODE_TYPES.TSCallSignatureDeclaration || node.type === import_utils69.AST_NODE_TYPES.TSConstructSignatureDeclaration || node.type === import_utils69.AST_NODE_TYPES.TSConstructorType || node.type === import_utils69.AST_NODE_TYPES.TSDeclareFunction || node.type === import_utils69.AST_NODE_TYPES.TSEmptyBodyFunctionExpression || node.type === import_utils69.AST_NODE_TYPES.TSFunctionType || node.type === import_utils69.AST_NODE_TYPES.TSMethodSignature) {
|
|
8668
8746
|
return node.params;
|
|
8669
8747
|
}
|
|
8670
8748
|
return void 0;
|
|
8671
8749
|
};
|
|
8672
8750
|
var getTypeAnnotationFromPattern4 = (pattern) => {
|
|
8673
|
-
if (pattern.type ===
|
|
8751
|
+
if (pattern.type === import_utils69.AST_NODE_TYPES.AssignmentPattern) {
|
|
8674
8752
|
return getTypeAnnotationFromPattern4(pattern.left);
|
|
8675
8753
|
}
|
|
8676
|
-
if (pattern.type ===
|
|
8754
|
+
if (pattern.type === import_utils69.AST_NODE_TYPES.RestElement) {
|
|
8677
8755
|
if (pattern.typeAnnotation !== void 0) {
|
|
8678
8756
|
return pattern.typeAnnotation;
|
|
8679
8757
|
}
|
|
8680
8758
|
const argument = pattern.argument;
|
|
8681
|
-
if (argument.type !==
|
|
8759
|
+
if (argument.type !== import_utils69.AST_NODE_TYPES.ArrayPattern && argument.type !== import_utils69.AST_NODE_TYPES.Identifier && argument.type !== import_utils69.AST_NODE_TYPES.ObjectPattern) {
|
|
8682
8760
|
return void 0;
|
|
8683
8761
|
}
|
|
8684
8762
|
return argument.typeAnnotation;
|
|
@@ -8686,17 +8764,17 @@ var getTypeAnnotationFromPattern4 = (pattern) => {
|
|
|
8686
8764
|
return pattern.typeAnnotation;
|
|
8687
8765
|
};
|
|
8688
8766
|
var getTypeAnnotationFromParameter4 = (parameter) => {
|
|
8689
|
-
if (parameter.type ===
|
|
8767
|
+
if (parameter.type === import_utils69.AST_NODE_TYPES.TSParameterProperty) {
|
|
8690
8768
|
return getTypeAnnotationFromPattern4(parameter.parameter);
|
|
8691
8769
|
}
|
|
8692
8770
|
return getTypeAnnotationFromPattern4(parameter);
|
|
8693
8771
|
};
|
|
8694
|
-
var isSetTypeReference = (node) => node.typeName.type ===
|
|
8772
|
+
var isSetTypeReference = (node) => node.typeName.type === import_utils69.AST_NODE_TYPES.Identifier && node.typeName.name === "Set";
|
|
8695
8773
|
var collectMutableSetTypeNodes = (typeNode) => {
|
|
8696
|
-
if (typeNode.type ===
|
|
8774
|
+
if (typeNode.type === import_utils69.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils69.AST_NODE_TYPES.TSUnionType) {
|
|
8697
8775
|
return typeNode.types.flatMap((subTypeNode) => collectMutableSetTypeNodes(subTypeNode));
|
|
8698
8776
|
}
|
|
8699
|
-
if (typeNode.type !==
|
|
8777
|
+
if (typeNode.type !== import_utils69.AST_NODE_TYPES.TSTypeReference || !isSetTypeReference(typeNode)) {
|
|
8700
8778
|
return [];
|
|
8701
8779
|
}
|
|
8702
8780
|
return [typeNode.typeName];
|
|
@@ -8755,12 +8833,13 @@ var rule124 = ruleCreator({
|
|
|
8755
8833
|
var typescript_require_readonly_set_parameter_type_default = rule124;
|
|
8756
8834
|
|
|
8757
8835
|
// dist/rules/typescript-require-readonly-set-property-type.js
|
|
8758
|
-
var
|
|
8836
|
+
var import_utils70 = require("@typescript-eslint/utils");
|
|
8837
|
+
var isSetTypeReference2 = (node) => node.typeName.type === import_utils70.AST_NODE_TYPES.Identifier && node.typeName.name === "Set";
|
|
8759
8838
|
var collectMutableSetTypeNodes2 = (typeNode) => {
|
|
8760
|
-
if (typeNode.type ===
|
|
8839
|
+
if (typeNode.type === import_utils70.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils70.AST_NODE_TYPES.TSUnionType) {
|
|
8761
8840
|
return typeNode.types.flatMap((subTypeNode) => collectMutableSetTypeNodes2(subTypeNode));
|
|
8762
8841
|
}
|
|
8763
|
-
if (typeNode.type !==
|
|
8842
|
+
if (typeNode.type !== import_utils70.AST_NODE_TYPES.TSTypeReference || !isSetTypeReference2(typeNode)) {
|
|
8764
8843
|
return [];
|
|
8765
8844
|
}
|
|
8766
8845
|
return [typeNode.typeName];
|
|
@@ -8768,14 +8847,11 @@ var collectMutableSetTypeNodes2 = (typeNode) => {
|
|
|
8768
8847
|
var buildReadonlySetFix2 = (node) => (fixer) => fixer.replaceText(node, "ReadonlySet");
|
|
8769
8848
|
var isTopLevelPropertySignature4 = (node) => {
|
|
8770
8849
|
const parent = node.parent;
|
|
8771
|
-
if (parent
|
|
8850
|
+
if (parent.type === import_utils70.AST_NODE_TYPES.TSInterfaceBody) {
|
|
8772
8851
|
return true;
|
|
8773
8852
|
}
|
|
8774
|
-
if (parent?.type !== "TSTypeLiteral") {
|
|
8775
|
-
return false;
|
|
8776
|
-
}
|
|
8777
8853
|
const maybeTypeAliasDeclaration = parent.parent;
|
|
8778
|
-
return maybeTypeAliasDeclaration
|
|
8854
|
+
return maybeTypeAliasDeclaration.type === import_utils70.AST_NODE_TYPES.TSTypeAliasDeclaration;
|
|
8779
8855
|
};
|
|
8780
8856
|
var rule125 = ruleCreator({
|
|
8781
8857
|
create: (context) => ({
|
|
@@ -8827,19 +8903,20 @@ var rule125 = ruleCreator({
|
|
|
8827
8903
|
var typescript_require_readonly_set_property_type_default = rule125;
|
|
8828
8904
|
|
|
8829
8905
|
// dist/rules/typescript-require-readonly-set-return-type.js
|
|
8906
|
+
var import_utils71 = require("@typescript-eslint/utils");
|
|
8830
8907
|
var functionLikeNodeSelector9 = ":matches(ArrowFunctionExpression, FunctionDeclaration, FunctionExpression, TSCallSignatureDeclaration, TSConstructSignatureDeclaration, TSConstructorType, TSDeclareFunction, TSEmptyBodyFunctionExpression, TSFunctionType, TSMethodSignature)";
|
|
8831
8908
|
var getReturnTypeAnnotationFromFunctionLikeNode4 = (node) => {
|
|
8832
|
-
if (node.type ===
|
|
8909
|
+
if (node.type === import_utils71.AST_NODE_TYPES.ArrowFunctionExpression || node.type === import_utils71.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils71.AST_NODE_TYPES.FunctionExpression || node.type === import_utils71.AST_NODE_TYPES.TSCallSignatureDeclaration || node.type === import_utils71.AST_NODE_TYPES.TSConstructSignatureDeclaration || node.type === import_utils71.AST_NODE_TYPES.TSConstructorType || node.type === import_utils71.AST_NODE_TYPES.TSDeclareFunction || node.type === import_utils71.AST_NODE_TYPES.TSEmptyBodyFunctionExpression || node.type === import_utils71.AST_NODE_TYPES.TSFunctionType || node.type === import_utils71.AST_NODE_TYPES.TSMethodSignature) {
|
|
8833
8910
|
return node.returnType;
|
|
8834
8911
|
}
|
|
8835
8912
|
return void 0;
|
|
8836
8913
|
};
|
|
8837
|
-
var isSetTypeReference3 = (node) => node.typeName.type ===
|
|
8914
|
+
var isSetTypeReference3 = (node) => node.typeName.type === import_utils71.AST_NODE_TYPES.Identifier && node.typeName.name === "Set";
|
|
8838
8915
|
var collectMutableSetTypeNodes3 = (typeNode) => {
|
|
8839
|
-
if (typeNode.type ===
|
|
8916
|
+
if (typeNode.type === import_utils71.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils71.AST_NODE_TYPES.TSUnionType) {
|
|
8840
8917
|
return typeNode.types.flatMap((subTypeNode) => collectMutableSetTypeNodes3(subTypeNode));
|
|
8841
8918
|
}
|
|
8842
|
-
if (typeNode.type !==
|
|
8919
|
+
if (typeNode.type !== import_utils71.AST_NODE_TYPES.TSTypeReference || !isSetTypeReference3(typeNode)) {
|
|
8843
8920
|
return [];
|
|
8844
8921
|
}
|
|
8845
8922
|
return [typeNode.typeName];
|
|
@@ -8892,12 +8969,13 @@ var rule126 = ruleCreator({
|
|
|
8892
8969
|
var typescript_require_readonly_set_return_type_default = rule126;
|
|
8893
8970
|
|
|
8894
8971
|
// dist/rules/typescript-require-readonly-set-type-alias.js
|
|
8895
|
-
var
|
|
8972
|
+
var import_utils72 = require("@typescript-eslint/utils");
|
|
8973
|
+
var isSetTypeReference4 = (node) => node.typeName.type === import_utils72.AST_NODE_TYPES.Identifier && node.typeName.name === "Set";
|
|
8896
8974
|
var collectMutableSetTypeNodes4 = (typeNode) => {
|
|
8897
|
-
if (typeNode.type ===
|
|
8975
|
+
if (typeNode.type === import_utils72.AST_NODE_TYPES.TSIntersectionType || typeNode.type === import_utils72.AST_NODE_TYPES.TSUnionType) {
|
|
8898
8976
|
return typeNode.types.flatMap((subTypeNode) => collectMutableSetTypeNodes4(subTypeNode));
|
|
8899
8977
|
}
|
|
8900
|
-
if (typeNode.type !==
|
|
8978
|
+
if (typeNode.type !== import_utils72.AST_NODE_TYPES.TSTypeReference || !isSetTypeReference4(typeNode)) {
|
|
8901
8979
|
return [];
|
|
8902
8980
|
}
|
|
8903
8981
|
return [typeNode.typeName];
|
|
@@ -8946,11 +9024,12 @@ var rule127 = ruleCreator({
|
|
|
8946
9024
|
var typescript_require_readonly_set_type_alias_default = rule127;
|
|
8947
9025
|
|
|
8948
9026
|
// dist/rules/typescript-require-this-void.js
|
|
8949
|
-
var
|
|
9027
|
+
var import_utils73 = require("@typescript-eslint/utils");
|
|
9028
|
+
var import_ts_extras69 = require("ts-extras");
|
|
8950
9029
|
var selector24 = "MethodDefinition[static=true] > FunctionExpression:not([params.0.name='this'][params.0.typeAnnotation.typeAnnotation.type='TSVoidKeyword'])";
|
|
8951
9030
|
var createThisVoidSuggestionFix = (sourceCode, functionExpression) => {
|
|
8952
|
-
const firstParameter = (0,
|
|
8953
|
-
if (firstParameter?.type ===
|
|
9031
|
+
const firstParameter = (0, import_ts_extras69.arrayFirst)(functionExpression.params);
|
|
9032
|
+
if (firstParameter?.type === import_utils73.AST_NODE_TYPES.Identifier && firstParameter.name === "this") {
|
|
8954
9033
|
const existingTypeAnnotation = firstParameter.typeAnnotation;
|
|
8955
9034
|
if (existingTypeAnnotation === void 0) {
|
|
8956
9035
|
return (fixer) => fixer.insertTextAfter(firstParameter, ": void");
|
|
@@ -8968,7 +9047,7 @@ var rule128 = ruleCreator({
|
|
|
8968
9047
|
const sourceCode = context.sourceCode;
|
|
8969
9048
|
return {
|
|
8970
9049
|
[selector24]: (node) => {
|
|
8971
|
-
if (node.type !==
|
|
9050
|
+
if (node.type !== import_utils73.AST_NODE_TYPES.FunctionExpression) {
|
|
8972
9051
|
return;
|
|
8973
9052
|
}
|
|
8974
9053
|
const suggestionFix = createThisVoidSuggestionFix(sourceCode, node);
|
|
@@ -9011,9 +9090,10 @@ var rule128 = ruleCreator({
|
|
|
9011
9090
|
var typescript_require_this_void_default = rule128;
|
|
9012
9091
|
|
|
9013
9092
|
// dist/rules/underscore-internal.js
|
|
9014
|
-
var
|
|
9093
|
+
var import_utils74 = require("@typescript-eslint/utils");
|
|
9094
|
+
var internalTagPattern = /@internal\b/v;
|
|
9015
9095
|
var isNonUnderscoreIdentifier = (identifier) => !identifier.name.startsWith("_");
|
|
9016
|
-
var isExportDeclaration = (node) => node?.type ===
|
|
9096
|
+
var isExportDeclaration = (node) => node?.type === import_utils74.AST_NODE_TYPES.ExportDefaultDeclaration || node?.type === import_utils74.AST_NODE_TYPES.ExportNamedDeclaration;
|
|
9017
9097
|
var rule129 = ruleCreator({
|
|
9018
9098
|
create: (context) => {
|
|
9019
9099
|
const hasInternalTag = (node) => {
|
|
@@ -9049,13 +9129,13 @@ var rule129 = ruleCreator({
|
|
|
9049
9129
|
reportIfInternal(node.id, node);
|
|
9050
9130
|
},
|
|
9051
9131
|
"MethodDefinition[key.type='Identifier']": (node) => {
|
|
9052
|
-
if (node.key.type !==
|
|
9132
|
+
if (node.key.type !== import_utils74.AST_NODE_TYPES.Identifier) {
|
|
9053
9133
|
return;
|
|
9054
9134
|
}
|
|
9055
9135
|
reportIfInternal(node.key, node);
|
|
9056
9136
|
},
|
|
9057
9137
|
"PropertyDefinition[key.type='Identifier']": (node) => {
|
|
9058
|
-
if (node.key.type !==
|
|
9138
|
+
if (node.key.type !== import_utils74.AST_NODE_TYPES.Identifier) {
|
|
9059
9139
|
return;
|
|
9060
9140
|
}
|
|
9061
9141
|
reportIfInternal(node.key, node);
|
|
@@ -9064,7 +9144,7 @@ var rule129 = ruleCreator({
|
|
|
9064
9144
|
reportIfInternal(node.id, node);
|
|
9065
9145
|
},
|
|
9066
9146
|
"TSEnumMember[id.type='Identifier']": (node) => {
|
|
9067
|
-
if (node.id.type !==
|
|
9147
|
+
if (node.id.type !== import_utils74.AST_NODE_TYPES.Identifier) {
|
|
9068
9148
|
return;
|
|
9069
9149
|
}
|
|
9070
9150
|
reportIfInternal(node.id, node);
|
|
@@ -9073,13 +9153,13 @@ var rule129 = ruleCreator({
|
|
|
9073
9153
|
reportIfInternal(node.id, node);
|
|
9074
9154
|
},
|
|
9075
9155
|
"TSMethodSignature[key.type='Identifier']": (node) => {
|
|
9076
|
-
if (node.key.type !==
|
|
9156
|
+
if (node.key.type !== import_utils74.AST_NODE_TYPES.Identifier) {
|
|
9077
9157
|
return;
|
|
9078
9158
|
}
|
|
9079
9159
|
reportIfInternal(node.key, node);
|
|
9080
9160
|
},
|
|
9081
9161
|
"TSPropertySignature[key.type='Identifier']": (node) => {
|
|
9082
|
-
if (node.key.type !==
|
|
9162
|
+
if (node.key.type !== import_utils74.AST_NODE_TYPES.Identifier) {
|
|
9083
9163
|
return;
|
|
9084
9164
|
}
|
|
9085
9165
|
reportIfInternal(node.key, node);
|
|
@@ -9088,13 +9168,10 @@ var rule129 = ruleCreator({
|
|
|
9088
9168
|
reportIfInternal(node.id, node);
|
|
9089
9169
|
},
|
|
9090
9170
|
"VariableDeclarator[id.type='Identifier']": (node) => {
|
|
9091
|
-
if (node.id.type !==
|
|
9171
|
+
if (node.id.type !== import_utils74.AST_NODE_TYPES.Identifier) {
|
|
9092
9172
|
return;
|
|
9093
9173
|
}
|
|
9094
9174
|
const declaration = node.parent;
|
|
9095
|
-
if (declaration?.type !== "VariableDeclaration") {
|
|
9096
|
-
return;
|
|
9097
|
-
}
|
|
9098
9175
|
reportIfInternal(node.id, declaration);
|
|
9099
9176
|
}
|
|
9100
9177
|
};
|
|
@@ -9122,7 +9199,7 @@ var underscore_internal_default = rule129;
|
|
|
9122
9199
|
// dist/rules/unused-internal-properties.js
|
|
9123
9200
|
var import_eslint_plugin_unicorn3 = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
9124
9201
|
var rule130 = adaptExternalRule(getExternalRuleFromPlugin(import_eslint_plugin_unicorn3.default, "no-unused-properties", "eslint-plugin-unicorn"), "https://nick2bad4u.github.io/eslint-plugin-etc-misc/docs/rules/unused-internal-properties");
|
|
9125
|
-
var
|
|
9202
|
+
var deprecatedRule26 = withDeprecatedRuleLifecycle(rule130, {
|
|
9126
9203
|
message: "Deprecated in favor of unicorn/no-unused-properties.",
|
|
9127
9204
|
replacedBy: [
|
|
9128
9205
|
createReplacementRuleInfo({
|
|
@@ -9138,12 +9215,12 @@ var deprecatedRule27 = withDeprecatedRuleLifecycle(rule130, {
|
|
|
9138
9215
|
],
|
|
9139
9216
|
ruleId: "unused-internal-properties"
|
|
9140
9217
|
});
|
|
9141
|
-
var unused_internal_properties_default =
|
|
9218
|
+
var unused_internal_properties_default = deprecatedRule26;
|
|
9142
9219
|
|
|
9143
9220
|
// dist/rules/uppercase-iife.js
|
|
9144
9221
|
var import_eslint_plugin_unicorn4 = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
9145
9222
|
var rule131 = adaptExternalRule(getExternalRuleFromPlugin(import_eslint_plugin_unicorn4.default, "no-unreadable-iife", "eslint-plugin-unicorn"), "https://nick2bad4u.github.io/eslint-plugin-etc-misc/docs/rules/uppercase-iife");
|
|
9146
|
-
var
|
|
9223
|
+
var deprecatedRule27 = withDeprecatedRuleLifecycle(rule131, {
|
|
9147
9224
|
message: "Deprecated in favor of unicorn/no-unreadable-iife.",
|
|
9148
9225
|
replacedBy: [
|
|
9149
9226
|
createReplacementRuleInfo({
|
|
@@ -9159,12 +9236,12 @@ var deprecatedRule28 = withDeprecatedRuleLifecycle(rule131, {
|
|
|
9159
9236
|
],
|
|
9160
9237
|
ruleId: "uppercase-iife"
|
|
9161
9238
|
});
|
|
9162
|
-
var uppercase_iife_default =
|
|
9239
|
+
var uppercase_iife_default = deprecatedRule27;
|
|
9163
9240
|
|
|
9164
9241
|
// dist/rules/words.js
|
|
9165
9242
|
var import_eslint_plugin_write_good_comments_2 = __toESM(require("eslint-plugin-write-good-comments-2"), 1);
|
|
9166
9243
|
var rule132 = adaptExternalRule(getExternalRuleFromPlugin(import_eslint_plugin_write_good_comments_2.default, "write-good-comments", "eslint-plugin-write-good-comments-2"), "https://nick2bad4u.github.io/eslint-plugin-etc-misc/docs/rules/words");
|
|
9167
|
-
var
|
|
9244
|
+
var deprecatedRule28 = withDeprecatedRuleLifecycle(rule132, {
|
|
9168
9245
|
message: "Deprecated in favor of write-good-comments/write-good-comments.",
|
|
9169
9246
|
replacedBy: [
|
|
9170
9247
|
createReplacementRuleInfo({
|
|
@@ -9180,7 +9257,7 @@ var deprecatedRule29 = withDeprecatedRuleLifecycle(rule132, {
|
|
|
9180
9257
|
],
|
|
9181
9258
|
ruleId: "words"
|
|
9182
9259
|
});
|
|
9183
|
-
var words_default =
|
|
9260
|
+
var words_default = deprecatedRule28;
|
|
9184
9261
|
|
|
9185
9262
|
// dist/rules.js
|
|
9186
9263
|
var rulesWithRequiredTypeChecking = /* @__PURE__ */ new Set([
|
|
@@ -9356,7 +9433,7 @@ var baseRules = {
|
|
|
9356
9433
|
"uppercase-iife": uppercase_iife_default,
|
|
9357
9434
|
words: words_default
|
|
9358
9435
|
};
|
|
9359
|
-
var ruleCatalog = buildRuleCatalog((0,
|
|
9436
|
+
var ruleCatalog = buildRuleCatalog((0, import_ts_extras70.objectKeys)(baseRules));
|
|
9360
9437
|
var ruleCatalogEntries = ruleCatalog.ordered;
|
|
9361
9438
|
var ruleCatalogByRuleName = ruleCatalog.byRuleName;
|
|
9362
9439
|
var ruleCatalogByDocId = ruleCatalog.byDocId;
|
|
@@ -9365,8 +9442,9 @@ var withCatalogDocsMetadata = (ruleName, ruleModule) => {
|
|
|
9365
9442
|
if (!catalogEntry) {
|
|
9366
9443
|
throw new Error(`Missing rule catalog entry for rule "${ruleName}".`);
|
|
9367
9444
|
}
|
|
9368
|
-
const currentDocsMetadata =
|
|
9369
|
-
|
|
9445
|
+
const currentDocsMetadata = ruleModule.meta.docs;
|
|
9446
|
+
(0, import_ts_extras70.assertDefined)(currentDocsMetadata);
|
|
9447
|
+
const hasRequiredTypeChecking = (0, import_ts_extras70.setHas)(rulesWithRequiredTypeChecking, ruleName);
|
|
9370
9448
|
const deprecatedMetadata = ruleModule.meta.deprecated ?? false;
|
|
9371
9449
|
const isDeprecatedRule = deprecatedMetadata !== false;
|
|
9372
9450
|
const docsWithCatalogMetadata = {
|
|
@@ -9375,7 +9453,7 @@ var withCatalogDocsMetadata = (ruleName, ruleModule) => {
|
|
|
9375
9453
|
catalogIndex: catalogEntry.catalogIndex,
|
|
9376
9454
|
deprecated: currentDocsMetadata.deprecated ?? isDeprecatedRule,
|
|
9377
9455
|
frozen: currentDocsMetadata.frozen ?? currentDocsMetadata.deprecated ?? isDeprecatedRule,
|
|
9378
|
-
recommended: (0,
|
|
9456
|
+
recommended: (0, import_ts_extras70.setHas)(recommendedRuleNames, ruleName),
|
|
9379
9457
|
requiresTypeChecking: currentDocsMetadata.requiresTypeChecking ?? hasRequiredTypeChecking,
|
|
9380
9458
|
ruleName
|
|
9381
9459
|
};
|
|
@@ -9388,7 +9466,7 @@ var withCatalogDocsMetadata = (ruleName, ruleModule) => {
|
|
|
9388
9466
|
}
|
|
9389
9467
|
};
|
|
9390
9468
|
};
|
|
9391
|
-
var decoratedRuleEntries = (0,
|
|
9469
|
+
var decoratedRuleEntries = (0, import_ts_extras70.objectEntries)(baseRules).map(([ruleName, ruleModule]) => [ruleName, withCatalogDocsMetadata(ruleName, ruleModule)]);
|
|
9392
9470
|
var decoratedRulesAccumulator = {};
|
|
9393
9471
|
for (const [ruleName, ruleModule] of decoratedRuleEntries) {
|
|
9394
9472
|
decoratedRulesAccumulator = {
|
|
@@ -9400,26 +9478,35 @@ var decoratedRules = decoratedRulesAccumulator;
|
|
|
9400
9478
|
var rules = Object.freeze(decoratedRules);
|
|
9401
9479
|
|
|
9402
9480
|
// dist/configs/all-strict.js
|
|
9403
|
-
var
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9407
|
-
|
|
9481
|
+
var allStrictRulesAccumulator = {};
|
|
9482
|
+
for (const [ruleName, ruleModule] of (0, import_ts_extras71.objectEntries)(rules)) {
|
|
9483
|
+
allStrictRulesAccumulator = {
|
|
9484
|
+
...allStrictRulesAccumulator,
|
|
9485
|
+
[`etc-misc/${ruleName}`]: ruleModule.meta.deprecated === false ? "error" : "warn"
|
|
9486
|
+
};
|
|
9487
|
+
}
|
|
9488
|
+
var allStrictRules = Object.freeze(allStrictRulesAccumulator);
|
|
9408
9489
|
var allStrict = {
|
|
9409
9490
|
name: "etc-misc/all-strict",
|
|
9410
9491
|
rules: allStrictRules
|
|
9411
9492
|
};
|
|
9412
9493
|
|
|
9413
9494
|
// dist/configs/all.js
|
|
9414
|
-
var
|
|
9495
|
+
var import_ts_extras72 = require("ts-extras");
|
|
9415
9496
|
var getAllPresetSeverity = (ruleModule) => {
|
|
9416
9497
|
if (ruleModule.meta.deprecated !== false) {
|
|
9417
9498
|
return "warn";
|
|
9418
9499
|
}
|
|
9419
9500
|
return ruleModule.meta.type === "problem" ? "error" : "warn";
|
|
9420
9501
|
};
|
|
9421
|
-
var
|
|
9422
|
-
|
|
9502
|
+
var allRulesAccumulator = {};
|
|
9503
|
+
for (const [ruleName, ruleModule] of (0, import_ts_extras72.objectEntries)(rules)) {
|
|
9504
|
+
allRulesAccumulator = {
|
|
9505
|
+
...allRulesAccumulator,
|
|
9506
|
+
[`etc-misc/${ruleName}`]: getAllPresetSeverity(ruleModule)
|
|
9507
|
+
};
|
|
9508
|
+
}
|
|
9509
|
+
var allRules = Object.freeze(allRulesAccumulator);
|
|
9423
9510
|
var all = {
|
|
9424
9511
|
name: "etc-misc/all",
|
|
9425
9512
|
rules: allRules
|
|
@@ -9479,35 +9566,41 @@ var recommended = {
|
|
|
9479
9566
|
};
|
|
9480
9567
|
|
|
9481
9568
|
// dist/configs/strict-type-checked.js
|
|
9482
|
-
var
|
|
9569
|
+
var import_ts_extras74 = require("ts-extras");
|
|
9483
9570
|
|
|
9484
9571
|
// dist/configs/strict.js
|
|
9485
|
-
var
|
|
9486
|
-
var recommendedRuleNames2 = (0,
|
|
9487
|
-
var
|
|
9572
|
+
var import_ts_extras73 = require("ts-extras");
|
|
9573
|
+
var recommendedRuleNames2 = (0, import_ts_extras73.safeCastTo)((0, import_ts_extras73.objectKeys)(recommended.rules));
|
|
9574
|
+
var strictRulesCandidate = (0, import_ts_extras73.objectFromEntries)(recommendedRuleNames2.map((ruleName) => [ruleName, "error"]));
|
|
9575
|
+
var hasStrictRuleCoverage = (candidateRules) => recommendedRuleNames2.every((ruleName) => candidateRules[ruleName] === "error");
|
|
9576
|
+
if (!hasStrictRuleCoverage(strictRulesCandidate)) {
|
|
9577
|
+
throw new Error("Strict preset synthesis failed to include every recommended rule.");
|
|
9578
|
+
}
|
|
9579
|
+
var strictRules = strictRulesCandidate;
|
|
9488
9580
|
var strict = {
|
|
9489
9581
|
name: "etc-misc/strict",
|
|
9490
9582
|
rules: strictRules
|
|
9491
9583
|
};
|
|
9492
9584
|
|
|
9493
9585
|
// dist/configs/strict-type-checked.js
|
|
9494
|
-
var additionalTypeCheckedRuleEntries = (0,
|
|
9586
|
+
var additionalTypeCheckedRuleEntries = (0, import_ts_extras74.objectEntries)(rules).flatMap(([ruleName, ruleModule]) => {
|
|
9495
9587
|
if (ruleModule.meta.deprecated !== false) {
|
|
9496
9588
|
return [];
|
|
9497
9589
|
}
|
|
9498
|
-
const docsMetadata = ruleModule.meta.docs;
|
|
9590
|
+
const docsMetadata = (0, import_ts_extras74.safeCastTo)(ruleModule.meta.docs);
|
|
9499
9591
|
if (docsMetadata?.requiresTypeChecking !== true) {
|
|
9500
9592
|
return [];
|
|
9501
9593
|
}
|
|
9502
9594
|
const qualifiedRuleName = `etc-misc/${ruleName}`;
|
|
9503
|
-
if ((0,
|
|
9595
|
+
if ((0, import_ts_extras74.objectHasOwn)(strict.rules, qualifiedRuleName)) {
|
|
9504
9596
|
return [];
|
|
9505
9597
|
}
|
|
9506
|
-
|
|
9598
|
+
const severity = "error";
|
|
9599
|
+
return [[qualifiedRuleName, severity]];
|
|
9507
9600
|
});
|
|
9508
9601
|
var strictTypeCheckedRules = {
|
|
9509
9602
|
...strict.rules,
|
|
9510
|
-
...(0,
|
|
9603
|
+
...(0, import_ts_extras74.objectFromEntries)(additionalTypeCheckedRuleEntries)
|
|
9511
9604
|
};
|
|
9512
9605
|
var strictTypeChecked = {
|
|
9513
9606
|
languageOptions: {
|
|
@@ -9544,13 +9637,13 @@ var configs = {
|
|
|
9544
9637
|
};
|
|
9545
9638
|
|
|
9546
9639
|
// dist/plugin.js
|
|
9547
|
-
var
|
|
9640
|
+
var plugin2 = {
|
|
9548
9641
|
configs,
|
|
9549
9642
|
meta: pluginMeta,
|
|
9550
9643
|
processors: {},
|
|
9551
9644
|
rules
|
|
9552
9645
|
};
|
|
9553
|
-
var plugin_default =
|
|
9646
|
+
var plugin_default = plugin2;
|
|
9554
9647
|
/**
|
|
9555
9648
|
* @license Use of this source code is governed by an MIT-style license that can
|
|
9556
9649
|
* be found in the LICENSE file at
|