@pobammer-ts/eslint-cease-nonsense-rules 1.14.1 → 1.16.0
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/README.md +115 -0
- package/dist/build-metadata.json +3 -3
- package/dist/constants/react-sources.d.ts +4 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +529 -221
- package/dist/oxfmt-sync.d.ts +0 -1
- package/dist/oxfmt-worker.d.ts +0 -1
- package/dist/oxfmt-worker.js +0 -2
- package/dist/recognizers/camel-case-detector.d.ts +0 -1
- package/dist/recognizers/code-recognizer.d.ts +0 -1
- package/dist/recognizers/contains-detector.d.ts +0 -1
- package/dist/recognizers/detector.d.ts +0 -1
- package/dist/recognizers/end-with-detector.d.ts +0 -1
- package/dist/recognizers/javascript-footprint.d.ts +0 -1
- package/dist/recognizers/keywords-detector.d.ts +0 -1
- package/dist/rules/ban-instances.d.ts +0 -1
- package/dist/rules/ban-react-fc.d.ts +0 -1
- package/dist/rules/enforce-ianitor-check-type.d.ts +0 -1
- package/dist/rules/fast-format.d.ts +0 -1
- package/dist/rules/no-async-constructor.d.ts +0 -1
- package/dist/rules/no-color3-constructor.d.ts +0 -1
- package/dist/rules/no-commented-code.d.ts +0 -1
- package/dist/rules/no-god-components.d.ts +0 -1
- package/dist/rules/no-identity-map.d.ts +0 -1
- package/dist/rules/no-instance-methods-without-this.d.ts +0 -1
- package/dist/rules/no-memo-children.d.ts +19 -0
- package/dist/rules/no-print.d.ts +0 -1
- package/dist/rules/no-shorthand-names.d.ts +0 -1
- package/dist/rules/no-useless-use-spring.d.ts +0 -1
- package/dist/rules/no-warn.d.ts +0 -1
- package/dist/rules/prefer-class-properties.d.ts +0 -1
- package/dist/rules/prefer-early-return.d.ts +0 -1
- package/dist/rules/prefer-enum-item.d.ts +0 -1
- package/dist/rules/prefer-module-scope-constants.d.ts +0 -1
- package/dist/rules/prefer-pascal-case-enums.d.ts +0 -1
- package/dist/rules/prefer-pattern-replacements.d.ts +0 -1
- package/dist/rules/prefer-sequence-overloads.d.ts +0 -1
- package/dist/rules/prefer-singular-enums.d.ts +0 -1
- package/dist/rules/prefer-udim2-shorthand.d.ts +0 -1
- package/dist/rules/react-hooks-strict-return.d.ts +0 -1
- package/dist/rules/require-module-level-instantiation.d.ts +25 -0
- package/dist/rules/require-named-effect-functions.d.ts +1 -4
- package/dist/rules/require-paired-calls.d.ts +0 -1
- package/dist/rules/require-react-component-keys.d.ts +0 -1
- package/dist/rules/require-react-display-names.d.ts +1 -2
- package/dist/rules/strict-component-boundaries.d.ts +5 -2
- package/dist/rules/use-exhaustive-dependencies.d.ts +0 -1
- package/dist/rules/use-hook-at-top-level.d.ts +0 -1
- package/dist/types/environment-mode.d.ts +3 -0
- package/dist/utilities/casing-utilities.d.ts +0 -1
- package/dist/utilities/configure-utilities.d.ts +14 -1
- package/dist/utilities/create-rule.d.ts +0 -1
- package/dist/utilities/format-utilities.d.ts +0 -1
- package/dist/utilities/pattern-replacement/constant-folder.d.ts +0 -1
- package/dist/utilities/pattern-replacement/index.d.ts +0 -1
- package/dist/utilities/pattern-replacement/pattern-matcher.d.ts +0 -1
- package/dist/utilities/pattern-replacement/pattern-parser.d.ts +0 -1
- package/dist/utilities/pattern-replacement/pattern-types.d.ts +0 -1
- package/dist/utilities/pattern-replacement/replacement-generator.d.ts +0 -1
- package/dist/utilities/resolve-import.d.ts +0 -1
- package/package.json +14 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -725
- package/dist/oxfmt-sync.d.ts.map +0 -1
- package/dist/oxfmt-worker.d.ts.map +0 -1
- package/dist/oxfmt-worker.js.map +0 -10
- package/dist/recognizers/camel-case-detector.d.ts.map +0 -1
- package/dist/recognizers/code-recognizer.d.ts.map +0 -1
- package/dist/recognizers/contains-detector.d.ts.map +0 -1
- package/dist/recognizers/detector.d.ts.map +0 -1
- package/dist/recognizers/end-with-detector.d.ts.map +0 -1
- package/dist/recognizers/javascript-footprint.d.ts.map +0 -1
- package/dist/recognizers/keywords-detector.d.ts.map +0 -1
- package/dist/rules/ban-instances.d.ts.map +0 -1
- package/dist/rules/ban-react-fc.d.ts.map +0 -1
- package/dist/rules/enforce-ianitor-check-type.d.ts.map +0 -1
- package/dist/rules/fast-format.d.ts.map +0 -1
- package/dist/rules/no-async-constructor.d.ts.map +0 -1
- package/dist/rules/no-color3-constructor.d.ts.map +0 -1
- package/dist/rules/no-commented-code.d.ts.map +0 -1
- package/dist/rules/no-god-components.d.ts.map +0 -1
- package/dist/rules/no-identity-map.d.ts.map +0 -1
- package/dist/rules/no-instance-methods-without-this.d.ts.map +0 -1
- package/dist/rules/no-print.d.ts.map +0 -1
- package/dist/rules/no-shorthand-names.d.ts.map +0 -1
- package/dist/rules/no-useless-use-spring.d.ts.map +0 -1
- package/dist/rules/no-warn.d.ts.map +0 -1
- package/dist/rules/prefer-class-properties.d.ts.map +0 -1
- package/dist/rules/prefer-early-return.d.ts.map +0 -1
- package/dist/rules/prefer-enum-item.d.ts.map +0 -1
- package/dist/rules/prefer-module-scope-constants.d.ts.map +0 -1
- package/dist/rules/prefer-pascal-case-enums.d.ts.map +0 -1
- package/dist/rules/prefer-pattern-replacements.d.ts.map +0 -1
- package/dist/rules/prefer-sequence-overloads.d.ts.map +0 -1
- package/dist/rules/prefer-singular-enums.d.ts.map +0 -1
- package/dist/rules/prefer-udim2-shorthand.d.ts.map +0 -1
- package/dist/rules/react-hooks-strict-return.d.ts.map +0 -1
- package/dist/rules/require-named-effect-functions.d.ts.map +0 -1
- package/dist/rules/require-paired-calls.d.ts.map +0 -1
- package/dist/rules/require-react-component-keys.d.ts.map +0 -1
- package/dist/rules/require-react-display-names.d.ts.map +0 -1
- package/dist/rules/strict-component-boundaries.d.ts.map +0 -1
- package/dist/rules/use-exhaustive-dependencies.d.ts.map +0 -1
- package/dist/rules/use-hook-at-top-level.d.ts.map +0 -1
- package/dist/utilities/casing-utilities.d.ts.map +0 -1
- package/dist/utilities/configure-utilities.d.ts.map +0 -1
- package/dist/utilities/create-rule.d.ts.map +0 -1
- package/dist/utilities/format-utilities.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/constant-folder.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/index.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/pattern-matcher.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/pattern-parser.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/pattern-types.d.ts.map +0 -1
- package/dist/utilities/pattern-replacement/replacement-generator.d.ts.map +0 -1
- package/dist/utilities/resolve-import.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -9658,7 +9658,7 @@ function ParsePatternIntoTypes(pattern) {
|
|
|
9658
9658
|
return result;
|
|
9659
9659
|
}
|
|
9660
9660
|
|
|
9661
|
-
// node_modules/typebox/build/type/engine/template-literal/finite.mjs
|
|
9661
|
+
// node_modules/typebox/build/type/engine/template-literal/is-finite.mjs
|
|
9662
9662
|
function FromLiteral(value) {
|
|
9663
9663
|
return true;
|
|
9664
9664
|
}
|
|
@@ -9673,7 +9673,7 @@ function FromTypes(types) {
|
|
|
9673
9673
|
function FromType2(type) {
|
|
9674
9674
|
return IsUnion(type) ? FromTypes(type.anyOf) : IsLiteral(type) ? FromLiteral(type.const) : false;
|
|
9675
9675
|
}
|
|
9676
|
-
function
|
|
9676
|
+
function IsTemplateLiteralFinite(types) {
|
|
9677
9677
|
const result = FromTypes(types);
|
|
9678
9678
|
return result;
|
|
9679
9679
|
}
|
|
@@ -9715,9 +9715,14 @@ function DecodeTypesAsUnion(types) {
|
|
|
9715
9715
|
function DecodeTypes(types) {
|
|
9716
9716
|
return exports_guard.IsEqual(types.length, 0) ? Unreachable() : exports_guard.IsEqual(types.length, 1) && IsLiteral(types[0]) ? types[0] : DecodeTypesAsUnion(types);
|
|
9717
9717
|
}
|
|
9718
|
-
function
|
|
9718
|
+
function TemplateLiteralDecodeUnsafe(pattern) {
|
|
9719
9719
|
const types = ParsePatternIntoTypes(pattern);
|
|
9720
|
-
const result = exports_guard.IsEqual(types.length, 0) ? String2() :
|
|
9720
|
+
const result = exports_guard.IsEqual(types.length, 0) ? String2() : IsTemplateLiteralFinite(types) ? DecodeTypes(types) : TemplateLiteralCreate(pattern);
|
|
9721
|
+
return result;
|
|
9722
|
+
}
|
|
9723
|
+
function TemplateLiteralDecode(pattern) {
|
|
9724
|
+
const decoded = TemplateLiteralDecodeUnsafe(pattern);
|
|
9725
|
+
const result = IsTemplateLiteral(decoded) ? String2() : decoded;
|
|
9721
9726
|
return result;
|
|
9722
9727
|
}
|
|
9723
9728
|
|
|
@@ -9749,7 +9754,7 @@ function RecordPattern(type) {
|
|
|
9749
9754
|
}
|
|
9750
9755
|
function RecordKey(type) {
|
|
9751
9756
|
const pattern = RecordPattern(type);
|
|
9752
|
-
const result = exports_guard.IsEqual(pattern, StringKey) ? String2() : exports_guard.IsEqual(pattern, IntegerKey) ? Integer() : exports_guard.IsEqual(pattern, NumberKey) ? Number2() :
|
|
9757
|
+
const result = exports_guard.IsEqual(pattern, StringKey) ? String2() : exports_guard.IsEqual(pattern, IntegerKey) ? Integer() : exports_guard.IsEqual(pattern, NumberKey) ? Number2() : TemplateLiteralDecodeUnsafe(pattern);
|
|
9753
9758
|
return result;
|
|
9754
9759
|
}
|
|
9755
9760
|
function RecordValue(type) {
|
|
@@ -12271,7 +12276,7 @@ function FromStringKey(key, value) {
|
|
|
12271
12276
|
// node_modules/typebox/build/type/engine/record/from-key-template-literal.mjs
|
|
12272
12277
|
function FromTemplateKey(pattern, value) {
|
|
12273
12278
|
const types = ParsePatternIntoTypes(pattern);
|
|
12274
|
-
const finite =
|
|
12279
|
+
const finite = IsTemplateLiteralFinite(types);
|
|
12275
12280
|
const result = finite ? FromKey(TemplateLiteralDecode(pattern), value) : CreateRecord(pattern, value);
|
|
12276
12281
|
return result;
|
|
12277
12282
|
}
|
|
@@ -18818,6 +18823,201 @@ var no_instance_methods_without_this_default = createRule({
|
|
|
18818
18823
|
name: "no-instance-methods-without-this"
|
|
18819
18824
|
});
|
|
18820
18825
|
|
|
18826
|
+
// src/rules/no-memo-children.ts
|
|
18827
|
+
import { TSESTree as TSESTree6 } from "@typescript-eslint/types";
|
|
18828
|
+
import { ESLintUtils as ESLintUtils3 } from "@typescript-eslint/utils";
|
|
18829
|
+
|
|
18830
|
+
// src/constants/react-sources.ts
|
|
18831
|
+
var REACT_SOURCES_ROBLOX = new Set(["@rbxts/react", "@rbxts/roact"]);
|
|
18832
|
+
var REACT_SOURCES_STANDARD = new Set(["react", "react-dom"]);
|
|
18833
|
+
function getReactSources(environment2) {
|
|
18834
|
+
return environment2 === "roblox-ts" ? REACT_SOURCES_ROBLOX : REACT_SOURCES_STANDARD;
|
|
18835
|
+
}
|
|
18836
|
+
function isReactImport(node, reactSources) {
|
|
18837
|
+
return reactSources.has(node.source.value);
|
|
18838
|
+
}
|
|
18839
|
+
|
|
18840
|
+
// src/rules/no-memo-children.ts
|
|
18841
|
+
var DEFAULT_OPTIONS2 = {
|
|
18842
|
+
allowedComponents: [],
|
|
18843
|
+
environment: "roblox-ts"
|
|
18844
|
+
};
|
|
18845
|
+
function isMemoCall(node, memoIdentifiers, reactNamespaces) {
|
|
18846
|
+
const { callee } = node;
|
|
18847
|
+
if (callee.type === TSESTree6.AST_NODE_TYPES.Identifier)
|
|
18848
|
+
return memoIdentifiers.has(callee.name);
|
|
18849
|
+
if (callee.type === TSESTree6.AST_NODE_TYPES.MemberExpression && callee.object.type === TSESTree6.AST_NODE_TYPES.Identifier && callee.property.type === TSESTree6.AST_NODE_TYPES.Identifier) {
|
|
18850
|
+
return reactNamespaces.has(callee.object.name) && callee.property.name === "memo";
|
|
18851
|
+
}
|
|
18852
|
+
return false;
|
|
18853
|
+
}
|
|
18854
|
+
function typeHasChildrenProperty(checker, type3, visited2 = new WeakSet) {
|
|
18855
|
+
if (visited2.has(type3))
|
|
18856
|
+
return false;
|
|
18857
|
+
visited2.add(type3);
|
|
18858
|
+
const allProperties = checker.getPropertiesOfType(type3);
|
|
18859
|
+
for (const prop of allProperties)
|
|
18860
|
+
if (prop.getName() === "children")
|
|
18861
|
+
return true;
|
|
18862
|
+
if (type3.isUnion()) {
|
|
18863
|
+
for (const constituent of type3.types)
|
|
18864
|
+
if (typeHasChildrenProperty(checker, constituent, visited2))
|
|
18865
|
+
return true;
|
|
18866
|
+
}
|
|
18867
|
+
if (type3.isIntersection()) {
|
|
18868
|
+
for (const constituent of type3.types)
|
|
18869
|
+
if (typeHasChildrenProperty(checker, constituent, visited2))
|
|
18870
|
+
return true;
|
|
18871
|
+
}
|
|
18872
|
+
const baseTypes = type3.getBaseTypes?.();
|
|
18873
|
+
if (baseTypes) {
|
|
18874
|
+
for (const baseType of baseTypes)
|
|
18875
|
+
if (typeHasChildrenProperty(checker, baseType, visited2))
|
|
18876
|
+
return true;
|
|
18877
|
+
}
|
|
18878
|
+
return false;
|
|
18879
|
+
}
|
|
18880
|
+
function getPropertiesTypeFromMemoCall(services, checker, node) {
|
|
18881
|
+
const tsCallNode = services.esTreeNodeToTSNodeMap.get(node);
|
|
18882
|
+
if (!tsCallNode)
|
|
18883
|
+
return;
|
|
18884
|
+
const memoResultType = checker.getTypeAtLocation(tsCallNode);
|
|
18885
|
+
if (!memoResultType)
|
|
18886
|
+
return;
|
|
18887
|
+
const memoResultSignatures = memoResultType.getCallSignatures();
|
|
18888
|
+
if (memoResultSignatures.length > 0) {
|
|
18889
|
+
const [firstSignature2] = memoResultSignatures;
|
|
18890
|
+
if (firstSignature2) {
|
|
18891
|
+
const [propertyParameter] = firstSignature2.getParameters();
|
|
18892
|
+
if (propertyParameter)
|
|
18893
|
+
return checker.getTypeOfSymbol(propertyParameter);
|
|
18894
|
+
}
|
|
18895
|
+
}
|
|
18896
|
+
if (node.typeArguments && node.typeArguments.params.length > 0) {
|
|
18897
|
+
const [typeArgNode] = node.typeArguments.params;
|
|
18898
|
+
if (typeArgNode) {
|
|
18899
|
+
const tsTypeArgNode = services.esTreeNodeToTSNodeMap.get(typeArgNode);
|
|
18900
|
+
if (tsTypeArgNode) {
|
|
18901
|
+
const typeFromArgument = checker.getTypeAtLocation(tsTypeArgNode);
|
|
18902
|
+
if (typeFromArgument)
|
|
18903
|
+
return typeFromArgument;
|
|
18904
|
+
}
|
|
18905
|
+
}
|
|
18906
|
+
}
|
|
18907
|
+
const [firstArgument] = node.arguments;
|
|
18908
|
+
if (!firstArgument)
|
|
18909
|
+
return;
|
|
18910
|
+
const tsNode = services.esTreeNodeToTSNodeMap.get(firstArgument);
|
|
18911
|
+
if (!tsNode)
|
|
18912
|
+
return;
|
|
18913
|
+
const componentType = checker.getTypeAtLocation(tsNode);
|
|
18914
|
+
if (!componentType)
|
|
18915
|
+
return;
|
|
18916
|
+
const callSignatures = componentType.getCallSignatures();
|
|
18917
|
+
if (callSignatures.length === 0)
|
|
18918
|
+
return;
|
|
18919
|
+
const [firstSignature] = callSignatures;
|
|
18920
|
+
if (!firstSignature)
|
|
18921
|
+
return;
|
|
18922
|
+
const parameters3 = firstSignature.getParameters();
|
|
18923
|
+
if (parameters3.length === 0)
|
|
18924
|
+
return;
|
|
18925
|
+
const [propertiesParameter] = parameters3;
|
|
18926
|
+
return propertiesParameter ? checker.getTypeOfSymbol(propertiesParameter) : undefined;
|
|
18927
|
+
}
|
|
18928
|
+
function getComponentName(node) {
|
|
18929
|
+
const [firstArgument] = node.arguments;
|
|
18930
|
+
if (!firstArgument)
|
|
18931
|
+
return;
|
|
18932
|
+
if (firstArgument.type === TSESTree6.AST_NODE_TYPES.Identifier)
|
|
18933
|
+
return firstArgument.name;
|
|
18934
|
+
if (firstArgument.type === TSESTree6.AST_NODE_TYPES.FunctionExpression && firstArgument.id) {
|
|
18935
|
+
return firstArgument.id.name;
|
|
18936
|
+
}
|
|
18937
|
+
const { parent } = node;
|
|
18938
|
+
if (parent?.type === TSESTree6.AST_NODE_TYPES.VariableDeclarator && parent.id.type === TSESTree6.AST_NODE_TYPES.Identifier) {
|
|
18939
|
+
return parent.id.name;
|
|
18940
|
+
}
|
|
18941
|
+
return;
|
|
18942
|
+
}
|
|
18943
|
+
var no_memo_children_default = createRule({
|
|
18944
|
+
create(context) {
|
|
18945
|
+
const options3 = {
|
|
18946
|
+
...DEFAULT_OPTIONS2,
|
|
18947
|
+
...context.options[0]
|
|
18948
|
+
};
|
|
18949
|
+
const reactSources = getReactSources(options3.environment);
|
|
18950
|
+
const memoIdentifiers = new Set;
|
|
18951
|
+
const reactNamespaces = new Set;
|
|
18952
|
+
const allowedSet = new Set(options3.allowedComponents);
|
|
18953
|
+
const services = ESLintUtils3.getParserServices(context);
|
|
18954
|
+
const checker = services.program.getTypeChecker();
|
|
18955
|
+
return {
|
|
18956
|
+
CallExpression(node) {
|
|
18957
|
+
if (!isMemoCall(node, memoIdentifiers, reactNamespaces))
|
|
18958
|
+
return;
|
|
18959
|
+
const componentName = getComponentName(node);
|
|
18960
|
+
if (componentName && allowedSet.has(componentName))
|
|
18961
|
+
return;
|
|
18962
|
+
const propsType = getPropertiesTypeFromMemoCall(services, checker, node);
|
|
18963
|
+
if (!propsType)
|
|
18964
|
+
return;
|
|
18965
|
+
if (typeHasChildrenProperty(checker, propsType)) {
|
|
18966
|
+
context.report({
|
|
18967
|
+
data: { componentName: componentName ?? "Component" },
|
|
18968
|
+
messageId: "memoWithChildren",
|
|
18969
|
+
node
|
|
18970
|
+
});
|
|
18971
|
+
}
|
|
18972
|
+
},
|
|
18973
|
+
ImportDeclaration(node) {
|
|
18974
|
+
if (!isReactImport(node, reactSources))
|
|
18975
|
+
return;
|
|
18976
|
+
for (const specifier of node.specifiers) {
|
|
18977
|
+
if (specifier.type === TSESTree6.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === TSESTree6.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
18978
|
+
reactNamespaces.add(specifier.local.name);
|
|
18979
|
+
} else if (specifier.type === TSESTree6.AST_NODE_TYPES.ImportSpecifier) {
|
|
18980
|
+
const importedName = specifier.imported.type === TSESTree6.AST_NODE_TYPES.Identifier ? specifier.imported.name : specifier.imported.value;
|
|
18981
|
+
if (importedName === "memo")
|
|
18982
|
+
memoIdentifiers.add(specifier.local.name);
|
|
18983
|
+
}
|
|
18984
|
+
}
|
|
18985
|
+
}
|
|
18986
|
+
};
|
|
18987
|
+
},
|
|
18988
|
+
defaultOptions: [DEFAULT_OPTIONS2],
|
|
18989
|
+
meta: {
|
|
18990
|
+
docs: {
|
|
18991
|
+
description: "Disallow React.memo on components with children props, which defeats memoization since children change on every render."
|
|
18992
|
+
},
|
|
18993
|
+
messages: {
|
|
18994
|
+
memoWithChildren: "React.memo is ineffective on '{{componentName}}' because it accepts a 'children' prop. " + "The 'children' prop is typically a new JSX element on every render, causing the shallow comparison " + "performed by memo to return false on every render, negating any performance benefit. " + "Either remove 'children' from the props interface, pass children via a render prop pattern, " + "or remove the React.memo wrapper entirely."
|
|
18995
|
+
},
|
|
18996
|
+
schema: [
|
|
18997
|
+
{
|
|
18998
|
+
additionalProperties: false,
|
|
18999
|
+
properties: {
|
|
19000
|
+
allowedComponents: {
|
|
19001
|
+
default: [],
|
|
19002
|
+
description: "Component names to allow with children despite memo wrapper. " + "Use this for components where you've verified memoization is still beneficial.",
|
|
19003
|
+
items: { type: "string" },
|
|
19004
|
+
type: "array"
|
|
19005
|
+
},
|
|
19006
|
+
environment: {
|
|
19007
|
+
default: "roblox-ts",
|
|
19008
|
+
description: "The React environment: 'roblox-ts' uses @rbxts/react, 'standard' uses react.",
|
|
19009
|
+
enum: ["roblox-ts", "standard"],
|
|
19010
|
+
type: "string"
|
|
19011
|
+
}
|
|
19012
|
+
},
|
|
19013
|
+
type: "object"
|
|
19014
|
+
}
|
|
19015
|
+
],
|
|
19016
|
+
type: "suggestion"
|
|
19017
|
+
},
|
|
19018
|
+
name: "no-memo-children"
|
|
19019
|
+
});
|
|
19020
|
+
|
|
18821
19021
|
// src/rules/no-print.ts
|
|
18822
19022
|
var no_print_default = createRule({
|
|
18823
19023
|
create(context) {
|
|
@@ -18845,7 +19045,7 @@ var no_print_default = createRule({
|
|
|
18845
19045
|
});
|
|
18846
19046
|
|
|
18847
19047
|
// src/rules/no-shorthand-names.ts
|
|
18848
|
-
import { TSESTree as
|
|
19048
|
+
import { TSESTree as TSESTree7 } from "@typescript-eslint/types";
|
|
18849
19049
|
var isRuleOptions = Compile(build_default.Object({
|
|
18850
19050
|
allowPropertyAccess: build_default.Optional(build_default.Array(build_default.String())),
|
|
18851
19051
|
ignoreShorthands: build_default.Optional(build_default.Array(build_default.String())),
|
|
@@ -18854,7 +19054,7 @@ var isRuleOptions = Compile(build_default.Object({
|
|
|
18854
19054
|
function isRecord2(value) {
|
|
18855
19055
|
return value !== null && typeof value === "object";
|
|
18856
19056
|
}
|
|
18857
|
-
var
|
|
19057
|
+
var DEFAULT_OPTIONS3 = {
|
|
18858
19058
|
allowPropertyAccess: ["char"],
|
|
18859
19059
|
ignoreShorthands: [],
|
|
18860
19060
|
shorthands: {
|
|
@@ -18984,7 +19184,7 @@ function isWordIgnored(word, ignoreMatchers, ignoreExact) {
|
|
|
18984
19184
|
return false;
|
|
18985
19185
|
}
|
|
18986
19186
|
function normalizeOptions2(rawOptions) {
|
|
18987
|
-
const mergedShorthands = { ...
|
|
19187
|
+
const mergedShorthands = { ...DEFAULT_OPTIONS3.shorthands };
|
|
18988
19188
|
if (rawOptions?.shorthands) {
|
|
18989
19189
|
for (const [key, value] of Object.entries(rawOptions.shorthands))
|
|
18990
19190
|
mergedShorthands[key] = value;
|
|
@@ -18998,7 +19198,7 @@ function normalizeOptions2(rawOptions) {
|
|
|
18998
19198
|
else
|
|
18999
19199
|
matchers.push(result.matcher);
|
|
19000
19200
|
}
|
|
19001
|
-
const allowPropertyAccessSource = rawOptions?.allowPropertyAccess ??
|
|
19201
|
+
const allowPropertyAccessSource = rawOptions?.allowPropertyAccess ?? DEFAULT_OPTIONS3.allowPropertyAccess;
|
|
19002
19202
|
const ignoreMatchers = new Array;
|
|
19003
19203
|
const ignoreExact = new Set;
|
|
19004
19204
|
for (const pattern4 of rawOptions?.ignoreShorthands ?? []) {
|
|
@@ -19106,9 +19306,9 @@ var noShorthandNames = {
|
|
|
19106
19306
|
return;
|
|
19107
19307
|
}
|
|
19108
19308
|
}
|
|
19109
|
-
if (identifierName === "plr" && parent?.type ===
|
|
19309
|
+
if (identifierName === "plr" && parent?.type === TSESTree7.AST_NODE_TYPES.VariableDeclarator && parent.id === node) {
|
|
19110
19310
|
const { init } = parent;
|
|
19111
|
-
if (init && isRecord2(init) && init.type ===
|
|
19311
|
+
if (init && isRecord2(init) && init.type === TSESTree7.AST_NODE_TYPES.MemberExpression && init.object !== undefined && isRecord2(init.object) && init.object.type === TSESTree7.AST_NODE_TYPES.Identifier && init.object.name === "Players" && init.property !== undefined && isRecord2(init.property) && init.property.type === TSESTree7.AST_NODE_TYPES.Identifier && init.property.name === "LocalPlayer") {
|
|
19112
19312
|
context.report({
|
|
19113
19313
|
data: { replacement: "localPlayer", shorthand: "plr" },
|
|
19114
19314
|
messageId: "useReplacement",
|
|
@@ -19752,7 +19952,7 @@ var prefer_early_return_default = createRule({
|
|
|
19752
19952
|
});
|
|
19753
19953
|
|
|
19754
19954
|
// src/rules/prefer-enum-item.ts
|
|
19755
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES7, ESLintUtils as
|
|
19955
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES7, ESLintUtils as ESLintUtils4 } from "@typescript-eslint/utils";
|
|
19756
19956
|
|
|
19757
19957
|
// node_modules/ts-api-utils/lib/index.js
|
|
19758
19958
|
import ts9 from "typescript";
|
|
@@ -20594,7 +20794,7 @@ function createEnumMatch(enumPath) {
|
|
|
20594
20794
|
var prefer_enum_item_default = createRule({
|
|
20595
20795
|
create(context) {
|
|
20596
20796
|
const [{ fixNumericToValue = false, performanceMode = false } = {}] = context.options;
|
|
20597
|
-
const services =
|
|
20797
|
+
const services = ESLintUtils4.getParserServices(context);
|
|
20598
20798
|
const checker = services.program.getTypeChecker();
|
|
20599
20799
|
const unionTypesCache = new WeakMap;
|
|
20600
20800
|
const enumPathCache = new WeakMap;
|
|
@@ -21636,7 +21836,7 @@ var prefer_singular_enums_default = createRule({
|
|
|
21636
21836
|
});
|
|
21637
21837
|
|
|
21638
21838
|
// src/rules/prefer-udim2-shorthand.ts
|
|
21639
|
-
import { TSESTree as
|
|
21839
|
+
import { TSESTree as TSESTree8 } from "@typescript-eslint/utils";
|
|
21640
21840
|
function isNumber(value) {
|
|
21641
21841
|
return typeof value === "number" && !Number.isNaN(value);
|
|
21642
21842
|
}
|
|
@@ -21650,15 +21850,15 @@ var OPERATORS2 = new Set(["+", "-", "*", "/", "%"]);
|
|
|
21650
21850
|
function reconstructText(node) {
|
|
21651
21851
|
const nodeType = node.type;
|
|
21652
21852
|
let text;
|
|
21653
|
-
if (nodeType ===
|
|
21853
|
+
if (nodeType === TSESTree8.AST_NODE_TYPES.Literal) {
|
|
21654
21854
|
const { value } = node;
|
|
21655
21855
|
text = isNumber(value) ? String(value) : undefined;
|
|
21656
21856
|
}
|
|
21657
|
-
if (nodeType ===
|
|
21857
|
+
if (nodeType === TSESTree8.AST_NODE_TYPES.Identifier) {
|
|
21658
21858
|
const { name } = node;
|
|
21659
21859
|
text = typeof name === "string" ? name : undefined;
|
|
21660
21860
|
}
|
|
21661
|
-
if (nodeType ===
|
|
21861
|
+
if (nodeType === TSESTree8.AST_NODE_TYPES.UnaryExpression) {
|
|
21662
21862
|
const { operator } = node;
|
|
21663
21863
|
if (typeof operator === "string") {
|
|
21664
21864
|
const { argument } = node;
|
|
@@ -21669,7 +21869,7 @@ function reconstructText(node) {
|
|
|
21669
21869
|
}
|
|
21670
21870
|
}
|
|
21671
21871
|
}
|
|
21672
|
-
if (nodeType ===
|
|
21872
|
+
if (nodeType === TSESTree8.AST_NODE_TYPES.BinaryExpression) {
|
|
21673
21873
|
const { operator } = node;
|
|
21674
21874
|
if (typeof operator === "string" && OPERATORS2.has(operator)) {
|
|
21675
21875
|
const { left, right } = node;
|
|
@@ -21732,11 +21932,11 @@ function evaluateExpression(node) {
|
|
|
21732
21932
|
if (!isRecord3(node))
|
|
21733
21933
|
return;
|
|
21734
21934
|
switch (node.type) {
|
|
21735
|
-
case
|
|
21935
|
+
case TSESTree8.AST_NODE_TYPES.Literal:
|
|
21736
21936
|
return evaluateLiteral(node);
|
|
21737
|
-
case
|
|
21937
|
+
case TSESTree8.AST_NODE_TYPES.UnaryExpression:
|
|
21738
21938
|
return evaluateUnary(node);
|
|
21739
|
-
case
|
|
21939
|
+
case TSESTree8.AST_NODE_TYPES.BinaryExpression:
|
|
21740
21940
|
return evaluateBinary(node);
|
|
21741
21941
|
default:
|
|
21742
21942
|
return;
|
|
@@ -21750,7 +21950,7 @@ function collectArguments(_context2, parameters3) {
|
|
|
21750
21950
|
const parameter2 = parameters3[index2];
|
|
21751
21951
|
if (!(isRecord3(parameter2) && hasTypeProperty(parameter2)))
|
|
21752
21952
|
return;
|
|
21753
|
-
if (parameter2.type ===
|
|
21953
|
+
if (parameter2.type === TSESTree8.AST_NODE_TYPES.SpreadElement)
|
|
21754
21954
|
return;
|
|
21755
21955
|
const text = reconstructText(parameter2);
|
|
21756
21956
|
if (text === undefined)
|
|
@@ -21767,7 +21967,7 @@ var preferUDim2Shorthand = {
|
|
|
21767
21967
|
create(context) {
|
|
21768
21968
|
return {
|
|
21769
21969
|
NewExpression(node) {
|
|
21770
|
-
if (node.callee.type !==
|
|
21970
|
+
if (node.callee.type !== TSESTree8.AST_NODE_TYPES.Identifier || node.callee.name !== "UDim2")
|
|
21771
21971
|
return;
|
|
21772
21972
|
const collected = collectArguments(context, node.arguments);
|
|
21773
21973
|
if (!collected)
|
|
@@ -21952,14 +22152,117 @@ var react_hooks_strict_return_default = createRule({
|
|
|
21952
22152
|
name: "react-hooks-strict-return"
|
|
21953
22153
|
});
|
|
21954
22154
|
|
|
22155
|
+
// src/rules/require-module-level-instantiation.ts
|
|
22156
|
+
var import_scope_manager4 = __toESM(require_dist2(), 1);
|
|
22157
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES14 } from "@typescript-eslint/utils";
|
|
22158
|
+
var isOptionsObject2 = Compile(build_default.Object({
|
|
22159
|
+
classes: build_default.Record(build_default.String(), build_default.String())
|
|
22160
|
+
}));
|
|
22161
|
+
function normalizeConfiguration(options3) {
|
|
22162
|
+
if (!isOptionsObject2.Check(options3))
|
|
22163
|
+
return { trackedImports: new Map };
|
|
22164
|
+
const { classes } = options3;
|
|
22165
|
+
const trackedImports = new Map;
|
|
22166
|
+
for (const [className, source] of Object.entries(classes))
|
|
22167
|
+
trackedImports.set(className, { className, source });
|
|
22168
|
+
return { trackedImports };
|
|
22169
|
+
}
|
|
22170
|
+
function isTopScope2({ type: type3 }) {
|
|
22171
|
+
return type3 === import_scope_manager4.ScopeType.module || type3 === import_scope_manager4.ScopeType.global;
|
|
22172
|
+
}
|
|
22173
|
+
var require_module_level_instantiation_default = createRule({
|
|
22174
|
+
create(context) {
|
|
22175
|
+
const { trackedImports } = normalizeConfiguration(context.options[0]);
|
|
22176
|
+
if (trackedImports.size === 0)
|
|
22177
|
+
return {};
|
|
22178
|
+
const localBindings = new Map;
|
|
22179
|
+
return {
|
|
22180
|
+
ImportDeclaration(node) {
|
|
22181
|
+
const source = node.source.value;
|
|
22182
|
+
for (const specifier of node.specifiers) {
|
|
22183
|
+
for (const [className, tracked] of trackedImports) {
|
|
22184
|
+
if (tracked.source !== source)
|
|
22185
|
+
continue;
|
|
22186
|
+
if (specifier.type === AST_NODE_TYPES14.ImportDefaultSpecifier && specifier.local.name === className) {
|
|
22187
|
+
localBindings.set(specifier.local.name, tracked);
|
|
22188
|
+
}
|
|
22189
|
+
if (specifier.type === AST_NODE_TYPES14.ImportSpecifier) {
|
|
22190
|
+
const importedName = specifier.imported.type === AST_NODE_TYPES14.Identifier ? specifier.imported.name : specifier.imported.value;
|
|
22191
|
+
if (importedName === className)
|
|
22192
|
+
localBindings.set(specifier.local.name, tracked);
|
|
22193
|
+
}
|
|
22194
|
+
}
|
|
22195
|
+
}
|
|
22196
|
+
},
|
|
22197
|
+
NewExpression(node) {
|
|
22198
|
+
let trackedInfo;
|
|
22199
|
+
let calleeName;
|
|
22200
|
+
if (node.callee.type === AST_NODE_TYPES14.Identifier) {
|
|
22201
|
+
calleeName = node.callee.name;
|
|
22202
|
+
trackedInfo = localBindings.get(calleeName);
|
|
22203
|
+
}
|
|
22204
|
+
if (node.callee.type === AST_NODE_TYPES14.MemberExpression) {
|
|
22205
|
+
const { property } = node.callee;
|
|
22206
|
+
if (property.type === AST_NODE_TYPES14.Identifier) {
|
|
22207
|
+
calleeName = property.name;
|
|
22208
|
+
trackedInfo = trackedImports.get(calleeName);
|
|
22209
|
+
}
|
|
22210
|
+
}
|
|
22211
|
+
if (!(trackedInfo && calleeName))
|
|
22212
|
+
return;
|
|
22213
|
+
const scope = context.sourceCode.getScope(node);
|
|
22214
|
+
if (isTopScope2(scope))
|
|
22215
|
+
return;
|
|
22216
|
+
context.report({
|
|
22217
|
+
data: {
|
|
22218
|
+
className: trackedInfo.className,
|
|
22219
|
+
source: trackedInfo.source
|
|
22220
|
+
},
|
|
22221
|
+
messageId: "mustBeModuleLevel",
|
|
22222
|
+
node
|
|
22223
|
+
});
|
|
22224
|
+
}
|
|
22225
|
+
};
|
|
22226
|
+
},
|
|
22227
|
+
defaultOptions: [{ classes: {} }],
|
|
22228
|
+
meta: {
|
|
22229
|
+
docs: {
|
|
22230
|
+
description: "Require certain classes to be instantiated at module level rather than inside functions. Classes like Log should be instantiated once at module scope, not recreated on every function call."
|
|
22231
|
+
},
|
|
22232
|
+
messages: {
|
|
22233
|
+
mustBeModuleLevel: "'{{className}}' from '{{source}}' must be instantiated at module level, not inside a function. Move `new {{className}}()` to the top of the file outside any function body. Instantiating inside functions recreates the object on every call, which wastes resources and may cause unexpected behavior."
|
|
22234
|
+
},
|
|
22235
|
+
schema: [
|
|
22236
|
+
{
|
|
22237
|
+
additionalProperties: false,
|
|
22238
|
+
properties: {
|
|
22239
|
+
classes: {
|
|
22240
|
+
additionalProperties: { type: "string" },
|
|
22241
|
+
description: "Map of class names to their import sources. Classes imported from these sources must be instantiated at module level.",
|
|
22242
|
+
type: "object"
|
|
22243
|
+
}
|
|
22244
|
+
},
|
|
22245
|
+
required: ["classes"],
|
|
22246
|
+
type: "object"
|
|
22247
|
+
}
|
|
22248
|
+
],
|
|
22249
|
+
type: "problem"
|
|
22250
|
+
},
|
|
22251
|
+
name: "require-module-level-instantiation"
|
|
22252
|
+
});
|
|
22253
|
+
|
|
22254
|
+
// src/rules/require-named-effect-functions.ts
|
|
22255
|
+
import { TSESTree as TSESTree9 } from "@typescript-eslint/types";
|
|
22256
|
+
|
|
22257
|
+
// src/types/environment-mode.ts
|
|
22258
|
+
var isEnvironmentMode = build_default.Union([build_default.Literal("roblox-ts"), build_default.Literal("standard")]);
|
|
22259
|
+
|
|
21955
22260
|
// src/rules/require-named-effect-functions.ts
|
|
21956
|
-
import { TSESTree as TSESTree8 } from "@typescript-eslint/types";
|
|
21957
22261
|
var DEFAULT_HOOKS = [
|
|
21958
22262
|
{ allowAsync: false, name: "useEffect" },
|
|
21959
22263
|
{ allowAsync: false, name: "useLayoutEffect" },
|
|
21960
22264
|
{ allowAsync: false, name: "useInsertionEffect" }
|
|
21961
22265
|
];
|
|
21962
|
-
var isEnvironmentMode = build_default.Union([build_default.Literal("roblox-ts"), build_default.Literal("standard")]);
|
|
21963
22266
|
var isHookConfiguration = build_default.Object({
|
|
21964
22267
|
allowAsync: build_default.Boolean(),
|
|
21965
22268
|
name: build_default.String()
|
|
@@ -21988,10 +22291,10 @@ function parseOptions2(options3) {
|
|
|
21988
22291
|
}
|
|
21989
22292
|
function getHookName3(callExpression) {
|
|
21990
22293
|
const { callee } = callExpression;
|
|
21991
|
-
if (callee.type ===
|
|
22294
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.Identifier && typeof callee.name === "string" && callee.name.length > 0) {
|
|
21992
22295
|
return callee.name;
|
|
21993
22296
|
}
|
|
21994
|
-
if (callee.type ===
|
|
22297
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.MemberExpression && callee.property?.type === TSESTree9.AST_NODE_TYPES.Identifier && typeof callee.property.name === "string" && callee.property.name.length > 0) {
|
|
21995
22298
|
return callee.property.name;
|
|
21996
22299
|
}
|
|
21997
22300
|
return;
|
|
@@ -22034,14 +22337,14 @@ function processFunctionExpression(init) {
|
|
|
22034
22337
|
}
|
|
22035
22338
|
function checkVariableDeclaratorDef(node) {
|
|
22036
22339
|
const castNode = node;
|
|
22037
|
-
if (castNode.type !==
|
|
22340
|
+
if (castNode.type !== TSESTree9.AST_NODE_TYPES.VariableDeclarator)
|
|
22038
22341
|
return;
|
|
22039
22342
|
if (typeof castNode.init !== "object" || castNode.init === null)
|
|
22040
22343
|
return;
|
|
22041
22344
|
const castInit = castNode.init;
|
|
22042
|
-
if (castInit.type ===
|
|
22345
|
+
if (castInit.type === TSESTree9.AST_NODE_TYPES.ArrowFunctionExpression)
|
|
22043
22346
|
return processArrowFunction(castNode.init);
|
|
22044
|
-
if (castInit.type ===
|
|
22347
|
+
if (castInit.type === TSESTree9.AST_NODE_TYPES.FunctionExpression)
|
|
22045
22348
|
return processFunctionExpression(castNode.init);
|
|
22046
22349
|
return;
|
|
22047
22350
|
}
|
|
@@ -22053,7 +22356,7 @@ function processSingleDefinition(definition) {
|
|
|
22053
22356
|
if (typeof node !== "object" || node === null)
|
|
22054
22357
|
return;
|
|
22055
22358
|
const castNode = node;
|
|
22056
|
-
if (castNode.type ===
|
|
22359
|
+
if (castNode.type === TSESTree9.AST_NODE_TYPES.FunctionDeclaration)
|
|
22057
22360
|
return processFunctionDeclaration(node);
|
|
22058
22361
|
return checkVariableDeclaratorDef(node);
|
|
22059
22362
|
}
|
|
@@ -22113,12 +22416,12 @@ function isCallbackHookResult(identifier3, context) {
|
|
|
22113
22416
|
if (typeof node !== "object" || node === null)
|
|
22114
22417
|
continue;
|
|
22115
22418
|
const castNode = node;
|
|
22116
|
-
if (castNode.type !==
|
|
22419
|
+
if (castNode.type !== TSESTree9.AST_NODE_TYPES.VariableDeclarator)
|
|
22117
22420
|
continue;
|
|
22118
22421
|
if (typeof castNode.init !== "object" || castNode.init === null)
|
|
22119
22422
|
continue;
|
|
22120
22423
|
const init = castNode.init;
|
|
22121
|
-
if (init.type !==
|
|
22424
|
+
if (init.type !== TSESTree9.AST_NODE_TYPES.CallExpression)
|
|
22122
22425
|
continue;
|
|
22123
22426
|
const calleeHookName = getHookName3(init);
|
|
22124
22427
|
if (calleeHookName === "useCallback" || calleeHookName === "useMemo")
|
|
@@ -22149,7 +22452,7 @@ var requireNamedEffectFunctions = {
|
|
|
22149
22452
|
if (firstArgument === undefined)
|
|
22150
22453
|
return;
|
|
22151
22454
|
const argumentNode = firstArgument;
|
|
22152
|
-
if (argumentNode.type ===
|
|
22455
|
+
if (argumentNode.type === TSESTree9.AST_NODE_TYPES.Identifier) {
|
|
22153
22456
|
const identifier3 = argumentNode;
|
|
22154
22457
|
const resolved = resolveIdentifierToFunction(identifier3, context);
|
|
22155
22458
|
if (resolved === undefined) {
|
|
@@ -22202,7 +22505,7 @@ var requireNamedEffectFunctions = {
|
|
|
22202
22505
|
}
|
|
22203
22506
|
return;
|
|
22204
22507
|
}
|
|
22205
|
-
if (argumentNode.type ===
|
|
22508
|
+
if (argumentNode.type === TSESTree9.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
22206
22509
|
if (argumentNode.async) {
|
|
22207
22510
|
context.report({
|
|
22208
22511
|
data: { hook: hookName },
|
|
@@ -22218,7 +22521,7 @@ var requireNamedEffectFunctions = {
|
|
|
22218
22521
|
}
|
|
22219
22522
|
return;
|
|
22220
22523
|
}
|
|
22221
|
-
if (argumentNode.type ===
|
|
22524
|
+
if (argumentNode.type === TSESTree9.AST_NODE_TYPES.FunctionExpression) {
|
|
22222
22525
|
const functionHasId = Boolean(argumentNode.id);
|
|
22223
22526
|
if (functionHasId && argumentNode.async) {
|
|
22224
22527
|
context.report({
|
|
@@ -22307,7 +22610,7 @@ var requireNamedEffectFunctions = {
|
|
|
22307
22610
|
var require_named_effect_functions_default = requireNamedEffectFunctions;
|
|
22308
22611
|
|
|
22309
22612
|
// src/rules/require-paired-calls.ts
|
|
22310
|
-
import { AST_NODE_TYPES as
|
|
22613
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES15 } from "@typescript-eslint/types";
|
|
22311
22614
|
var isStringArray = Compile(build_default.Readonly(build_default.Array(build_default.String())));
|
|
22312
22615
|
var isPairConfiguration = Compile(build_default.Readonly(build_default.Object({
|
|
22313
22616
|
alternatives: build_default.Optional(isStringArray),
|
|
@@ -22325,20 +22628,20 @@ var isRuleOptions4 = Compile(build_default.Partial(build_default.Readonly(build_
|
|
|
22325
22628
|
pairs: build_default.Readonly(build_default.Array(isPairConfiguration))
|
|
22326
22629
|
}))));
|
|
22327
22630
|
var LOOP_NODE_TYPES = new Set([
|
|
22328
|
-
|
|
22329
|
-
|
|
22330
|
-
|
|
22331
|
-
|
|
22332
|
-
|
|
22631
|
+
AST_NODE_TYPES15.DoWhileStatement,
|
|
22632
|
+
AST_NODE_TYPES15.ForInStatement,
|
|
22633
|
+
AST_NODE_TYPES15.ForOfStatement,
|
|
22634
|
+
AST_NODE_TYPES15.ForStatement,
|
|
22635
|
+
AST_NODE_TYPES15.WhileStatement
|
|
22333
22636
|
]);
|
|
22334
22637
|
var DEFAULT_ROBLOX_YIELDING_FUNCTIONS = ["task.wait", "wait", "*.WaitForChild", "*.*Async"];
|
|
22335
22638
|
function getCallName(node) {
|
|
22336
22639
|
const { callee } = node;
|
|
22337
|
-
if (callee.type ===
|
|
22640
|
+
if (callee.type === AST_NODE_TYPES15.Identifier)
|
|
22338
22641
|
return callee.name;
|
|
22339
|
-
if (callee.type ===
|
|
22340
|
-
const object3 = callee.object.type ===
|
|
22341
|
-
const property = callee.property.type ===
|
|
22642
|
+
if (callee.type === AST_NODE_TYPES15.MemberExpression) {
|
|
22643
|
+
const object3 = callee.object.type === AST_NODE_TYPES15.Identifier ? callee.object.name : undefined;
|
|
22644
|
+
const property = callee.property.type === AST_NODE_TYPES15.Identifier ? callee.property.name : undefined;
|
|
22342
22645
|
if (object3 !== undefined && property !== undefined)
|
|
22343
22646
|
return `${object3}.${property}`;
|
|
22344
22647
|
}
|
|
@@ -22374,12 +22677,12 @@ function isLoopLikeStatement(node) {
|
|
|
22374
22677
|
return LOOP_NODE_TYPES.has(node.type);
|
|
22375
22678
|
}
|
|
22376
22679
|
function isSwitchStatement(node) {
|
|
22377
|
-
return node?.type ===
|
|
22680
|
+
return node?.type === AST_NODE_TYPES15.SwitchStatement;
|
|
22378
22681
|
}
|
|
22379
22682
|
function findLabeledStatementBody(label, startingNode) {
|
|
22380
22683
|
let current = startingNode;
|
|
22381
22684
|
while (current) {
|
|
22382
|
-
if (current.type ===
|
|
22685
|
+
if (current.type === AST_NODE_TYPES15.LabeledStatement && current.label.name === label.name)
|
|
22383
22686
|
return current.body;
|
|
22384
22687
|
current = current.parent ?? undefined;
|
|
22385
22688
|
}
|
|
@@ -22641,7 +22944,7 @@ var rule = {
|
|
|
22641
22944
|
function onIfConsequentExit(node) {
|
|
22642
22945
|
const consequentNode = node;
|
|
22643
22946
|
const { parent } = consequentNode;
|
|
22644
|
-
if (parent?.type ===
|
|
22947
|
+
if (parent?.type === AST_NODE_TYPES15.IfStatement) {
|
|
22645
22948
|
const branches = branchStacks.get(parent) ?? [];
|
|
22646
22949
|
branches.push(cloneStack());
|
|
22647
22950
|
branchStacks.set(parent, branches);
|
|
@@ -22656,7 +22959,7 @@ var rule = {
|
|
|
22656
22959
|
function onIfAlternateExit(node) {
|
|
22657
22960
|
const alternateNode = node;
|
|
22658
22961
|
const { parent } = alternateNode;
|
|
22659
|
-
if (parent?.type ===
|
|
22962
|
+
if (parent?.type === AST_NODE_TYPES15.IfStatement) {
|
|
22660
22963
|
const branches = branchStacks.get(parent) ?? [];
|
|
22661
22964
|
branches.push(cloneStack());
|
|
22662
22965
|
branchStacks.set(parent, branches);
|
|
@@ -22705,7 +23008,7 @@ var rule = {
|
|
|
22705
23008
|
function onTryBlockExit(node) {
|
|
22706
23009
|
const blockNode = node;
|
|
22707
23010
|
const { parent } = blockNode;
|
|
22708
|
-
if (parent?.type ===
|
|
23011
|
+
if (parent?.type === AST_NODE_TYPES15.TryStatement) {
|
|
22709
23012
|
const branches = branchStacks.get(parent) ?? [];
|
|
22710
23013
|
branches.push(cloneStack());
|
|
22711
23014
|
branchStacks.set(parent, branches);
|
|
@@ -22724,7 +23027,7 @@ var rule = {
|
|
|
22724
23027
|
function onCatchClauseExit(node) {
|
|
22725
23028
|
const catchNode = node;
|
|
22726
23029
|
const { parent } = catchNode;
|
|
22727
|
-
if (parent?.type ===
|
|
23030
|
+
if (parent?.type === AST_NODE_TYPES15.TryStatement) {
|
|
22728
23031
|
const branches = branchStacks.get(parent) ?? [];
|
|
22729
23032
|
branches.push(cloneStack());
|
|
22730
23033
|
branchStacks.set(parent, branches);
|
|
@@ -22787,7 +23090,7 @@ var rule = {
|
|
|
22787
23090
|
function onSwitchCaseExit(node) {
|
|
22788
23091
|
const caseNode = node;
|
|
22789
23092
|
const { parent } = caseNode;
|
|
22790
|
-
if (parent?.type ===
|
|
23093
|
+
if (parent?.type === AST_NODE_TYPES15.SwitchStatement) {
|
|
22791
23094
|
const branches = branchStacks.get(parent) ?? [];
|
|
22792
23095
|
branches.push(cloneStack());
|
|
22793
23096
|
branchStacks.set(parent, branches);
|
|
@@ -22818,7 +23121,7 @@ var rule = {
|
|
|
22818
23121
|
for (const { opener, config, node: node2 } of openerStack) {
|
|
22819
23122
|
const validClosers = getValidClosers(config);
|
|
22820
23123
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
22821
|
-
const statementType = statementNode.type ===
|
|
23124
|
+
const statementType = statementNode.type === AST_NODE_TYPES15.ReturnStatement ? "return" : "throw";
|
|
22822
23125
|
const lineNumber = statementNode.loc?.start.line ?? 0;
|
|
22823
23126
|
context.report({
|
|
22824
23127
|
data: {
|
|
@@ -22835,7 +23138,7 @@ var rule = {
|
|
|
22835
23138
|
const statementNode = node;
|
|
22836
23139
|
if (openerStack.length === 0)
|
|
22837
23140
|
return;
|
|
22838
|
-
const targetLoop = statementNode.type ===
|
|
23141
|
+
const targetLoop = statementNode.type === AST_NODE_TYPES15.ContinueStatement ? resolveContinueTargetLoop(statementNode) : resolveBreakTargetLoop(statementNode);
|
|
22839
23142
|
if (!targetLoop)
|
|
22840
23143
|
return;
|
|
22841
23144
|
for (const { node: openerNode, config, opener, loopAncestors } of openerStack) {
|
|
@@ -22843,7 +23146,7 @@ var rule = {
|
|
|
22843
23146
|
continue;
|
|
22844
23147
|
const validClosers = getValidClosers(config);
|
|
22845
23148
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
22846
|
-
const statementType = statementNode.type ===
|
|
23149
|
+
const statementType = statementNode.type === AST_NODE_TYPES15.BreakStatement ? "break" : "continue";
|
|
22847
23150
|
const lineNumber = statementNode.loc?.start.line ?? 0;
|
|
22848
23151
|
context.report({
|
|
22849
23152
|
data: {
|
|
@@ -22981,7 +23284,7 @@ var rule = {
|
|
|
22981
23284
|
continue;
|
|
22982
23285
|
const validClosers = getValidClosers(config);
|
|
22983
23286
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
22984
|
-
const asyncType = asyncNode.type ===
|
|
23287
|
+
const asyncType = asyncNode.type === AST_NODE_TYPES15.AwaitExpression ? "await" : "yield";
|
|
22985
23288
|
context.report({
|
|
22986
23289
|
data: { asyncType, closer, opener },
|
|
22987
23290
|
messageId: "asyncViolation",
|
|
@@ -23116,8 +23419,8 @@ var rule = {
|
|
|
23116
23419
|
var require_paired_calls_default = rule;
|
|
23117
23420
|
|
|
23118
23421
|
// src/rules/require-react-component-keys.ts
|
|
23119
|
-
import { TSESTree as
|
|
23120
|
-
var
|
|
23422
|
+
import { TSESTree as TSESTree10 } from "@typescript-eslint/types";
|
|
23423
|
+
var DEFAULT_OPTIONS4 = {
|
|
23121
23424
|
allowRootKeys: false,
|
|
23122
23425
|
ignoreCallExpressions: ["ReactTree.mount", "CreateReactStory"],
|
|
23123
23426
|
iterationMethods: [
|
|
@@ -23159,17 +23462,17 @@ function ascendPastWrappers(node) {
|
|
|
23159
23462
|
}
|
|
23160
23463
|
function hasKeyAttribute(node) {
|
|
23161
23464
|
for (const attribute of node.openingElement.attributes) {
|
|
23162
|
-
if (attribute.type ===
|
|
23465
|
+
if (attribute.type === TSESTree10.AST_NODE_TYPES.JSXAttribute && attribute.name.name === "key")
|
|
23163
23466
|
return true;
|
|
23164
23467
|
}
|
|
23165
23468
|
return false;
|
|
23166
23469
|
}
|
|
23167
23470
|
function isHigherOrderComponent(callExpr) {
|
|
23168
23471
|
const { callee } = callExpr;
|
|
23169
|
-
if (callee.type ===
|
|
23472
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
23170
23473
|
return callee.name === "forwardRef" || callee.name === "memo";
|
|
23171
23474
|
}
|
|
23172
|
-
if (callee.type ===
|
|
23475
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.object.type === TSESTree10.AST_NODE_TYPES.Identifier && callee.object.name === "React" && callee.property.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
23173
23476
|
return callee.property.name === "forwardRef" || callee.property.name === "memo";
|
|
23174
23477
|
}
|
|
23175
23478
|
return false;
|
|
@@ -23177,7 +23480,7 @@ function isHigherOrderComponent(callExpr) {
|
|
|
23177
23480
|
function getEnclosingFunctionLike(node) {
|
|
23178
23481
|
let current = node.parent;
|
|
23179
23482
|
while (current) {
|
|
23180
|
-
if (current.type ===
|
|
23483
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression || current.type === TSESTree10.AST_NODE_TYPES.FunctionExpression || current.type === TSESTree10.AST_NODE_TYPES.FunctionDeclaration) {
|
|
23181
23484
|
return current;
|
|
23182
23485
|
}
|
|
23183
23486
|
current = current.parent;
|
|
@@ -23186,16 +23489,16 @@ function getEnclosingFunctionLike(node) {
|
|
|
23186
23489
|
}
|
|
23187
23490
|
function isIterationOrMemoCallback(callExpression, iterationMethods, memoizationHooks) {
|
|
23188
23491
|
const { callee } = callExpression;
|
|
23189
|
-
if (callee.type ===
|
|
23492
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.Identifier && memoizationHooks.has(callee.name))
|
|
23190
23493
|
return true;
|
|
23191
|
-
if (callee.type ===
|
|
23494
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
23192
23495
|
const { name } = callee.property;
|
|
23193
23496
|
if (iterationMethods.has(name))
|
|
23194
23497
|
return true;
|
|
23195
|
-
if (name === "from" && callee.object.type ===
|
|
23498
|
+
if (name === "from" && callee.object.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.object.object.type === TSESTree10.AST_NODE_TYPES.Identifier && callee.object.object.name === "Array" && callExpression.arguments.length >= 2) {
|
|
23196
23499
|
return true;
|
|
23197
23500
|
}
|
|
23198
|
-
if (name === "call" && callee.object.type ===
|
|
23501
|
+
if (name === "call" && callee.object.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.object.object.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.object.object.property.type === TSESTree10.AST_NODE_TYPES.Identifier && iterationMethods.has(callee.object.object.property.name)) {
|
|
23199
23502
|
return true;
|
|
23200
23503
|
}
|
|
23201
23504
|
}
|
|
@@ -23205,11 +23508,11 @@ function findEnclosingCallExpression(node) {
|
|
|
23205
23508
|
let current = node;
|
|
23206
23509
|
let { parent } = node;
|
|
23207
23510
|
while (parent) {
|
|
23208
|
-
if (parent.type ===
|
|
23511
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.CallExpression) {
|
|
23209
23512
|
for (const argument of parent.arguments) {
|
|
23210
23513
|
if (argument === current)
|
|
23211
23514
|
return parent;
|
|
23212
|
-
if (argument.type ===
|
|
23515
|
+
if (argument.type === TSESTree10.AST_NODE_TYPES.SpreadElement && argument.argument === current) {
|
|
23213
23516
|
return parent;
|
|
23214
23517
|
}
|
|
23215
23518
|
}
|
|
@@ -23225,7 +23528,7 @@ function findEnclosingCallExpression(node) {
|
|
|
23225
23528
|
return;
|
|
23226
23529
|
}
|
|
23227
23530
|
function getVariableForFunction(context, functionLike) {
|
|
23228
|
-
if (functionLike.type ===
|
|
23531
|
+
if (functionLike.type === TSESTree10.AST_NODE_TYPES.FunctionDeclaration) {
|
|
23229
23532
|
const declared = context.sourceCode.getDeclaredVariables(functionLike);
|
|
23230
23533
|
if (declared.length > 0)
|
|
23231
23534
|
return declared[0];
|
|
@@ -23234,7 +23537,7 @@ function getVariableForFunction(context, functionLike) {
|
|
|
23234
23537
|
const { parent } = functionLike;
|
|
23235
23538
|
if (!parent)
|
|
23236
23539
|
return;
|
|
23237
|
-
if (parent.type ===
|
|
23540
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.VariableDeclarator || parent.type === TSESTree10.AST_NODE_TYPES.AssignmentExpression) {
|
|
23238
23541
|
const declared = context.sourceCode.getDeclaredVariables(parent);
|
|
23239
23542
|
if (declared.length > 0)
|
|
23240
23543
|
return declared[0];
|
|
@@ -23268,33 +23571,33 @@ function isFunctionUsedAsCallback(context, functionLike, iterationMethods, memoi
|
|
|
23268
23571
|
return false;
|
|
23269
23572
|
}
|
|
23270
23573
|
var SHOULD_ASCEND_TYPES = new Set([
|
|
23271
|
-
|
|
23272
|
-
|
|
23574
|
+
TSESTree10.AST_NODE_TYPES.ConditionalExpression,
|
|
23575
|
+
TSESTree10.AST_NODE_TYPES.LogicalExpression
|
|
23273
23576
|
]);
|
|
23274
23577
|
var IS_FUNCTION_EXPRESSION = new Set([
|
|
23275
|
-
|
|
23276
|
-
|
|
23578
|
+
TSESTree10.AST_NODE_TYPES.FunctionExpression,
|
|
23579
|
+
TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression
|
|
23277
23580
|
]);
|
|
23278
23581
|
var CONTROL_FLOW_TYPES = new Set([
|
|
23279
|
-
|
|
23280
|
-
|
|
23281
|
-
|
|
23282
|
-
|
|
23283
|
-
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
|
|
23290
|
-
|
|
23291
|
-
|
|
23582
|
+
TSESTree10.AST_NODE_TYPES.BlockStatement,
|
|
23583
|
+
TSESTree10.AST_NODE_TYPES.IfStatement,
|
|
23584
|
+
TSESTree10.AST_NODE_TYPES.SwitchStatement,
|
|
23585
|
+
TSESTree10.AST_NODE_TYPES.SwitchCase,
|
|
23586
|
+
TSESTree10.AST_NODE_TYPES.TryStatement,
|
|
23587
|
+
TSESTree10.AST_NODE_TYPES.CatchClause,
|
|
23588
|
+
TSESTree10.AST_NODE_TYPES.WhileStatement,
|
|
23589
|
+
TSESTree10.AST_NODE_TYPES.DoWhileStatement,
|
|
23590
|
+
TSESTree10.AST_NODE_TYPES.ForStatement,
|
|
23591
|
+
TSESTree10.AST_NODE_TYPES.ForInStatement,
|
|
23592
|
+
TSESTree10.AST_NODE_TYPES.ForOfStatement,
|
|
23593
|
+
TSESTree10.AST_NODE_TYPES.LabeledStatement,
|
|
23594
|
+
TSESTree10.AST_NODE_TYPES.WithStatement
|
|
23292
23595
|
]);
|
|
23293
23596
|
function isTopLevelReturn(node) {
|
|
23294
23597
|
let parent = ascendPastWrappers(node.parent);
|
|
23295
23598
|
if (!parent)
|
|
23296
23599
|
return false;
|
|
23297
|
-
if (parent.type ===
|
|
23600
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.JSXExpressionContainer)
|
|
23298
23601
|
parent = ascendPastWrappers(parent.parent);
|
|
23299
23602
|
if (!parent)
|
|
23300
23603
|
return false;
|
|
@@ -23302,11 +23605,11 @@ function isTopLevelReturn(node) {
|
|
|
23302
23605
|
parent = ascendPastWrappers(parent.parent);
|
|
23303
23606
|
if (!parent)
|
|
23304
23607
|
return false;
|
|
23305
|
-
if (parent.type ===
|
|
23608
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.JSXExpressionContainer)
|
|
23306
23609
|
parent = ascendPastWrappers(parent.parent);
|
|
23307
23610
|
if (!parent)
|
|
23308
23611
|
return false;
|
|
23309
|
-
if (parent.type ===
|
|
23612
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.ReturnStatement) {
|
|
23310
23613
|
let currentNode = ascendPastWrappers(parent.parent);
|
|
23311
23614
|
while (currentNode && CONTROL_FLOW_TYPES.has(currentNode.type)) {
|
|
23312
23615
|
currentNode = ascendPastWrappers(currentNode.parent);
|
|
@@ -23315,16 +23618,16 @@ function isTopLevelReturn(node) {
|
|
|
23315
23618
|
return false;
|
|
23316
23619
|
if (IS_FUNCTION_EXPRESSION.has(currentNode.type)) {
|
|
23317
23620
|
const functionParent = ascendPastWrappers(currentNode.parent);
|
|
23318
|
-
if (functionParent?.type ===
|
|
23621
|
+
if (functionParent?.type === TSESTree10.AST_NODE_TYPES.CallExpression) {
|
|
23319
23622
|
return isHigherOrderComponent(functionParent);
|
|
23320
23623
|
}
|
|
23321
23624
|
return true;
|
|
23322
23625
|
}
|
|
23323
|
-
return currentNode.type ===
|
|
23626
|
+
return currentNode.type === TSESTree10.AST_NODE_TYPES.FunctionDeclaration;
|
|
23324
23627
|
}
|
|
23325
|
-
if (parent.type ===
|
|
23628
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
23326
23629
|
const functionParent = ascendPastWrappers(parent.parent);
|
|
23327
|
-
if (functionParent?.type ===
|
|
23630
|
+
if (functionParent?.type === TSESTree10.AST_NODE_TYPES.CallExpression) {
|
|
23328
23631
|
return isHigherOrderComponent(functionParent);
|
|
23329
23632
|
}
|
|
23330
23633
|
return true;
|
|
@@ -23335,7 +23638,7 @@ function isIgnoredCallExpression(node, ignoreList) {
|
|
|
23335
23638
|
let parent = node.parent;
|
|
23336
23639
|
if (!parent)
|
|
23337
23640
|
return false;
|
|
23338
|
-
if (parent.type ===
|
|
23641
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
23339
23642
|
({ parent } = parent);
|
|
23340
23643
|
if (!parent)
|
|
23341
23644
|
return false;
|
|
@@ -23343,11 +23646,11 @@ function isIgnoredCallExpression(node, ignoreList) {
|
|
|
23343
23646
|
const maxDepth = 20;
|
|
23344
23647
|
for (let depth = 0;depth < maxDepth && parent; depth += 1) {
|
|
23345
23648
|
const { type: type3 } = parent;
|
|
23346
|
-
if (type3 ===
|
|
23649
|
+
if (type3 === TSESTree10.AST_NODE_TYPES.CallExpression) {
|
|
23347
23650
|
const { callee } = parent;
|
|
23348
|
-
if (callee.type ===
|
|
23651
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.Identifier)
|
|
23349
23652
|
return ignoreList.includes(callee.name);
|
|
23350
|
-
if (callee.type ===
|
|
23653
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.object.type === TSESTree10.AST_NODE_TYPES.Identifier && callee.property.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
23351
23654
|
return ignoreList.includes(`${callee.object.name}.${callee.property.name}`);
|
|
23352
23655
|
}
|
|
23353
23656
|
return false;
|
|
@@ -23360,41 +23663,41 @@ function isJSXPropValue(node) {
|
|
|
23360
23663
|
let { parent } = node;
|
|
23361
23664
|
if (!parent)
|
|
23362
23665
|
return false;
|
|
23363
|
-
while (parent && (parent.type ===
|
|
23666
|
+
while (parent && (parent.type === TSESTree10.AST_NODE_TYPES.ConditionalExpression || parent.type === TSESTree10.AST_NODE_TYPES.LogicalExpression)) {
|
|
23364
23667
|
({ parent } = parent);
|
|
23365
23668
|
}
|
|
23366
23669
|
if (!parent)
|
|
23367
23670
|
return false;
|
|
23368
|
-
if (parent.type ===
|
|
23671
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
23369
23672
|
({ parent } = parent);
|
|
23370
23673
|
if (!parent)
|
|
23371
23674
|
return false;
|
|
23372
23675
|
}
|
|
23373
|
-
return parent.type ===
|
|
23676
|
+
return parent.type === TSESTree10.AST_NODE_TYPES.JSXAttribute;
|
|
23374
23677
|
}
|
|
23375
23678
|
function isTernaryJSXChild(node) {
|
|
23376
23679
|
let current = node.parent;
|
|
23377
23680
|
if (!current)
|
|
23378
23681
|
return false;
|
|
23379
23682
|
let foundTernary = false;
|
|
23380
|
-
while (current && (current.type ===
|
|
23381
|
-
if (current.type ===
|
|
23683
|
+
while (current && (current.type === TSESTree10.AST_NODE_TYPES.ConditionalExpression || WRAPPER_PARENT_TYPES.has(current.type))) {
|
|
23684
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.ConditionalExpression)
|
|
23382
23685
|
foundTernary = true;
|
|
23383
23686
|
current = current.parent;
|
|
23384
23687
|
}
|
|
23385
23688
|
if (!(foundTernary && current))
|
|
23386
23689
|
return false;
|
|
23387
|
-
if (current.type !==
|
|
23690
|
+
if (current.type !== TSESTree10.AST_NODE_TYPES.JSXExpressionContainer)
|
|
23388
23691
|
return false;
|
|
23389
23692
|
const containerParent = current.parent;
|
|
23390
23693
|
if (!containerParent)
|
|
23391
23694
|
return false;
|
|
23392
|
-
return containerParent.type ===
|
|
23695
|
+
return containerParent.type === TSESTree10.AST_NODE_TYPES.JSXElement || containerParent.type === TSESTree10.AST_NODE_TYPES.JSXFragment;
|
|
23393
23696
|
}
|
|
23394
23697
|
var require_react_component_keys_default = createRule({
|
|
23395
23698
|
create(context) {
|
|
23396
23699
|
const options3 = {
|
|
23397
|
-
...
|
|
23700
|
+
...DEFAULT_OPTIONS4,
|
|
23398
23701
|
...context.options[0]
|
|
23399
23702
|
};
|
|
23400
23703
|
const iterationMethods = new Set(options3.iterationMethods);
|
|
@@ -23404,7 +23707,7 @@ var require_react_component_keys_default = createRule({
|
|
|
23404
23707
|
const isCallback = functionLike ? isFunctionUsedAsCallback(context, functionLike, iterationMethods, memoizationHooks) : false;
|
|
23405
23708
|
const isRoot = isTopLevelReturn(node);
|
|
23406
23709
|
if (isRoot && !isCallback) {
|
|
23407
|
-
if (!options3.allowRootKeys && node.type ===
|
|
23710
|
+
if (!options3.allowRootKeys && node.type === TSESTree10.AST_NODE_TYPES.JSXElement && hasKeyAttribute(node)) {
|
|
23408
23711
|
context.report({
|
|
23409
23712
|
messageId: "rootComponentWithKey",
|
|
23410
23713
|
node
|
|
@@ -23418,7 +23721,7 @@ var require_react_component_keys_default = createRule({
|
|
|
23418
23721
|
return;
|
|
23419
23722
|
if (isTernaryJSXChild(node))
|
|
23420
23723
|
return;
|
|
23421
|
-
if (node.type ===
|
|
23724
|
+
if (node.type === TSESTree10.AST_NODE_TYPES.JSXFragment) {
|
|
23422
23725
|
context.report({
|
|
23423
23726
|
messageId: "missingKey",
|
|
23424
23727
|
node
|
|
@@ -23441,7 +23744,7 @@ var require_react_component_keys_default = createRule({
|
|
|
23441
23744
|
}
|
|
23442
23745
|
};
|
|
23443
23746
|
},
|
|
23444
|
-
defaultOptions: [
|
|
23747
|
+
defaultOptions: [DEFAULT_OPTIONS4],
|
|
23445
23748
|
meta: {
|
|
23446
23749
|
docs: {
|
|
23447
23750
|
description: "Require keys on React components when used in lists or iteration."
|
|
@@ -23498,38 +23801,30 @@ var require_react_component_keys_default = createRule({
|
|
|
23498
23801
|
});
|
|
23499
23802
|
|
|
23500
23803
|
// src/rules/require-react-display-names.ts
|
|
23501
|
-
import { TSESTree as
|
|
23502
|
-
var
|
|
23804
|
+
import { TSESTree as TSESTree11 } from "@typescript-eslint/types";
|
|
23805
|
+
var DEFAULT_OPTIONS5 = {
|
|
23503
23806
|
environment: "roblox-ts"
|
|
23504
23807
|
};
|
|
23505
|
-
|
|
23506
|
-
var REACT_SOURCES_STANDARD = new Set(["react", "react-dom"]);
|
|
23507
|
-
function getReactSources(environment2) {
|
|
23508
|
-
return environment2 === "roblox-ts" ? REACT_SOURCES_ROBLOX : REACT_SOURCES_STANDARD;
|
|
23509
|
-
}
|
|
23510
|
-
function isReactImport(node, reactSources) {
|
|
23511
|
-
return reactSources.has(node.source.value);
|
|
23512
|
-
}
|
|
23513
|
-
function isMemoCall(node, memoIdentifiers, reactNamespaces) {
|
|
23808
|
+
function isMemoCall2(node, memoIdentifiers, reactNamespaces) {
|
|
23514
23809
|
const { callee } = node;
|
|
23515
|
-
if (callee.type ===
|
|
23810
|
+
if (callee.type === TSESTree11.AST_NODE_TYPES.Identifier)
|
|
23516
23811
|
return memoIdentifiers.has(callee.name);
|
|
23517
|
-
if (callee.type ===
|
|
23812
|
+
if (callee.type === TSESTree11.AST_NODE_TYPES.MemberExpression && callee.object.type === TSESTree11.AST_NODE_TYPES.Identifier && callee.property.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
23518
23813
|
return reactNamespaces.has(callee.object.name) && callee.property.name === "memo";
|
|
23519
23814
|
}
|
|
23520
23815
|
return false;
|
|
23521
23816
|
}
|
|
23522
23817
|
function isCreateContextCall(node, createContextIdentifiers, reactNamespaces) {
|
|
23523
23818
|
const { callee } = node;
|
|
23524
|
-
if (callee.type ===
|
|
23819
|
+
if (callee.type === TSESTree11.AST_NODE_TYPES.Identifier)
|
|
23525
23820
|
return createContextIdentifiers.has(callee.name);
|
|
23526
|
-
if (callee.type ===
|
|
23821
|
+
if (callee.type === TSESTree11.AST_NODE_TYPES.MemberExpression && callee.object.type === TSESTree11.AST_NODE_TYPES.Identifier && callee.property.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
23527
23822
|
return reactNamespaces.has(callee.object.name) && callee.property.name === "createContext";
|
|
23528
23823
|
}
|
|
23529
23824
|
return false;
|
|
23530
23825
|
}
|
|
23531
23826
|
function getVariableName(node) {
|
|
23532
|
-
if (node.id.type ===
|
|
23827
|
+
if (node.id.type === TSESTree11.AST_NODE_TYPES.Identifier)
|
|
23533
23828
|
return node.id.name;
|
|
23534
23829
|
return;
|
|
23535
23830
|
}
|
|
@@ -23537,9 +23832,9 @@ function isNodeInExport(node) {
|
|
|
23537
23832
|
let current = node;
|
|
23538
23833
|
while (current) {
|
|
23539
23834
|
const { type: type3 } = current;
|
|
23540
|
-
if (type3 ===
|
|
23835
|
+
if (type3 === TSESTree11.AST_NODE_TYPES.ExportNamedDeclaration)
|
|
23541
23836
|
return true;
|
|
23542
|
-
if (type3 ===
|
|
23837
|
+
if (type3 === TSESTree11.AST_NODE_TYPES.ExportDefaultDeclaration)
|
|
23543
23838
|
return true;
|
|
23544
23839
|
current = current.parent;
|
|
23545
23840
|
}
|
|
@@ -23551,7 +23846,7 @@ function isReferenceExported(reference) {
|
|
|
23551
23846
|
var require_react_display_names_default = createRule({
|
|
23552
23847
|
create(context) {
|
|
23553
23848
|
const options3 = {
|
|
23554
|
-
...
|
|
23849
|
+
...DEFAULT_OPTIONS5,
|
|
23555
23850
|
...context.options[0]
|
|
23556
23851
|
};
|
|
23557
23852
|
const reactSources = getReactSources(options3.environment);
|
|
@@ -23563,14 +23858,14 @@ var require_react_display_names_default = createRule({
|
|
|
23563
23858
|
return {
|
|
23564
23859
|
"AssignmentExpression[left.type='MemberExpression'][left.property.name='displayName']"(node) {
|
|
23565
23860
|
const left = node.left;
|
|
23566
|
-
if (left.object.type ===
|
|
23861
|
+
if (left.object.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
23567
23862
|
displayNameAssignments.add(left.object.name);
|
|
23568
23863
|
}
|
|
23569
23864
|
},
|
|
23570
23865
|
ExportDefaultDeclaration(node) {
|
|
23571
23866
|
const { declaration } = node;
|
|
23572
|
-
if (declaration.type ===
|
|
23573
|
-
if (
|
|
23867
|
+
if (declaration.type === TSESTree11.AST_NODE_TYPES.CallExpression) {
|
|
23868
|
+
if (isMemoCall2(declaration, memoIdentifiers, reactNamespaces)) {
|
|
23574
23869
|
context.report({
|
|
23575
23870
|
messageId: "directMemoExport",
|
|
23576
23871
|
node
|
|
@@ -23585,7 +23880,7 @@ var require_react_display_names_default = createRule({
|
|
|
23585
23880
|
return;
|
|
23586
23881
|
}
|
|
23587
23882
|
}
|
|
23588
|
-
if (declaration.type ===
|
|
23883
|
+
if (declaration.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
23589
23884
|
const tracked = trackedVariables.get(declaration.name);
|
|
23590
23885
|
if (tracked) {
|
|
23591
23886
|
trackedVariables.set(declaration.name, {
|
|
@@ -23599,10 +23894,10 @@ var require_react_display_names_default = createRule({
|
|
|
23599
23894
|
if (!node.specifiers)
|
|
23600
23895
|
return;
|
|
23601
23896
|
for (const specifier of node.specifiers) {
|
|
23602
|
-
if (specifier.type !==
|
|
23897
|
+
if (specifier.type !== TSESTree11.AST_NODE_TYPES.ExportSpecifier)
|
|
23603
23898
|
continue;
|
|
23604
|
-
const localName = specifier.local.type ===
|
|
23605
|
-
const exportedName = specifier.exported.type ===
|
|
23899
|
+
const localName = specifier.local.type === TSESTree11.AST_NODE_TYPES.Identifier ? specifier.local.name : specifier.local.value;
|
|
23900
|
+
const exportedName = specifier.exported.type === TSESTree11.AST_NODE_TYPES.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
23606
23901
|
if (exportedName === "default") {
|
|
23607
23902
|
const tracked = trackedVariables.get(localName);
|
|
23608
23903
|
if (tracked) {
|
|
@@ -23618,10 +23913,10 @@ var require_react_display_names_default = createRule({
|
|
|
23618
23913
|
if (!isReactImport(node, reactSources))
|
|
23619
23914
|
return;
|
|
23620
23915
|
for (const specifier of node.specifiers) {
|
|
23621
|
-
if (specifier.type ===
|
|
23916
|
+
if (specifier.type === TSESTree11.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === TSESTree11.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
23622
23917
|
reactNamespaces.add(specifier.local.name);
|
|
23623
|
-
} else if (specifier.type ===
|
|
23624
|
-
const importedName = specifier.imported.type ===
|
|
23918
|
+
} else if (specifier.type === TSESTree11.AST_NODE_TYPES.ImportSpecifier) {
|
|
23919
|
+
const importedName = specifier.imported.type === TSESTree11.AST_NODE_TYPES.Identifier ? specifier.imported.name : specifier.imported.value;
|
|
23625
23920
|
if (importedName === "memo")
|
|
23626
23921
|
memoIdentifiers.add(specifier.local.name);
|
|
23627
23922
|
else if (importedName === "createContext")
|
|
@@ -23640,7 +23935,7 @@ var require_react_display_names_default = createRule({
|
|
|
23640
23935
|
if (variable)
|
|
23641
23936
|
isExported ||= variable.references.some(isReferenceExported);
|
|
23642
23937
|
const declarationParent = tracked.node.parent;
|
|
23643
|
-
if (declarationParent?.parent?.type ===
|
|
23938
|
+
if (declarationParent?.parent?.type === TSESTree11.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
23644
23939
|
isExported = true;
|
|
23645
23940
|
}
|
|
23646
23941
|
if (isExported) {
|
|
@@ -23653,12 +23948,12 @@ var require_react_display_names_default = createRule({
|
|
|
23653
23948
|
}
|
|
23654
23949
|
},
|
|
23655
23950
|
VariableDeclarator(node) {
|
|
23656
|
-
if (!node.init || node.init.type !==
|
|
23951
|
+
if (!node.init || node.init.type !== TSESTree11.AST_NODE_TYPES.CallExpression)
|
|
23657
23952
|
return;
|
|
23658
23953
|
const name = getVariableName(node);
|
|
23659
23954
|
if (!name)
|
|
23660
23955
|
return;
|
|
23661
|
-
if (
|
|
23956
|
+
if (isMemoCall2(node.init, memoIdentifiers, reactNamespaces)) {
|
|
23662
23957
|
trackedVariables.set(name, {
|
|
23663
23958
|
hasDisplayName: false,
|
|
23664
23959
|
isDefaultExported: false,
|
|
@@ -23678,7 +23973,7 @@ var require_react_display_names_default = createRule({
|
|
|
23678
23973
|
}
|
|
23679
23974
|
};
|
|
23680
23975
|
},
|
|
23681
|
-
defaultOptions: [
|
|
23976
|
+
defaultOptions: [DEFAULT_OPTIONS5],
|
|
23682
23977
|
meta: {
|
|
23683
23978
|
docs: {
|
|
23684
23979
|
description: "Require displayName property on exported React.memo components and React.createContext contexts for better debugging."
|
|
@@ -23819,16 +24114,16 @@ var strict_component_boundaries_default = createRule({
|
|
|
23819
24114
|
});
|
|
23820
24115
|
|
|
23821
24116
|
// src/rules/use-exhaustive-dependencies.ts
|
|
23822
|
-
import { TSESTree as
|
|
24117
|
+
import { TSESTree as TSESTree12 } from "@typescript-eslint/types";
|
|
23823
24118
|
var FUNCTION_DECLARATIONS = new Set([
|
|
23824
|
-
|
|
23825
|
-
|
|
23826
|
-
|
|
24119
|
+
TSESTree12.AST_NODE_TYPES.FunctionExpression,
|
|
24120
|
+
TSESTree12.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
24121
|
+
TSESTree12.AST_NODE_TYPES.FunctionDeclaration
|
|
23827
24122
|
]);
|
|
23828
24123
|
var UNSTABLE_VALUES = new Set([
|
|
23829
24124
|
...FUNCTION_DECLARATIONS,
|
|
23830
|
-
|
|
23831
|
-
|
|
24125
|
+
TSESTree12.AST_NODE_TYPES.ObjectExpression,
|
|
24126
|
+
TSESTree12.AST_NODE_TYPES.ArrayExpression
|
|
23832
24127
|
]);
|
|
23833
24128
|
var testingMetrics = {
|
|
23834
24129
|
moduleLevelStableConst: 0,
|
|
@@ -23912,9 +24207,9 @@ var GLOBAL_BUILTINS = new Set([
|
|
|
23912
24207
|
]);
|
|
23913
24208
|
function getHookName4(node) {
|
|
23914
24209
|
const { callee } = node;
|
|
23915
|
-
if (callee.type ===
|
|
24210
|
+
if (callee.type === TSESTree12.AST_NODE_TYPES.Identifier)
|
|
23916
24211
|
return callee.name;
|
|
23917
|
-
if (callee.type ===
|
|
24212
|
+
if (callee.type === TSESTree12.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree12.AST_NODE_TYPES.Identifier) {
|
|
23918
24213
|
return callee.property.name;
|
|
23919
24214
|
}
|
|
23920
24215
|
return;
|
|
@@ -23922,9 +24217,9 @@ function getHookName4(node) {
|
|
|
23922
24217
|
function getMemberExpressionDepth(node) {
|
|
23923
24218
|
let depth = 0;
|
|
23924
24219
|
let current = node;
|
|
23925
|
-
if (current.type ===
|
|
24220
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.ChainExpression)
|
|
23926
24221
|
current = current.expression;
|
|
23927
|
-
while (current.type ===
|
|
24222
|
+
while (current.type === TSESTree12.AST_NODE_TYPES.MemberExpression) {
|
|
23928
24223
|
depth += 1;
|
|
23929
24224
|
current = current.object;
|
|
23930
24225
|
}
|
|
@@ -23932,36 +24227,36 @@ function getMemberExpressionDepth(node) {
|
|
|
23932
24227
|
}
|
|
23933
24228
|
function getRootIdentifier(node) {
|
|
23934
24229
|
let current = node;
|
|
23935
|
-
if (current.type ===
|
|
24230
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.ChainExpression)
|
|
23936
24231
|
current = current.expression;
|
|
23937
|
-
while (current.type ===
|
|
23938
|
-
if (current.type ===
|
|
24232
|
+
while (current.type === TSESTree12.AST_NODE_TYPES.MemberExpression || current.type === TSESTree12.AST_NODE_TYPES.TSNonNullExpression) {
|
|
24233
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.MemberExpression)
|
|
23939
24234
|
current = current.object;
|
|
23940
24235
|
else
|
|
23941
24236
|
current = current.expression;
|
|
23942
24237
|
}
|
|
23943
|
-
return current.type ===
|
|
24238
|
+
return current.type === TSESTree12.AST_NODE_TYPES.Identifier ? current : undefined;
|
|
23944
24239
|
}
|
|
23945
24240
|
function nodeToDependencyString(node, sourceCode) {
|
|
23946
24241
|
return sourceCode.getText(node);
|
|
23947
24242
|
}
|
|
23948
24243
|
function nodeToSafeDependencyPath(node, sourceCode) {
|
|
23949
|
-
if (node.type ===
|
|
24244
|
+
if (node.type === TSESTree12.AST_NODE_TYPES.Identifier)
|
|
23950
24245
|
return node.name;
|
|
23951
|
-
if (node.type ===
|
|
24246
|
+
if (node.type === TSESTree12.AST_NODE_TYPES.ChainExpression) {
|
|
23952
24247
|
return nodeToSafeDependencyPath(node.expression, sourceCode);
|
|
23953
24248
|
}
|
|
23954
24249
|
if (TS_RUNTIME_EXPRESSIONS.has(node.type)) {
|
|
23955
24250
|
const expr = node;
|
|
23956
24251
|
return nodeToSafeDependencyPath(expr.expression, sourceCode);
|
|
23957
24252
|
}
|
|
23958
|
-
if (node.type ===
|
|
24253
|
+
if (node.type === TSESTree12.AST_NODE_TYPES.MemberExpression) {
|
|
23959
24254
|
const objectPath = nodeToSafeDependencyPath(node.object, sourceCode);
|
|
23960
24255
|
if (node.computed) {
|
|
23961
24256
|
const propertyText = sourceCode.getText(node.property);
|
|
23962
24257
|
return `${objectPath}[${propertyText}]`;
|
|
23963
24258
|
}
|
|
23964
|
-
const propertyName = node.property.type ===
|
|
24259
|
+
const propertyName = node.property.type === TSESTree12.AST_NODE_TYPES.Identifier ? node.property.name : "";
|
|
23965
24260
|
const separator = node.optional ? "?." : ".";
|
|
23966
24261
|
return `${objectPath}${separator}${propertyName}`;
|
|
23967
24262
|
}
|
|
@@ -23970,13 +24265,13 @@ function nodeToSafeDependencyPath(node, sourceCode) {
|
|
|
23970
24265
|
function isStableArrayIndex(stableResult, node, identifierName) {
|
|
23971
24266
|
if (!stableResult)
|
|
23972
24267
|
return false;
|
|
23973
|
-
if (!(stableResult instanceof Set) || node.type !==
|
|
24268
|
+
if (!(stableResult instanceof Set) || node.type !== TSESTree12.AST_NODE_TYPES.VariableDeclarator || node.id.type !== TSESTree12.AST_NODE_TYPES.ArrayPattern) {
|
|
23974
24269
|
return false;
|
|
23975
24270
|
}
|
|
23976
24271
|
const { elements } = node.id;
|
|
23977
24272
|
let index2 = 0;
|
|
23978
24273
|
for (const element of elements) {
|
|
23979
|
-
if (element.type ===
|
|
24274
|
+
if (element.type === TSESTree12.AST_NODE_TYPES.Identifier && element.name === identifierName) {
|
|
23980
24275
|
return stableResult.has(index2);
|
|
23981
24276
|
}
|
|
23982
24277
|
index2 += 1;
|
|
@@ -23985,7 +24280,7 @@ function isStableArrayIndex(stableResult, node, identifierName) {
|
|
|
23985
24280
|
}
|
|
23986
24281
|
function isStableHookValue(init, node, identifierName, stableHooks) {
|
|
23987
24282
|
const castInit = init;
|
|
23988
|
-
if (castInit.type !==
|
|
24283
|
+
if (castInit.type !== TSESTree12.AST_NODE_TYPES.CallExpression)
|
|
23989
24284
|
return false;
|
|
23990
24285
|
const hookName = getHookName4(castInit);
|
|
23991
24286
|
if (!hookName)
|
|
@@ -24005,35 +24300,35 @@ function isStableValue(variable, identifierName, stableHooks) {
|
|
|
24005
24300
|
const { node, type: type3 } = definition;
|
|
24006
24301
|
if (STABLE_VALUE_TYPES.has(type3))
|
|
24007
24302
|
return true;
|
|
24008
|
-
if (type3 === "Variable" && node.type ===
|
|
24303
|
+
if (type3 === "Variable" && node.type === TSESTree12.AST_NODE_TYPES.VariableDeclarator) {
|
|
24009
24304
|
const { parent } = node;
|
|
24010
|
-
if (!parent || parent.type !==
|
|
24305
|
+
if (!parent || parent.type !== TSESTree12.AST_NODE_TYPES.VariableDeclaration || parent.kind !== "const") {
|
|
24011
24306
|
continue;
|
|
24012
24307
|
}
|
|
24013
24308
|
const init = node.init;
|
|
24014
24309
|
if (init && isStableHookValue(init, node, identifierName, stableHooks))
|
|
24015
24310
|
return true;
|
|
24016
|
-
if (init?.type ===
|
|
24311
|
+
if (init?.type === TSESTree12.AST_NODE_TYPES.CallExpression) {
|
|
24017
24312
|
const { callee } = init;
|
|
24018
|
-
if (callee.type ===
|
|
24313
|
+
if (callee.type === TSESTree12.AST_NODE_TYPES.MemberExpression && callee.object.type === TSESTree12.AST_NODE_TYPES.Identifier && callee.object.name === "React" && callee.property.type === TSESTree12.AST_NODE_TYPES.Identifier && callee.property.name === "joinBindings") {
|
|
24019
24314
|
return true;
|
|
24020
24315
|
}
|
|
24021
|
-
if (callee.type ===
|
|
24316
|
+
if (callee.type === TSESTree12.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree12.AST_NODE_TYPES.Identifier && callee.property.name === "map") {
|
|
24022
24317
|
return true;
|
|
24023
24318
|
}
|
|
24024
24319
|
}
|
|
24025
24320
|
if (init) {
|
|
24026
|
-
if (init.type ===
|
|
24321
|
+
if (init.type === TSESTree12.AST_NODE_TYPES.Literal || init.type === TSESTree12.AST_NODE_TYPES.TemplateLiteral) {
|
|
24027
24322
|
return true;
|
|
24028
24323
|
}
|
|
24029
|
-
if (init.type ===
|
|
24324
|
+
if (init.type === TSESTree12.AST_NODE_TYPES.UnaryExpression && init.argument.type === TSESTree12.AST_NODE_TYPES.Literal) {
|
|
24030
24325
|
return true;
|
|
24031
24326
|
}
|
|
24032
24327
|
}
|
|
24033
24328
|
const variableDefinition = variable.defs.find((definition2) => definition2.node === node);
|
|
24034
|
-
if (variableDefinition && variableDefinition.node.type ===
|
|
24329
|
+
if (variableDefinition && variableDefinition.node.type === TSESTree12.AST_NODE_TYPES.VariableDeclarator) {
|
|
24035
24330
|
const declarationParent = variableDefinition.node.parent?.parent;
|
|
24036
|
-
if (declarationParent && (declarationParent.type ===
|
|
24331
|
+
if (declarationParent && (declarationParent.type === TSESTree12.AST_NODE_TYPES.Program || declarationParent.type === TSESTree12.AST_NODE_TYPES.ExportNamedDeclaration)) {
|
|
24037
24332
|
testingMetrics.moduleLevelStableConst += 1;
|
|
24038
24333
|
return true;
|
|
24039
24334
|
}
|
|
@@ -24046,14 +24341,14 @@ function findTopmostMemberExpression(node) {
|
|
|
24046
24341
|
let current = node;
|
|
24047
24342
|
let { parent } = node;
|
|
24048
24343
|
while (parent) {
|
|
24049
|
-
if (parent.type ===
|
|
24050
|
-
if (current.type ===
|
|
24344
|
+
if (parent.type === TSESTree12.AST_NODE_TYPES.CallExpression && parent.callee === current) {
|
|
24345
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.MemberExpression)
|
|
24051
24346
|
return current.object;
|
|
24052
24347
|
break;
|
|
24053
24348
|
}
|
|
24054
|
-
const isMemberParent = parent.type ===
|
|
24055
|
-
const isChainParent = parent.type ===
|
|
24056
|
-
const isNonNullParent = parent.type ===
|
|
24349
|
+
const isMemberParent = parent.type === TSESTree12.AST_NODE_TYPES.MemberExpression && parent.object === current;
|
|
24350
|
+
const isChainParent = parent.type === TSESTree12.AST_NODE_TYPES.ChainExpression;
|
|
24351
|
+
const isNonNullParent = parent.type === TSESTree12.AST_NODE_TYPES.TSNonNullExpression;
|
|
24057
24352
|
if (!(isMemberParent || isChainParent || isNonNullParent))
|
|
24058
24353
|
break;
|
|
24059
24354
|
current = parent;
|
|
@@ -24062,21 +24357,21 @@ function findTopmostMemberExpression(node) {
|
|
|
24062
24357
|
return current;
|
|
24063
24358
|
}
|
|
24064
24359
|
var IS_CEASE_BOUNDARY = new Set([
|
|
24065
|
-
|
|
24066
|
-
|
|
24067
|
-
|
|
24068
|
-
|
|
24360
|
+
TSESTree12.AST_NODE_TYPES.FunctionDeclaration,
|
|
24361
|
+
TSESTree12.AST_NODE_TYPES.FunctionExpression,
|
|
24362
|
+
TSESTree12.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
24363
|
+
TSESTree12.AST_NODE_TYPES.VariableDeclarator
|
|
24069
24364
|
]);
|
|
24070
24365
|
var TS_RUNTIME_EXPRESSIONS = new Set([
|
|
24071
|
-
|
|
24072
|
-
|
|
24073
|
-
|
|
24074
|
-
|
|
24075
|
-
|
|
24366
|
+
TSESTree12.AST_NODE_TYPES.TSNonNullExpression,
|
|
24367
|
+
TSESTree12.AST_NODE_TYPES.TSAsExpression,
|
|
24368
|
+
TSESTree12.AST_NODE_TYPES.TSSatisfiesExpression,
|
|
24369
|
+
TSESTree12.AST_NODE_TYPES.TSTypeAssertion,
|
|
24370
|
+
TSESTree12.AST_NODE_TYPES.TSInstantiationExpression
|
|
24076
24371
|
]);
|
|
24077
24372
|
function isComputedPropertyIdentifier(identifier3) {
|
|
24078
24373
|
const { parent } = identifier3;
|
|
24079
|
-
return parent?.type ===
|
|
24374
|
+
return parent?.type === TSESTree12.AST_NODE_TYPES.Property && parent.computed && parent.key === identifier3;
|
|
24080
24375
|
}
|
|
24081
24376
|
function isInTypePosition(identifier3) {
|
|
24082
24377
|
let parent = identifier3.parent;
|
|
@@ -24130,10 +24425,10 @@ function resolveFunctionReference(identifier3, scope) {
|
|
|
24130
24425
|
return;
|
|
24131
24426
|
for (const definition of variable.defs) {
|
|
24132
24427
|
const { node } = definition;
|
|
24133
|
-
if (node.type ===
|
|
24428
|
+
if (node.type === TSESTree12.AST_NODE_TYPES.FunctionDeclaration) {
|
|
24134
24429
|
return node;
|
|
24135
24430
|
}
|
|
24136
|
-
if (node.type ===
|
|
24431
|
+
if (node.type === TSESTree12.AST_NODE_TYPES.VariableDeclarator && node.init && (node.init.type === TSESTree12.AST_NODE_TYPES.ArrowFunctionExpression || node.init.type === TSESTree12.AST_NODE_TYPES.FunctionExpression)) {
|
|
24137
24432
|
return node.init;
|
|
24138
24433
|
}
|
|
24139
24434
|
}
|
|
@@ -24143,7 +24438,7 @@ function collectCaptures(node, sourceCode) {
|
|
|
24143
24438
|
const captures = new Array;
|
|
24144
24439
|
const captureSet = new Set;
|
|
24145
24440
|
function visit(current) {
|
|
24146
|
-
if (current.type ===
|
|
24441
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.Identifier) {
|
|
24147
24442
|
const { name } = current;
|
|
24148
24443
|
if (captureSet.has(name) || GLOBAL_BUILTINS.has(name) || isInTypePosition(current))
|
|
24149
24444
|
return;
|
|
@@ -24185,21 +24480,21 @@ function collectCaptures(node, sourceCode) {
|
|
|
24185
24480
|
}
|
|
24186
24481
|
}
|
|
24187
24482
|
}
|
|
24188
|
-
if (current.type ===
|
|
24483
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.TSSatisfiesExpression || current.type === TSESTree12.AST_NODE_TYPES.TSAsExpression || current.type === TSESTree12.AST_NODE_TYPES.TSTypeAssertion || current.type === TSESTree12.AST_NODE_TYPES.TSNonNullExpression) {
|
|
24189
24484
|
visit(current.expression);
|
|
24190
24485
|
return;
|
|
24191
24486
|
}
|
|
24192
|
-
if (current.type ===
|
|
24487
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.MemberExpression) {
|
|
24193
24488
|
visit(current.object);
|
|
24194
24489
|
if (current.computed)
|
|
24195
24490
|
visit(current.property);
|
|
24196
24491
|
return;
|
|
24197
24492
|
}
|
|
24198
|
-
if (current.type ===
|
|
24493
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.ChainExpression) {
|
|
24199
24494
|
visit(current.expression);
|
|
24200
24495
|
return;
|
|
24201
24496
|
}
|
|
24202
|
-
if (current.type ===
|
|
24497
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.Property) {
|
|
24203
24498
|
if (current.computed)
|
|
24204
24499
|
visit(current.key);
|
|
24205
24500
|
visit(current.value);
|
|
@@ -24224,7 +24519,7 @@ function parseDependencies(node, sourceCode) {
|
|
|
24224
24519
|
for (const element of node.elements) {
|
|
24225
24520
|
if (!element)
|
|
24226
24521
|
continue;
|
|
24227
|
-
const actualNode = element.type ===
|
|
24522
|
+
const actualNode = element.type === TSESTree12.AST_NODE_TYPES.SpreadElement ? element.argument : element;
|
|
24228
24523
|
const name = nodeToDependencyString(actualNode, sourceCode);
|
|
24229
24524
|
const depth = getMemberExpressionDepth(actualNode);
|
|
24230
24525
|
dependencies4.push({
|
|
@@ -24301,9 +24596,9 @@ var useExhaustiveDependencies = {
|
|
|
24301
24596
|
if (closureArgument === undefined)
|
|
24302
24597
|
return;
|
|
24303
24598
|
let closureFunction;
|
|
24304
|
-
if (closureArgument.type ===
|
|
24599
|
+
if (closureArgument.type === TSESTree12.AST_NODE_TYPES.ArrowFunctionExpression || closureArgument.type === TSESTree12.AST_NODE_TYPES.FunctionExpression) {
|
|
24305
24600
|
closureFunction = closureArgument;
|
|
24306
|
-
} else if (closureArgument.type ===
|
|
24601
|
+
} else if (closureArgument.type === TSESTree12.AST_NODE_TYPES.Identifier) {
|
|
24307
24602
|
const scope = getScope(callNode);
|
|
24308
24603
|
closureFunction = resolveFunctionReference(closureArgument, scope);
|
|
24309
24604
|
}
|
|
@@ -24337,7 +24632,7 @@ var useExhaustiveDependencies = {
|
|
|
24337
24632
|
}
|
|
24338
24633
|
if (!dependenciesArgument)
|
|
24339
24634
|
return;
|
|
24340
|
-
if (dependenciesArgument.type !==
|
|
24635
|
+
if (dependenciesArgument.type !== TSESTree12.AST_NODE_TYPES.ArrayExpression)
|
|
24341
24636
|
return;
|
|
24342
24637
|
const dependenciesArray = dependenciesArgument;
|
|
24343
24638
|
const captures = collectCaptures(closureFunction, context.sourceCode);
|
|
@@ -24547,7 +24842,7 @@ var useExhaustiveDependencies = {
|
|
|
24547
24842
|
var use_exhaustive_dependencies_default = useExhaustiveDependencies;
|
|
24548
24843
|
|
|
24549
24844
|
// src/rules/use-hook-at-top-level.ts
|
|
24550
|
-
import { TSESTree as
|
|
24845
|
+
import { TSESTree as TSESTree13 } from "@typescript-eslint/types";
|
|
24551
24846
|
var HOOK_NAME_PATTERN = /^use[A-Z]/;
|
|
24552
24847
|
var COMPONENT_NAME_PATTERN2 = /^[A-Z]/;
|
|
24553
24848
|
function isReactHook(name) {
|
|
@@ -24557,23 +24852,23 @@ function isComponent(name) {
|
|
|
24557
24852
|
return COMPONENT_NAME_PATTERN2.test(name);
|
|
24558
24853
|
}
|
|
24559
24854
|
function isComponentOrHook(node) {
|
|
24560
|
-
if (node.type ===
|
|
24855
|
+
if (node.type === TSESTree13.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
24561
24856
|
const { name } = node.id;
|
|
24562
24857
|
return isComponent(name) || isReactHook(name);
|
|
24563
24858
|
}
|
|
24564
|
-
if (node.type ===
|
|
24859
|
+
if (node.type === TSESTree13.AST_NODE_TYPES.FunctionExpression || node.type === TSESTree13.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
24565
24860
|
const { parent } = node;
|
|
24566
24861
|
if (parent === undefined)
|
|
24567
24862
|
return false;
|
|
24568
|
-
if (parent.type ===
|
|
24863
|
+
if (parent.type === TSESTree13.AST_NODE_TYPES.VariableDeclarator && parent.id.type === TSESTree13.AST_NODE_TYPES.Identifier) {
|
|
24569
24864
|
const { name } = parent.id;
|
|
24570
24865
|
return isComponent(name) || isReactHook(name);
|
|
24571
24866
|
}
|
|
24572
|
-
if (parent.type ===
|
|
24867
|
+
if (parent.type === TSESTree13.AST_NODE_TYPES.Property && parent.key.type === TSESTree13.AST_NODE_TYPES.Identifier) {
|
|
24573
24868
|
const { name } = parent.key;
|
|
24574
24869
|
return isComponent(name) || isReactHook(name);
|
|
24575
24870
|
}
|
|
24576
|
-
if (parent.type ===
|
|
24871
|
+
if (parent.type === TSESTree13.AST_NODE_TYPES.MethodDefinition && parent.key.type === TSESTree13.AST_NODE_TYPES.Identifier) {
|
|
24577
24872
|
const { name } = parent.key;
|
|
24578
24873
|
return isComponent(name) || isReactHook(name);
|
|
24579
24874
|
}
|
|
@@ -24582,17 +24877,17 @@ function isComponentOrHook(node) {
|
|
|
24582
24877
|
}
|
|
24583
24878
|
function isHookCall(node) {
|
|
24584
24879
|
const { callee } = node;
|
|
24585
|
-
if (callee.type ===
|
|
24880
|
+
if (callee.type === TSESTree13.AST_NODE_TYPES.Identifier)
|
|
24586
24881
|
return isReactHook(callee.name);
|
|
24587
|
-
if (callee.type ===
|
|
24882
|
+
if (callee.type === TSESTree13.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree13.AST_NODE_TYPES.Identifier) {
|
|
24588
24883
|
return isReactHook(callee.property.name);
|
|
24589
24884
|
}
|
|
24590
24885
|
return false;
|
|
24591
24886
|
}
|
|
24592
24887
|
var FUNCTION_BOUNDARIES2 = new Set([
|
|
24593
|
-
|
|
24594
|
-
|
|
24595
|
-
|
|
24888
|
+
TSESTree13.AST_NODE_TYPES.FunctionDeclaration,
|
|
24889
|
+
TSESTree13.AST_NODE_TYPES.FunctionExpression,
|
|
24890
|
+
TSESTree13.AST_NODE_TYPES.ArrowFunctionExpression
|
|
24596
24891
|
]);
|
|
24597
24892
|
function isInFinallyBlock(node) {
|
|
24598
24893
|
let current = node.parent;
|
|
@@ -24601,7 +24896,7 @@ function isInFinallyBlock(node) {
|
|
|
24601
24896
|
for (let depth = 0;depth < maxDepth && current; depth += 1) {
|
|
24602
24897
|
if (FUNCTION_BOUNDARIES2.has(current.type))
|
|
24603
24898
|
break;
|
|
24604
|
-
if (current.type ===
|
|
24899
|
+
if (current.type === TSESTree13.AST_NODE_TYPES.TryStatement) {
|
|
24605
24900
|
let checkNode = node;
|
|
24606
24901
|
while (checkNode && checkNode !== current) {
|
|
24607
24902
|
if (checkNode === current.finalizer) {
|
|
@@ -24649,14 +24944,14 @@ var useHookAtTopLevel = {
|
|
|
24649
24944
|
if (ignoreHooks?.includes(hookName))
|
|
24650
24945
|
return true;
|
|
24651
24946
|
if (importSources && Object.keys(importSources).length > 0) {
|
|
24652
|
-
if (node.callee.type ===
|
|
24653
|
-
const objectName = node.callee.object.type ===
|
|
24947
|
+
if (node.callee.type === TSESTree13.AST_NODE_TYPES.MemberExpression) {
|
|
24948
|
+
const objectName = node.callee.object.type === TSESTree13.AST_NODE_TYPES.Identifier ? node.callee.object.name : undefined;
|
|
24654
24949
|
if (objectName && importSources[objectName] === false)
|
|
24655
24950
|
return true;
|
|
24656
24951
|
if (objectName && importSources[objectName] === true)
|
|
24657
24952
|
return false;
|
|
24658
24953
|
}
|
|
24659
|
-
if (node.callee.type ===
|
|
24954
|
+
if (node.callee.type === TSESTree13.AST_NODE_TYPES.Identifier) {
|
|
24660
24955
|
const importSource = importSourceMap.get(hookName);
|
|
24661
24956
|
if (importSource && importSources[importSource] === false)
|
|
24662
24957
|
return true;
|
|
@@ -24671,7 +24966,7 @@ var useHookAtTopLevel = {
|
|
|
24671
24966
|
const current = getCurrentContext();
|
|
24672
24967
|
const depth = current ? current.functionDepth + 1 : 0;
|
|
24673
24968
|
const isComponentOrHookFlag = isComponentOrHook(functionNode);
|
|
24674
|
-
if (functionNode.type ===
|
|
24969
|
+
if (functionNode.type === TSESTree13.AST_NODE_TYPES.FunctionDeclaration && functionNode.id) {
|
|
24675
24970
|
currentFunctionName = functionNode.id.name;
|
|
24676
24971
|
}
|
|
24677
24972
|
if (current?.isComponentOrHook) {
|
|
@@ -24710,7 +25005,7 @@ var useHookAtTopLevel = {
|
|
|
24710
25005
|
if (!isHookCall(callNode))
|
|
24711
25006
|
return;
|
|
24712
25007
|
const { callee } = callNode;
|
|
24713
|
-
const hookName = callee.type ===
|
|
25008
|
+
const hookName = callee.type === TSESTree13.AST_NODE_TYPES.Identifier ? callee.name : callee.type === TSESTree13.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree13.AST_NODE_TYPES.Identifier ? callee.property.name : undefined;
|
|
24714
25009
|
if (!hookName || shouldIgnoreHook(hookName, callNode))
|
|
24715
25010
|
return;
|
|
24716
25011
|
const current = getCurrentContext();
|
|
@@ -24808,10 +25103,10 @@ var useHookAtTopLevel = {
|
|
|
24808
25103
|
if (!configuration.importSources || Object.keys(configuration.importSources).length === 0)
|
|
24809
25104
|
return;
|
|
24810
25105
|
for (const specifier of importNode.specifiers) {
|
|
24811
|
-
if (specifier.type !==
|
|
25106
|
+
if (specifier.type !== TSESTree13.AST_NODE_TYPES.ImportSpecifier)
|
|
24812
25107
|
continue;
|
|
24813
25108
|
const { imported } = specifier;
|
|
24814
|
-
if (imported.type !==
|
|
25109
|
+
if (imported.type !== TSESTree13.AST_NODE_TYPES.Identifier)
|
|
24815
25110
|
continue;
|
|
24816
25111
|
if (isReactHook(imported.name))
|
|
24817
25112
|
importSourceMap.set(specifier.local.name, source);
|
|
@@ -24920,6 +25215,9 @@ function createNoInstanceMethodsOptions(options3 = {}) {
|
|
|
24920
25215
|
...options3
|
|
24921
25216
|
};
|
|
24922
25217
|
}
|
|
25218
|
+
function createNoMemoChildrenOptions(options3 = {}) {
|
|
25219
|
+
return { allowedComponents: [], environment: "roblox-ts", ...options3 };
|
|
25220
|
+
}
|
|
24923
25221
|
function createNoShorthandOptions(options3 = {}) {
|
|
24924
25222
|
return { allowPropertyAccess: [], ignoreShorthands: [], shorthands: {}, ...options3 };
|
|
24925
25223
|
}
|
|
@@ -24987,9 +25285,15 @@ function createNoUselessUseSpringOptions(options3 = {}) {
|
|
|
24987
25285
|
function createPreferPatternReplacementsOptions(patterns2 = []) {
|
|
24988
25286
|
return { patterns: patterns2 };
|
|
24989
25287
|
}
|
|
25288
|
+
function createPreferEnumItemOptions(options3 = {}) {
|
|
25289
|
+
return { fixNumericToValue: false, performanceMode: false, ...options3 };
|
|
25290
|
+
}
|
|
24990
25291
|
function createRequireReactDisplayNamesOptions(options3 = {}) {
|
|
24991
25292
|
return { environment: "roblox-ts", ...options3 };
|
|
24992
25293
|
}
|
|
25294
|
+
function createRequireModuleLevelInstantiationOptions(options3 = {}) {
|
|
25295
|
+
return { classes: {}, ...options3 };
|
|
25296
|
+
}
|
|
24993
25297
|
|
|
24994
25298
|
// src/index.ts
|
|
24995
25299
|
var rules = {
|
|
@@ -25003,6 +25307,7 @@ var rules = {
|
|
|
25003
25307
|
"no-god-components": no_god_components_default,
|
|
25004
25308
|
"no-identity-map": no_identity_map_default,
|
|
25005
25309
|
"no-instance-methods-without-this": no_instance_methods_without_this_default,
|
|
25310
|
+
"no-memo-children": no_memo_children_default,
|
|
25006
25311
|
"no-print": no_print_default,
|
|
25007
25312
|
"no-shorthand-names": no_shorthand_names_default,
|
|
25008
25313
|
"no-useless-use-spring": no_useless_use_spring_default,
|
|
@@ -25017,6 +25322,7 @@ var rules = {
|
|
|
25017
25322
|
"prefer-singular-enums": prefer_singular_enums_default,
|
|
25018
25323
|
"prefer-udim2-shorthand": prefer_udim2_shorthand_default,
|
|
25019
25324
|
"react-hooks-strict-return": react_hooks_strict_return_default,
|
|
25325
|
+
"require-module-level-instantiation": require_module_level_instantiation_default,
|
|
25020
25326
|
"require-named-effect-functions": require_named_effect_functions_default,
|
|
25021
25327
|
"require-paired-calls": require_paired_calls_default,
|
|
25022
25328
|
"require-react-component-keys": require_react_component_keys_default,
|
|
@@ -25038,6 +25344,7 @@ var recommended = {
|
|
|
25038
25344
|
"cease-nonsense/no-god-components": "error",
|
|
25039
25345
|
"cease-nonsense/no-identity-map": "error",
|
|
25040
25346
|
"cease-nonsense/no-instance-methods-without-this": "error",
|
|
25347
|
+
"cease-nonsense/no-memo-children": "error",
|
|
25041
25348
|
"cease-nonsense/no-print": "error",
|
|
25042
25349
|
"cease-nonsense/no-shorthand-names": "error",
|
|
25043
25350
|
"cease-nonsense/no-warn": "error",
|
|
@@ -25063,11 +25370,14 @@ export {
|
|
|
25063
25370
|
createUseExhaustiveDependenciesOptions,
|
|
25064
25371
|
createRequireReactDisplayNamesOptions,
|
|
25065
25372
|
createRequirePairedCallsOptions,
|
|
25373
|
+
createRequireModuleLevelInstantiationOptions,
|
|
25066
25374
|
createReactKeysOptions,
|
|
25067
25375
|
createPreferPatternReplacementsOptions,
|
|
25376
|
+
createPreferEnumItemOptions,
|
|
25068
25377
|
createPairConfiguration,
|
|
25069
25378
|
createNoUselessUseSpringOptions,
|
|
25070
25379
|
createNoShorthandOptions,
|
|
25380
|
+
createNoMemoChildrenOptions,
|
|
25071
25381
|
createNoInstanceMethodsOptions,
|
|
25072
25382
|
createNoGodComponentsOptions,
|
|
25073
25383
|
createHookConfiguration,
|
|
@@ -25075,5 +25385,3 @@ export {
|
|
|
25075
25385
|
createComplexityConfiguration,
|
|
25076
25386
|
createBanInstancesOptions
|
|
25077
25387
|
};
|
|
25078
|
-
|
|
25079
|
-
//# debugId=A96F64DDBF4FBDA864756E2164756E21
|