eslint-linter-browserify 10.5.0 → 10.6.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/linter.cjs CHANGED
@@ -4216,7 +4216,7 @@ function requireEslintVisitorKeys$2 () {
4216
4216
  return eslintVisitorKeys$2;
4217
4217
  }
4218
4218
 
4219
- var version = "10.5.0";
4219
+ var version = "10.6.0";
4220
4220
  var require$$3$1 = {
4221
4221
  version: version};
4222
4222
 
@@ -69766,6 +69766,10 @@ function requireMaxClassesPerFile () {
69766
69766
  if (classCount > max) {
69767
69767
  context.report({
69768
69768
  node,
69769
+ loc: {
69770
+ start: node.body[0].loc.start,
69771
+ end: node.body.at(-1).loc.end,
69772
+ },
69769
69773
  messageId: "maximumExceeded",
69770
69774
  data: {
69771
69775
  classCount,
@@ -71032,10 +71036,12 @@ function requireMaxNestedCallbacks () {
71032
71036
  function checkFunction(node) {
71033
71037
  const parent = node.parent;
71034
71038
 
71035
- if (parent.type === "CallExpression") {
71036
- callbackStack.push(node);
71039
+ if (parent.type !== "CallExpression" || parent.callee === node) {
71040
+ return;
71037
71041
  }
71038
71042
 
71043
+ callbackStack.push(node);
71044
+
71039
71045
  if (callbackStack.length > THRESHOLD) {
71040
71046
  const opts = { num: callbackStack.length, max: THRESHOLD };
71041
71047
 
@@ -75598,6 +75604,8 @@ function requireNoConstantBinaryExpression () {
75598
75604
  ">>>",
75599
75605
  ]);
75600
75606
 
75607
+ const RELATIONAL_OPERATORS = new Set(["<", "<=", ">", ">="]);
75608
+
75601
75609
  //------------------------------------------------------------------------------
75602
75610
  // Helpers
75603
75611
  //------------------------------------------------------------------------------
@@ -75657,7 +75665,9 @@ function requireNoConstantBinaryExpression () {
75657
75665
  return (
75658
75666
  (functionName === "Boolean" ||
75659
75667
  functionName === "String" ||
75660
- functionName === "Number") &&
75668
+ functionName === "Number" ||
75669
+ functionName === "Symbol" ||
75670
+ functionName === "BigInt") &&
75661
75671
  isReferenceToGlobalVariable(scope, node.callee)
75662
75672
  );
75663
75673
  }
@@ -75942,7 +75952,10 @@ function requireNoConstantBinaryExpression () {
75942
75952
  const functionName = node.callee.name;
75943
75953
 
75944
75954
  if (
75945
- (functionName === "String" || functionName === "Number") &&
75955
+ (functionName === "String" ||
75956
+ functionName === "Number" ||
75957
+ functionName === "BigInt" ||
75958
+ functionName === "Symbol") &&
75946
75959
  isReferenceToGlobalVariable(scope, node.callee)
75947
75960
  ) {
75948
75961
  return true;
@@ -76055,6 +76068,33 @@ function requireNoConstantBinaryExpression () {
76055
76068
  return null;
76056
76069
  }
76057
76070
 
76071
+ /**
76072
+ * Checks if a node is a statically knowable literal.
76073
+ * @param {Scope} scope The scope in which the node was found.
76074
+ * @param {ASTNode} node The node to test.
76075
+ * @returns {boolean} `true` if the node is a literal.
76076
+ */
76077
+ function isStaticLiteral(scope, node) {
76078
+ switch (node.type) {
76079
+ case "Literal":
76080
+ return true;
76081
+ case "UnaryExpression":
76082
+ return (
76083
+ ["-", "+", "~"].includes(node.operator) &&
76084
+ node.argument.type === "Literal"
76085
+ );
76086
+ case "Identifier":
76087
+ return (
76088
+ node.name === "undefined" &&
76089
+ isReferenceToGlobalVariable(scope, node)
76090
+ );
76091
+ case "TemplateLiteral":
76092
+ return node.expressions.length === 0;
76093
+ default:
76094
+ return false;
76095
+ }
76096
+ }
76097
+
76058
76098
  //------------------------------------------------------------------------------
76059
76099
  // Rule Definition
76060
76100
  //------------------------------------------------------------------------------
@@ -76069,7 +76109,22 @@ function requireNoConstantBinaryExpression () {
76069
76109
  recommended: true,
76070
76110
  url: "https://eslint.org/docs/latest/rules/no-constant-binary-expression",
76071
76111
  },
76072
- schema: [],
76112
+ defaultOptions: [
76113
+ {
76114
+ checkRelationalComparisons: false,
76115
+ },
76116
+ ],
76117
+ schema: [
76118
+ {
76119
+ type: "object",
76120
+ properties: {
76121
+ checkRelationalComparisons: {
76122
+ type: "boolean",
76123
+ },
76124
+ },
76125
+ additionalProperties: false,
76126
+ },
76127
+ ],
76073
76128
  messages: {
76074
76129
  constantBinaryOperand:
76075
76130
  "Unexpected constant binary expression. Compares constantly with the {{otherSide}}-hand side of the `{{operator}}`.",
@@ -76079,11 +76134,14 @@ function requireNoConstantBinaryExpression () {
76079
76134
  "Unexpected comparison to newly constructed object. These two values can never be equal.",
76080
76135
  bothAlwaysNew:
76081
76136
  "Unexpected comparison of two newly constructed objects. These two values can never be equal.",
76137
+ constantRelationalComparison:
76138
+ "Unexpected constant relational comparison. Both sides of the `{{operator}}` are literal values.",
76082
76139
  },
76083
76140
  },
76084
76141
 
76085
76142
  create(context) {
76086
76143
  const sourceCode = context.sourceCode;
76144
+ const { checkRelationalComparisons } = context.options[0];
76087
76145
 
76088
76146
  return {
76089
76147
  LogicalExpression(node) {
@@ -76157,6 +76215,20 @@ function requireNoConstantBinaryExpression () {
76157
76215
  messageId: "bothAlwaysNew",
76158
76216
  });
76159
76217
  }
76218
+ } else if (
76219
+ checkRelationalComparisons &&
76220
+ RELATIONAL_OPERATORS.has(operator)
76221
+ ) {
76222
+ if (
76223
+ isStaticLiteral(scope, left) &&
76224
+ isStaticLiteral(scope, right)
76225
+ ) {
76226
+ context.report({
76227
+ node,
76228
+ messageId: "constantRelationalComparison",
76229
+ data: { operator },
76230
+ });
76231
+ }
76160
76232
  }
76161
76233
  },
76162
76234
 
@@ -83083,7 +83155,8 @@ function requireNoExtraBooleanCast () {
83083
83155
  (node.type === "CallExpression" ||
83084
83156
  node.type === "NewExpression") &&
83085
83157
  node.callee.type === "Identifier" &&
83086
- node.callee.name === "Boolean"
83158
+ node.callee.name === "Boolean" &&
83159
+ sourceCode.isGlobalReference(node.callee)
83087
83160
  );
83088
83161
  }
83089
83162
 
@@ -83315,7 +83388,8 @@ function requireNoExtraBooleanCast () {
83315
83388
  CallExpression(node) {
83316
83389
  if (
83317
83390
  node.callee.type !== "Identifier" ||
83318
- node.callee.name !== "Boolean"
83391
+ node.callee.name !== "Boolean" ||
83392
+ !sourceCode.isGlobalReference(node.callee)
83319
83393
  ) {
83320
83394
  return;
83321
83395
  }
@@ -94136,10 +94210,11 @@ function requireNoPromiseExecutorReturn () {
94136
94210
  });
94137
94211
  }
94138
94212
 
94139
- // Do not suggest wrapping an unnamed FunctionExpression in braces as that would be invalid syntax.
94213
+ // Do not suggest wrapping an unnamed function or class expression in braces as that would be invalid syntax.
94140
94214
  if (
94141
94215
  !(
94142
- node.body.type === "FunctionExpression" &&
94216
+ (node.body.type === "FunctionExpression" ||
94217
+ node.body.type === "ClassExpression") &&
94143
94218
  !node.body.id
94144
94219
  )
94145
94220
  ) {
@@ -100240,12 +100315,17 @@ function requireNoThrowLiteral () {
100240
100315
  },
100241
100316
 
100242
100317
  create(context) {
100318
+ const sourceCode = context.sourceCode;
100319
+
100243
100320
  return {
100244
100321
  ThrowStatement(node) {
100245
100322
  if (!astUtils.couldBeError(node.argument)) {
100246
100323
  context.report({ node, messageId: "object" });
100247
100324
  } else if (node.argument.type === "Identifier") {
100248
- if (node.argument.name === "undefined") {
100325
+ if (
100326
+ node.argument.name === "undefined" &&
100327
+ sourceCode.isGlobalReference(node.argument)
100328
+ ) {
100249
100329
  context.report({ node, messageId: "undef" });
100250
100330
  }
100251
100331
  }
@@ -115332,6 +115412,11 @@ function requirePreferExponentiationOperator () {
115332
115412
  operator: "**",
115333
115413
  });
115334
115414
 
115415
+ /*
115416
+ * Characters that can cause continuation without preceding semi
115417
+ */
115418
+ const continuationChars = new Set(["(", "[", "/", "`"]);
115419
+
115335
115420
  /**
115336
115421
  * Determines whether the given node needs parens if used as the base in an exponentiation binary expression.
115337
115422
  * @param {ASTNode} base The node to check.
@@ -115460,11 +115545,36 @@ function requirePreferExponentiationOperator () {
115460
115545
  shouldParenthesizeBase = doesBaseNeedParens(base),
115461
115546
  shouldParenthesizeExponent =
115462
115547
  doesExponentNeedParens(exponent),
115463
- shouldParenthesizeAll =
115464
- doesExponentiationExpressionNeedParens(
115465
- node,
115466
- sourceCode,
115467
- );
115548
+ isStartOfExpressionStatement =
115549
+ astUtils.isStartOfExpressionStatement(node);
115550
+
115551
+ let shouldParenthesizeAll =
115552
+ doesExponentiationExpressionNeedParens(
115553
+ node,
115554
+ sourceCode,
115555
+ );
115556
+
115557
+ /*
115558
+ * `function`, `class`, or `{` token at the start of an expression statement
115559
+ * would cause incorrect parsing.
115560
+ * https://github.com/eslint/eslint/issues/20987
115561
+ */
115562
+ if (
115563
+ !shouldParenthesizeAll &&
115564
+ !shouldParenthesizeBase &&
115565
+ isStartOfExpressionStatement
115566
+ ) {
115567
+ const firstTokenOfBase = sourceCode.getFirstToken(base);
115568
+
115569
+ if (
115570
+ astUtils.isOpeningBraceToken(firstTokenOfBase) ||
115571
+ (firstTokenOfBase.type === "Keyword" &&
115572
+ (firstTokenOfBase.value === "function" ||
115573
+ firstTokenOfBase.value === "class"))
115574
+ ) {
115575
+ shouldParenthesizeAll = true;
115576
+ }
115577
+ }
115468
115578
 
115469
115579
  let prefix = "",
115470
115580
  suffix = "";
@@ -115517,6 +115627,15 @@ function requirePreferExponentiationOperator () {
115517
115627
  shouldParenthesizeAll,
115518
115628
  );
115519
115629
 
115630
+ if (
115631
+ !prefix &&
115632
+ isStartOfExpressionStatement &&
115633
+ continuationChars.has(replacement[0]) &&
115634
+ astUtils.needsPrecedingSemicolon(sourceCode, node)
115635
+ ) {
115636
+ prefix = ";";
115637
+ }
115638
+
115520
115639
  return fixer.replaceText(
115521
115640
  node,
115522
115641
  `${prefix}${replacement}${suffix}`,
@@ -116471,11 +116590,15 @@ function requirePreferPromiseRejectErrors () {
116471
116590
  if (!callExpression.arguments.length && allowEmptyReject) {
116472
116591
  return;
116473
116592
  }
116593
+
116594
+ const rejectionReason = callExpression.arguments[0];
116595
+
116474
116596
  if (
116475
116597
  !callExpression.arguments.length ||
116476
- !astUtils.couldBeError(callExpression.arguments[0]) ||
116477
- (callExpression.arguments[0].type === "Identifier" &&
116478
- callExpression.arguments[0].name === "undefined")
116598
+ !astUtils.couldBeError(rejectionReason) ||
116599
+ (rejectionReason.type === "Identifier" &&
116600
+ rejectionReason.name === "undefined" &&
116601
+ sourceCode.isGlobalReference(rejectionReason))
116479
116602
  ) {
116480
116603
  context.report({
116481
116604
  node: callExpression,
@@ -116490,10 +116613,15 @@ function requirePreferPromiseRejectErrors () {
116490
116613
  * @returns {boolean} `true` if the call is a Promise.reject() call
116491
116614
  */
116492
116615
  function isPromiseRejectCall(node) {
116493
- return astUtils.isSpecificMemberAccess(
116494
- node.callee,
116495
- "Promise",
116496
- "reject",
116616
+ return (
116617
+ astUtils.isSpecificMemberAccess(
116618
+ node.callee,
116619
+ "Promise",
116620
+ "reject",
116621
+ ) &&
116622
+ sourceCode.isGlobalReference(
116623
+ astUtils.skipChainExpression(node.callee).object,
116624
+ )
116497
116625
  );
116498
116626
  }
116499
116627
 
@@ -116518,6 +116646,7 @@ function requirePreferPromiseRejectErrors () {
116518
116646
  if (
116519
116647
  node.callee.type === "Identifier" &&
116520
116648
  node.callee.name === "Promise" &&
116649
+ sourceCode.isGlobalReference(node.callee) &&
116521
116650
  node.arguments.length &&
116522
116651
  astUtils.isFunction(node.arguments[0]) &&
116523
116652
  node.arguments[0].params.length > 1 &&
@@ -119357,12 +119486,15 @@ function requireRadix () {
119357
119486
  * - A literal except integers between 2 and 36.
119358
119487
  * - undefined.
119359
119488
  * @param {ASTNode} radix A node of radix to check.
119489
+ * @param {SourceCode} sourceCode The source code object.
119360
119490
  * @returns {boolean} `true` if the node is valid.
119361
119491
  */
119362
- function isValidRadix(radix) {
119492
+ function isValidRadix(radix, sourceCode) {
119363
119493
  return !(
119364
119494
  (radix.type === "Literal" && !validRadixValues.has(radix.value)) ||
119365
- (radix.type === "Identifier" && radix.name === "undefined")
119495
+ (radix.type === "Identifier" &&
119496
+ radix.name === "undefined" &&
119497
+ sourceCode.isGlobalReference(radix))
119366
119498
  );
119367
119499
  }
119368
119500
 
@@ -119448,7 +119580,7 @@ function requireRadix () {
119448
119580
  break;
119449
119581
 
119450
119582
  default:
119451
- if (!isValidRadix(args[1])) {
119583
+ if (!isValidRadix(args[1], sourceCode)) {
119452
119584
  context.report({
119453
119585
  node,
119454
119586
  messageId: "invalidRadix",
package/linter.js CHANGED
@@ -4218,7 +4218,7 @@
4218
4218
  return eslintVisitorKeys$2;
4219
4219
  }
4220
4220
 
4221
- var version = "10.5.0";
4221
+ var version = "10.6.0";
4222
4222
  var require$$3$1 = {
4223
4223
  version: version};
4224
4224
 
@@ -69768,6 +69768,10 @@
69768
69768
  if (classCount > max) {
69769
69769
  context.report({
69770
69770
  node,
69771
+ loc: {
69772
+ start: node.body[0].loc.start,
69773
+ end: node.body.at(-1).loc.end,
69774
+ },
69771
69775
  messageId: "maximumExceeded",
69772
69776
  data: {
69773
69777
  classCount,
@@ -71034,10 +71038,12 @@
71034
71038
  function checkFunction(node) {
71035
71039
  const parent = node.parent;
71036
71040
 
71037
- if (parent.type === "CallExpression") {
71038
- callbackStack.push(node);
71041
+ if (parent.type !== "CallExpression" || parent.callee === node) {
71042
+ return;
71039
71043
  }
71040
71044
 
71045
+ callbackStack.push(node);
71046
+
71041
71047
  if (callbackStack.length > THRESHOLD) {
71042
71048
  const opts = { num: callbackStack.length, max: THRESHOLD };
71043
71049
 
@@ -75600,6 +75606,8 @@
75600
75606
  ">>>",
75601
75607
  ]);
75602
75608
 
75609
+ const RELATIONAL_OPERATORS = new Set(["<", "<=", ">", ">="]);
75610
+
75603
75611
  //------------------------------------------------------------------------------
75604
75612
  // Helpers
75605
75613
  //------------------------------------------------------------------------------
@@ -75659,7 +75667,9 @@
75659
75667
  return (
75660
75668
  (functionName === "Boolean" ||
75661
75669
  functionName === "String" ||
75662
- functionName === "Number") &&
75670
+ functionName === "Number" ||
75671
+ functionName === "Symbol" ||
75672
+ functionName === "BigInt") &&
75663
75673
  isReferenceToGlobalVariable(scope, node.callee)
75664
75674
  );
75665
75675
  }
@@ -75944,7 +75954,10 @@
75944
75954
  const functionName = node.callee.name;
75945
75955
 
75946
75956
  if (
75947
- (functionName === "String" || functionName === "Number") &&
75957
+ (functionName === "String" ||
75958
+ functionName === "Number" ||
75959
+ functionName === "BigInt" ||
75960
+ functionName === "Symbol") &&
75948
75961
  isReferenceToGlobalVariable(scope, node.callee)
75949
75962
  ) {
75950
75963
  return true;
@@ -76057,6 +76070,33 @@
76057
76070
  return null;
76058
76071
  }
76059
76072
 
76073
+ /**
76074
+ * Checks if a node is a statically knowable literal.
76075
+ * @param {Scope} scope The scope in which the node was found.
76076
+ * @param {ASTNode} node The node to test.
76077
+ * @returns {boolean} `true` if the node is a literal.
76078
+ */
76079
+ function isStaticLiteral(scope, node) {
76080
+ switch (node.type) {
76081
+ case "Literal":
76082
+ return true;
76083
+ case "UnaryExpression":
76084
+ return (
76085
+ ["-", "+", "~"].includes(node.operator) &&
76086
+ node.argument.type === "Literal"
76087
+ );
76088
+ case "Identifier":
76089
+ return (
76090
+ node.name === "undefined" &&
76091
+ isReferenceToGlobalVariable(scope, node)
76092
+ );
76093
+ case "TemplateLiteral":
76094
+ return node.expressions.length === 0;
76095
+ default:
76096
+ return false;
76097
+ }
76098
+ }
76099
+
76060
76100
  //------------------------------------------------------------------------------
76061
76101
  // Rule Definition
76062
76102
  //------------------------------------------------------------------------------
@@ -76071,7 +76111,22 @@
76071
76111
  recommended: true,
76072
76112
  url: "https://eslint.org/docs/latest/rules/no-constant-binary-expression",
76073
76113
  },
76074
- schema: [],
76114
+ defaultOptions: [
76115
+ {
76116
+ checkRelationalComparisons: false,
76117
+ },
76118
+ ],
76119
+ schema: [
76120
+ {
76121
+ type: "object",
76122
+ properties: {
76123
+ checkRelationalComparisons: {
76124
+ type: "boolean",
76125
+ },
76126
+ },
76127
+ additionalProperties: false,
76128
+ },
76129
+ ],
76075
76130
  messages: {
76076
76131
  constantBinaryOperand:
76077
76132
  "Unexpected constant binary expression. Compares constantly with the {{otherSide}}-hand side of the `{{operator}}`.",
@@ -76081,11 +76136,14 @@
76081
76136
  "Unexpected comparison to newly constructed object. These two values can never be equal.",
76082
76137
  bothAlwaysNew:
76083
76138
  "Unexpected comparison of two newly constructed objects. These two values can never be equal.",
76139
+ constantRelationalComparison:
76140
+ "Unexpected constant relational comparison. Both sides of the `{{operator}}` are literal values.",
76084
76141
  },
76085
76142
  },
76086
76143
 
76087
76144
  create(context) {
76088
76145
  const sourceCode = context.sourceCode;
76146
+ const { checkRelationalComparisons } = context.options[0];
76089
76147
 
76090
76148
  return {
76091
76149
  LogicalExpression(node) {
@@ -76159,6 +76217,20 @@
76159
76217
  messageId: "bothAlwaysNew",
76160
76218
  });
76161
76219
  }
76220
+ } else if (
76221
+ checkRelationalComparisons &&
76222
+ RELATIONAL_OPERATORS.has(operator)
76223
+ ) {
76224
+ if (
76225
+ isStaticLiteral(scope, left) &&
76226
+ isStaticLiteral(scope, right)
76227
+ ) {
76228
+ context.report({
76229
+ node,
76230
+ messageId: "constantRelationalComparison",
76231
+ data: { operator },
76232
+ });
76233
+ }
76162
76234
  }
76163
76235
  },
76164
76236
 
@@ -83085,7 +83157,8 @@
83085
83157
  (node.type === "CallExpression" ||
83086
83158
  node.type === "NewExpression") &&
83087
83159
  node.callee.type === "Identifier" &&
83088
- node.callee.name === "Boolean"
83160
+ node.callee.name === "Boolean" &&
83161
+ sourceCode.isGlobalReference(node.callee)
83089
83162
  );
83090
83163
  }
83091
83164
 
@@ -83317,7 +83390,8 @@
83317
83390
  CallExpression(node) {
83318
83391
  if (
83319
83392
  node.callee.type !== "Identifier" ||
83320
- node.callee.name !== "Boolean"
83393
+ node.callee.name !== "Boolean" ||
83394
+ !sourceCode.isGlobalReference(node.callee)
83321
83395
  ) {
83322
83396
  return;
83323
83397
  }
@@ -94138,10 +94212,11 @@
94138
94212
  });
94139
94213
  }
94140
94214
 
94141
- // Do not suggest wrapping an unnamed FunctionExpression in braces as that would be invalid syntax.
94215
+ // Do not suggest wrapping an unnamed function or class expression in braces as that would be invalid syntax.
94142
94216
  if (
94143
94217
  !(
94144
- node.body.type === "FunctionExpression" &&
94218
+ (node.body.type === "FunctionExpression" ||
94219
+ node.body.type === "ClassExpression") &&
94145
94220
  !node.body.id
94146
94221
  )
94147
94222
  ) {
@@ -100242,12 +100317,17 @@
100242
100317
  },
100243
100318
 
100244
100319
  create(context) {
100320
+ const sourceCode = context.sourceCode;
100321
+
100245
100322
  return {
100246
100323
  ThrowStatement(node) {
100247
100324
  if (!astUtils.couldBeError(node.argument)) {
100248
100325
  context.report({ node, messageId: "object" });
100249
100326
  } else if (node.argument.type === "Identifier") {
100250
- if (node.argument.name === "undefined") {
100327
+ if (
100328
+ node.argument.name === "undefined" &&
100329
+ sourceCode.isGlobalReference(node.argument)
100330
+ ) {
100251
100331
  context.report({ node, messageId: "undef" });
100252
100332
  }
100253
100333
  }
@@ -115334,6 +115414,11 @@
115334
115414
  operator: "**",
115335
115415
  });
115336
115416
 
115417
+ /*
115418
+ * Characters that can cause continuation without preceding semi
115419
+ */
115420
+ const continuationChars = new Set(["(", "[", "/", "`"]);
115421
+
115337
115422
  /**
115338
115423
  * Determines whether the given node needs parens if used as the base in an exponentiation binary expression.
115339
115424
  * @param {ASTNode} base The node to check.
@@ -115462,11 +115547,36 @@
115462
115547
  shouldParenthesizeBase = doesBaseNeedParens(base),
115463
115548
  shouldParenthesizeExponent =
115464
115549
  doesExponentNeedParens(exponent),
115465
- shouldParenthesizeAll =
115466
- doesExponentiationExpressionNeedParens(
115467
- node,
115468
- sourceCode,
115469
- );
115550
+ isStartOfExpressionStatement =
115551
+ astUtils.isStartOfExpressionStatement(node);
115552
+
115553
+ let shouldParenthesizeAll =
115554
+ doesExponentiationExpressionNeedParens(
115555
+ node,
115556
+ sourceCode,
115557
+ );
115558
+
115559
+ /*
115560
+ * `function`, `class`, or `{` token at the start of an expression statement
115561
+ * would cause incorrect parsing.
115562
+ * https://github.com/eslint/eslint/issues/20987
115563
+ */
115564
+ if (
115565
+ !shouldParenthesizeAll &&
115566
+ !shouldParenthesizeBase &&
115567
+ isStartOfExpressionStatement
115568
+ ) {
115569
+ const firstTokenOfBase = sourceCode.getFirstToken(base);
115570
+
115571
+ if (
115572
+ astUtils.isOpeningBraceToken(firstTokenOfBase) ||
115573
+ (firstTokenOfBase.type === "Keyword" &&
115574
+ (firstTokenOfBase.value === "function" ||
115575
+ firstTokenOfBase.value === "class"))
115576
+ ) {
115577
+ shouldParenthesizeAll = true;
115578
+ }
115579
+ }
115470
115580
 
115471
115581
  let prefix = "",
115472
115582
  suffix = "";
@@ -115519,6 +115629,15 @@
115519
115629
  shouldParenthesizeAll,
115520
115630
  );
115521
115631
 
115632
+ if (
115633
+ !prefix &&
115634
+ isStartOfExpressionStatement &&
115635
+ continuationChars.has(replacement[0]) &&
115636
+ astUtils.needsPrecedingSemicolon(sourceCode, node)
115637
+ ) {
115638
+ prefix = ";";
115639
+ }
115640
+
115522
115641
  return fixer.replaceText(
115523
115642
  node,
115524
115643
  `${prefix}${replacement}${suffix}`,
@@ -116473,11 +116592,15 @@
116473
116592
  if (!callExpression.arguments.length && allowEmptyReject) {
116474
116593
  return;
116475
116594
  }
116595
+
116596
+ const rejectionReason = callExpression.arguments[0];
116597
+
116476
116598
  if (
116477
116599
  !callExpression.arguments.length ||
116478
- !astUtils.couldBeError(callExpression.arguments[0]) ||
116479
- (callExpression.arguments[0].type === "Identifier" &&
116480
- callExpression.arguments[0].name === "undefined")
116600
+ !astUtils.couldBeError(rejectionReason) ||
116601
+ (rejectionReason.type === "Identifier" &&
116602
+ rejectionReason.name === "undefined" &&
116603
+ sourceCode.isGlobalReference(rejectionReason))
116481
116604
  ) {
116482
116605
  context.report({
116483
116606
  node: callExpression,
@@ -116492,10 +116615,15 @@
116492
116615
  * @returns {boolean} `true` if the call is a Promise.reject() call
116493
116616
  */
116494
116617
  function isPromiseRejectCall(node) {
116495
- return astUtils.isSpecificMemberAccess(
116496
- node.callee,
116497
- "Promise",
116498
- "reject",
116618
+ return (
116619
+ astUtils.isSpecificMemberAccess(
116620
+ node.callee,
116621
+ "Promise",
116622
+ "reject",
116623
+ ) &&
116624
+ sourceCode.isGlobalReference(
116625
+ astUtils.skipChainExpression(node.callee).object,
116626
+ )
116499
116627
  );
116500
116628
  }
116501
116629
 
@@ -116520,6 +116648,7 @@
116520
116648
  if (
116521
116649
  node.callee.type === "Identifier" &&
116522
116650
  node.callee.name === "Promise" &&
116651
+ sourceCode.isGlobalReference(node.callee) &&
116523
116652
  node.arguments.length &&
116524
116653
  astUtils.isFunction(node.arguments[0]) &&
116525
116654
  node.arguments[0].params.length > 1 &&
@@ -119359,12 +119488,15 @@
119359
119488
  * - A literal except integers between 2 and 36.
119360
119489
  * - undefined.
119361
119490
  * @param {ASTNode} radix A node of radix to check.
119491
+ * @param {SourceCode} sourceCode The source code object.
119362
119492
  * @returns {boolean} `true` if the node is valid.
119363
119493
  */
119364
- function isValidRadix(radix) {
119494
+ function isValidRadix(radix, sourceCode) {
119365
119495
  return !(
119366
119496
  (radix.type === "Literal" && !validRadixValues.has(radix.value)) ||
119367
- (radix.type === "Identifier" && radix.name === "undefined")
119497
+ (radix.type === "Identifier" &&
119498
+ radix.name === "undefined" &&
119499
+ sourceCode.isGlobalReference(radix))
119368
119500
  );
119369
119501
  }
119370
119502
 
@@ -119450,7 +119582,7 @@
119450
119582
  break;
119451
119583
 
119452
119584
  default:
119453
- if (!isValidRadix(args[1])) {
119585
+ if (!isValidRadix(args[1], sourceCode)) {
119454
119586
  context.report({
119455
119587
  node,
119456
119588
  messageId: "invalidRadix",