@pobammer-ts/eslint-cease-nonsense-rules 1.14.1 → 1.15.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 +72 -0
- package/dist/build-metadata.json +3 -3
- package/dist/constants/react-sources.d.ts +4 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +400 -200
- 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-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 +7 -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 +5 -4
- 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)
|
|
@@ -21953,13 +22153,17 @@ var react_hooks_strict_return_default = createRule({
|
|
|
21953
22153
|
});
|
|
21954
22154
|
|
|
21955
22155
|
// src/rules/require-named-effect-functions.ts
|
|
21956
|
-
import { TSESTree as
|
|
22156
|
+
import { TSESTree as TSESTree9 } from "@typescript-eslint/types";
|
|
22157
|
+
|
|
22158
|
+
// src/types/environment-mode.ts
|
|
22159
|
+
var isEnvironmentMode = build_default.Union([build_default.Literal("roblox-ts"), build_default.Literal("standard")]);
|
|
22160
|
+
|
|
22161
|
+
// src/rules/require-named-effect-functions.ts
|
|
21957
22162
|
var DEFAULT_HOOKS = [
|
|
21958
22163
|
{ allowAsync: false, name: "useEffect" },
|
|
21959
22164
|
{ allowAsync: false, name: "useLayoutEffect" },
|
|
21960
22165
|
{ allowAsync: false, name: "useInsertionEffect" }
|
|
21961
22166
|
];
|
|
21962
|
-
var isEnvironmentMode = build_default.Union([build_default.Literal("roblox-ts"), build_default.Literal("standard")]);
|
|
21963
22167
|
var isHookConfiguration = build_default.Object({
|
|
21964
22168
|
allowAsync: build_default.Boolean(),
|
|
21965
22169
|
name: build_default.String()
|
|
@@ -21988,10 +22192,10 @@ function parseOptions2(options3) {
|
|
|
21988
22192
|
}
|
|
21989
22193
|
function getHookName3(callExpression) {
|
|
21990
22194
|
const { callee } = callExpression;
|
|
21991
|
-
if (callee.type ===
|
|
22195
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.Identifier && typeof callee.name === "string" && callee.name.length > 0) {
|
|
21992
22196
|
return callee.name;
|
|
21993
22197
|
}
|
|
21994
|
-
if (callee.type ===
|
|
22198
|
+
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
22199
|
return callee.property.name;
|
|
21996
22200
|
}
|
|
21997
22201
|
return;
|
|
@@ -22034,14 +22238,14 @@ function processFunctionExpression(init) {
|
|
|
22034
22238
|
}
|
|
22035
22239
|
function checkVariableDeclaratorDef(node) {
|
|
22036
22240
|
const castNode = node;
|
|
22037
|
-
if (castNode.type !==
|
|
22241
|
+
if (castNode.type !== TSESTree9.AST_NODE_TYPES.VariableDeclarator)
|
|
22038
22242
|
return;
|
|
22039
22243
|
if (typeof castNode.init !== "object" || castNode.init === null)
|
|
22040
22244
|
return;
|
|
22041
22245
|
const castInit = castNode.init;
|
|
22042
|
-
if (castInit.type ===
|
|
22246
|
+
if (castInit.type === TSESTree9.AST_NODE_TYPES.ArrowFunctionExpression)
|
|
22043
22247
|
return processArrowFunction(castNode.init);
|
|
22044
|
-
if (castInit.type ===
|
|
22248
|
+
if (castInit.type === TSESTree9.AST_NODE_TYPES.FunctionExpression)
|
|
22045
22249
|
return processFunctionExpression(castNode.init);
|
|
22046
22250
|
return;
|
|
22047
22251
|
}
|
|
@@ -22053,7 +22257,7 @@ function processSingleDefinition(definition) {
|
|
|
22053
22257
|
if (typeof node !== "object" || node === null)
|
|
22054
22258
|
return;
|
|
22055
22259
|
const castNode = node;
|
|
22056
|
-
if (castNode.type ===
|
|
22260
|
+
if (castNode.type === TSESTree9.AST_NODE_TYPES.FunctionDeclaration)
|
|
22057
22261
|
return processFunctionDeclaration(node);
|
|
22058
22262
|
return checkVariableDeclaratorDef(node);
|
|
22059
22263
|
}
|
|
@@ -22113,12 +22317,12 @@ function isCallbackHookResult(identifier3, context) {
|
|
|
22113
22317
|
if (typeof node !== "object" || node === null)
|
|
22114
22318
|
continue;
|
|
22115
22319
|
const castNode = node;
|
|
22116
|
-
if (castNode.type !==
|
|
22320
|
+
if (castNode.type !== TSESTree9.AST_NODE_TYPES.VariableDeclarator)
|
|
22117
22321
|
continue;
|
|
22118
22322
|
if (typeof castNode.init !== "object" || castNode.init === null)
|
|
22119
22323
|
continue;
|
|
22120
22324
|
const init = castNode.init;
|
|
22121
|
-
if (init.type !==
|
|
22325
|
+
if (init.type !== TSESTree9.AST_NODE_TYPES.CallExpression)
|
|
22122
22326
|
continue;
|
|
22123
22327
|
const calleeHookName = getHookName3(init);
|
|
22124
22328
|
if (calleeHookName === "useCallback" || calleeHookName === "useMemo")
|
|
@@ -22149,7 +22353,7 @@ var requireNamedEffectFunctions = {
|
|
|
22149
22353
|
if (firstArgument === undefined)
|
|
22150
22354
|
return;
|
|
22151
22355
|
const argumentNode = firstArgument;
|
|
22152
|
-
if (argumentNode.type ===
|
|
22356
|
+
if (argumentNode.type === TSESTree9.AST_NODE_TYPES.Identifier) {
|
|
22153
22357
|
const identifier3 = argumentNode;
|
|
22154
22358
|
const resolved = resolveIdentifierToFunction(identifier3, context);
|
|
22155
22359
|
if (resolved === undefined) {
|
|
@@ -22202,7 +22406,7 @@ var requireNamedEffectFunctions = {
|
|
|
22202
22406
|
}
|
|
22203
22407
|
return;
|
|
22204
22408
|
}
|
|
22205
|
-
if (argumentNode.type ===
|
|
22409
|
+
if (argumentNode.type === TSESTree9.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
22206
22410
|
if (argumentNode.async) {
|
|
22207
22411
|
context.report({
|
|
22208
22412
|
data: { hook: hookName },
|
|
@@ -22218,7 +22422,7 @@ var requireNamedEffectFunctions = {
|
|
|
22218
22422
|
}
|
|
22219
22423
|
return;
|
|
22220
22424
|
}
|
|
22221
|
-
if (argumentNode.type ===
|
|
22425
|
+
if (argumentNode.type === TSESTree9.AST_NODE_TYPES.FunctionExpression) {
|
|
22222
22426
|
const functionHasId = Boolean(argumentNode.id);
|
|
22223
22427
|
if (functionHasId && argumentNode.async) {
|
|
22224
22428
|
context.report({
|
|
@@ -23116,8 +23320,8 @@ var rule = {
|
|
|
23116
23320
|
var require_paired_calls_default = rule;
|
|
23117
23321
|
|
|
23118
23322
|
// src/rules/require-react-component-keys.ts
|
|
23119
|
-
import { TSESTree as
|
|
23120
|
-
var
|
|
23323
|
+
import { TSESTree as TSESTree10 } from "@typescript-eslint/types";
|
|
23324
|
+
var DEFAULT_OPTIONS4 = {
|
|
23121
23325
|
allowRootKeys: false,
|
|
23122
23326
|
ignoreCallExpressions: ["ReactTree.mount", "CreateReactStory"],
|
|
23123
23327
|
iterationMethods: [
|
|
@@ -23159,17 +23363,17 @@ function ascendPastWrappers(node) {
|
|
|
23159
23363
|
}
|
|
23160
23364
|
function hasKeyAttribute(node) {
|
|
23161
23365
|
for (const attribute of node.openingElement.attributes) {
|
|
23162
|
-
if (attribute.type ===
|
|
23366
|
+
if (attribute.type === TSESTree10.AST_NODE_TYPES.JSXAttribute && attribute.name.name === "key")
|
|
23163
23367
|
return true;
|
|
23164
23368
|
}
|
|
23165
23369
|
return false;
|
|
23166
23370
|
}
|
|
23167
23371
|
function isHigherOrderComponent(callExpr) {
|
|
23168
23372
|
const { callee } = callExpr;
|
|
23169
|
-
if (callee.type ===
|
|
23373
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
23170
23374
|
return callee.name === "forwardRef" || callee.name === "memo";
|
|
23171
23375
|
}
|
|
23172
|
-
if (callee.type ===
|
|
23376
|
+
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
23377
|
return callee.property.name === "forwardRef" || callee.property.name === "memo";
|
|
23174
23378
|
}
|
|
23175
23379
|
return false;
|
|
@@ -23177,7 +23381,7 @@ function isHigherOrderComponent(callExpr) {
|
|
|
23177
23381
|
function getEnclosingFunctionLike(node) {
|
|
23178
23382
|
let current = node.parent;
|
|
23179
23383
|
while (current) {
|
|
23180
|
-
if (current.type ===
|
|
23384
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression || current.type === TSESTree10.AST_NODE_TYPES.FunctionExpression || current.type === TSESTree10.AST_NODE_TYPES.FunctionDeclaration) {
|
|
23181
23385
|
return current;
|
|
23182
23386
|
}
|
|
23183
23387
|
current = current.parent;
|
|
@@ -23186,16 +23390,16 @@ function getEnclosingFunctionLike(node) {
|
|
|
23186
23390
|
}
|
|
23187
23391
|
function isIterationOrMemoCallback(callExpression, iterationMethods, memoizationHooks) {
|
|
23188
23392
|
const { callee } = callExpression;
|
|
23189
|
-
if (callee.type ===
|
|
23393
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.Identifier && memoizationHooks.has(callee.name))
|
|
23190
23394
|
return true;
|
|
23191
|
-
if (callee.type ===
|
|
23395
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
23192
23396
|
const { name } = callee.property;
|
|
23193
23397
|
if (iterationMethods.has(name))
|
|
23194
23398
|
return true;
|
|
23195
|
-
if (name === "from" && callee.object.type ===
|
|
23399
|
+
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
23400
|
return true;
|
|
23197
23401
|
}
|
|
23198
|
-
if (name === "call" && callee.object.type ===
|
|
23402
|
+
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
23403
|
return true;
|
|
23200
23404
|
}
|
|
23201
23405
|
}
|
|
@@ -23205,11 +23409,11 @@ function findEnclosingCallExpression(node) {
|
|
|
23205
23409
|
let current = node;
|
|
23206
23410
|
let { parent } = node;
|
|
23207
23411
|
while (parent) {
|
|
23208
|
-
if (parent.type ===
|
|
23412
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.CallExpression) {
|
|
23209
23413
|
for (const argument of parent.arguments) {
|
|
23210
23414
|
if (argument === current)
|
|
23211
23415
|
return parent;
|
|
23212
|
-
if (argument.type ===
|
|
23416
|
+
if (argument.type === TSESTree10.AST_NODE_TYPES.SpreadElement && argument.argument === current) {
|
|
23213
23417
|
return parent;
|
|
23214
23418
|
}
|
|
23215
23419
|
}
|
|
@@ -23225,7 +23429,7 @@ function findEnclosingCallExpression(node) {
|
|
|
23225
23429
|
return;
|
|
23226
23430
|
}
|
|
23227
23431
|
function getVariableForFunction(context, functionLike) {
|
|
23228
|
-
if (functionLike.type ===
|
|
23432
|
+
if (functionLike.type === TSESTree10.AST_NODE_TYPES.FunctionDeclaration) {
|
|
23229
23433
|
const declared = context.sourceCode.getDeclaredVariables(functionLike);
|
|
23230
23434
|
if (declared.length > 0)
|
|
23231
23435
|
return declared[0];
|
|
@@ -23234,7 +23438,7 @@ function getVariableForFunction(context, functionLike) {
|
|
|
23234
23438
|
const { parent } = functionLike;
|
|
23235
23439
|
if (!parent)
|
|
23236
23440
|
return;
|
|
23237
|
-
if (parent.type ===
|
|
23441
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.VariableDeclarator || parent.type === TSESTree10.AST_NODE_TYPES.AssignmentExpression) {
|
|
23238
23442
|
const declared = context.sourceCode.getDeclaredVariables(parent);
|
|
23239
23443
|
if (declared.length > 0)
|
|
23240
23444
|
return declared[0];
|
|
@@ -23268,33 +23472,33 @@ function isFunctionUsedAsCallback(context, functionLike, iterationMethods, memoi
|
|
|
23268
23472
|
return false;
|
|
23269
23473
|
}
|
|
23270
23474
|
var SHOULD_ASCEND_TYPES = new Set([
|
|
23271
|
-
|
|
23272
|
-
|
|
23475
|
+
TSESTree10.AST_NODE_TYPES.ConditionalExpression,
|
|
23476
|
+
TSESTree10.AST_NODE_TYPES.LogicalExpression
|
|
23273
23477
|
]);
|
|
23274
23478
|
var IS_FUNCTION_EXPRESSION = new Set([
|
|
23275
|
-
|
|
23276
|
-
|
|
23479
|
+
TSESTree10.AST_NODE_TYPES.FunctionExpression,
|
|
23480
|
+
TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression
|
|
23277
23481
|
]);
|
|
23278
23482
|
var CONTROL_FLOW_TYPES = new Set([
|
|
23279
|
-
|
|
23280
|
-
|
|
23281
|
-
|
|
23282
|
-
|
|
23283
|
-
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
|
|
23290
|
-
|
|
23291
|
-
|
|
23483
|
+
TSESTree10.AST_NODE_TYPES.BlockStatement,
|
|
23484
|
+
TSESTree10.AST_NODE_TYPES.IfStatement,
|
|
23485
|
+
TSESTree10.AST_NODE_TYPES.SwitchStatement,
|
|
23486
|
+
TSESTree10.AST_NODE_TYPES.SwitchCase,
|
|
23487
|
+
TSESTree10.AST_NODE_TYPES.TryStatement,
|
|
23488
|
+
TSESTree10.AST_NODE_TYPES.CatchClause,
|
|
23489
|
+
TSESTree10.AST_NODE_TYPES.WhileStatement,
|
|
23490
|
+
TSESTree10.AST_NODE_TYPES.DoWhileStatement,
|
|
23491
|
+
TSESTree10.AST_NODE_TYPES.ForStatement,
|
|
23492
|
+
TSESTree10.AST_NODE_TYPES.ForInStatement,
|
|
23493
|
+
TSESTree10.AST_NODE_TYPES.ForOfStatement,
|
|
23494
|
+
TSESTree10.AST_NODE_TYPES.LabeledStatement,
|
|
23495
|
+
TSESTree10.AST_NODE_TYPES.WithStatement
|
|
23292
23496
|
]);
|
|
23293
23497
|
function isTopLevelReturn(node) {
|
|
23294
23498
|
let parent = ascendPastWrappers(node.parent);
|
|
23295
23499
|
if (!parent)
|
|
23296
23500
|
return false;
|
|
23297
|
-
if (parent.type ===
|
|
23501
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.JSXExpressionContainer)
|
|
23298
23502
|
parent = ascendPastWrappers(parent.parent);
|
|
23299
23503
|
if (!parent)
|
|
23300
23504
|
return false;
|
|
@@ -23302,11 +23506,11 @@ function isTopLevelReturn(node) {
|
|
|
23302
23506
|
parent = ascendPastWrappers(parent.parent);
|
|
23303
23507
|
if (!parent)
|
|
23304
23508
|
return false;
|
|
23305
|
-
if (parent.type ===
|
|
23509
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.JSXExpressionContainer)
|
|
23306
23510
|
parent = ascendPastWrappers(parent.parent);
|
|
23307
23511
|
if (!parent)
|
|
23308
23512
|
return false;
|
|
23309
|
-
if (parent.type ===
|
|
23513
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.ReturnStatement) {
|
|
23310
23514
|
let currentNode = ascendPastWrappers(parent.parent);
|
|
23311
23515
|
while (currentNode && CONTROL_FLOW_TYPES.has(currentNode.type)) {
|
|
23312
23516
|
currentNode = ascendPastWrappers(currentNode.parent);
|
|
@@ -23315,16 +23519,16 @@ function isTopLevelReturn(node) {
|
|
|
23315
23519
|
return false;
|
|
23316
23520
|
if (IS_FUNCTION_EXPRESSION.has(currentNode.type)) {
|
|
23317
23521
|
const functionParent = ascendPastWrappers(currentNode.parent);
|
|
23318
|
-
if (functionParent?.type ===
|
|
23522
|
+
if (functionParent?.type === TSESTree10.AST_NODE_TYPES.CallExpression) {
|
|
23319
23523
|
return isHigherOrderComponent(functionParent);
|
|
23320
23524
|
}
|
|
23321
23525
|
return true;
|
|
23322
23526
|
}
|
|
23323
|
-
return currentNode.type ===
|
|
23527
|
+
return currentNode.type === TSESTree10.AST_NODE_TYPES.FunctionDeclaration;
|
|
23324
23528
|
}
|
|
23325
|
-
if (parent.type ===
|
|
23529
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
23326
23530
|
const functionParent = ascendPastWrappers(parent.parent);
|
|
23327
|
-
if (functionParent?.type ===
|
|
23531
|
+
if (functionParent?.type === TSESTree10.AST_NODE_TYPES.CallExpression) {
|
|
23328
23532
|
return isHigherOrderComponent(functionParent);
|
|
23329
23533
|
}
|
|
23330
23534
|
return true;
|
|
@@ -23335,7 +23539,7 @@ function isIgnoredCallExpression(node, ignoreList) {
|
|
|
23335
23539
|
let parent = node.parent;
|
|
23336
23540
|
if (!parent)
|
|
23337
23541
|
return false;
|
|
23338
|
-
if (parent.type ===
|
|
23542
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
23339
23543
|
({ parent } = parent);
|
|
23340
23544
|
if (!parent)
|
|
23341
23545
|
return false;
|
|
@@ -23343,11 +23547,11 @@ function isIgnoredCallExpression(node, ignoreList) {
|
|
|
23343
23547
|
const maxDepth = 20;
|
|
23344
23548
|
for (let depth = 0;depth < maxDepth && parent; depth += 1) {
|
|
23345
23549
|
const { type: type3 } = parent;
|
|
23346
|
-
if (type3 ===
|
|
23550
|
+
if (type3 === TSESTree10.AST_NODE_TYPES.CallExpression) {
|
|
23347
23551
|
const { callee } = parent;
|
|
23348
|
-
if (callee.type ===
|
|
23552
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.Identifier)
|
|
23349
23553
|
return ignoreList.includes(callee.name);
|
|
23350
|
-
if (callee.type ===
|
|
23554
|
+
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
23555
|
return ignoreList.includes(`${callee.object.name}.${callee.property.name}`);
|
|
23352
23556
|
}
|
|
23353
23557
|
return false;
|
|
@@ -23360,41 +23564,41 @@ function isJSXPropValue(node) {
|
|
|
23360
23564
|
let { parent } = node;
|
|
23361
23565
|
if (!parent)
|
|
23362
23566
|
return false;
|
|
23363
|
-
while (parent && (parent.type ===
|
|
23567
|
+
while (parent && (parent.type === TSESTree10.AST_NODE_TYPES.ConditionalExpression || parent.type === TSESTree10.AST_NODE_TYPES.LogicalExpression)) {
|
|
23364
23568
|
({ parent } = parent);
|
|
23365
23569
|
}
|
|
23366
23570
|
if (!parent)
|
|
23367
23571
|
return false;
|
|
23368
|
-
if (parent.type ===
|
|
23572
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
23369
23573
|
({ parent } = parent);
|
|
23370
23574
|
if (!parent)
|
|
23371
23575
|
return false;
|
|
23372
23576
|
}
|
|
23373
|
-
return parent.type ===
|
|
23577
|
+
return parent.type === TSESTree10.AST_NODE_TYPES.JSXAttribute;
|
|
23374
23578
|
}
|
|
23375
23579
|
function isTernaryJSXChild(node) {
|
|
23376
23580
|
let current = node.parent;
|
|
23377
23581
|
if (!current)
|
|
23378
23582
|
return false;
|
|
23379
23583
|
let foundTernary = false;
|
|
23380
|
-
while (current && (current.type ===
|
|
23381
|
-
if (current.type ===
|
|
23584
|
+
while (current && (current.type === TSESTree10.AST_NODE_TYPES.ConditionalExpression || WRAPPER_PARENT_TYPES.has(current.type))) {
|
|
23585
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.ConditionalExpression)
|
|
23382
23586
|
foundTernary = true;
|
|
23383
23587
|
current = current.parent;
|
|
23384
23588
|
}
|
|
23385
23589
|
if (!(foundTernary && current))
|
|
23386
23590
|
return false;
|
|
23387
|
-
if (current.type !==
|
|
23591
|
+
if (current.type !== TSESTree10.AST_NODE_TYPES.JSXExpressionContainer)
|
|
23388
23592
|
return false;
|
|
23389
23593
|
const containerParent = current.parent;
|
|
23390
23594
|
if (!containerParent)
|
|
23391
23595
|
return false;
|
|
23392
|
-
return containerParent.type ===
|
|
23596
|
+
return containerParent.type === TSESTree10.AST_NODE_TYPES.JSXElement || containerParent.type === TSESTree10.AST_NODE_TYPES.JSXFragment;
|
|
23393
23597
|
}
|
|
23394
23598
|
var require_react_component_keys_default = createRule({
|
|
23395
23599
|
create(context) {
|
|
23396
23600
|
const options3 = {
|
|
23397
|
-
...
|
|
23601
|
+
...DEFAULT_OPTIONS4,
|
|
23398
23602
|
...context.options[0]
|
|
23399
23603
|
};
|
|
23400
23604
|
const iterationMethods = new Set(options3.iterationMethods);
|
|
@@ -23404,7 +23608,7 @@ var require_react_component_keys_default = createRule({
|
|
|
23404
23608
|
const isCallback = functionLike ? isFunctionUsedAsCallback(context, functionLike, iterationMethods, memoizationHooks) : false;
|
|
23405
23609
|
const isRoot = isTopLevelReturn(node);
|
|
23406
23610
|
if (isRoot && !isCallback) {
|
|
23407
|
-
if (!options3.allowRootKeys && node.type ===
|
|
23611
|
+
if (!options3.allowRootKeys && node.type === TSESTree10.AST_NODE_TYPES.JSXElement && hasKeyAttribute(node)) {
|
|
23408
23612
|
context.report({
|
|
23409
23613
|
messageId: "rootComponentWithKey",
|
|
23410
23614
|
node
|
|
@@ -23418,7 +23622,7 @@ var require_react_component_keys_default = createRule({
|
|
|
23418
23622
|
return;
|
|
23419
23623
|
if (isTernaryJSXChild(node))
|
|
23420
23624
|
return;
|
|
23421
|
-
if (node.type ===
|
|
23625
|
+
if (node.type === TSESTree10.AST_NODE_TYPES.JSXFragment) {
|
|
23422
23626
|
context.report({
|
|
23423
23627
|
messageId: "missingKey",
|
|
23424
23628
|
node
|
|
@@ -23441,7 +23645,7 @@ var require_react_component_keys_default = createRule({
|
|
|
23441
23645
|
}
|
|
23442
23646
|
};
|
|
23443
23647
|
},
|
|
23444
|
-
defaultOptions: [
|
|
23648
|
+
defaultOptions: [DEFAULT_OPTIONS4],
|
|
23445
23649
|
meta: {
|
|
23446
23650
|
docs: {
|
|
23447
23651
|
description: "Require keys on React components when used in lists or iteration."
|
|
@@ -23498,38 +23702,30 @@ var require_react_component_keys_default = createRule({
|
|
|
23498
23702
|
});
|
|
23499
23703
|
|
|
23500
23704
|
// src/rules/require-react-display-names.ts
|
|
23501
|
-
import { TSESTree as
|
|
23502
|
-
var
|
|
23705
|
+
import { TSESTree as TSESTree11 } from "@typescript-eslint/types";
|
|
23706
|
+
var DEFAULT_OPTIONS5 = {
|
|
23503
23707
|
environment: "roblox-ts"
|
|
23504
23708
|
};
|
|
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) {
|
|
23709
|
+
function isMemoCall2(node, memoIdentifiers, reactNamespaces) {
|
|
23514
23710
|
const { callee } = node;
|
|
23515
|
-
if (callee.type ===
|
|
23711
|
+
if (callee.type === TSESTree11.AST_NODE_TYPES.Identifier)
|
|
23516
23712
|
return memoIdentifiers.has(callee.name);
|
|
23517
|
-
if (callee.type ===
|
|
23713
|
+
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
23714
|
return reactNamespaces.has(callee.object.name) && callee.property.name === "memo";
|
|
23519
23715
|
}
|
|
23520
23716
|
return false;
|
|
23521
23717
|
}
|
|
23522
23718
|
function isCreateContextCall(node, createContextIdentifiers, reactNamespaces) {
|
|
23523
23719
|
const { callee } = node;
|
|
23524
|
-
if (callee.type ===
|
|
23720
|
+
if (callee.type === TSESTree11.AST_NODE_TYPES.Identifier)
|
|
23525
23721
|
return createContextIdentifiers.has(callee.name);
|
|
23526
|
-
if (callee.type ===
|
|
23722
|
+
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
23723
|
return reactNamespaces.has(callee.object.name) && callee.property.name === "createContext";
|
|
23528
23724
|
}
|
|
23529
23725
|
return false;
|
|
23530
23726
|
}
|
|
23531
23727
|
function getVariableName(node) {
|
|
23532
|
-
if (node.id.type ===
|
|
23728
|
+
if (node.id.type === TSESTree11.AST_NODE_TYPES.Identifier)
|
|
23533
23729
|
return node.id.name;
|
|
23534
23730
|
return;
|
|
23535
23731
|
}
|
|
@@ -23537,9 +23733,9 @@ function isNodeInExport(node) {
|
|
|
23537
23733
|
let current = node;
|
|
23538
23734
|
while (current) {
|
|
23539
23735
|
const { type: type3 } = current;
|
|
23540
|
-
if (type3 ===
|
|
23736
|
+
if (type3 === TSESTree11.AST_NODE_TYPES.ExportNamedDeclaration)
|
|
23541
23737
|
return true;
|
|
23542
|
-
if (type3 ===
|
|
23738
|
+
if (type3 === TSESTree11.AST_NODE_TYPES.ExportDefaultDeclaration)
|
|
23543
23739
|
return true;
|
|
23544
23740
|
current = current.parent;
|
|
23545
23741
|
}
|
|
@@ -23551,7 +23747,7 @@ function isReferenceExported(reference) {
|
|
|
23551
23747
|
var require_react_display_names_default = createRule({
|
|
23552
23748
|
create(context) {
|
|
23553
23749
|
const options3 = {
|
|
23554
|
-
...
|
|
23750
|
+
...DEFAULT_OPTIONS5,
|
|
23555
23751
|
...context.options[0]
|
|
23556
23752
|
};
|
|
23557
23753
|
const reactSources = getReactSources(options3.environment);
|
|
@@ -23563,14 +23759,14 @@ var require_react_display_names_default = createRule({
|
|
|
23563
23759
|
return {
|
|
23564
23760
|
"AssignmentExpression[left.type='MemberExpression'][left.property.name='displayName']"(node) {
|
|
23565
23761
|
const left = node.left;
|
|
23566
|
-
if (left.object.type ===
|
|
23762
|
+
if (left.object.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
23567
23763
|
displayNameAssignments.add(left.object.name);
|
|
23568
23764
|
}
|
|
23569
23765
|
},
|
|
23570
23766
|
ExportDefaultDeclaration(node) {
|
|
23571
23767
|
const { declaration } = node;
|
|
23572
|
-
if (declaration.type ===
|
|
23573
|
-
if (
|
|
23768
|
+
if (declaration.type === TSESTree11.AST_NODE_TYPES.CallExpression) {
|
|
23769
|
+
if (isMemoCall2(declaration, memoIdentifiers, reactNamespaces)) {
|
|
23574
23770
|
context.report({
|
|
23575
23771
|
messageId: "directMemoExport",
|
|
23576
23772
|
node
|
|
@@ -23585,7 +23781,7 @@ var require_react_display_names_default = createRule({
|
|
|
23585
23781
|
return;
|
|
23586
23782
|
}
|
|
23587
23783
|
}
|
|
23588
|
-
if (declaration.type ===
|
|
23784
|
+
if (declaration.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
23589
23785
|
const tracked = trackedVariables.get(declaration.name);
|
|
23590
23786
|
if (tracked) {
|
|
23591
23787
|
trackedVariables.set(declaration.name, {
|
|
@@ -23599,10 +23795,10 @@ var require_react_display_names_default = createRule({
|
|
|
23599
23795
|
if (!node.specifiers)
|
|
23600
23796
|
return;
|
|
23601
23797
|
for (const specifier of node.specifiers) {
|
|
23602
|
-
if (specifier.type !==
|
|
23798
|
+
if (specifier.type !== TSESTree11.AST_NODE_TYPES.ExportSpecifier)
|
|
23603
23799
|
continue;
|
|
23604
|
-
const localName = specifier.local.type ===
|
|
23605
|
-
const exportedName = specifier.exported.type ===
|
|
23800
|
+
const localName = specifier.local.type === TSESTree11.AST_NODE_TYPES.Identifier ? specifier.local.name : specifier.local.value;
|
|
23801
|
+
const exportedName = specifier.exported.type === TSESTree11.AST_NODE_TYPES.Identifier ? specifier.exported.name : specifier.exported.value;
|
|
23606
23802
|
if (exportedName === "default") {
|
|
23607
23803
|
const tracked = trackedVariables.get(localName);
|
|
23608
23804
|
if (tracked) {
|
|
@@ -23618,10 +23814,10 @@ var require_react_display_names_default = createRule({
|
|
|
23618
23814
|
if (!isReactImport(node, reactSources))
|
|
23619
23815
|
return;
|
|
23620
23816
|
for (const specifier of node.specifiers) {
|
|
23621
|
-
if (specifier.type ===
|
|
23817
|
+
if (specifier.type === TSESTree11.AST_NODE_TYPES.ImportDefaultSpecifier || specifier.type === TSESTree11.AST_NODE_TYPES.ImportNamespaceSpecifier) {
|
|
23622
23818
|
reactNamespaces.add(specifier.local.name);
|
|
23623
|
-
} else if (specifier.type ===
|
|
23624
|
-
const importedName = specifier.imported.type ===
|
|
23819
|
+
} else if (specifier.type === TSESTree11.AST_NODE_TYPES.ImportSpecifier) {
|
|
23820
|
+
const importedName = specifier.imported.type === TSESTree11.AST_NODE_TYPES.Identifier ? specifier.imported.name : specifier.imported.value;
|
|
23625
23821
|
if (importedName === "memo")
|
|
23626
23822
|
memoIdentifiers.add(specifier.local.name);
|
|
23627
23823
|
else if (importedName === "createContext")
|
|
@@ -23640,7 +23836,7 @@ var require_react_display_names_default = createRule({
|
|
|
23640
23836
|
if (variable)
|
|
23641
23837
|
isExported ||= variable.references.some(isReferenceExported);
|
|
23642
23838
|
const declarationParent = tracked.node.parent;
|
|
23643
|
-
if (declarationParent?.parent?.type ===
|
|
23839
|
+
if (declarationParent?.parent?.type === TSESTree11.AST_NODE_TYPES.ExportNamedDeclaration) {
|
|
23644
23840
|
isExported = true;
|
|
23645
23841
|
}
|
|
23646
23842
|
if (isExported) {
|
|
@@ -23653,12 +23849,12 @@ var require_react_display_names_default = createRule({
|
|
|
23653
23849
|
}
|
|
23654
23850
|
},
|
|
23655
23851
|
VariableDeclarator(node) {
|
|
23656
|
-
if (!node.init || node.init.type !==
|
|
23852
|
+
if (!node.init || node.init.type !== TSESTree11.AST_NODE_TYPES.CallExpression)
|
|
23657
23853
|
return;
|
|
23658
23854
|
const name = getVariableName(node);
|
|
23659
23855
|
if (!name)
|
|
23660
23856
|
return;
|
|
23661
|
-
if (
|
|
23857
|
+
if (isMemoCall2(node.init, memoIdentifiers, reactNamespaces)) {
|
|
23662
23858
|
trackedVariables.set(name, {
|
|
23663
23859
|
hasDisplayName: false,
|
|
23664
23860
|
isDefaultExported: false,
|
|
@@ -23678,7 +23874,7 @@ var require_react_display_names_default = createRule({
|
|
|
23678
23874
|
}
|
|
23679
23875
|
};
|
|
23680
23876
|
},
|
|
23681
|
-
defaultOptions: [
|
|
23877
|
+
defaultOptions: [DEFAULT_OPTIONS5],
|
|
23682
23878
|
meta: {
|
|
23683
23879
|
docs: {
|
|
23684
23880
|
description: "Require displayName property on exported React.memo components and React.createContext contexts for better debugging."
|
|
@@ -23819,16 +24015,16 @@ var strict_component_boundaries_default = createRule({
|
|
|
23819
24015
|
});
|
|
23820
24016
|
|
|
23821
24017
|
// src/rules/use-exhaustive-dependencies.ts
|
|
23822
|
-
import { TSESTree as
|
|
24018
|
+
import { TSESTree as TSESTree12 } from "@typescript-eslint/types";
|
|
23823
24019
|
var FUNCTION_DECLARATIONS = new Set([
|
|
23824
|
-
|
|
23825
|
-
|
|
23826
|
-
|
|
24020
|
+
TSESTree12.AST_NODE_TYPES.FunctionExpression,
|
|
24021
|
+
TSESTree12.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
24022
|
+
TSESTree12.AST_NODE_TYPES.FunctionDeclaration
|
|
23827
24023
|
]);
|
|
23828
24024
|
var UNSTABLE_VALUES = new Set([
|
|
23829
24025
|
...FUNCTION_DECLARATIONS,
|
|
23830
|
-
|
|
23831
|
-
|
|
24026
|
+
TSESTree12.AST_NODE_TYPES.ObjectExpression,
|
|
24027
|
+
TSESTree12.AST_NODE_TYPES.ArrayExpression
|
|
23832
24028
|
]);
|
|
23833
24029
|
var testingMetrics = {
|
|
23834
24030
|
moduleLevelStableConst: 0,
|
|
@@ -23912,9 +24108,9 @@ var GLOBAL_BUILTINS = new Set([
|
|
|
23912
24108
|
]);
|
|
23913
24109
|
function getHookName4(node) {
|
|
23914
24110
|
const { callee } = node;
|
|
23915
|
-
if (callee.type ===
|
|
24111
|
+
if (callee.type === TSESTree12.AST_NODE_TYPES.Identifier)
|
|
23916
24112
|
return callee.name;
|
|
23917
|
-
if (callee.type ===
|
|
24113
|
+
if (callee.type === TSESTree12.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree12.AST_NODE_TYPES.Identifier) {
|
|
23918
24114
|
return callee.property.name;
|
|
23919
24115
|
}
|
|
23920
24116
|
return;
|
|
@@ -23922,9 +24118,9 @@ function getHookName4(node) {
|
|
|
23922
24118
|
function getMemberExpressionDepth(node) {
|
|
23923
24119
|
let depth = 0;
|
|
23924
24120
|
let current = node;
|
|
23925
|
-
if (current.type ===
|
|
24121
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.ChainExpression)
|
|
23926
24122
|
current = current.expression;
|
|
23927
|
-
while (current.type ===
|
|
24123
|
+
while (current.type === TSESTree12.AST_NODE_TYPES.MemberExpression) {
|
|
23928
24124
|
depth += 1;
|
|
23929
24125
|
current = current.object;
|
|
23930
24126
|
}
|
|
@@ -23932,36 +24128,36 @@ function getMemberExpressionDepth(node) {
|
|
|
23932
24128
|
}
|
|
23933
24129
|
function getRootIdentifier(node) {
|
|
23934
24130
|
let current = node;
|
|
23935
|
-
if (current.type ===
|
|
24131
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.ChainExpression)
|
|
23936
24132
|
current = current.expression;
|
|
23937
|
-
while (current.type ===
|
|
23938
|
-
if (current.type ===
|
|
24133
|
+
while (current.type === TSESTree12.AST_NODE_TYPES.MemberExpression || current.type === TSESTree12.AST_NODE_TYPES.TSNonNullExpression) {
|
|
24134
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.MemberExpression)
|
|
23939
24135
|
current = current.object;
|
|
23940
24136
|
else
|
|
23941
24137
|
current = current.expression;
|
|
23942
24138
|
}
|
|
23943
|
-
return current.type ===
|
|
24139
|
+
return current.type === TSESTree12.AST_NODE_TYPES.Identifier ? current : undefined;
|
|
23944
24140
|
}
|
|
23945
24141
|
function nodeToDependencyString(node, sourceCode) {
|
|
23946
24142
|
return sourceCode.getText(node);
|
|
23947
24143
|
}
|
|
23948
24144
|
function nodeToSafeDependencyPath(node, sourceCode) {
|
|
23949
|
-
if (node.type ===
|
|
24145
|
+
if (node.type === TSESTree12.AST_NODE_TYPES.Identifier)
|
|
23950
24146
|
return node.name;
|
|
23951
|
-
if (node.type ===
|
|
24147
|
+
if (node.type === TSESTree12.AST_NODE_TYPES.ChainExpression) {
|
|
23952
24148
|
return nodeToSafeDependencyPath(node.expression, sourceCode);
|
|
23953
24149
|
}
|
|
23954
24150
|
if (TS_RUNTIME_EXPRESSIONS.has(node.type)) {
|
|
23955
24151
|
const expr = node;
|
|
23956
24152
|
return nodeToSafeDependencyPath(expr.expression, sourceCode);
|
|
23957
24153
|
}
|
|
23958
|
-
if (node.type ===
|
|
24154
|
+
if (node.type === TSESTree12.AST_NODE_TYPES.MemberExpression) {
|
|
23959
24155
|
const objectPath = nodeToSafeDependencyPath(node.object, sourceCode);
|
|
23960
24156
|
if (node.computed) {
|
|
23961
24157
|
const propertyText = sourceCode.getText(node.property);
|
|
23962
24158
|
return `${objectPath}[${propertyText}]`;
|
|
23963
24159
|
}
|
|
23964
|
-
const propertyName = node.property.type ===
|
|
24160
|
+
const propertyName = node.property.type === TSESTree12.AST_NODE_TYPES.Identifier ? node.property.name : "";
|
|
23965
24161
|
const separator = node.optional ? "?." : ".";
|
|
23966
24162
|
return `${objectPath}${separator}${propertyName}`;
|
|
23967
24163
|
}
|
|
@@ -23970,13 +24166,13 @@ function nodeToSafeDependencyPath(node, sourceCode) {
|
|
|
23970
24166
|
function isStableArrayIndex(stableResult, node, identifierName) {
|
|
23971
24167
|
if (!stableResult)
|
|
23972
24168
|
return false;
|
|
23973
|
-
if (!(stableResult instanceof Set) || node.type !==
|
|
24169
|
+
if (!(stableResult instanceof Set) || node.type !== TSESTree12.AST_NODE_TYPES.VariableDeclarator || node.id.type !== TSESTree12.AST_NODE_TYPES.ArrayPattern) {
|
|
23974
24170
|
return false;
|
|
23975
24171
|
}
|
|
23976
24172
|
const { elements } = node.id;
|
|
23977
24173
|
let index2 = 0;
|
|
23978
24174
|
for (const element of elements) {
|
|
23979
|
-
if (element.type ===
|
|
24175
|
+
if (element.type === TSESTree12.AST_NODE_TYPES.Identifier && element.name === identifierName) {
|
|
23980
24176
|
return stableResult.has(index2);
|
|
23981
24177
|
}
|
|
23982
24178
|
index2 += 1;
|
|
@@ -23985,7 +24181,7 @@ function isStableArrayIndex(stableResult, node, identifierName) {
|
|
|
23985
24181
|
}
|
|
23986
24182
|
function isStableHookValue(init, node, identifierName, stableHooks) {
|
|
23987
24183
|
const castInit = init;
|
|
23988
|
-
if (castInit.type !==
|
|
24184
|
+
if (castInit.type !== TSESTree12.AST_NODE_TYPES.CallExpression)
|
|
23989
24185
|
return false;
|
|
23990
24186
|
const hookName = getHookName4(castInit);
|
|
23991
24187
|
if (!hookName)
|
|
@@ -24005,35 +24201,35 @@ function isStableValue(variable, identifierName, stableHooks) {
|
|
|
24005
24201
|
const { node, type: type3 } = definition;
|
|
24006
24202
|
if (STABLE_VALUE_TYPES.has(type3))
|
|
24007
24203
|
return true;
|
|
24008
|
-
if (type3 === "Variable" && node.type ===
|
|
24204
|
+
if (type3 === "Variable" && node.type === TSESTree12.AST_NODE_TYPES.VariableDeclarator) {
|
|
24009
24205
|
const { parent } = node;
|
|
24010
|
-
if (!parent || parent.type !==
|
|
24206
|
+
if (!parent || parent.type !== TSESTree12.AST_NODE_TYPES.VariableDeclaration || parent.kind !== "const") {
|
|
24011
24207
|
continue;
|
|
24012
24208
|
}
|
|
24013
24209
|
const init = node.init;
|
|
24014
24210
|
if (init && isStableHookValue(init, node, identifierName, stableHooks))
|
|
24015
24211
|
return true;
|
|
24016
|
-
if (init?.type ===
|
|
24212
|
+
if (init?.type === TSESTree12.AST_NODE_TYPES.CallExpression) {
|
|
24017
24213
|
const { callee } = init;
|
|
24018
|
-
if (callee.type ===
|
|
24214
|
+
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
24215
|
return true;
|
|
24020
24216
|
}
|
|
24021
|
-
if (callee.type ===
|
|
24217
|
+
if (callee.type === TSESTree12.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree12.AST_NODE_TYPES.Identifier && callee.property.name === "map") {
|
|
24022
24218
|
return true;
|
|
24023
24219
|
}
|
|
24024
24220
|
}
|
|
24025
24221
|
if (init) {
|
|
24026
|
-
if (init.type ===
|
|
24222
|
+
if (init.type === TSESTree12.AST_NODE_TYPES.Literal || init.type === TSESTree12.AST_NODE_TYPES.TemplateLiteral) {
|
|
24027
24223
|
return true;
|
|
24028
24224
|
}
|
|
24029
|
-
if (init.type ===
|
|
24225
|
+
if (init.type === TSESTree12.AST_NODE_TYPES.UnaryExpression && init.argument.type === TSESTree12.AST_NODE_TYPES.Literal) {
|
|
24030
24226
|
return true;
|
|
24031
24227
|
}
|
|
24032
24228
|
}
|
|
24033
24229
|
const variableDefinition = variable.defs.find((definition2) => definition2.node === node);
|
|
24034
|
-
if (variableDefinition && variableDefinition.node.type ===
|
|
24230
|
+
if (variableDefinition && variableDefinition.node.type === TSESTree12.AST_NODE_TYPES.VariableDeclarator) {
|
|
24035
24231
|
const declarationParent = variableDefinition.node.parent?.parent;
|
|
24036
|
-
if (declarationParent && (declarationParent.type ===
|
|
24232
|
+
if (declarationParent && (declarationParent.type === TSESTree12.AST_NODE_TYPES.Program || declarationParent.type === TSESTree12.AST_NODE_TYPES.ExportNamedDeclaration)) {
|
|
24037
24233
|
testingMetrics.moduleLevelStableConst += 1;
|
|
24038
24234
|
return true;
|
|
24039
24235
|
}
|
|
@@ -24046,14 +24242,14 @@ function findTopmostMemberExpression(node) {
|
|
|
24046
24242
|
let current = node;
|
|
24047
24243
|
let { parent } = node;
|
|
24048
24244
|
while (parent) {
|
|
24049
|
-
if (parent.type ===
|
|
24050
|
-
if (current.type ===
|
|
24245
|
+
if (parent.type === TSESTree12.AST_NODE_TYPES.CallExpression && parent.callee === current) {
|
|
24246
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.MemberExpression)
|
|
24051
24247
|
return current.object;
|
|
24052
24248
|
break;
|
|
24053
24249
|
}
|
|
24054
|
-
const isMemberParent = parent.type ===
|
|
24055
|
-
const isChainParent = parent.type ===
|
|
24056
|
-
const isNonNullParent = parent.type ===
|
|
24250
|
+
const isMemberParent = parent.type === TSESTree12.AST_NODE_TYPES.MemberExpression && parent.object === current;
|
|
24251
|
+
const isChainParent = parent.type === TSESTree12.AST_NODE_TYPES.ChainExpression;
|
|
24252
|
+
const isNonNullParent = parent.type === TSESTree12.AST_NODE_TYPES.TSNonNullExpression;
|
|
24057
24253
|
if (!(isMemberParent || isChainParent || isNonNullParent))
|
|
24058
24254
|
break;
|
|
24059
24255
|
current = parent;
|
|
@@ -24062,21 +24258,21 @@ function findTopmostMemberExpression(node) {
|
|
|
24062
24258
|
return current;
|
|
24063
24259
|
}
|
|
24064
24260
|
var IS_CEASE_BOUNDARY = new Set([
|
|
24065
|
-
|
|
24066
|
-
|
|
24067
|
-
|
|
24068
|
-
|
|
24261
|
+
TSESTree12.AST_NODE_TYPES.FunctionDeclaration,
|
|
24262
|
+
TSESTree12.AST_NODE_TYPES.FunctionExpression,
|
|
24263
|
+
TSESTree12.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
24264
|
+
TSESTree12.AST_NODE_TYPES.VariableDeclarator
|
|
24069
24265
|
]);
|
|
24070
24266
|
var TS_RUNTIME_EXPRESSIONS = new Set([
|
|
24071
|
-
|
|
24072
|
-
|
|
24073
|
-
|
|
24074
|
-
|
|
24075
|
-
|
|
24267
|
+
TSESTree12.AST_NODE_TYPES.TSNonNullExpression,
|
|
24268
|
+
TSESTree12.AST_NODE_TYPES.TSAsExpression,
|
|
24269
|
+
TSESTree12.AST_NODE_TYPES.TSSatisfiesExpression,
|
|
24270
|
+
TSESTree12.AST_NODE_TYPES.TSTypeAssertion,
|
|
24271
|
+
TSESTree12.AST_NODE_TYPES.TSInstantiationExpression
|
|
24076
24272
|
]);
|
|
24077
24273
|
function isComputedPropertyIdentifier(identifier3) {
|
|
24078
24274
|
const { parent } = identifier3;
|
|
24079
|
-
return parent?.type ===
|
|
24275
|
+
return parent?.type === TSESTree12.AST_NODE_TYPES.Property && parent.computed && parent.key === identifier3;
|
|
24080
24276
|
}
|
|
24081
24277
|
function isInTypePosition(identifier3) {
|
|
24082
24278
|
let parent = identifier3.parent;
|
|
@@ -24130,10 +24326,10 @@ function resolveFunctionReference(identifier3, scope) {
|
|
|
24130
24326
|
return;
|
|
24131
24327
|
for (const definition of variable.defs) {
|
|
24132
24328
|
const { node } = definition;
|
|
24133
|
-
if (node.type ===
|
|
24329
|
+
if (node.type === TSESTree12.AST_NODE_TYPES.FunctionDeclaration) {
|
|
24134
24330
|
return node;
|
|
24135
24331
|
}
|
|
24136
|
-
if (node.type ===
|
|
24332
|
+
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
24333
|
return node.init;
|
|
24138
24334
|
}
|
|
24139
24335
|
}
|
|
@@ -24143,7 +24339,7 @@ function collectCaptures(node, sourceCode) {
|
|
|
24143
24339
|
const captures = new Array;
|
|
24144
24340
|
const captureSet = new Set;
|
|
24145
24341
|
function visit(current) {
|
|
24146
|
-
if (current.type ===
|
|
24342
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.Identifier) {
|
|
24147
24343
|
const { name } = current;
|
|
24148
24344
|
if (captureSet.has(name) || GLOBAL_BUILTINS.has(name) || isInTypePosition(current))
|
|
24149
24345
|
return;
|
|
@@ -24185,21 +24381,21 @@ function collectCaptures(node, sourceCode) {
|
|
|
24185
24381
|
}
|
|
24186
24382
|
}
|
|
24187
24383
|
}
|
|
24188
|
-
if (current.type ===
|
|
24384
|
+
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
24385
|
visit(current.expression);
|
|
24190
24386
|
return;
|
|
24191
24387
|
}
|
|
24192
|
-
if (current.type ===
|
|
24388
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.MemberExpression) {
|
|
24193
24389
|
visit(current.object);
|
|
24194
24390
|
if (current.computed)
|
|
24195
24391
|
visit(current.property);
|
|
24196
24392
|
return;
|
|
24197
24393
|
}
|
|
24198
|
-
if (current.type ===
|
|
24394
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.ChainExpression) {
|
|
24199
24395
|
visit(current.expression);
|
|
24200
24396
|
return;
|
|
24201
24397
|
}
|
|
24202
|
-
if (current.type ===
|
|
24398
|
+
if (current.type === TSESTree12.AST_NODE_TYPES.Property) {
|
|
24203
24399
|
if (current.computed)
|
|
24204
24400
|
visit(current.key);
|
|
24205
24401
|
visit(current.value);
|
|
@@ -24224,7 +24420,7 @@ function parseDependencies(node, sourceCode) {
|
|
|
24224
24420
|
for (const element of node.elements) {
|
|
24225
24421
|
if (!element)
|
|
24226
24422
|
continue;
|
|
24227
|
-
const actualNode = element.type ===
|
|
24423
|
+
const actualNode = element.type === TSESTree12.AST_NODE_TYPES.SpreadElement ? element.argument : element;
|
|
24228
24424
|
const name = nodeToDependencyString(actualNode, sourceCode);
|
|
24229
24425
|
const depth = getMemberExpressionDepth(actualNode);
|
|
24230
24426
|
dependencies4.push({
|
|
@@ -24301,9 +24497,9 @@ var useExhaustiveDependencies = {
|
|
|
24301
24497
|
if (closureArgument === undefined)
|
|
24302
24498
|
return;
|
|
24303
24499
|
let closureFunction;
|
|
24304
|
-
if (closureArgument.type ===
|
|
24500
|
+
if (closureArgument.type === TSESTree12.AST_NODE_TYPES.ArrowFunctionExpression || closureArgument.type === TSESTree12.AST_NODE_TYPES.FunctionExpression) {
|
|
24305
24501
|
closureFunction = closureArgument;
|
|
24306
|
-
} else if (closureArgument.type ===
|
|
24502
|
+
} else if (closureArgument.type === TSESTree12.AST_NODE_TYPES.Identifier) {
|
|
24307
24503
|
const scope = getScope(callNode);
|
|
24308
24504
|
closureFunction = resolveFunctionReference(closureArgument, scope);
|
|
24309
24505
|
}
|
|
@@ -24337,7 +24533,7 @@ var useExhaustiveDependencies = {
|
|
|
24337
24533
|
}
|
|
24338
24534
|
if (!dependenciesArgument)
|
|
24339
24535
|
return;
|
|
24340
|
-
if (dependenciesArgument.type !==
|
|
24536
|
+
if (dependenciesArgument.type !== TSESTree12.AST_NODE_TYPES.ArrayExpression)
|
|
24341
24537
|
return;
|
|
24342
24538
|
const dependenciesArray = dependenciesArgument;
|
|
24343
24539
|
const captures = collectCaptures(closureFunction, context.sourceCode);
|
|
@@ -24547,7 +24743,7 @@ var useExhaustiveDependencies = {
|
|
|
24547
24743
|
var use_exhaustive_dependencies_default = useExhaustiveDependencies;
|
|
24548
24744
|
|
|
24549
24745
|
// src/rules/use-hook-at-top-level.ts
|
|
24550
|
-
import { TSESTree as
|
|
24746
|
+
import { TSESTree as TSESTree13 } from "@typescript-eslint/types";
|
|
24551
24747
|
var HOOK_NAME_PATTERN = /^use[A-Z]/;
|
|
24552
24748
|
var COMPONENT_NAME_PATTERN2 = /^[A-Z]/;
|
|
24553
24749
|
function isReactHook(name) {
|
|
@@ -24557,23 +24753,23 @@ function isComponent(name) {
|
|
|
24557
24753
|
return COMPONENT_NAME_PATTERN2.test(name);
|
|
24558
24754
|
}
|
|
24559
24755
|
function isComponentOrHook(node) {
|
|
24560
|
-
if (node.type ===
|
|
24756
|
+
if (node.type === TSESTree13.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
24561
24757
|
const { name } = node.id;
|
|
24562
24758
|
return isComponent(name) || isReactHook(name);
|
|
24563
24759
|
}
|
|
24564
|
-
if (node.type ===
|
|
24760
|
+
if (node.type === TSESTree13.AST_NODE_TYPES.FunctionExpression || node.type === TSESTree13.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
24565
24761
|
const { parent } = node;
|
|
24566
24762
|
if (parent === undefined)
|
|
24567
24763
|
return false;
|
|
24568
|
-
if (parent.type ===
|
|
24764
|
+
if (parent.type === TSESTree13.AST_NODE_TYPES.VariableDeclarator && parent.id.type === TSESTree13.AST_NODE_TYPES.Identifier) {
|
|
24569
24765
|
const { name } = parent.id;
|
|
24570
24766
|
return isComponent(name) || isReactHook(name);
|
|
24571
24767
|
}
|
|
24572
|
-
if (parent.type ===
|
|
24768
|
+
if (parent.type === TSESTree13.AST_NODE_TYPES.Property && parent.key.type === TSESTree13.AST_NODE_TYPES.Identifier) {
|
|
24573
24769
|
const { name } = parent.key;
|
|
24574
24770
|
return isComponent(name) || isReactHook(name);
|
|
24575
24771
|
}
|
|
24576
|
-
if (parent.type ===
|
|
24772
|
+
if (parent.type === TSESTree13.AST_NODE_TYPES.MethodDefinition && parent.key.type === TSESTree13.AST_NODE_TYPES.Identifier) {
|
|
24577
24773
|
const { name } = parent.key;
|
|
24578
24774
|
return isComponent(name) || isReactHook(name);
|
|
24579
24775
|
}
|
|
@@ -24582,17 +24778,17 @@ function isComponentOrHook(node) {
|
|
|
24582
24778
|
}
|
|
24583
24779
|
function isHookCall(node) {
|
|
24584
24780
|
const { callee } = node;
|
|
24585
|
-
if (callee.type ===
|
|
24781
|
+
if (callee.type === TSESTree13.AST_NODE_TYPES.Identifier)
|
|
24586
24782
|
return isReactHook(callee.name);
|
|
24587
|
-
if (callee.type ===
|
|
24783
|
+
if (callee.type === TSESTree13.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree13.AST_NODE_TYPES.Identifier) {
|
|
24588
24784
|
return isReactHook(callee.property.name);
|
|
24589
24785
|
}
|
|
24590
24786
|
return false;
|
|
24591
24787
|
}
|
|
24592
24788
|
var FUNCTION_BOUNDARIES2 = new Set([
|
|
24593
|
-
|
|
24594
|
-
|
|
24595
|
-
|
|
24789
|
+
TSESTree13.AST_NODE_TYPES.FunctionDeclaration,
|
|
24790
|
+
TSESTree13.AST_NODE_TYPES.FunctionExpression,
|
|
24791
|
+
TSESTree13.AST_NODE_TYPES.ArrowFunctionExpression
|
|
24596
24792
|
]);
|
|
24597
24793
|
function isInFinallyBlock(node) {
|
|
24598
24794
|
let current = node.parent;
|
|
@@ -24601,7 +24797,7 @@ function isInFinallyBlock(node) {
|
|
|
24601
24797
|
for (let depth = 0;depth < maxDepth && current; depth += 1) {
|
|
24602
24798
|
if (FUNCTION_BOUNDARIES2.has(current.type))
|
|
24603
24799
|
break;
|
|
24604
|
-
if (current.type ===
|
|
24800
|
+
if (current.type === TSESTree13.AST_NODE_TYPES.TryStatement) {
|
|
24605
24801
|
let checkNode = node;
|
|
24606
24802
|
while (checkNode && checkNode !== current) {
|
|
24607
24803
|
if (checkNode === current.finalizer) {
|
|
@@ -24649,14 +24845,14 @@ var useHookAtTopLevel = {
|
|
|
24649
24845
|
if (ignoreHooks?.includes(hookName))
|
|
24650
24846
|
return true;
|
|
24651
24847
|
if (importSources && Object.keys(importSources).length > 0) {
|
|
24652
|
-
if (node.callee.type ===
|
|
24653
|
-
const objectName = node.callee.object.type ===
|
|
24848
|
+
if (node.callee.type === TSESTree13.AST_NODE_TYPES.MemberExpression) {
|
|
24849
|
+
const objectName = node.callee.object.type === TSESTree13.AST_NODE_TYPES.Identifier ? node.callee.object.name : undefined;
|
|
24654
24850
|
if (objectName && importSources[objectName] === false)
|
|
24655
24851
|
return true;
|
|
24656
24852
|
if (objectName && importSources[objectName] === true)
|
|
24657
24853
|
return false;
|
|
24658
24854
|
}
|
|
24659
|
-
if (node.callee.type ===
|
|
24855
|
+
if (node.callee.type === TSESTree13.AST_NODE_TYPES.Identifier) {
|
|
24660
24856
|
const importSource = importSourceMap.get(hookName);
|
|
24661
24857
|
if (importSource && importSources[importSource] === false)
|
|
24662
24858
|
return true;
|
|
@@ -24671,7 +24867,7 @@ var useHookAtTopLevel = {
|
|
|
24671
24867
|
const current = getCurrentContext();
|
|
24672
24868
|
const depth = current ? current.functionDepth + 1 : 0;
|
|
24673
24869
|
const isComponentOrHookFlag = isComponentOrHook(functionNode);
|
|
24674
|
-
if (functionNode.type ===
|
|
24870
|
+
if (functionNode.type === TSESTree13.AST_NODE_TYPES.FunctionDeclaration && functionNode.id) {
|
|
24675
24871
|
currentFunctionName = functionNode.id.name;
|
|
24676
24872
|
}
|
|
24677
24873
|
if (current?.isComponentOrHook) {
|
|
@@ -24710,7 +24906,7 @@ var useHookAtTopLevel = {
|
|
|
24710
24906
|
if (!isHookCall(callNode))
|
|
24711
24907
|
return;
|
|
24712
24908
|
const { callee } = callNode;
|
|
24713
|
-
const hookName = callee.type ===
|
|
24909
|
+
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
24910
|
if (!hookName || shouldIgnoreHook(hookName, callNode))
|
|
24715
24911
|
return;
|
|
24716
24912
|
const current = getCurrentContext();
|
|
@@ -24808,10 +25004,10 @@ var useHookAtTopLevel = {
|
|
|
24808
25004
|
if (!configuration.importSources || Object.keys(configuration.importSources).length === 0)
|
|
24809
25005
|
return;
|
|
24810
25006
|
for (const specifier of importNode.specifiers) {
|
|
24811
|
-
if (specifier.type !==
|
|
25007
|
+
if (specifier.type !== TSESTree13.AST_NODE_TYPES.ImportSpecifier)
|
|
24812
25008
|
continue;
|
|
24813
25009
|
const { imported } = specifier;
|
|
24814
|
-
if (imported.type !==
|
|
25010
|
+
if (imported.type !== TSESTree13.AST_NODE_TYPES.Identifier)
|
|
24815
25011
|
continue;
|
|
24816
25012
|
if (isReactHook(imported.name))
|
|
24817
25013
|
importSourceMap.set(specifier.local.name, source);
|
|
@@ -24920,6 +25116,9 @@ function createNoInstanceMethodsOptions(options3 = {}) {
|
|
|
24920
25116
|
...options3
|
|
24921
25117
|
};
|
|
24922
25118
|
}
|
|
25119
|
+
function createNoMemoChildrenOptions(options3 = {}) {
|
|
25120
|
+
return { allowedComponents: [], environment: "roblox-ts", ...options3 };
|
|
25121
|
+
}
|
|
24923
25122
|
function createNoShorthandOptions(options3 = {}) {
|
|
24924
25123
|
return { allowPropertyAccess: [], ignoreShorthands: [], shorthands: {}, ...options3 };
|
|
24925
25124
|
}
|
|
@@ -25003,6 +25202,7 @@ var rules = {
|
|
|
25003
25202
|
"no-god-components": no_god_components_default,
|
|
25004
25203
|
"no-identity-map": no_identity_map_default,
|
|
25005
25204
|
"no-instance-methods-without-this": no_instance_methods_without_this_default,
|
|
25205
|
+
"no-memo-children": no_memo_children_default,
|
|
25006
25206
|
"no-print": no_print_default,
|
|
25007
25207
|
"no-shorthand-names": no_shorthand_names_default,
|
|
25008
25208
|
"no-useless-use-spring": no_useless_use_spring_default,
|
|
@@ -25038,6 +25238,7 @@ var recommended = {
|
|
|
25038
25238
|
"cease-nonsense/no-god-components": "error",
|
|
25039
25239
|
"cease-nonsense/no-identity-map": "error",
|
|
25040
25240
|
"cease-nonsense/no-instance-methods-without-this": "error",
|
|
25241
|
+
"cease-nonsense/no-memo-children": "error",
|
|
25041
25242
|
"cease-nonsense/no-print": "error",
|
|
25042
25243
|
"cease-nonsense/no-shorthand-names": "error",
|
|
25043
25244
|
"cease-nonsense/no-warn": "error",
|
|
@@ -25068,6 +25269,7 @@ export {
|
|
|
25068
25269
|
createPairConfiguration,
|
|
25069
25270
|
createNoUselessUseSpringOptions,
|
|
25070
25271
|
createNoShorthandOptions,
|
|
25272
|
+
createNoMemoChildrenOptions,
|
|
25071
25273
|
createNoInstanceMethodsOptions,
|
|
25072
25274
|
createNoGodComponentsOptions,
|
|
25073
25275
|
createHookConfiguration,
|
|
@@ -25075,5 +25277,3 @@ export {
|
|
|
25075
25277
|
createComplexityConfiguration,
|
|
25076
25278
|
createBanInstancesOptions
|
|
25077
25279
|
};
|
|
25078
|
-
|
|
25079
|
-
//# debugId=A96F64DDBF4FBDA864756E2164756E21
|