@pobammer-ts/eslint-cease-nonsense-rules 1.2.4 → 1.3.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/dist/build-metadata.json +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +248 -38
- package/dist/index.js.map +5 -4
- package/dist/rules/no-async-constructor.d.ts +7 -0
- package/package.json +1 -1
package/dist/build-metadata.json
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ declare const recommended: {
|
|
|
35
35
|
readonly rules: {
|
|
36
36
|
readonly "cease-nonsense/ban-react-fc": "error";
|
|
37
37
|
readonly "cease-nonsense/enforce-ianitor-check-type": "error";
|
|
38
|
+
readonly "cease-nonsense/no-async-constructor": "error";
|
|
38
39
|
readonly "cease-nonsense/no-color3-constructor": "error";
|
|
39
40
|
readonly "cease-nonsense/no-instance-methods-without-this": "error";
|
|
40
41
|
readonly "cease-nonsense/no-print": "error";
|
package/dist/index.js
CHANGED
|
@@ -8420,6 +8420,214 @@ var enforceIanitorCheckType = createRule({
|
|
|
8420
8420
|
});
|
|
8421
8421
|
var enforce_ianitor_check_type_default = enforceIanitorCheckType;
|
|
8422
8422
|
|
|
8423
|
+
// src/rules/no-async-constructor.ts
|
|
8424
|
+
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
8425
|
+
var PROMISE_CHAIN_METHODS = new Set(["then", "catch", "finally"]);
|
|
8426
|
+
function isNode(value) {
|
|
8427
|
+
return typeof value === "object" && value !== null && "type" in value;
|
|
8428
|
+
}
|
|
8429
|
+
function hasDynamicProperties(_node) {
|
|
8430
|
+
return true;
|
|
8431
|
+
}
|
|
8432
|
+
function getAsyncMethodNames(classBody) {
|
|
8433
|
+
const asyncMethods = new Set;
|
|
8434
|
+
for (const element of classBody.body) {
|
|
8435
|
+
if (element.type !== AST_NODE_TYPES.MethodDefinition)
|
|
8436
|
+
continue;
|
|
8437
|
+
if (element.kind !== "method")
|
|
8438
|
+
continue;
|
|
8439
|
+
if (!element.value.async)
|
|
8440
|
+
continue;
|
|
8441
|
+
if (element.key.type === AST_NODE_TYPES.Identifier)
|
|
8442
|
+
asyncMethods.add(element.key.name);
|
|
8443
|
+
}
|
|
8444
|
+
return asyncMethods;
|
|
8445
|
+
}
|
|
8446
|
+
function isPromiseChainCall(node) {
|
|
8447
|
+
if (node.callee.type !== AST_NODE_TYPES.MemberExpression)
|
|
8448
|
+
return false;
|
|
8449
|
+
const { property } = node.callee;
|
|
8450
|
+
if (property.type !== AST_NODE_TYPES.Identifier)
|
|
8451
|
+
return false;
|
|
8452
|
+
return PROMISE_CHAIN_METHODS.has(property.name);
|
|
8453
|
+
}
|
|
8454
|
+
function isAsyncIIFE(node) {
|
|
8455
|
+
const { callee } = node;
|
|
8456
|
+
if (callee.type === AST_NODE_TYPES.ArrowFunctionExpression && callee.async)
|
|
8457
|
+
return true;
|
|
8458
|
+
if (callee.type === AST_NODE_TYPES.FunctionExpression && callee.async)
|
|
8459
|
+
return true;
|
|
8460
|
+
return false;
|
|
8461
|
+
}
|
|
8462
|
+
function isThisAsyncMethodCall(node, asyncMethods) {
|
|
8463
|
+
const { callee } = node;
|
|
8464
|
+
if (callee.type !== AST_NODE_TYPES.MemberExpression)
|
|
8465
|
+
return;
|
|
8466
|
+
if (callee.object.type !== AST_NODE_TYPES.ThisExpression)
|
|
8467
|
+
return;
|
|
8468
|
+
if (callee.property.type !== AST_NODE_TYPES.Identifier)
|
|
8469
|
+
return;
|
|
8470
|
+
const methodName = callee.property.name;
|
|
8471
|
+
return asyncMethods.has(methodName) ? methodName : undefined;
|
|
8472
|
+
}
|
|
8473
|
+
function isAssignedToThisProperty(node, parent) {
|
|
8474
|
+
if (!parent)
|
|
8475
|
+
return false;
|
|
8476
|
+
if (parent.type !== AST_NODE_TYPES.AssignmentExpression)
|
|
8477
|
+
return false;
|
|
8478
|
+
if (parent.right !== node)
|
|
8479
|
+
return false;
|
|
8480
|
+
const { left } = parent;
|
|
8481
|
+
return left.type === AST_NODE_TYPES.MemberExpression && left.object.type === AST_NODE_TYPES.ThisExpression;
|
|
8482
|
+
}
|
|
8483
|
+
function getLocalVariableAssignment(node, parent) {
|
|
8484
|
+
if (!parent)
|
|
8485
|
+
return;
|
|
8486
|
+
if (parent.type !== AST_NODE_TYPES.VariableDeclarator)
|
|
8487
|
+
return;
|
|
8488
|
+
if (parent.init !== node)
|
|
8489
|
+
return;
|
|
8490
|
+
if (parent.id.type !== AST_NODE_TYPES.Identifier)
|
|
8491
|
+
return;
|
|
8492
|
+
return parent.id.name;
|
|
8493
|
+
}
|
|
8494
|
+
function isExpressionStatement(parent) {
|
|
8495
|
+
return parent?.type === AST_NODE_TYPES.ExpressionStatement;
|
|
8496
|
+
}
|
|
8497
|
+
function checkAsyncMethodCall(current, parent, asyncMethods) {
|
|
8498
|
+
const asyncMethodName = isThisAsyncMethodCall(current, asyncMethods);
|
|
8499
|
+
if (asyncMethodName === undefined)
|
|
8500
|
+
return;
|
|
8501
|
+
if (isAssignedToThisProperty(current, parent))
|
|
8502
|
+
return;
|
|
8503
|
+
if (isExpressionStatement(parent)) {
|
|
8504
|
+
return {
|
|
8505
|
+
data: { methodName: asyncMethodName },
|
|
8506
|
+
messageId: "unhandledAsyncCall",
|
|
8507
|
+
node: current
|
|
8508
|
+
};
|
|
8509
|
+
}
|
|
8510
|
+
const variableName = getLocalVariableAssignment(current, parent);
|
|
8511
|
+
if (variableName !== undefined) {
|
|
8512
|
+
return {
|
|
8513
|
+
data: { variableName },
|
|
8514
|
+
messageId: "orphanedPromise",
|
|
8515
|
+
node: current
|
|
8516
|
+
};
|
|
8517
|
+
}
|
|
8518
|
+
return;
|
|
8519
|
+
}
|
|
8520
|
+
function isNonIIFEFunction(node, parent) {
|
|
8521
|
+
if (node.type !== AST_NODE_TYPES.ArrowFunctionExpression && node.type !== AST_NODE_TYPES.FunctionExpression) {
|
|
8522
|
+
return false;
|
|
8523
|
+
}
|
|
8524
|
+
if (parent?.type === AST_NODE_TYPES.CallExpression && parent.callee === node) {
|
|
8525
|
+
return false;
|
|
8526
|
+
}
|
|
8527
|
+
return true;
|
|
8528
|
+
}
|
|
8529
|
+
function findConstructorViolations(constructorBody, asyncMethods) {
|
|
8530
|
+
const violations = new Array;
|
|
8531
|
+
let size = 0;
|
|
8532
|
+
const visited2 = new WeakSet;
|
|
8533
|
+
const parentMap = new WeakMap;
|
|
8534
|
+
function traverse(current) {
|
|
8535
|
+
if (visited2.has(current))
|
|
8536
|
+
return;
|
|
8537
|
+
visited2.add(current);
|
|
8538
|
+
const parent = parentMap.get(current);
|
|
8539
|
+
if (isNonIIFEFunction(current, parent))
|
|
8540
|
+
return;
|
|
8541
|
+
if (current.type === AST_NODE_TYPES.AwaitExpression) {
|
|
8542
|
+
violations[size++] = { messageId: "awaitInConstructor", node: current };
|
|
8543
|
+
}
|
|
8544
|
+
if (current.type === AST_NODE_TYPES.CallExpression) {
|
|
8545
|
+
if (isPromiseChainCall(current)) {
|
|
8546
|
+
violations[size++] = { messageId: "promiseChainInConstructor", node: current };
|
|
8547
|
+
}
|
|
8548
|
+
if (isAsyncIIFE(current))
|
|
8549
|
+
violations[size++] = { messageId: "asyncIifeInConstructor", node: current };
|
|
8550
|
+
const asyncViolation = checkAsyncMethodCall(current, parent, asyncMethods);
|
|
8551
|
+
if (asyncViolation)
|
|
8552
|
+
violations[size++] = asyncViolation;
|
|
8553
|
+
}
|
|
8554
|
+
if (!hasDynamicProperties(current))
|
|
8555
|
+
return;
|
|
8556
|
+
for (const key in current) {
|
|
8557
|
+
const childValue = current[key];
|
|
8558
|
+
if (childValue === undefined)
|
|
8559
|
+
continue;
|
|
8560
|
+
if (Array.isArray(childValue)) {
|
|
8561
|
+
for (const item of childValue) {
|
|
8562
|
+
if (!isNode(item))
|
|
8563
|
+
continue;
|
|
8564
|
+
parentMap.set(item, current);
|
|
8565
|
+
traverse(item);
|
|
8566
|
+
}
|
|
8567
|
+
continue;
|
|
8568
|
+
}
|
|
8569
|
+
if (!isNode(childValue))
|
|
8570
|
+
continue;
|
|
8571
|
+
parentMap.set(childValue, current);
|
|
8572
|
+
traverse(childValue);
|
|
8573
|
+
}
|
|
8574
|
+
}
|
|
8575
|
+
traverse(constructorBody);
|
|
8576
|
+
return violations;
|
|
8577
|
+
}
|
|
8578
|
+
function reportViolation(context, violation) {
|
|
8579
|
+
if (violation.data) {
|
|
8580
|
+
context.report({
|
|
8581
|
+
data: violation.data,
|
|
8582
|
+
messageId: violation.messageId,
|
|
8583
|
+
node: violation.node
|
|
8584
|
+
});
|
|
8585
|
+
return;
|
|
8586
|
+
}
|
|
8587
|
+
context.report({
|
|
8588
|
+
messageId: violation.messageId,
|
|
8589
|
+
node: violation.node
|
|
8590
|
+
});
|
|
8591
|
+
}
|
|
8592
|
+
var noAsyncConstructor = {
|
|
8593
|
+
create(context) {
|
|
8594
|
+
return {
|
|
8595
|
+
"MethodDefinition[kind='constructor']"(node) {
|
|
8596
|
+
const constructorValue = node.value;
|
|
8597
|
+
if (constructorValue.type !== AST_NODE_TYPES.FunctionExpression)
|
|
8598
|
+
return;
|
|
8599
|
+
const { body } = constructorValue;
|
|
8600
|
+
if (body.type !== AST_NODE_TYPES.BlockStatement)
|
|
8601
|
+
return;
|
|
8602
|
+
const classNode = node.parent;
|
|
8603
|
+
if (classNode.type !== AST_NODE_TYPES.ClassBody)
|
|
8604
|
+
return;
|
|
8605
|
+
const asyncMethods = getAsyncMethodNames(classNode);
|
|
8606
|
+
const violations = findConstructorViolations(body, asyncMethods);
|
|
8607
|
+
for (const violation of violations)
|
|
8608
|
+
reportViolation(context, violation);
|
|
8609
|
+
}
|
|
8610
|
+
};
|
|
8611
|
+
},
|
|
8612
|
+
defaultOptions: [],
|
|
8613
|
+
meta: {
|
|
8614
|
+
docs: {
|
|
8615
|
+
description: "Disallow asynchronous operations inside class constructors. Constructors return immediately, " + "so async work causes race conditions, unhandled rejections, and incomplete object states.",
|
|
8616
|
+
recommended: true
|
|
8617
|
+
},
|
|
8618
|
+
messages: {
|
|
8619
|
+
asyncIifeInConstructor: "Refactor this asynchronous operation outside of the constructor. " + "Async IIFEs create unhandled promises and incomplete object state.",
|
|
8620
|
+
awaitInConstructor: "Refactor this asynchronous operation outside of the constructor. " + "Using 'await' in a constructor causes the class to be instantiated before the async operation completes.",
|
|
8621
|
+
orphanedPromise: "Refactor this asynchronous operation outside of the constructor. " + "Promise assigned to '{{variableName}}' is never consumed - errors will be silently swallowed.",
|
|
8622
|
+
promiseChainInConstructor: "Refactor this asynchronous operation outside of the constructor. " + "Promise chains (.then/.catch/.finally) in constructors lead to race conditions.",
|
|
8623
|
+
unhandledAsyncCall: "Refactor this asynchronous operation outside of the constructor. " + "Calling async method '{{methodName}}' without handling its result creates uncontrolled async behavior."
|
|
8624
|
+
},
|
|
8625
|
+
schema: [],
|
|
8626
|
+
type: "problem"
|
|
8627
|
+
}
|
|
8628
|
+
};
|
|
8629
|
+
var no_async_constructor_default = noAsyncConstructor;
|
|
8630
|
+
|
|
8423
8631
|
// src/rules/no-color3-constructor.ts
|
|
8424
8632
|
import { TSESTree as TSESTree4 } from "@typescript-eslint/types";
|
|
8425
8633
|
var isNumericLiteralNode = Compile(build_default.Object({
|
|
@@ -8496,7 +8704,7 @@ var noColor3Constructor = {
|
|
|
8496
8704
|
var no_color3_constructor_default = noColor3Constructor;
|
|
8497
8705
|
|
|
8498
8706
|
// src/rules/no-instance-methods-without-this.ts
|
|
8499
|
-
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
8707
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES2 } from "@typescript-eslint/types";
|
|
8500
8708
|
var DEFAULT_OPTIONS = {
|
|
8501
8709
|
checkPrivate: true,
|
|
8502
8710
|
checkProtected: true,
|
|
@@ -8526,19 +8734,19 @@ function shouldCheckMethod(node, options3) {
|
|
|
8526
8734
|
return false;
|
|
8527
8735
|
return true;
|
|
8528
8736
|
}
|
|
8529
|
-
function
|
|
8737
|
+
function isNode2(value) {
|
|
8530
8738
|
return typeof value === "object" && value !== null && "type" in value;
|
|
8531
8739
|
}
|
|
8532
|
-
function
|
|
8740
|
+
function hasDynamicProperties2(_node) {
|
|
8533
8741
|
return true;
|
|
8534
8742
|
}
|
|
8535
8743
|
function traverseForThis(currentNode, visited2) {
|
|
8536
8744
|
if (visited2.has(currentNode))
|
|
8537
8745
|
return false;
|
|
8538
8746
|
visited2.add(currentNode);
|
|
8539
|
-
if (currentNode.type ===
|
|
8747
|
+
if (currentNode.type === AST_NODE_TYPES2.ThisExpression || currentNode.type === AST_NODE_TYPES2.Super)
|
|
8540
8748
|
return true;
|
|
8541
|
-
if (!
|
|
8749
|
+
if (!hasDynamicProperties2(currentNode))
|
|
8542
8750
|
return false;
|
|
8543
8751
|
for (const key in currentNode) {
|
|
8544
8752
|
const childValue = currentNode[key];
|
|
@@ -8546,18 +8754,18 @@ function traverseForThis(currentNode, visited2) {
|
|
|
8546
8754
|
continue;
|
|
8547
8755
|
if (Array.isArray(childValue)) {
|
|
8548
8756
|
for (const item of childValue)
|
|
8549
|
-
if (
|
|
8757
|
+
if (isNode2(item) && traverseForThis(item, visited2))
|
|
8550
8758
|
return true;
|
|
8551
8759
|
continue;
|
|
8552
8760
|
}
|
|
8553
|
-
if (
|
|
8761
|
+
if (isNode2(childValue) && traverseForThis(childValue, visited2))
|
|
8554
8762
|
return true;
|
|
8555
8763
|
}
|
|
8556
8764
|
return false;
|
|
8557
8765
|
}
|
|
8558
8766
|
function methodUsesThis(node) {
|
|
8559
8767
|
const value = node.value;
|
|
8560
|
-
if (value === undefined || value.type !==
|
|
8768
|
+
if (value === undefined || value.type !== AST_NODE_TYPES2.FunctionExpression)
|
|
8561
8769
|
return false;
|
|
8562
8770
|
return traverseForThis(value, new WeakSet);
|
|
8563
8771
|
}
|
|
@@ -8571,7 +8779,7 @@ var noInstanceMethodsWithoutThis = {
|
|
|
8571
8779
|
return;
|
|
8572
8780
|
if (methodUsesThis(node))
|
|
8573
8781
|
return;
|
|
8574
|
-
const methodName = node.key.type ===
|
|
8782
|
+
const methodName = node.key.type === AST_NODE_TYPES2.Identifier ? node.key.name : "unknown";
|
|
8575
8783
|
context.report({
|
|
8576
8784
|
data: { methodName },
|
|
8577
8785
|
messageId: "noInstanceMethodWithoutThis",
|
|
@@ -8769,13 +8977,13 @@ var noWarn = {
|
|
|
8769
8977
|
var no_warn_default = noWarn;
|
|
8770
8978
|
|
|
8771
8979
|
// src/rules/prefer-sequence-overloads.ts
|
|
8772
|
-
import { AST_NODE_TYPES as
|
|
8980
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/types";
|
|
8773
8981
|
var sequenceDescriptors = [
|
|
8774
8982
|
{ keypointName: "ColorSequenceKeypoint", sequenceName: "ColorSequence" },
|
|
8775
8983
|
{ keypointName: "NumberSequenceKeypoint", sequenceName: "NumberSequence" }
|
|
8776
8984
|
];
|
|
8777
8985
|
function isSequenceIdentifier(node) {
|
|
8778
|
-
if (node.type !==
|
|
8986
|
+
if (node.type !== AST_NODE_TYPES3.Identifier)
|
|
8779
8987
|
return false;
|
|
8780
8988
|
for (const { sequenceName } of sequenceDescriptors)
|
|
8781
8989
|
if (sequenceName === node.name)
|
|
@@ -8789,16 +8997,16 @@ function findDescriptor(sequenceName) {
|
|
|
8789
8997
|
return;
|
|
8790
8998
|
}
|
|
8791
8999
|
var isNumericLiteral = Compile(build_default.Object({
|
|
8792
|
-
type: build_default.Literal(
|
|
9000
|
+
type: build_default.Literal(AST_NODE_TYPES3.Literal),
|
|
8793
9001
|
value: build_default.Number()
|
|
8794
9002
|
}));
|
|
8795
9003
|
function isExpressionArgument(argument) {
|
|
8796
|
-
return argument !== undefined && argument.type !==
|
|
9004
|
+
return argument !== undefined && argument.type !== AST_NODE_TYPES3.SpreadElement;
|
|
8797
9005
|
}
|
|
8798
9006
|
function extractKeypoint(element, descriptor) {
|
|
8799
|
-
if (element === undefined || element.type !==
|
|
9007
|
+
if (element === undefined || element.type !== AST_NODE_TYPES3.NewExpression)
|
|
8800
9008
|
return;
|
|
8801
|
-
if (element.callee.type !==
|
|
9009
|
+
if (element.callee.type !== AST_NODE_TYPES3.Identifier || element.callee.name !== descriptor.keypointName)
|
|
8802
9010
|
return;
|
|
8803
9011
|
if (element.arguments.length !== 2)
|
|
8804
9012
|
return;
|
|
@@ -8828,7 +9036,7 @@ var preferSequenceOverloads = {
|
|
|
8828
9036
|
if (descriptor === undefined || node.arguments.length !== 1)
|
|
8829
9037
|
return;
|
|
8830
9038
|
const [argument] = node.arguments;
|
|
8831
|
-
if (argument === undefined || argument.type !==
|
|
9039
|
+
if (argument === undefined || argument.type !== AST_NODE_TYPES3.ArrayExpression || argument.elements.length !== 2)
|
|
8832
9040
|
return;
|
|
8833
9041
|
const firstElement = argument.elements[0] ?? undefined;
|
|
8834
9042
|
const secondElement = argument.elements[1] ?? undefined;
|
|
@@ -9368,7 +9576,7 @@ var requireNamedEffectFunctions = {
|
|
|
9368
9576
|
var require_named_effect_functions_default = requireNamedEffectFunctions;
|
|
9369
9577
|
|
|
9370
9578
|
// src/rules/require-paired-calls.ts
|
|
9371
|
-
import { AST_NODE_TYPES as
|
|
9579
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/types";
|
|
9372
9580
|
var isStringArray = Compile(build_default.Readonly(build_default.Array(build_default.String())));
|
|
9373
9581
|
var isPairConfiguration = Compile(build_default.Readonly(build_default.Object({
|
|
9374
9582
|
alternatives: build_default.Optional(isStringArray),
|
|
@@ -9386,20 +9594,20 @@ var isRuleOptions3 = Compile(build_default.Partial(build_default.Readonly(build_
|
|
|
9386
9594
|
pairs: build_default.Readonly(build_default.Array(isPairConfiguration))
|
|
9387
9595
|
}))));
|
|
9388
9596
|
var LOOP_NODE_TYPES = new Set([
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9597
|
+
AST_NODE_TYPES4.DoWhileStatement,
|
|
9598
|
+
AST_NODE_TYPES4.ForInStatement,
|
|
9599
|
+
AST_NODE_TYPES4.ForOfStatement,
|
|
9600
|
+
AST_NODE_TYPES4.ForStatement,
|
|
9601
|
+
AST_NODE_TYPES4.WhileStatement
|
|
9394
9602
|
]);
|
|
9395
9603
|
var DEFAULT_ROBLOX_YIELDING_FUNCTIONS = ["task.wait", "wait", "*.WaitForChild", "*.*Async"];
|
|
9396
9604
|
function getCallName(node) {
|
|
9397
9605
|
const { callee } = node;
|
|
9398
|
-
if (callee.type ===
|
|
9606
|
+
if (callee.type === AST_NODE_TYPES4.Identifier)
|
|
9399
9607
|
return callee.name;
|
|
9400
|
-
if (callee.type ===
|
|
9401
|
-
const object3 = callee.object.type ===
|
|
9402
|
-
const property = callee.property.type ===
|
|
9608
|
+
if (callee.type === AST_NODE_TYPES4.MemberExpression) {
|
|
9609
|
+
const object3 = callee.object.type === AST_NODE_TYPES4.Identifier ? callee.object.name : undefined;
|
|
9610
|
+
const property = callee.property.type === AST_NODE_TYPES4.Identifier ? callee.property.name : undefined;
|
|
9403
9611
|
if (object3 !== undefined && property !== undefined)
|
|
9404
9612
|
return `${object3}.${property}`;
|
|
9405
9613
|
}
|
|
@@ -9435,12 +9643,12 @@ function isLoopLikeStatement(node) {
|
|
|
9435
9643
|
return LOOP_NODE_TYPES.has(node.type);
|
|
9436
9644
|
}
|
|
9437
9645
|
function isSwitchStatement(node) {
|
|
9438
|
-
return node?.type ===
|
|
9646
|
+
return node?.type === AST_NODE_TYPES4.SwitchStatement;
|
|
9439
9647
|
}
|
|
9440
9648
|
function findLabeledStatementBody(label, startingNode) {
|
|
9441
9649
|
let current = startingNode;
|
|
9442
9650
|
while (current) {
|
|
9443
|
-
if (current.type ===
|
|
9651
|
+
if (current.type === AST_NODE_TYPES4.LabeledStatement && current.label.name === label.name)
|
|
9444
9652
|
return current.body;
|
|
9445
9653
|
current = current.parent ?? undefined;
|
|
9446
9654
|
}
|
|
@@ -9693,7 +9901,7 @@ var rule = {
|
|
|
9693
9901
|
function onIfConsequentExit(node) {
|
|
9694
9902
|
const consequentNode = node;
|
|
9695
9903
|
const parent = consequentNode.parent;
|
|
9696
|
-
if (parent?.type ===
|
|
9904
|
+
if (parent?.type === AST_NODE_TYPES4.IfStatement) {
|
|
9697
9905
|
const branches = branchStacks.get(parent) ?? [];
|
|
9698
9906
|
branches.push(cloneStack());
|
|
9699
9907
|
branchStacks.set(parent, branches);
|
|
@@ -9708,7 +9916,7 @@ var rule = {
|
|
|
9708
9916
|
function onIfAlternateExit(node) {
|
|
9709
9917
|
const alternateNode = node;
|
|
9710
9918
|
const parent = alternateNode.parent;
|
|
9711
|
-
if (parent?.type ===
|
|
9919
|
+
if (parent?.type === AST_NODE_TYPES4.IfStatement) {
|
|
9712
9920
|
const branches = branchStacks.get(parent) ?? [];
|
|
9713
9921
|
branches.push(cloneStack());
|
|
9714
9922
|
branchStacks.set(parent, branches);
|
|
@@ -9757,7 +9965,7 @@ var rule = {
|
|
|
9757
9965
|
function onTryBlockExit(node) {
|
|
9758
9966
|
const blockNode = node;
|
|
9759
9967
|
const { parent } = blockNode;
|
|
9760
|
-
if (parent?.type ===
|
|
9968
|
+
if (parent?.type === AST_NODE_TYPES4.TryStatement) {
|
|
9761
9969
|
const branches = branchStacks.get(parent) ?? [];
|
|
9762
9970
|
branches.push(cloneStack());
|
|
9763
9971
|
branchStacks.set(parent, branches);
|
|
@@ -9776,7 +9984,7 @@ var rule = {
|
|
|
9776
9984
|
function onCatchClauseExit(node) {
|
|
9777
9985
|
const catchNode = node;
|
|
9778
9986
|
const { parent } = catchNode;
|
|
9779
|
-
if (parent?.type ===
|
|
9987
|
+
if (parent?.type === AST_NODE_TYPES4.TryStatement) {
|
|
9780
9988
|
const branches = branchStacks.get(parent) ?? [];
|
|
9781
9989
|
branches.push(cloneStack());
|
|
9782
9990
|
branchStacks.set(parent, branches);
|
|
@@ -9839,7 +10047,7 @@ var rule = {
|
|
|
9839
10047
|
function onSwitchCaseExit(node) {
|
|
9840
10048
|
const caseNode = node;
|
|
9841
10049
|
const { parent } = caseNode;
|
|
9842
|
-
if (parent?.type ===
|
|
10050
|
+
if (parent?.type === AST_NODE_TYPES4.SwitchStatement) {
|
|
9843
10051
|
const branches = branchStacks.get(parent) ?? [];
|
|
9844
10052
|
branches.push(cloneStack());
|
|
9845
10053
|
branchStacks.set(parent, branches);
|
|
@@ -9870,7 +10078,7 @@ var rule = {
|
|
|
9870
10078
|
for (const { opener, config, node: node2 } of openerStack) {
|
|
9871
10079
|
const validClosers = getValidClosers(config);
|
|
9872
10080
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
9873
|
-
const statementType = statementNode.type ===
|
|
10081
|
+
const statementType = statementNode.type === AST_NODE_TYPES4.ReturnStatement ? "return" : "throw";
|
|
9874
10082
|
const lineNumber = statementNode.loc?.start.line ?? 0;
|
|
9875
10083
|
context.report({
|
|
9876
10084
|
data: {
|
|
@@ -9887,7 +10095,7 @@ var rule = {
|
|
|
9887
10095
|
const statementNode = node;
|
|
9888
10096
|
if (openerStack.length === 0)
|
|
9889
10097
|
return;
|
|
9890
|
-
const targetLoop = statementNode.type ===
|
|
10098
|
+
const targetLoop = statementNode.type === AST_NODE_TYPES4.ContinueStatement ? resolveContinueTargetLoop(statementNode) : resolveBreakTargetLoop(statementNode);
|
|
9891
10099
|
if (!targetLoop)
|
|
9892
10100
|
return;
|
|
9893
10101
|
for (const { node: openerNode, config, opener, loopAncestors } of openerStack) {
|
|
@@ -9895,7 +10103,7 @@ var rule = {
|
|
|
9895
10103
|
continue;
|
|
9896
10104
|
const validClosers = getValidClosers(config);
|
|
9897
10105
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
9898
|
-
const statementType = statementNode.type ===
|
|
10106
|
+
const statementType = statementNode.type === AST_NODE_TYPES4.BreakStatement ? "break" : "continue";
|
|
9899
10107
|
const lineNumber = statementNode.loc?.start.line ?? 0;
|
|
9900
10108
|
context.report({
|
|
9901
10109
|
data: {
|
|
@@ -10033,7 +10241,7 @@ var rule = {
|
|
|
10033
10241
|
continue;
|
|
10034
10242
|
const validClosers = getValidClosers(config);
|
|
10035
10243
|
const closer = validClosers.length === 1 ? validClosers[0] ?? "closer" : validClosers.join("' or '");
|
|
10036
|
-
const asyncType = asyncNode.type ===
|
|
10244
|
+
const asyncType = asyncNode.type === AST_NODE_TYPES4.AwaitExpression ? "await" : "yield";
|
|
10037
10245
|
context.report({
|
|
10038
10246
|
data: { asyncType, closer, opener },
|
|
10039
10247
|
messageId: "asyncViolation",
|
|
@@ -11580,6 +11788,7 @@ var rules = {
|
|
|
11580
11788
|
"ban-instances": ban_instances_default,
|
|
11581
11789
|
"ban-react-fc": ban_react_fc_default,
|
|
11582
11790
|
"enforce-ianitor-check-type": enforce_ianitor_check_type_default,
|
|
11791
|
+
"no-async-constructor": no_async_constructor_default,
|
|
11583
11792
|
"no-color3-constructor": no_color3_constructor_default,
|
|
11584
11793
|
"no-instance-methods-without-this": no_instance_methods_without_this_default,
|
|
11585
11794
|
"no-print": no_print_default,
|
|
@@ -11602,6 +11811,7 @@ var recommended = {
|
|
|
11602
11811
|
rules: {
|
|
11603
11812
|
"cease-nonsense/ban-react-fc": "error",
|
|
11604
11813
|
"cease-nonsense/enforce-ianitor-check-type": "error",
|
|
11814
|
+
"cease-nonsense/no-async-constructor": "error",
|
|
11605
11815
|
"cease-nonsense/no-color3-constructor": "error",
|
|
11606
11816
|
"cease-nonsense/no-instance-methods-without-this": "error",
|
|
11607
11817
|
"cease-nonsense/no-print": "error",
|
|
@@ -11636,4 +11846,4 @@ export {
|
|
|
11636
11846
|
createBanInstancesOptions
|
|
11637
11847
|
};
|
|
11638
11848
|
|
|
11639
|
-
//# debugId=
|
|
11849
|
+
//# debugId=734DB8BE5C92D79464756E2164756E21
|