eslint-linter-browserify 10.4.1 → 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.
Files changed (5) hide show
  1. package/linter.cjs +252 -139
  2. package/linter.js +252 -139
  3. package/linter.min.js +3 -3
  4. package/linter.mjs +252 -139
  5. package/package.json +4 -4
package/linter.cjs CHANGED
@@ -4216,7 +4216,7 @@ function requireEslintVisitorKeys$2 () {
4216
4216
  return eslintVisitorKeys$2;
4217
4217
  }
4218
4218
 
4219
- var version = "10.4.1";
4219
+ var version = "10.6.0";
4220
4220
  var require$$3$1 = {
4221
4221
  version: version};
4222
4222
 
@@ -50101,6 +50101,36 @@ function requireArrayBracketSpacing () {
50101
50101
  return arrayBracketSpacing;
50102
50102
  }
50103
50103
 
50104
+ /**
50105
+ * @fileoverview Code path related utilities.
50106
+ */
50107
+
50108
+ var codePathUtils;
50109
+ var hasRequiredCodePathUtils;
50110
+
50111
+ function requireCodePathUtils () {
50112
+ if (hasRequiredCodePathUtils) return codePathUtils;
50113
+ hasRequiredCodePathUtils = 1;
50114
+
50115
+ /**
50116
+ * Checks all segments in a set and returns true if any are reachable.
50117
+ * @param {Set<CodePathSegment>} segments The segments to check.
50118
+ * @returns {boolean} `true` if any segment is reachable; `false` otherwise.
50119
+ */
50120
+ function isAnySegmentReachable(segments) {
50121
+ for (const segment of segments) {
50122
+ if (segment.reachable) {
50123
+ return true;
50124
+ }
50125
+ }
50126
+
50127
+ return false;
50128
+ }
50129
+
50130
+ codePathUtils = { isAnySegmentReachable };
50131
+ return codePathUtils;
50132
+ }
50133
+
50104
50134
  /**
50105
50135
  * @fileoverview Rule to enforce return statements in callbacks of array's methods
50106
50136
  * @author Toru Nagashima
@@ -50118,6 +50148,7 @@ function requireArrayCallbackReturn () {
50118
50148
  //------------------------------------------------------------------------------
50119
50149
 
50120
50150
  const astUtils = requireAstUtils();
50151
+ const { isAnySegmentReachable } = requireCodePathUtils();
50121
50152
 
50122
50153
  //------------------------------------------------------------------------------
50123
50154
  // Helpers
@@ -50138,21 +50169,6 @@ function requireArrayCallbackReturn () {
50138
50169
  return astUtils.isSpecificMemberAccess(node, null, TARGET_METHODS);
50139
50170
  }
50140
50171
 
50141
- /**
50142
- * Checks all segments in a set and returns true if any are reachable.
50143
- * @param {Set<CodePathSegment>} segments The segments to check.
50144
- * @returns {boolean} True if any segment is reachable; false otherwise.
50145
- */
50146
- function isAnySegmentReachable(segments) {
50147
- for (const segment of segments) {
50148
- if (segment.reachable) {
50149
- return true;
50150
- }
50151
- }
50152
-
50153
- return false;
50154
- }
50155
-
50156
50172
  /**
50157
50173
  * Returns a human-legible description of an array method
50158
50174
  * @param {string} arrayMethodName A method name to fully qualify
@@ -55364,26 +55380,12 @@ function requireConsistentReturn () {
55364
55380
 
55365
55381
  const astUtils = requireAstUtils();
55366
55382
  const { upperCaseFirst } = requireStringUtils();
55383
+ const { isAnySegmentReachable } = requireCodePathUtils();
55367
55384
 
55368
55385
  //------------------------------------------------------------------------------
55369
55386
  // Helpers
55370
55387
  //------------------------------------------------------------------------------
55371
55388
 
55372
- /**
55373
- * Checks all segments in a set and returns true if all are unreachable.
55374
- * @param {Set<CodePathSegment>} segments The segments to check.
55375
- * @returns {boolean} True if all segments are unreachable; false otherwise.
55376
- */
55377
- function areAllSegmentsUnreachable(segments) {
55378
- for (const segment of segments) {
55379
- if (segment.reachable) {
55380
- return false;
55381
- }
55382
- }
55383
-
55384
- return true;
55385
- }
55386
-
55387
55389
  /**
55388
55390
  * Checks whether a given node is a `constructor` method in an ES6 class
55389
55391
  * @param {ASTNode} node A node to check
@@ -55454,7 +55456,7 @@ function requireConsistentReturn () {
55454
55456
  */
55455
55457
  if (
55456
55458
  !funcInfo.hasReturnValue ||
55457
- areAllSegmentsUnreachable(funcInfo.currentSegments) ||
55459
+ !isAnySegmentReachable(funcInfo.currentSegments) ||
55458
55460
  astUtils.isES5Constructor(node) ||
55459
55461
  isClassConstructor(node)
55460
55462
  ) {
@@ -59846,6 +59848,7 @@ function requireGetterReturn () {
59846
59848
  //------------------------------------------------------------------------------
59847
59849
 
59848
59850
  const astUtils = requireAstUtils();
59851
+ const { isAnySegmentReachable } = requireCodePathUtils();
59849
59852
 
59850
59853
  //------------------------------------------------------------------------------
59851
59854
  // Helpers
@@ -59853,21 +59856,6 @@ function requireGetterReturn () {
59853
59856
 
59854
59857
  const TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u;
59855
59858
 
59856
- /**
59857
- * Checks all segments in a set and returns true if any are reachable.
59858
- * @param {Set<CodePathSegment>} segments The segments to check.
59859
- * @returns {boolean} True if any segment is reachable; false otherwise.
59860
- */
59861
- function isAnySegmentReachable(segments) {
59862
- for (const segment of segments) {
59863
- if (segment.reachable) {
59864
- return true;
59865
- }
59866
- }
59867
-
59868
- return false;
59869
- }
59870
-
59871
59859
  //------------------------------------------------------------------------------
59872
59860
  // Rule Definition
59873
59861
  //------------------------------------------------------------------------------
@@ -69778,6 +69766,10 @@ function requireMaxClassesPerFile () {
69778
69766
  if (classCount > max) {
69779
69767
  context.report({
69780
69768
  node,
69769
+ loc: {
69770
+ start: node.body[0].loc.start,
69771
+ end: node.body.at(-1).loc.end,
69772
+ },
69781
69773
  messageId: "maximumExceeded",
69782
69774
  data: {
69783
69775
  classCount,
@@ -69861,6 +69853,8 @@ function requireMaxDepth () {
69861
69853
  },
69862
69854
 
69863
69855
  create(context) {
69856
+ const sourceCode = context.sourceCode;
69857
+
69864
69858
  //--------------------------------------------------------------------------
69865
69859
  // Helpers
69866
69860
  //--------------------------------------------------------------------------
@@ -69909,6 +69903,7 @@ function requireMaxDepth () {
69909
69903
  if (len > maxDepth) {
69910
69904
  context.report({
69911
69905
  node,
69906
+ loc: sourceCode.getFirstToken(node).loc,
69912
69907
  messageId: "tooDeeply",
69913
69908
  data: { depth: len, maxDepth },
69914
69909
  });
@@ -69924,6 +69919,18 @@ function requireMaxDepth () {
69924
69919
  functionStack[functionStack.length - 1]--;
69925
69920
  }
69926
69921
 
69922
+ /**
69923
+ * Checks whether a node is an else-if statement.
69924
+ * @param {ASTNode} node node to evaluate
69925
+ * @returns {boolean} Whether the node is an else-if statement
69926
+ */
69927
+ function isElseIf(node) {
69928
+ return (
69929
+ node.parent.type === "IfStatement" &&
69930
+ node.parent.alternate === node
69931
+ );
69932
+ }
69933
+
69927
69934
  //--------------------------------------------------------------------------
69928
69935
  // Public API
69929
69936
  //--------------------------------------------------------------------------
@@ -69936,7 +69943,7 @@ function requireMaxDepth () {
69936
69943
  StaticBlock: startFunction,
69937
69944
 
69938
69945
  IfStatement(node) {
69939
- if (node.parent.type !== "IfStatement") {
69946
+ if (!isElseIf(node)) {
69940
69947
  pushBlock(node);
69941
69948
  }
69942
69949
  },
@@ -69949,7 +69956,11 @@ function requireMaxDepth () {
69949
69956
  ForInStatement: pushBlock,
69950
69957
  ForOfStatement: pushBlock,
69951
69958
 
69952
- "IfStatement:exit": popBlock,
69959
+ "IfStatement:exit"(node) {
69960
+ if (!isElseIf(node)) {
69961
+ popBlock();
69962
+ }
69963
+ },
69953
69964
  "SwitchStatement:exit": popBlock,
69954
69965
  "TryStatement:exit": popBlock,
69955
69966
  "DoWhileStatement:exit": popBlock,
@@ -70906,6 +70917,7 @@ function requireMaxLinesPerFunction () {
70906
70917
 
70907
70918
  context.report({
70908
70919
  node,
70920
+ loc: astUtils.getFunctionHeadLoc(funcNode, sourceCode),
70909
70921
  messageId: "exceed",
70910
70922
  data: { name, lineCount, maxLines },
70911
70923
  });
@@ -70938,6 +70950,12 @@ function requireMaxNestedCallbacks () {
70938
70950
  if (hasRequiredMaxNestedCallbacks) return maxNestedCallbacks;
70939
70951
  hasRequiredMaxNestedCallbacks = 1;
70940
70952
 
70953
+ //------------------------------------------------------------------------------
70954
+ // Requirements
70955
+ //------------------------------------------------------------------------------
70956
+
70957
+ const astUtils = requireAstUtils();
70958
+
70941
70959
  //------------------------------------------------------------------------------
70942
70960
  // Rule Definition
70943
70961
  //------------------------------------------------------------------------------
@@ -70986,6 +71004,8 @@ function requireMaxNestedCallbacks () {
70986
71004
  },
70987
71005
 
70988
71006
  create(context) {
71007
+ const sourceCode = context.sourceCode;
71008
+
70989
71009
  //--------------------------------------------------------------------------
70990
71010
  // Constants
70991
71011
  //--------------------------------------------------------------------------
@@ -71016,24 +71036,34 @@ function requireMaxNestedCallbacks () {
71016
71036
  function checkFunction(node) {
71017
71037
  const parent = node.parent;
71018
71038
 
71019
- if (parent.type === "CallExpression") {
71020
- callbackStack.push(node);
71039
+ if (parent.type !== "CallExpression" || parent.callee === node) {
71040
+ return;
71021
71041
  }
71022
71042
 
71043
+ callbackStack.push(node);
71044
+
71023
71045
  if (callbackStack.length > THRESHOLD) {
71024
71046
  const opts = { num: callbackStack.length, max: THRESHOLD };
71025
71047
 
71026
- context.report({ node, messageId: "exceed", data: opts });
71048
+ context.report({
71049
+ node,
71050
+ loc: astUtils.getFunctionHeadLoc(node, sourceCode),
71051
+ messageId: "exceed",
71052
+ data: opts,
71053
+ });
71027
71054
  }
71028
71055
  }
71029
71056
 
71030
71057
  /**
71031
71058
  * Pops the call stack.
71059
+ * @param {ASTNode} node The node to check.
71032
71060
  * @returns {void}
71033
71061
  * @private
71034
71062
  */
71035
- function popStack() {
71036
- callbackStack.pop();
71063
+ function popStack(node) {
71064
+ if (callbackStack.at(-1) === node) {
71065
+ callbackStack.pop();
71066
+ }
71037
71067
  }
71038
71068
 
71039
71069
  //--------------------------------------------------------------------------
@@ -71325,6 +71355,7 @@ function requireMaxStatements () {
71325
71355
 
71326
71356
  context.report({
71327
71357
  node,
71358
+ loc: astUtils.getFunctionHeadLoc(node, context.sourceCode),
71328
71359
  messageId: "exceed",
71329
71360
  data: { name, count, max },
71330
71361
  });
@@ -75573,6 +75604,8 @@ function requireNoConstantBinaryExpression () {
75573
75604
  ">>>",
75574
75605
  ]);
75575
75606
 
75607
+ const RELATIONAL_OPERATORS = new Set(["<", "<=", ">", ">="]);
75608
+
75576
75609
  //------------------------------------------------------------------------------
75577
75610
  // Helpers
75578
75611
  //------------------------------------------------------------------------------
@@ -75632,7 +75665,9 @@ function requireNoConstantBinaryExpression () {
75632
75665
  return (
75633
75666
  (functionName === "Boolean" ||
75634
75667
  functionName === "String" ||
75635
- functionName === "Number") &&
75668
+ functionName === "Number" ||
75669
+ functionName === "Symbol" ||
75670
+ functionName === "BigInt") &&
75636
75671
  isReferenceToGlobalVariable(scope, node.callee)
75637
75672
  );
75638
75673
  }
@@ -75917,7 +75952,10 @@ function requireNoConstantBinaryExpression () {
75917
75952
  const functionName = node.callee.name;
75918
75953
 
75919
75954
  if (
75920
- (functionName === "String" || functionName === "Number") &&
75955
+ (functionName === "String" ||
75956
+ functionName === "Number" ||
75957
+ functionName === "BigInt" ||
75958
+ functionName === "Symbol") &&
75921
75959
  isReferenceToGlobalVariable(scope, node.callee)
75922
75960
  ) {
75923
75961
  return true;
@@ -76030,6 +76068,33 @@ function requireNoConstantBinaryExpression () {
76030
76068
  return null;
76031
76069
  }
76032
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
+
76033
76098
  //------------------------------------------------------------------------------
76034
76099
  // Rule Definition
76035
76100
  //------------------------------------------------------------------------------
@@ -76044,7 +76109,22 @@ function requireNoConstantBinaryExpression () {
76044
76109
  recommended: true,
76045
76110
  url: "https://eslint.org/docs/latest/rules/no-constant-binary-expression",
76046
76111
  },
76047
- 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
+ ],
76048
76128
  messages: {
76049
76129
  constantBinaryOperand:
76050
76130
  "Unexpected constant binary expression. Compares constantly with the {{otherSide}}-hand side of the `{{operator}}`.",
@@ -76054,11 +76134,14 @@ function requireNoConstantBinaryExpression () {
76054
76134
  "Unexpected comparison to newly constructed object. These two values can never be equal.",
76055
76135
  bothAlwaysNew:
76056
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.",
76057
76139
  },
76058
76140
  },
76059
76141
 
76060
76142
  create(context) {
76061
76143
  const sourceCode = context.sourceCode;
76144
+ const { checkRelationalComparisons } = context.options[0];
76062
76145
 
76063
76146
  return {
76064
76147
  LogicalExpression(node) {
@@ -76132,6 +76215,20 @@ function requireNoConstantBinaryExpression () {
76132
76215
  messageId: "bothAlwaysNew",
76133
76216
  });
76134
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
+ }
76135
76232
  }
76136
76233
  },
76137
76234
 
@@ -83058,7 +83155,8 @@ function requireNoExtraBooleanCast () {
83058
83155
  (node.type === "CallExpression" ||
83059
83156
  node.type === "NewExpression") &&
83060
83157
  node.callee.type === "Identifier" &&
83061
- node.callee.name === "Boolean"
83158
+ node.callee.name === "Boolean" &&
83159
+ sourceCode.isGlobalReference(node.callee)
83062
83160
  );
83063
83161
  }
83064
83162
 
@@ -83290,7 +83388,8 @@ function requireNoExtraBooleanCast () {
83290
83388
  CallExpression(node) {
83291
83389
  if (
83292
83390
  node.callee.type !== "Identifier" ||
83293
- node.callee.name !== "Boolean"
83391
+ node.callee.name !== "Boolean" ||
83392
+ !sourceCode.isGlobalReference(node.callee)
83294
83393
  ) {
83295
83394
  return;
83296
83395
  }
@@ -85431,6 +85530,7 @@ function requireNoFallthrough () {
85431
85530
  //------------------------------------------------------------------------------
85432
85531
 
85433
85532
  const { directivesPattern } = requireDirectives();
85533
+ const { isAnySegmentReachable } = requireCodePathUtils();
85434
85534
 
85435
85535
  //------------------------------------------------------------------------------
85436
85536
  // Helpers
@@ -85438,21 +85538,6 @@ function requireNoFallthrough () {
85438
85538
 
85439
85539
  const DEFAULT_FALLTHROUGH_COMMENT = /falls?\s?through/iu;
85440
85540
 
85441
- /**
85442
- * Checks all segments in a set and returns true if any are reachable.
85443
- * @param {Set<CodePathSegment>} segments The segments to check.
85444
- * @returns {boolean} True if any segment is reachable; false otherwise.
85445
- */
85446
- function isAnySegmentReachable(segments) {
85447
- for (const segment of segments) {
85448
- if (segment.reachable) {
85449
- return true;
85450
- }
85451
- }
85452
-
85453
- return false;
85454
- }
85455
-
85456
85541
  /**
85457
85542
  * Checks whether or not a given comment string is really a fallthrough comment and not an ESLint directive.
85458
85543
  * @param {string} comment The comment string to check.
@@ -94125,10 +94210,11 @@ function requireNoPromiseExecutorReturn () {
94125
94210
  });
94126
94211
  }
94127
94212
 
94128
- // 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.
94129
94214
  if (
94130
94215
  !(
94131
- node.body.type === "FunctionExpression" &&
94216
+ (node.body.type === "FunctionExpression" ||
94217
+ node.body.type === "ClassExpression") &&
94132
94218
  !node.body.id
94133
94219
  )
94134
94220
  ) {
@@ -100229,12 +100315,17 @@ function requireNoThrowLiteral () {
100229
100315
  },
100230
100316
 
100231
100317
  create(context) {
100318
+ const sourceCode = context.sourceCode;
100319
+
100232
100320
  return {
100233
100321
  ThrowStatement(node) {
100234
100322
  if (!astUtils.couldBeError(node.argument)) {
100235
100323
  context.report({ node, messageId: "object" });
100236
100324
  } else if (node.argument.type === "Identifier") {
100237
- if (node.argument.name === "undefined") {
100325
+ if (
100326
+ node.argument.name === "undefined" &&
100327
+ sourceCode.isGlobalReference(node.argument)
100328
+ ) {
100238
100329
  context.report({ node, messageId: "undef" });
100239
100330
  }
100240
100331
  }
@@ -102039,6 +102130,12 @@ function requireNoUnreachable () {
102039
102130
  if (hasRequiredNoUnreachable) return noUnreachable;
102040
102131
  hasRequiredNoUnreachable = 1;
102041
102132
 
102133
+ //------------------------------------------------------------------------------
102134
+ // Requirements
102135
+ //------------------------------------------------------------------------------
102136
+
102137
+ const { isAnySegmentReachable } = requireCodePathUtils();
102138
+
102042
102139
  //------------------------------------------------------------------------------
102043
102140
  // Helpers
102044
102141
  //------------------------------------------------------------------------------
@@ -102058,21 +102155,6 @@ function requireNoUnreachable () {
102058
102155
  return Boolean(node.init);
102059
102156
  }
102060
102157
 
102061
- /**
102062
- * Checks all segments in a set and returns true if all are unreachable.
102063
- * @param {Set<CodePathSegment>} segments The segments to check.
102064
- * @returns {boolean} True if all segments are unreachable; false otherwise.
102065
- */
102066
- function areAllSegmentsUnreachable(segments) {
102067
- for (const segment of segments) {
102068
- if (segment.reachable) {
102069
- return false;
102070
- }
102071
- }
102072
-
102073
- return true;
102074
- }
102075
-
102076
102158
  /**
102077
102159
  * The class to distinguish consecutive unreachable statements.
102078
102160
  */
@@ -102189,7 +102271,7 @@ function requireNoUnreachable () {
102189
102271
  if (
102190
102272
  node &&
102191
102273
  (node.type === "PropertyDefinition" ||
102192
- areAllSegmentsUnreachable(currentCodePathSegments))
102274
+ !isAnySegmentReachable(currentCodePathSegments))
102193
102275
  ) {
102194
102276
  // Store this statement to distinguish consecutive statements.
102195
102277
  if (range.isEmpty) {
@@ -102348,6 +102430,8 @@ function requireNoUnreachableLoop () {
102348
102430
  if (hasRequiredNoUnreachableLoop) return noUnreachableLoop;
102349
102431
  hasRequiredNoUnreachableLoop = 1;
102350
102432
 
102433
+ const { isAnySegmentReachable } = requireCodePathUtils();
102434
+
102351
102435
  //------------------------------------------------------------------------------
102352
102436
  // Helpers
102353
102437
  //------------------------------------------------------------------------------
@@ -102360,21 +102444,6 @@ function requireNoUnreachableLoop () {
102360
102444
  "ForOfStatement",
102361
102445
  ];
102362
102446
 
102363
- /**
102364
- * Checks all segments in a set and returns true if any are reachable.
102365
- * @param {Set<CodePathSegment>} segments The segments to check.
102366
- * @returns {boolean} True if any segment is reachable; false otherwise.
102367
- */
102368
- function isAnySegmentReachable(segments) {
102369
- for (const segment of segments) {
102370
- if (segment.reachable) {
102371
- return true;
102372
- }
102373
- }
102374
-
102375
- return false;
102376
- }
102377
-
102378
102447
  /**
102379
102448
  * Determines whether the given node is the first node in the code path to which a loop statement
102380
102449
  * 'loops' for the next iteration.
@@ -108448,6 +108517,7 @@ function requireNoUselessReturn () {
108448
108517
 
108449
108518
  const astUtils = requireAstUtils(),
108450
108519
  FixTracker = requireFixTracker();
108520
+ const { isAnySegmentReachable } = requireCodePathUtils();
108451
108521
 
108452
108522
  //------------------------------------------------------------------------------
108453
108523
  // Helpers
@@ -108498,21 +108568,6 @@ function requireNoUselessReturn () {
108498
108568
  return false;
108499
108569
  }
108500
108570
 
108501
- /**
108502
- * Checks all segments in a set and returns true if any are reachable.
108503
- * @param {Set<CodePathSegment>} segments The segments to check.
108504
- * @returns {boolean} True if any segment is reachable; false otherwise.
108505
- */
108506
- function isAnySegmentReachable(segments) {
108507
- for (const segment of segments) {
108508
- if (segment.reachable) {
108509
- return true;
108510
- }
108511
- }
108512
-
108513
- return false;
108514
- }
108515
-
108516
108571
  //------------------------------------------------------------------------------
108517
108572
  // Rule Definition
108518
108573
  //------------------------------------------------------------------------------
@@ -109739,9 +109794,15 @@ function requireNoWith () {
109739
109794
  },
109740
109795
 
109741
109796
  create(context) {
109797
+ const sourceCode = context.sourceCode;
109798
+
109742
109799
  return {
109743
109800
  WithStatement(node) {
109744
- context.report({ node, messageId: "unexpectedWith" });
109801
+ context.report({
109802
+ node,
109803
+ loc: sourceCode.getFirstToken(node).loc,
109804
+ messageId: "unexpectedWith",
109805
+ });
109745
109806
  },
109746
109807
  };
109747
109808
  },
@@ -115351,6 +115412,11 @@ function requirePreferExponentiationOperator () {
115351
115412
  operator: "**",
115352
115413
  });
115353
115414
 
115415
+ /*
115416
+ * Characters that can cause continuation without preceding semi
115417
+ */
115418
+ const continuationChars = new Set(["(", "[", "/", "`"]);
115419
+
115354
115420
  /**
115355
115421
  * Determines whether the given node needs parens if used as the base in an exponentiation binary expression.
115356
115422
  * @param {ASTNode} base The node to check.
@@ -115479,11 +115545,36 @@ function requirePreferExponentiationOperator () {
115479
115545
  shouldParenthesizeBase = doesBaseNeedParens(base),
115480
115546
  shouldParenthesizeExponent =
115481
115547
  doesExponentNeedParens(exponent),
115482
- shouldParenthesizeAll =
115483
- doesExponentiationExpressionNeedParens(
115484
- node,
115485
- sourceCode,
115486
- );
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
+ }
115487
115578
 
115488
115579
  let prefix = "",
115489
115580
  suffix = "";
@@ -115536,6 +115627,15 @@ function requirePreferExponentiationOperator () {
115536
115627
  shouldParenthesizeAll,
115537
115628
  );
115538
115629
 
115630
+ if (
115631
+ !prefix &&
115632
+ isStartOfExpressionStatement &&
115633
+ continuationChars.has(replacement[0]) &&
115634
+ astUtils.needsPrecedingSemicolon(sourceCode, node)
115635
+ ) {
115636
+ prefix = ";";
115637
+ }
115638
+
115539
115639
  return fixer.replaceText(
115540
115640
  node,
115541
115641
  `${prefix}${replacement}${suffix}`,
@@ -116490,11 +116590,15 @@ function requirePreferPromiseRejectErrors () {
116490
116590
  if (!callExpression.arguments.length && allowEmptyReject) {
116491
116591
  return;
116492
116592
  }
116593
+
116594
+ const rejectionReason = callExpression.arguments[0];
116595
+
116493
116596
  if (
116494
116597
  !callExpression.arguments.length ||
116495
- !astUtils.couldBeError(callExpression.arguments[0]) ||
116496
- (callExpression.arguments[0].type === "Identifier" &&
116497
- callExpression.arguments[0].name === "undefined")
116598
+ !astUtils.couldBeError(rejectionReason) ||
116599
+ (rejectionReason.type === "Identifier" &&
116600
+ rejectionReason.name === "undefined" &&
116601
+ sourceCode.isGlobalReference(rejectionReason))
116498
116602
  ) {
116499
116603
  context.report({
116500
116604
  node: callExpression,
@@ -116509,10 +116613,15 @@ function requirePreferPromiseRejectErrors () {
116509
116613
  * @returns {boolean} `true` if the call is a Promise.reject() call
116510
116614
  */
116511
116615
  function isPromiseRejectCall(node) {
116512
- return astUtils.isSpecificMemberAccess(
116513
- node.callee,
116514
- "Promise",
116515
- "reject",
116616
+ return (
116617
+ astUtils.isSpecificMemberAccess(
116618
+ node.callee,
116619
+ "Promise",
116620
+ "reject",
116621
+ ) &&
116622
+ sourceCode.isGlobalReference(
116623
+ astUtils.skipChainExpression(node.callee).object,
116624
+ )
116516
116625
  );
116517
116626
  }
116518
116627
 
@@ -116537,6 +116646,7 @@ function requirePreferPromiseRejectErrors () {
116537
116646
  if (
116538
116647
  node.callee.type === "Identifier" &&
116539
116648
  node.callee.name === "Promise" &&
116649
+ sourceCode.isGlobalReference(node.callee) &&
116540
116650
  node.arguments.length &&
116541
116651
  astUtils.isFunction(node.arguments[0]) &&
116542
116652
  node.arguments[0].params.length > 1 &&
@@ -119376,12 +119486,15 @@ function requireRadix () {
119376
119486
  * - A literal except integers between 2 and 36.
119377
119487
  * - undefined.
119378
119488
  * @param {ASTNode} radix A node of radix to check.
119489
+ * @param {SourceCode} sourceCode The source code object.
119379
119490
  * @returns {boolean} `true` if the node is valid.
119380
119491
  */
119381
- function isValidRadix(radix) {
119492
+ function isValidRadix(radix, sourceCode) {
119382
119493
  return !(
119383
119494
  (radix.type === "Literal" && !validRadixValues.has(radix.value)) ||
119384
- (radix.type === "Identifier" && radix.name === "undefined")
119495
+ (radix.type === "Identifier" &&
119496
+ radix.name === "undefined" &&
119497
+ sourceCode.isGlobalReference(radix))
119385
119498
  );
119386
119499
  }
119387
119500
 
@@ -119467,7 +119580,7 @@ function requireRadix () {
119467
119580
  break;
119468
119581
 
119469
119582
  default:
119470
- if (!isValidRadix(args[1])) {
119583
+ if (!isValidRadix(args[1], sourceCode)) {
119471
119584
  context.report({
119472
119585
  node,
119473
119586
  messageId: "invalidRadix",