eslint-linter-browserify 10.0.3 → 10.1.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.0.3";
4219
+ var version = "10.1.0";
4220
4220
  var require$$3$1 = {
4221
4221
  version: version};
4222
4222
 
@@ -8346,7 +8346,6 @@ function requireUtils$1 () {
8346
8346
  for (
8347
8347
  let minIndex = 0, maxIndex = tokens.length - 1;
8348
8348
  minIndex <= maxIndex;
8349
-
8350
8349
  ) {
8351
8350
  /*
8352
8351
  * Calculate the index in the middle between minIndex and maxIndex.
@@ -45111,24 +45110,24 @@ function requireEspree () {
45111
45110
  * Normalize sourceType from the initial config
45112
45111
  * @param {string} sourceType to normalize
45113
45112
  * @throws {Error} throw an error if sourceType is invalid
45114
- * @returns {"script"|"module"} normalized sourceType
45113
+ * @returns {"script"|"module"|"commonjs"} normalized sourceType
45115
45114
  */
45116
45115
  function normalizeSourceType(sourceType = "script") {
45117
- if (sourceType === "script" || sourceType === "module") {
45116
+ if (
45117
+ sourceType === "script" ||
45118
+ sourceType === "module" ||
45119
+ sourceType === "commonjs"
45120
+ ) {
45118
45121
  return sourceType;
45119
45122
  }
45120
45123
 
45121
- if (sourceType === "commonjs") {
45122
- return "script";
45123
- }
45124
-
45125
45124
  throw new Error("Invalid sourceType.");
45126
45125
  }
45127
45126
 
45128
45127
  /**
45129
45128
  * @typedef {{
45130
45129
  * ecmaVersion: NormalizedEcmaVersion,
45131
- * sourceType: "script"|"module",
45130
+ * sourceType: "script"|"module"|"commonjs",
45132
45131
  * range?: boolean,
45133
45132
  * loc?: boolean,
45134
45133
  * allowReserved: boolean | "never",
@@ -45933,7 +45932,7 @@ function requireEspree () {
45933
45932
  //------------------------------------------------------------------------------
45934
45933
 
45935
45934
  /** @type {string} */
45936
- const version = "11.1.1"; // x-release-please-version
45935
+ const version = "11.2.0"; // x-release-please-version
45937
45936
  const name = "espree";
45938
45937
 
45939
45938
  // Derive node types from VisitorKeys
@@ -46419,9 +46418,9 @@ function requireAstUtils () {
46419
46418
  if (left.regex || right.regex) {
46420
46419
  return Boolean(
46421
46420
  left.regex &&
46422
- right.regex &&
46423
- left.regex.pattern === right.regex.pattern &&
46424
- left.regex.flags === right.regex.flags,
46421
+ right.regex &&
46422
+ left.regex.pattern === right.regex.pattern &&
46423
+ left.regex.flags === right.regex.flags,
46425
46424
  );
46426
46425
  }
46427
46426
 
@@ -47062,9 +47061,9 @@ function requireAstUtils () {
47062
47061
 
47063
47062
  return Boolean(
47064
47063
  reference &&
47065
- reference.resolved &&
47066
- reference.resolved.scope.type === "global" &&
47067
- reference.resolved.defs.length === 0,
47064
+ reference.resolved &&
47065
+ reference.resolved.scope.type === "global" &&
47066
+ reference.resolved.defs.length === 0,
47068
47067
  );
47069
47068
  }
47070
47069
 
@@ -53154,9 +53153,9 @@ function requireCapitalizedComments () {
53154
53153
 
53155
53154
  return Boolean(
53156
53155
  previousToken &&
53157
- nextToken &&
53158
- comment.loc.start.line === previousToken.loc.end.line &&
53159
- comment.loc.end.line === nextToken.loc.start.line,
53156
+ nextToken &&
53157
+ comment.loc.start.line === previousToken.loc.end.line &&
53158
+ comment.loc.end.line === nextToken.loc.start.line,
53160
53159
  );
53161
53160
  }
53162
53161
 
@@ -53172,7 +53171,7 @@ function requireCapitalizedComments () {
53172
53171
 
53173
53172
  return Boolean(
53174
53173
  previousTokenOrComment &&
53175
- ["Block", "Line"].includes(previousTokenOrComment.type),
53174
+ ["Block", "Line"].includes(previousTokenOrComment.type),
53176
53175
  );
53177
53176
  }
53178
53177
 
@@ -82358,11 +82357,11 @@ function requireNoExtendNative () {
82358
82357
  function isPrototypePropertyAccessed(identifierNode) {
82359
82358
  return Boolean(
82360
82359
  identifierNode &&
82361
- identifierNode.parent &&
82362
- identifierNode.parent.type === "MemberExpression" &&
82363
- identifierNode.parent.object === identifierNode &&
82364
- astUtils.getStaticPropertyName(identifierNode.parent) ===
82365
- "prototype",
82360
+ identifierNode.parent &&
82361
+ identifierNode.parent.type === "MemberExpression" &&
82362
+ identifierNode.parent.object === identifierNode &&
82363
+ astUtils.getStaticPropertyName(identifierNode.parent) ===
82364
+ "prototype",
82366
82365
  );
82367
82366
  }
82368
82367
 
@@ -99723,9 +99722,7 @@ function requireNoThisBeforeSuper () {
99723
99722
  isConstructor: true,
99724
99723
  hasExtends: Boolean(
99725
99724
  classNode.superClass &&
99726
- !astUtils.isNullOrUndefined(
99727
- classNode.superClass,
99728
- ),
99725
+ !astUtils.isNullOrUndefined(classNode.superClass),
99729
99726
  ),
99730
99727
  codePath,
99731
99728
  currentSegments: new Set(),
@@ -101278,11 +101275,11 @@ function requireNoUnmodifiedLoopCondition () {
101278
101275
  condition.isInLoop(modifier) ||
101279
101276
  Boolean(
101280
101277
  (funcNode = getEncloseFunctionDeclaration(modifier)) &&
101281
- (funcVar = astUtils.getVariableByName(
101282
- modifier.from.upper,
101283
- funcNode.id.name,
101284
- )) &&
101285
- funcVar.references.some(condition.isInLoop),
101278
+ (funcVar = astUtils.getVariableByName(
101279
+ modifier.from.upper,
101280
+ funcNode.id.name,
101281
+ )) &&
101282
+ funcVar.references.some(condition.isInLoop),
101286
101283
  );
101287
101284
 
101288
101285
  condition.modified = inLoop;
@@ -108558,6 +108555,28 @@ function requireNoVar () {
108558
108555
  return variable.name === "let";
108559
108556
  }
108560
108557
 
108558
+ /**
108559
+ * Checks whether a given variable has any references before its declaration.
108560
+ * This is important because var allows hoisting, but let/const do not.
108561
+ * @param {Variable} variable The variable to check.
108562
+ * @returns {boolean} `true` if the variable is referenced before its declaration.
108563
+ */
108564
+ function hasReferenceBeforeDeclaration(variable) {
108565
+ const declarationStart = variable.defs[0].node.range[0];
108566
+
108567
+ return variable.references.some(reference => {
108568
+ const referenceStart = reference.identifier.range[0];
108569
+
108570
+ /*
108571
+ * Check if the reference occurs before the declaration.
108572
+ * We don't need to check scopes because all references to this variable
108573
+ * are already in variable.references (which only includes references
108574
+ * that resolve to this specific variable binding).
108575
+ */
108576
+ return !reference.init && referenceStart < declarationStart;
108577
+ });
108578
+ }
108579
+
108561
108580
  //------------------------------------------------------------------------------
108562
108581
  // Rule Definition
108563
108582
  //------------------------------------------------------------------------------
@@ -108611,6 +108630,7 @@ function requireNoVar () {
108611
108630
  * - A variable is used from a closure within a loop.
108612
108631
  * - A variable might be used before it is assigned within a loop.
108613
108632
  * - A variable might be used in TDZ.
108633
+ * - A variable is referenced before its declaration.
108614
108634
  * - A variable is declared in statement position (e.g. a single-line `IfStatement`)
108615
108635
  * - A variable has name that is disallowed for `let` declarations.
108616
108636
  *
@@ -108655,6 +108675,10 @@ function requireNoVar () {
108655
108675
  function canFix(node) {
108656
108676
  const variables = sourceCode.getDeclaredVariables(node);
108657
108677
  const scopeNode = getScopeNode(node);
108678
+ const parentStatementList = new Set([
108679
+ ...astUtils.STATEMENT_LIST_PARENTS,
108680
+ "TSModuleBlock",
108681
+ ]);
108658
108682
 
108659
108683
  if (
108660
108684
  node.parent.type === "SwitchCase" ||
@@ -108662,7 +108686,8 @@ function requireNoVar () {
108662
108686
  variables.some(isGlobal) ||
108663
108687
  variables.some(isRedeclared) ||
108664
108688
  variables.some(isUsedFromOutsideOf(scopeNode)) ||
108665
- variables.some(hasNameDisallowedForLetDeclarations)
108689
+ variables.some(hasNameDisallowedForLetDeclarations) ||
108690
+ variables.some(hasReferenceBeforeDeclaration)
108666
108691
  ) {
108667
108692
  return false;
108668
108693
  }
@@ -108682,7 +108707,7 @@ function requireNoVar () {
108682
108707
  node.parent.type === "ForStatement" &&
108683
108708
  node.parent.init === node
108684
108709
  ) &&
108685
- !astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)
108710
+ !parentStatementList.has(node.parent.type)
108686
108711
  ) {
108687
108712
  // If the declaration is not in a block, e.g. `if (foo) var bar = 1;`, then it can't be fixed.
108688
108713
  return false;
@@ -112985,11 +113010,11 @@ function requirePaddingLineBetweenStatements () {
112985
113010
  const nextToken = sourceCode.getTokenAfter(semiToken);
112986
113011
  const isSemicolonLessStyle = Boolean(
112987
113012
  prevToken &&
112988
- nextToken &&
112989
- prevToken.range[0] >= node.range[0] &&
112990
- astUtils.isSemicolonToken(semiToken) &&
112991
- semiToken.loc.start.line !== prevToken.loc.end.line &&
112992
- semiToken.loc.end.line === nextToken.loc.start.line,
113013
+ nextToken &&
113014
+ prevToken.range[0] >= node.range[0] &&
113015
+ astUtils.isSemicolonToken(semiToken) &&
113016
+ semiToken.loc.start.line !== prevToken.loc.end.line &&
113017
+ semiToken.loc.end.line === nextToken.loc.start.line,
112993
113018
  );
112994
113019
 
112995
113020
  return isSemicolonLessStyle ? prevToken : semiToken;
package/linter.js CHANGED
@@ -4218,7 +4218,7 @@
4218
4218
  return eslintVisitorKeys$2;
4219
4219
  }
4220
4220
 
4221
- var version = "10.0.3";
4221
+ var version = "10.1.0";
4222
4222
  var require$$3$1 = {
4223
4223
  version: version};
4224
4224
 
@@ -8348,7 +8348,6 @@
8348
8348
  for (
8349
8349
  let minIndex = 0, maxIndex = tokens.length - 1;
8350
8350
  minIndex <= maxIndex;
8351
-
8352
8351
  ) {
8353
8352
  /*
8354
8353
  * Calculate the index in the middle between minIndex and maxIndex.
@@ -45113,24 +45112,24 @@
45113
45112
  * Normalize sourceType from the initial config
45114
45113
  * @param {string} sourceType to normalize
45115
45114
  * @throws {Error} throw an error if sourceType is invalid
45116
- * @returns {"script"|"module"} normalized sourceType
45115
+ * @returns {"script"|"module"|"commonjs"} normalized sourceType
45117
45116
  */
45118
45117
  function normalizeSourceType(sourceType = "script") {
45119
- if (sourceType === "script" || sourceType === "module") {
45118
+ if (
45119
+ sourceType === "script" ||
45120
+ sourceType === "module" ||
45121
+ sourceType === "commonjs"
45122
+ ) {
45120
45123
  return sourceType;
45121
45124
  }
45122
45125
 
45123
- if (sourceType === "commonjs") {
45124
- return "script";
45125
- }
45126
-
45127
45126
  throw new Error("Invalid sourceType.");
45128
45127
  }
45129
45128
 
45130
45129
  /**
45131
45130
  * @typedef {{
45132
45131
  * ecmaVersion: NormalizedEcmaVersion,
45133
- * sourceType: "script"|"module",
45132
+ * sourceType: "script"|"module"|"commonjs",
45134
45133
  * range?: boolean,
45135
45134
  * loc?: boolean,
45136
45135
  * allowReserved: boolean | "never",
@@ -45935,7 +45934,7 @@
45935
45934
  //------------------------------------------------------------------------------
45936
45935
 
45937
45936
  /** @type {string} */
45938
- const version = "11.1.1"; // x-release-please-version
45937
+ const version = "11.2.0"; // x-release-please-version
45939
45938
  const name = "espree";
45940
45939
 
45941
45940
  // Derive node types from VisitorKeys
@@ -46421,9 +46420,9 @@
46421
46420
  if (left.regex || right.regex) {
46422
46421
  return Boolean(
46423
46422
  left.regex &&
46424
- right.regex &&
46425
- left.regex.pattern === right.regex.pattern &&
46426
- left.regex.flags === right.regex.flags,
46423
+ right.regex &&
46424
+ left.regex.pattern === right.regex.pattern &&
46425
+ left.regex.flags === right.regex.flags,
46427
46426
  );
46428
46427
  }
46429
46428
 
@@ -47064,9 +47063,9 @@
47064
47063
 
47065
47064
  return Boolean(
47066
47065
  reference &&
47067
- reference.resolved &&
47068
- reference.resolved.scope.type === "global" &&
47069
- reference.resolved.defs.length === 0,
47066
+ reference.resolved &&
47067
+ reference.resolved.scope.type === "global" &&
47068
+ reference.resolved.defs.length === 0,
47070
47069
  );
47071
47070
  }
47072
47071
 
@@ -53156,9 +53155,9 @@
53156
53155
 
53157
53156
  return Boolean(
53158
53157
  previousToken &&
53159
- nextToken &&
53160
- comment.loc.start.line === previousToken.loc.end.line &&
53161
- comment.loc.end.line === nextToken.loc.start.line,
53158
+ nextToken &&
53159
+ comment.loc.start.line === previousToken.loc.end.line &&
53160
+ comment.loc.end.line === nextToken.loc.start.line,
53162
53161
  );
53163
53162
  }
53164
53163
 
@@ -53174,7 +53173,7 @@
53174
53173
 
53175
53174
  return Boolean(
53176
53175
  previousTokenOrComment &&
53177
- ["Block", "Line"].includes(previousTokenOrComment.type),
53176
+ ["Block", "Line"].includes(previousTokenOrComment.type),
53178
53177
  );
53179
53178
  }
53180
53179
 
@@ -82360,11 +82359,11 @@
82360
82359
  function isPrototypePropertyAccessed(identifierNode) {
82361
82360
  return Boolean(
82362
82361
  identifierNode &&
82363
- identifierNode.parent &&
82364
- identifierNode.parent.type === "MemberExpression" &&
82365
- identifierNode.parent.object === identifierNode &&
82366
- astUtils.getStaticPropertyName(identifierNode.parent) ===
82367
- "prototype",
82362
+ identifierNode.parent &&
82363
+ identifierNode.parent.type === "MemberExpression" &&
82364
+ identifierNode.parent.object === identifierNode &&
82365
+ astUtils.getStaticPropertyName(identifierNode.parent) ===
82366
+ "prototype",
82368
82367
  );
82369
82368
  }
82370
82369
 
@@ -99725,9 +99724,7 @@
99725
99724
  isConstructor: true,
99726
99725
  hasExtends: Boolean(
99727
99726
  classNode.superClass &&
99728
- !astUtils.isNullOrUndefined(
99729
- classNode.superClass,
99730
- ),
99727
+ !astUtils.isNullOrUndefined(classNode.superClass),
99731
99728
  ),
99732
99729
  codePath,
99733
99730
  currentSegments: new Set(),
@@ -101280,11 +101277,11 @@
101280
101277
  condition.isInLoop(modifier) ||
101281
101278
  Boolean(
101282
101279
  (funcNode = getEncloseFunctionDeclaration(modifier)) &&
101283
- (funcVar = astUtils.getVariableByName(
101284
- modifier.from.upper,
101285
- funcNode.id.name,
101286
- )) &&
101287
- funcVar.references.some(condition.isInLoop),
101280
+ (funcVar = astUtils.getVariableByName(
101281
+ modifier.from.upper,
101282
+ funcNode.id.name,
101283
+ )) &&
101284
+ funcVar.references.some(condition.isInLoop),
101288
101285
  );
101289
101286
 
101290
101287
  condition.modified = inLoop;
@@ -108560,6 +108557,28 @@
108560
108557
  return variable.name === "let";
108561
108558
  }
108562
108559
 
108560
+ /**
108561
+ * Checks whether a given variable has any references before its declaration.
108562
+ * This is important because var allows hoisting, but let/const do not.
108563
+ * @param {Variable} variable The variable to check.
108564
+ * @returns {boolean} `true` if the variable is referenced before its declaration.
108565
+ */
108566
+ function hasReferenceBeforeDeclaration(variable) {
108567
+ const declarationStart = variable.defs[0].node.range[0];
108568
+
108569
+ return variable.references.some(reference => {
108570
+ const referenceStart = reference.identifier.range[0];
108571
+
108572
+ /*
108573
+ * Check if the reference occurs before the declaration.
108574
+ * We don't need to check scopes because all references to this variable
108575
+ * are already in variable.references (which only includes references
108576
+ * that resolve to this specific variable binding).
108577
+ */
108578
+ return !reference.init && referenceStart < declarationStart;
108579
+ });
108580
+ }
108581
+
108563
108582
  //------------------------------------------------------------------------------
108564
108583
  // Rule Definition
108565
108584
  //------------------------------------------------------------------------------
@@ -108613,6 +108632,7 @@
108613
108632
  * - A variable is used from a closure within a loop.
108614
108633
  * - A variable might be used before it is assigned within a loop.
108615
108634
  * - A variable might be used in TDZ.
108635
+ * - A variable is referenced before its declaration.
108616
108636
  * - A variable is declared in statement position (e.g. a single-line `IfStatement`)
108617
108637
  * - A variable has name that is disallowed for `let` declarations.
108618
108638
  *
@@ -108657,6 +108677,10 @@
108657
108677
  function canFix(node) {
108658
108678
  const variables = sourceCode.getDeclaredVariables(node);
108659
108679
  const scopeNode = getScopeNode(node);
108680
+ const parentStatementList = new Set([
108681
+ ...astUtils.STATEMENT_LIST_PARENTS,
108682
+ "TSModuleBlock",
108683
+ ]);
108660
108684
 
108661
108685
  if (
108662
108686
  node.parent.type === "SwitchCase" ||
@@ -108664,7 +108688,8 @@
108664
108688
  variables.some(isGlobal) ||
108665
108689
  variables.some(isRedeclared) ||
108666
108690
  variables.some(isUsedFromOutsideOf(scopeNode)) ||
108667
- variables.some(hasNameDisallowedForLetDeclarations)
108691
+ variables.some(hasNameDisallowedForLetDeclarations) ||
108692
+ variables.some(hasReferenceBeforeDeclaration)
108668
108693
  ) {
108669
108694
  return false;
108670
108695
  }
@@ -108684,7 +108709,7 @@
108684
108709
  node.parent.type === "ForStatement" &&
108685
108710
  node.parent.init === node
108686
108711
  ) &&
108687
- !astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)
108712
+ !parentStatementList.has(node.parent.type)
108688
108713
  ) {
108689
108714
  // If the declaration is not in a block, e.g. `if (foo) var bar = 1;`, then it can't be fixed.
108690
108715
  return false;
@@ -112987,11 +113012,11 @@
112987
113012
  const nextToken = sourceCode.getTokenAfter(semiToken);
112988
113013
  const isSemicolonLessStyle = Boolean(
112989
113014
  prevToken &&
112990
- nextToken &&
112991
- prevToken.range[0] >= node.range[0] &&
112992
- astUtils.isSemicolonToken(semiToken) &&
112993
- semiToken.loc.start.line !== prevToken.loc.end.line &&
112994
- semiToken.loc.end.line === nextToken.loc.start.line,
113015
+ nextToken &&
113016
+ prevToken.range[0] >= node.range[0] &&
113017
+ astUtils.isSemicolonToken(semiToken) &&
113018
+ semiToken.loc.start.line !== prevToken.loc.end.line &&
113019
+ semiToken.loc.end.line === nextToken.loc.start.line,
112995
113020
  );
112996
113021
 
112997
113022
  return isSemicolonLessStyle ? prevToken : semiToken;