eslint-linter-browserify 10.0.2 → 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.
Files changed (5) hide show
  1. package/linter.cjs +548 -182
  2. package/linter.js +548 -182
  3. package/linter.min.js +3 -3
  4. package/linter.mjs +548 -182
  5. package/package.json +5 -5
package/linter.cjs CHANGED
@@ -4003,7 +4003,7 @@ function requireEslintScope () {
4003
4003
  }
4004
4004
 
4005
4005
  /** @name module:escope.version */
4006
- const version = "9.1.1"; // x-release-please-version
4006
+ const version = "9.1.2"; // x-release-please-version
4007
4007
 
4008
4008
  /* vim: set sw=4 ts=4 et tw=80 : */
4009
4009
 
@@ -4216,7 +4216,7 @@ function requireEslintVisitorKeys$2 () {
4216
4216
  return eslintVisitorKeys$2;
4217
4217
  }
4218
4218
 
4219
- var version = "10.0.2";
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.
@@ -22788,7 +22787,7 @@ function requireCommonjs$1 () {
22788
22787
  const openPattern = /\\{/g;
22789
22788
  const closePattern = /\\}/g;
22790
22789
  const commaPattern = /\\,/g;
22791
- const periodPattern = /\\./g;
22790
+ const periodPattern = /\\\./g;
22792
22791
  exports$1.EXPANSION_MAX = 100_000;
22793
22792
  function numeric(str) {
22794
22793
  return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
@@ -23208,12 +23207,114 @@ function requireAst$1 () {
23208
23207
  if (hasRequiredAst$1) return ast$1;
23209
23208
  hasRequiredAst$1 = 1;
23210
23209
  // parse a single path portion
23210
+ var _a;
23211
23211
  Object.defineProperty(ast$1, "__esModule", { value: true });
23212
23212
  ast$1.AST = void 0;
23213
23213
  const brace_expressions_js_1 = requireBraceExpressions();
23214
23214
  const unescape_js_1 = require_unescape();
23215
23215
  const types = new Set(['!', '?', '+', '*', '@']);
23216
23216
  const isExtglobType = (c) => types.has(c);
23217
+ const isExtglobAST = (c) => isExtglobType(c.type);
23218
+ // Map of which extglob types can adopt the children of a nested extglob
23219
+ //
23220
+ // anything but ! can adopt a matching type:
23221
+ // +(a|+(b|c)|d) => +(a|b|c|d)
23222
+ // *(a|*(b|c)|d) => *(a|b|c|d)
23223
+ // @(a|@(b|c)|d) => @(a|b|c|d)
23224
+ // ?(a|?(b|c)|d) => ?(a|b|c|d)
23225
+ //
23226
+ // * can adopt anything, because 0 or repetition is allowed
23227
+ // *(a|?(b|c)|d) => *(a|b|c|d)
23228
+ // *(a|+(b|c)|d) => *(a|b|c|d)
23229
+ // *(a|@(b|c)|d) => *(a|b|c|d)
23230
+ //
23231
+ // + can adopt @, because 1 or repetition is allowed
23232
+ // +(a|@(b|c)|d) => +(a|b|c|d)
23233
+ //
23234
+ // + and @ CANNOT adopt *, because 0 would be allowed
23235
+ // +(a|*(b|c)|d) => would match "", on *(b|c)
23236
+ // @(a|*(b|c)|d) => would match "", on *(b|c)
23237
+ //
23238
+ // + and @ CANNOT adopt ?, because 0 would be allowed
23239
+ // +(a|?(b|c)|d) => would match "", on ?(b|c)
23240
+ // @(a|?(b|c)|d) => would match "", on ?(b|c)
23241
+ //
23242
+ // ? can adopt @, because 0 or 1 is allowed
23243
+ // ?(a|@(b|c)|d) => ?(a|b|c|d)
23244
+ //
23245
+ // ? and @ CANNOT adopt * or +, because >1 would be allowed
23246
+ // ?(a|*(b|c)|d) => would match bbb on *(b|c)
23247
+ // @(a|*(b|c)|d) => would match bbb on *(b|c)
23248
+ // ?(a|+(b|c)|d) => would match bbb on +(b|c)
23249
+ // @(a|+(b|c)|d) => would match bbb on +(b|c)
23250
+ //
23251
+ // ! CANNOT adopt ! (nothing else can either)
23252
+ // !(a|!(b|c)|d) => !(a|b|c|d) would fail to match on b (not not b|c)
23253
+ //
23254
+ // ! can adopt @
23255
+ // !(a|@(b|c)|d) => !(a|b|c|d)
23256
+ //
23257
+ // ! CANNOT adopt *
23258
+ // !(a|*(b|c)|d) => !(a|b|c|d) would match on bbb, not allowed
23259
+ //
23260
+ // ! CANNOT adopt +
23261
+ // !(a|+(b|c)|d) => !(a|b|c|d) would match on bbb, not allowed
23262
+ //
23263
+ // ! CANNOT adopt ?
23264
+ // x!(a|?(b|c)|d) => x!(a|b|c|d) would fail to match "x"
23265
+ const adoptionMap = new Map([
23266
+ ['!', ['@']],
23267
+ ['?', ['?', '@']],
23268
+ ['@', ['@']],
23269
+ ['*', ['*', '+', '?', '@']],
23270
+ ['+', ['+', '@']],
23271
+ ]);
23272
+ // nested extglobs that can be adopted in, but with the addition of
23273
+ // a blank '' element.
23274
+ const adoptionWithSpaceMap = new Map([
23275
+ ['!', ['?']],
23276
+ ['@', ['?']],
23277
+ ['+', ['?', '*']],
23278
+ ]);
23279
+ // union of the previous two maps
23280
+ const adoptionAnyMap = new Map([
23281
+ ['!', ['?', '@']],
23282
+ ['?', ['?', '@']],
23283
+ ['@', ['?', '@']],
23284
+ ['*', ['*', '+', '?', '@']],
23285
+ ['+', ['+', '@', '?', '*']],
23286
+ ]);
23287
+ // Extglobs that can take over their parent if they are the only child
23288
+ // the key is parent, value maps child to resulting extglob parent type
23289
+ // '@' is omitted because it's a special case. An `@` extglob with a single
23290
+ // member can always be usurped by that subpattern.
23291
+ const usurpMap = new Map([
23292
+ ['!', new Map([['!', '@']])],
23293
+ [
23294
+ '?',
23295
+ new Map([
23296
+ ['*', '*'],
23297
+ ['+', '*'],
23298
+ ]),
23299
+ ],
23300
+ [
23301
+ '@',
23302
+ new Map([
23303
+ ['!', '!'],
23304
+ ['?', '?'],
23305
+ ['@', '@'],
23306
+ ['*', '*'],
23307
+ ['+', '+'],
23308
+ ]),
23309
+ ],
23310
+ [
23311
+ '+',
23312
+ new Map([
23313
+ ['?', '*'],
23314
+ ['*', '*'],
23315
+ ]),
23316
+ ],
23317
+ ]);
23217
23318
  // Patterns that get prepended to bind to the start of either the
23218
23319
  // entire string, or just a single path portion, to prevent dots
23219
23320
  // and/or traversal patterns, when needed.
@@ -23237,6 +23338,7 @@ function requireAst$1 () {
23237
23338
  const starNoEmpty = qmark + '+?';
23238
23339
  // remove the \ chars that we added if we end up doing a nonmagic compare
23239
23340
  // const deslash = (s: string) => s.replace(/\\(.)/g, '$1')
23341
+ let ID = 0;
23240
23342
  class AST {
23241
23343
  type;
23242
23344
  #root;
@@ -23252,6 +23354,22 @@ function requireAst$1 () {
23252
23354
  // set to true if it's an extglob with no children
23253
23355
  // (which really means one child of '')
23254
23356
  #emptyExt = false;
23357
+ id = ++ID;
23358
+ get depth() {
23359
+ return (this.#parent?.depth ?? -1) + 1;
23360
+ }
23361
+ [Symbol.for('nodejs.util.inspect.custom')]() {
23362
+ return {
23363
+ '@@type': 'AST',
23364
+ id: this.id,
23365
+ type: this.type,
23366
+ root: this.#root.id,
23367
+ parent: this.#parent?.id,
23368
+ depth: this.depth,
23369
+ partsLength: this.#parts.length,
23370
+ parts: this.#parts,
23371
+ };
23372
+ }
23255
23373
  constructor(type, parent, options = {}) {
23256
23374
  this.type = type;
23257
23375
  // extglobs are inherently magical
@@ -23331,7 +23449,7 @@ function requireAst$1 () {
23331
23449
  continue;
23332
23450
  /* c8 ignore start */
23333
23451
  if (typeof p !== 'string' &&
23334
- !(p instanceof AST && p.#parent === this)) {
23452
+ !(p instanceof _a && p.#parent === this)) {
23335
23453
  throw new Error('invalid part: ' + p);
23336
23454
  }
23337
23455
  /* c8 ignore stop */
@@ -23365,7 +23483,7 @@ function requireAst$1 () {
23365
23483
  const p = this.#parent;
23366
23484
  for (let i = 0; i < this.#parentIndex; i++) {
23367
23485
  const pp = p.#parts[i];
23368
- if (!(pp instanceof AST && pp.type === '!')) {
23486
+ if (!(pp instanceof _a && pp.type === '!')) {
23369
23487
  return false;
23370
23488
  }
23371
23489
  }
@@ -23393,13 +23511,14 @@ function requireAst$1 () {
23393
23511
  this.push(part.clone(this));
23394
23512
  }
23395
23513
  clone(parent) {
23396
- const c = new AST(this.type, parent);
23514
+ const c = new _a(this.type, parent);
23397
23515
  for (const p of this.#parts) {
23398
23516
  c.copyIn(p);
23399
23517
  }
23400
23518
  return c;
23401
23519
  }
23402
- static #parseAST(str, ast, pos, opt) {
23520
+ static #parseAST(str, ast, pos, opt, extDepth) {
23521
+ const maxDepth = opt.maxExtglobRecursion ?? 2;
23403
23522
  let escaping = false;
23404
23523
  let inBrace = false;
23405
23524
  let braceStart = -1;
@@ -23436,11 +23555,17 @@ function requireAst$1 () {
23436
23555
  acc += c;
23437
23556
  continue;
23438
23557
  }
23439
- if (!opt.noext && isExtglobType(c) && str.charAt(i) === '(') {
23558
+ // we don't have to check for adoption here, because that's
23559
+ // done at the other recursion point.
23560
+ const doRecurse = !opt.noext &&
23561
+ isExtglobType(c) &&
23562
+ str.charAt(i) === '(' &&
23563
+ extDepth <= maxDepth;
23564
+ if (doRecurse) {
23440
23565
  ast.push(acc);
23441
23566
  acc = '';
23442
- const ext = new AST(c, ast);
23443
- i = AST.#parseAST(str, ext, i, opt);
23567
+ const ext = new _a(c, ast);
23568
+ i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
23444
23569
  ast.push(ext);
23445
23570
  continue;
23446
23571
  }
@@ -23452,7 +23577,7 @@ function requireAst$1 () {
23452
23577
  // some kind of extglob, pos is at the (
23453
23578
  // find the next | or )
23454
23579
  let i = pos + 1;
23455
- let part = new AST(null, ast);
23580
+ let part = new _a(null, ast);
23456
23581
  const parts = [];
23457
23582
  let acc = '';
23458
23583
  while (i < str.length) {
@@ -23483,19 +23608,26 @@ function requireAst$1 () {
23483
23608
  acc += c;
23484
23609
  continue;
23485
23610
  }
23486
- if (isExtglobType(c) && str.charAt(i) === '(') {
23611
+ const doRecurse = !opt.noext &&
23612
+ isExtglobType(c) &&
23613
+ str.charAt(i) === '(' &&
23614
+ /* c8 ignore start - the maxDepth is sufficient here */
23615
+ (extDepth <= maxDepth || (ast && ast.#canAdoptType(c)));
23616
+ /* c8 ignore stop */
23617
+ if (doRecurse) {
23618
+ const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
23487
23619
  part.push(acc);
23488
23620
  acc = '';
23489
- const ext = new AST(c, part);
23621
+ const ext = new _a(c, part);
23490
23622
  part.push(ext);
23491
- i = AST.#parseAST(str, ext, i, opt);
23623
+ i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
23492
23624
  continue;
23493
23625
  }
23494
23626
  if (c === '|') {
23495
23627
  part.push(acc);
23496
23628
  acc = '';
23497
23629
  parts.push(part);
23498
- part = new AST(null, ast);
23630
+ part = new _a(null, ast);
23499
23631
  continue;
23500
23632
  }
23501
23633
  if (c === ')') {
@@ -23517,9 +23649,82 @@ function requireAst$1 () {
23517
23649
  ast.#parts = [str.substring(pos - 1)];
23518
23650
  return i;
23519
23651
  }
23652
+ #canAdoptWithSpace(child) {
23653
+ return this.#canAdopt(child, adoptionWithSpaceMap);
23654
+ }
23655
+ #canAdopt(child, map = adoptionMap) {
23656
+ if (!child ||
23657
+ typeof child !== 'object' ||
23658
+ child.type !== null ||
23659
+ child.#parts.length !== 1 ||
23660
+ this.type === null) {
23661
+ return false;
23662
+ }
23663
+ const gc = child.#parts[0];
23664
+ if (!gc || typeof gc !== 'object' || gc.type === null) {
23665
+ return false;
23666
+ }
23667
+ return this.#canAdoptType(gc.type, map);
23668
+ }
23669
+ #canAdoptType(c, map = adoptionAnyMap) {
23670
+ return !!map.get(this.type)?.includes(c);
23671
+ }
23672
+ #adoptWithSpace(child, index) {
23673
+ const gc = child.#parts[0];
23674
+ const blank = new _a(null, gc, this.options);
23675
+ blank.#parts.push('');
23676
+ gc.push(blank);
23677
+ this.#adopt(child, index);
23678
+ }
23679
+ #adopt(child, index) {
23680
+ const gc = child.#parts[0];
23681
+ this.#parts.splice(index, 1, ...gc.#parts);
23682
+ for (const p of gc.#parts) {
23683
+ if (typeof p === 'object')
23684
+ p.#parent = this;
23685
+ }
23686
+ this.#toString = undefined;
23687
+ }
23688
+ #canUsurpType(c) {
23689
+ const m = usurpMap.get(this.type);
23690
+ return !!(m?.has(c));
23691
+ }
23692
+ #canUsurp(child) {
23693
+ if (!child ||
23694
+ typeof child !== 'object' ||
23695
+ child.type !== null ||
23696
+ child.#parts.length !== 1 ||
23697
+ this.type === null ||
23698
+ this.#parts.length !== 1) {
23699
+ return false;
23700
+ }
23701
+ const gc = child.#parts[0];
23702
+ if (!gc || typeof gc !== 'object' || gc.type === null) {
23703
+ return false;
23704
+ }
23705
+ return this.#canUsurpType(gc.type);
23706
+ }
23707
+ #usurp(child) {
23708
+ const m = usurpMap.get(this.type);
23709
+ const gc = child.#parts[0];
23710
+ const nt = m?.get(gc.type);
23711
+ /* c8 ignore start - impossible */
23712
+ if (!nt)
23713
+ return false;
23714
+ /* c8 ignore stop */
23715
+ this.#parts = gc.#parts;
23716
+ for (const p of this.#parts) {
23717
+ if (typeof p === 'object') {
23718
+ p.#parent = this;
23719
+ }
23720
+ }
23721
+ this.type = nt;
23722
+ this.#toString = undefined;
23723
+ this.#emptyExt = false;
23724
+ }
23520
23725
  static fromGlob(pattern, options = {}) {
23521
- const ast = new AST(null, undefined, options);
23522
- AST.#parseAST(pattern, ast, 0, options);
23726
+ const ast = new _a(null, undefined, options);
23727
+ _a.#parseAST(pattern, ast, 0, options, 0);
23523
23728
  return ast;
23524
23729
  }
23525
23730
  // returns the regular expression if there's magic, or the unescaped
@@ -23623,16 +23828,18 @@ function requireAst$1 () {
23623
23828
  // or start or whatever) and prepend ^ or / at the Regexp construction.
23624
23829
  toRegExpSource(allowDot) {
23625
23830
  const dot = allowDot ?? !!this.#options.dot;
23626
- if (this.#root === this)
23831
+ if (this.#root === this) {
23832
+ this.#flatten();
23627
23833
  this.#fillNegs();
23628
- if (!this.type) {
23834
+ }
23835
+ if (!isExtglobAST(this)) {
23629
23836
  const noEmpty = this.isStart() &&
23630
23837
  this.isEnd() &&
23631
23838
  !this.#parts.some(s => typeof s !== 'string');
23632
23839
  const src = this.#parts
23633
23840
  .map(p => {
23634
23841
  const [re, _, hasMagic, uflag] = typeof p === 'string' ?
23635
- AST.#parseGlob(p, this.#hasMagic, noEmpty)
23842
+ _a.#parseGlob(p, this.#hasMagic, noEmpty)
23636
23843
  : p.toRegExpSource(allowDot);
23637
23844
  this.#hasMagic = this.#hasMagic || hasMagic;
23638
23845
  this.#uflag = this.#uflag || uflag;
@@ -23694,12 +23901,12 @@ function requireAst$1 () {
23694
23901
  // invalid extglob, has to at least be *something* present, if it's
23695
23902
  // the entire path portion.
23696
23903
  const s = this.toString();
23697
- this.#parts = [s];
23698
- this.type = null;
23699
- this.#hasMagic = undefined;
23904
+ const me = this;
23905
+ me.#parts = [s];
23906
+ me.type = null;
23907
+ me.#hasMagic = undefined;
23700
23908
  return [s, (0, unescape_js_1.unescape)(this.toString()), false, false];
23701
23909
  }
23702
- // XXX abstract out this map method
23703
23910
  let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ?
23704
23911
  ''
23705
23912
  : this.#partsToRegExp(true);
@@ -23735,6 +23942,42 @@ function requireAst$1 () {
23735
23942
  this.#uflag,
23736
23943
  ];
23737
23944
  }
23945
+ #flatten() {
23946
+ if (!isExtglobAST(this)) {
23947
+ for (const p of this.#parts) {
23948
+ if (typeof p === 'object') {
23949
+ p.#flatten();
23950
+ }
23951
+ }
23952
+ }
23953
+ else {
23954
+ // do up to 10 passes to flatten as much as possible
23955
+ let iterations = 0;
23956
+ let done = false;
23957
+ do {
23958
+ done = true;
23959
+ for (let i = 0; i < this.#parts.length; i++) {
23960
+ const c = this.#parts[i];
23961
+ if (typeof c === 'object') {
23962
+ c.#flatten();
23963
+ if (this.#canAdopt(c)) {
23964
+ done = false;
23965
+ this.#adopt(c, i);
23966
+ }
23967
+ else if (this.#canAdoptWithSpace(c)) {
23968
+ done = false;
23969
+ this.#adoptWithSpace(c, i);
23970
+ }
23971
+ else if (this.#canUsurp(c)) {
23972
+ done = false;
23973
+ this.#usurp(c);
23974
+ }
23975
+ }
23976
+ }
23977
+ } while (!done && ++iterations < 10);
23978
+ }
23979
+ this.#toString = undefined;
23980
+ }
23738
23981
  #partsToRegExp(dot) {
23739
23982
  return this.#parts
23740
23983
  .map(p => {
@@ -23806,6 +24049,7 @@ function requireAst$1 () {
23806
24049
  }
23807
24050
  }
23808
24051
  ast$1.AST = AST;
24052
+ _a = AST;
23809
24053
 
23810
24054
  return ast$1;
23811
24055
  }
@@ -24058,11 +24302,13 @@ function requireCommonjs () {
24058
24302
  isWindows;
24059
24303
  platform;
24060
24304
  windowsNoMagicRoot;
24305
+ maxGlobstarRecursion;
24061
24306
  regexp;
24062
24307
  constructor(pattern, options = {}) {
24063
24308
  (0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
24064
24309
  options = options || {};
24065
24310
  this.options = options;
24311
+ this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
24066
24312
  this.pattern = pattern;
24067
24313
  this.platform = options.platform || defaultPlatform;
24068
24314
  this.isWindows = this.platform === 'win32';
@@ -24467,7 +24713,8 @@ function requireCommonjs () {
24467
24713
  // out of pattern, then that's fine, as long as all
24468
24714
  // the parts match.
24469
24715
  matchOne(file, pattern, partial = false) {
24470
- const options = this.options;
24716
+ let fileStartIndex = 0;
24717
+ let patternStartIndex = 0;
24471
24718
  // UNC paths like //?/X:/... can match X:/... and vice versa
24472
24719
  // Drive letters in absolute drive or unc paths are always compared
24473
24720
  // case-insensitively.
@@ -24496,14 +24743,11 @@ function requireCommonjs () {
24496
24743
  file[fdi],
24497
24744
  pattern[pdi],
24498
24745
  ];
24746
+ // start matching at the drive letter index of each
24499
24747
  if (fd.toLowerCase() === pd.toLowerCase()) {
24500
24748
  pattern[pdi] = fd;
24501
- if (pdi > fdi) {
24502
- pattern = pattern.slice(pdi);
24503
- }
24504
- else if (fdi > pdi) {
24505
- file = file.slice(fdi);
24506
- }
24749
+ patternStartIndex = pdi;
24750
+ fileStartIndex = fdi;
24507
24751
  }
24508
24752
  }
24509
24753
  }
@@ -24513,99 +24757,185 @@ function requireCommonjs () {
24513
24757
  if (optimizationLevel >= 2) {
24514
24758
  file = this.levelTwoFileOptimize(file);
24515
24759
  }
24516
- this.debug('matchOne', this, { file, pattern });
24517
- this.debug('matchOne', file.length, pattern.length);
24518
- for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
24760
+ if (pattern.includes(exports$1.GLOBSTAR)) {
24761
+ return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
24762
+ }
24763
+ return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
24764
+ }
24765
+ #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
24766
+ // split the pattern into head, tail, and middle of ** delimited parts
24767
+ const firstgs = pattern.indexOf(exports$1.GLOBSTAR, patternIndex);
24768
+ const lastgs = pattern.lastIndexOf(exports$1.GLOBSTAR);
24769
+ // split the pattern up into globstar-delimited sections
24770
+ // the tail has to be at the end, and the others just have
24771
+ // to be found in order from the head.
24772
+ const [head, body, tail] = partial ? [
24773
+ pattern.slice(patternIndex, firstgs),
24774
+ pattern.slice(firstgs + 1),
24775
+ [],
24776
+ ] : [
24777
+ pattern.slice(patternIndex, firstgs),
24778
+ pattern.slice(firstgs + 1, lastgs),
24779
+ pattern.slice(lastgs + 1),
24780
+ ];
24781
+ // check the head, from the current file/pattern index.
24782
+ if (head.length) {
24783
+ const fileHead = file.slice(fileIndex, fileIndex + head.length);
24784
+ if (!this.#matchOne(fileHead, head, partial, 0, 0)) {
24785
+ return false;
24786
+ }
24787
+ fileIndex += head.length;
24788
+ patternIndex += head.length;
24789
+ }
24790
+ // now we know the head matches!
24791
+ // if the last portion is not empty, it MUST match the end
24792
+ // check the tail
24793
+ let fileTailMatch = 0;
24794
+ if (tail.length) {
24795
+ // if head + tail > file, then we cannot possibly match
24796
+ if (tail.length + fileIndex > file.length)
24797
+ return false;
24798
+ // try to match the tail
24799
+ let tailStart = file.length - tail.length;
24800
+ if (this.#matchOne(file, tail, partial, tailStart, 0)) {
24801
+ fileTailMatch = tail.length;
24802
+ }
24803
+ else {
24804
+ // affordance for stuff like a/**/* matching a/b/
24805
+ // if the last file portion is '', and there's more to the pattern
24806
+ // then try without the '' bit.
24807
+ if (file[file.length - 1] !== '' ||
24808
+ fileIndex + tail.length === file.length) {
24809
+ return false;
24810
+ }
24811
+ tailStart--;
24812
+ if (!this.#matchOne(file, tail, partial, tailStart, 0)) {
24813
+ return false;
24814
+ }
24815
+ fileTailMatch = tail.length + 1;
24816
+ }
24817
+ }
24818
+ // now we know the tail matches!
24819
+ // the middle is zero or more portions wrapped in **, possibly
24820
+ // containing more ** sections.
24821
+ // so a/**/b/**/c/**/d has become **/b/**/c/**
24822
+ // if it's empty, it means a/**/b, just verify we have no bad dots
24823
+ // if there's no tail, so it ends on /**, then we must have *something*
24824
+ // after the head, or it's not a matc
24825
+ if (!body.length) {
24826
+ let sawSome = !!fileTailMatch;
24827
+ for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
24828
+ const f = String(file[i]);
24829
+ sawSome = true;
24830
+ if (f === '.' ||
24831
+ f === '..' ||
24832
+ (!this.options.dot && f.startsWith('.'))) {
24833
+ return false;
24834
+ }
24835
+ }
24836
+ // in partial mode, we just need to get past all file parts
24837
+ return partial || sawSome;
24838
+ }
24839
+ // now we know that there's one or more body sections, which can
24840
+ // be matched anywhere from the 0 index (because the head was pruned)
24841
+ // through to the length-fileTailMatch index.
24842
+ // split the body up into sections, and note the minimum index it can
24843
+ // be found at (start with the length of all previous segments)
24844
+ // [section, before, after]
24845
+ const bodySegments = [[[], 0]];
24846
+ let currentBody = bodySegments[0];
24847
+ let nonGsParts = 0;
24848
+ const nonGsPartsSums = [0];
24849
+ for (const b of body) {
24850
+ if (b === exports$1.GLOBSTAR) {
24851
+ nonGsPartsSums.push(nonGsParts);
24852
+ currentBody = [[], 0];
24853
+ bodySegments.push(currentBody);
24854
+ }
24855
+ else {
24856
+ currentBody[0].push(b);
24857
+ nonGsParts++;
24858
+ }
24859
+ }
24860
+ let i = bodySegments.length - 1;
24861
+ const fileLength = file.length - fileTailMatch;
24862
+ for (const b of bodySegments) {
24863
+ b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
24864
+ }
24865
+ return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
24866
+ }
24867
+ // return false for "nope, not matching"
24868
+ // return null for "not matching, cannot keep trying"
24869
+ #matchGlobStarBodySections(file,
24870
+ // pattern section, last possible position for it
24871
+ bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
24872
+ // take the first body segment, and walk from fileIndex to its "after"
24873
+ // value at the end
24874
+ // If it doesn't match at that position, we increment, until we hit
24875
+ // that final possible position, and give up.
24876
+ // If it does match, then advance and try to rest.
24877
+ // If any of them fail we keep walking forward.
24878
+ // this is still a bit recursively painful, but it's more constrained
24879
+ // than previous implementations, because we never test something that
24880
+ // can't possibly be a valid matching condition.
24881
+ const bs = bodySegments[bodyIndex];
24882
+ if (!bs) {
24883
+ // just make sure that there's no bad dots
24884
+ for (let i = fileIndex; i < file.length; i++) {
24885
+ sawTail = true;
24886
+ const f = file[i];
24887
+ if (f === '.' ||
24888
+ f === '..' ||
24889
+ (!this.options.dot && f.startsWith('.'))) {
24890
+ return false;
24891
+ }
24892
+ }
24893
+ return sawTail;
24894
+ }
24895
+ // have a non-globstar body section to test
24896
+ const [body, after] = bs;
24897
+ while (fileIndex <= after) {
24898
+ const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
24899
+ // if limit exceeded, no match. intentional false negative,
24900
+ // acceptable break in correctness for security.
24901
+ if (m && globStarDepth < this.maxGlobstarRecursion) {
24902
+ // match! see if the rest match. if so, we're done!
24903
+ const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
24904
+ if (sub !== false) {
24905
+ return sub;
24906
+ }
24907
+ }
24908
+ const f = file[fileIndex];
24909
+ if (f === '.' ||
24910
+ f === '..' ||
24911
+ (!this.options.dot && f.startsWith('.'))) {
24912
+ return false;
24913
+ }
24914
+ fileIndex++;
24915
+ }
24916
+ // walked off. no point continuing
24917
+ return partial || null;
24918
+ }
24919
+ #matchOne(file, pattern, partial, fileIndex, patternIndex) {
24920
+ let fi;
24921
+ let pi;
24922
+ let pl;
24923
+ let fl;
24924
+ for (fi = fileIndex,
24925
+ pi = patternIndex,
24926
+ fl = file.length,
24927
+ pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
24519
24928
  this.debug('matchOne loop');
24520
- var p = pattern[pi];
24521
- var f = file[fi];
24929
+ let p = pattern[pi];
24930
+ let f = file[fi];
24522
24931
  this.debug(pattern, p, f);
24523
24932
  // should be impossible.
24524
24933
  // some invalid regexp stuff in the set.
24525
24934
  /* c8 ignore start */
24526
- if (p === false) {
24935
+ if (p === false || p === exports$1.GLOBSTAR) {
24527
24936
  return false;
24528
24937
  }
24529
24938
  /* c8 ignore stop */
24530
- if (p === exports$1.GLOBSTAR) {
24531
- this.debug('GLOBSTAR', [pattern, p, f]);
24532
- // "**"
24533
- // a/**/b/**/c would match the following:
24534
- // a/b/x/y/z/c
24535
- // a/x/y/z/b/c
24536
- // a/b/x/b/x/c
24537
- // a/b/c
24538
- // To do this, take the rest of the pattern after
24539
- // the **, and see if it would match the file remainder.
24540
- // If so, return success.
24541
- // If not, the ** "swallows" a segment, and try again.
24542
- // This is recursively awful.
24543
- //
24544
- // a/**/b/**/c matching a/b/x/y/z/c
24545
- // - a matches a
24546
- // - doublestar
24547
- // - matchOne(b/x/y/z/c, b/**/c)
24548
- // - b matches b
24549
- // - doublestar
24550
- // - matchOne(x/y/z/c, c) -> no
24551
- // - matchOne(y/z/c, c) -> no
24552
- // - matchOne(z/c, c) -> no
24553
- // - matchOne(c, c) yes, hit
24554
- var fr = fi;
24555
- var pr = pi + 1;
24556
- if (pr === pl) {
24557
- this.debug('** at the end');
24558
- // a ** at the end will just swallow the rest.
24559
- // We have found a match.
24560
- // however, it will not swallow /.x, unless
24561
- // options.dot is set.
24562
- // . and .. are *never* matched by **, for explosively
24563
- // exponential reasons.
24564
- for (; fi < fl; fi++) {
24565
- if (file[fi] === '.' ||
24566
- file[fi] === '..' ||
24567
- (!options.dot && file[fi].charAt(0) === '.'))
24568
- return false;
24569
- }
24570
- return true;
24571
- }
24572
- // ok, let's see if we can swallow whatever we can.
24573
- while (fr < fl) {
24574
- var swallowee = file[fr];
24575
- this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
24576
- // XXX remove this slice. Just pass the start index.
24577
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
24578
- this.debug('globstar found match!', fr, fl, swallowee);
24579
- // found a match.
24580
- return true;
24581
- }
24582
- else {
24583
- // can't swallow "." or ".." ever.
24584
- // can only swallow ".foo" when explicitly asked.
24585
- if (swallowee === '.' ||
24586
- swallowee === '..' ||
24587
- (!options.dot && swallowee.charAt(0) === '.')) {
24588
- this.debug('dot detected!', file, fr, pattern, pr);
24589
- break;
24590
- }
24591
- // ** swallows a segment, and continue.
24592
- this.debug('globstar swallow a segment, and continue');
24593
- fr++;
24594
- }
24595
- }
24596
- // no match was found.
24597
- // However, in partial mode, we can't say this is necessarily over.
24598
- /* c8 ignore start */
24599
- if (partial) {
24600
- // ran out of file
24601
- this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
24602
- if (fr === fl) {
24603
- return true;
24604
- }
24605
- }
24606
- /* c8 ignore stop */
24607
- return false;
24608
- }
24609
24939
  // something other than **
24610
24940
  // non-magic patterns just have to match exactly
24611
24941
  // patterns with magic have been turned into regexps.
@@ -25065,8 +25395,12 @@ function requireCjs$1 () {
25065
25395
  /** @import * as $typests from "./types.ts"; */
25066
25396
  /** @typedef {$typests.BuiltInMergeStrategy} BuiltInMergeStrategy */
25067
25397
  /** @typedef {$typests.BuiltInValidationStrategy} BuiltInValidationStrategy */
25398
+ /** @typedef {$typests.CustomMergeStrategy} CustomMergeStrategy */
25399
+ /** @typedef {$typests.CustomValidationStrategy} CustomValidationStrategy */
25068
25400
  /** @typedef {$typests.ObjectDefinition} ObjectDefinition */
25069
25401
  /** @typedef {$typests.PropertyDefinition} PropertyDefinition */
25402
+ /** @typedef {$typests.PropertyDefinitionWithSchema} PropertyDefinitionWithSchema */
25403
+ /** @typedef {$typests.PropertyDefinitionWithStrategies} PropertyDefinitionWithStrategies */
25070
25404
 
25071
25405
  //-----------------------------------------------------------------------------
25072
25406
  // Private
@@ -25579,6 +25913,9 @@ function requireCjs () {
25579
25913
 
25580
25914
  /** @import * as $typests from "./types.ts"; */
25581
25915
  /** @typedef {$typests.ConfigObject} ConfigObject */
25916
+ /** @typedef {$typests.FileMatcher} FileMatcher */
25917
+ /** @typedef {$typests.FilesMatcher} FilesMatcher */
25918
+ /** @typedef {$typests.ExtraConfigType} ExtraConfigType */
25582
25919
  /** @import * as $minimatch from "minimatch"; */
25583
25920
  /** @typedef {$minimatch.MinimatchOptions} MinimatchOptions */
25584
25921
  /** @import * as PathImpl from "@jsr/std__path" */
@@ -25621,7 +25958,7 @@ function requireCjs () {
25621
25958
 
25622
25959
  /**
25623
25960
  * The types of config objects that are supported.
25624
- * @type {Set<string>}
25961
+ * @type {Set<ExtraConfigType>}
25625
25962
  */
25626
25963
  const CONFIG_TYPES = new Set(["array", "function"]);
25627
25964
 
@@ -25706,7 +26043,7 @@ function requireCjs () {
25706
26043
 
25707
26044
  /**
25708
26045
  * Rethrows a config error with additional information about the config object.
25709
- * @param {object} config The config object to get the name of.
26046
+ * @param {ConfigObject} config The config object to get the name of.
25710
26047
  * @param {number} index The index of the config object in the array.
25711
26048
  * @param {Error} error The error to rethrow.
25712
26049
  * @throws {ConfigError} When the error is rethrown for a config.
@@ -25719,7 +26056,7 @@ function requireCjs () {
25719
26056
  /**
25720
26057
  * Shorthand for checking if a value is a string.
25721
26058
  * @param {any} value The value to check.
25722
- * @returns {boolean} True if a string, false if not.
26059
+ * @returns {value is string} True if a string, false if not.
25723
26060
  */
25724
26061
  function isString(value) {
25725
26062
  return typeof value === "string";
@@ -25779,8 +26116,8 @@ function requireCjs () {
25779
26116
  * faster matching speed over multiple file path evaluations.
25780
26117
  * @param {string} filepath The file path to match.
25781
26118
  * @param {string} pattern The glob pattern to match against.
25782
- * @param {object} options The minimatch options to use.
25783
- * @returns
26119
+ * @param {MinimatchOptions} options The minimatch options to use.
26120
+ * @returns {boolean} True if the file path matches, false if not.
25784
26121
  */
25785
26122
  function doMatch(filepath, pattern, options = {}) {
25786
26123
  let cache = minimatchCache;
@@ -25804,8 +26141,8 @@ function requireCjs () {
25804
26141
 
25805
26142
  /**
25806
26143
  * Normalizes a pattern by removing the leading "./" if present.
25807
- * @param {string} pattern The pattern to normalize.
25808
- * @returns {string} The normalized pattern.
26144
+ * @param {FileMatcher} pattern The pattern to normalize.
26145
+ * @returns {FileMatcher} The normalized pattern.
25809
26146
  */
25810
26147
  function normalizePattern(pattern) {
25811
26148
  if (isString(pattern)) {
@@ -25906,7 +26243,7 @@ function requireCjs () {
25906
26243
  * @param {Array} items The items in a `ConfigArray`.
25907
26244
  * @param {Object} context The context object to pass into any function
25908
26245
  * found.
25909
- * @param {Array<string>} extraConfigTypes The config types to check.
26246
+ * @param {ReadonlyArray<ExtraConfigType>} extraConfigTypes The config types to check.
25910
26247
  * @param {string} namespacedBasePath The namespaced base path of the directory to which config base paths are relative.
25911
26248
  * @param {PathImpl} path Path-handling implementation.
25912
26249
  * @returns {Promise<Array>} A flattened array containing only config objects.
@@ -25954,7 +26291,7 @@ function requireCjs () {
25954
26291
  * Async iterables cannot be used with the spread operator, so we need to manually
25955
26292
  * create the array to return.
25956
26293
  */
25957
- const asyncIterable = await flatTraverse(items);
26294
+ const asyncIterable = flatTraverse(items);
25958
26295
  const configs = [];
25959
26296
 
25960
26297
  for await (const config of asyncIterable) {
@@ -25970,7 +26307,7 @@ function requireCjs () {
25970
26307
  * @param {Array} items The items in a `ConfigArray`.
25971
26308
  * @param {Object} context The context object to pass into any function
25972
26309
  * found.
25973
- * @param {Array<string>} extraConfigTypes The config types to check.
26310
+ * @param {ReadonlyArray<ExtraConfigType>} extraConfigTypes The config types to check.
25974
26311
  * @param {string} namespacedBasePath The namespaced base path of the directory to which config base paths are relative.
25975
26312
  * @param {PathImpl} path Path-handling implementation
25976
26313
  * @returns {Array} A flattened array containing only config objects.
@@ -26043,13 +26380,13 @@ function requireCjs () {
26043
26380
  /**
26044
26381
  * Determines if a given file path should be ignored based on the given
26045
26382
  * matcher.
26046
- * @param {Array<{ basePath?: string, ignores: Array<string|((string) => boolean)>}>} configs Configuration objects containing `ignores`.
26383
+ * @param {Array<{ basePath?: string, ignores: FileMatcher[] }>} configs Configuration objects containing `ignores`.
26047
26384
  * @param {string} filePath The unprocessed file path to check.
26048
26385
  * @param {string} relativeFilePath The path of the file to check relative to the base path,
26049
26386
  * using forward slash (`"/"`) as a separator.
26050
26387
  * @param {Object} [basePathData] Additional data needed to recalculate paths for configuration objects
26051
26388
  * that have `basePath` property.
26052
- * @param {string} [basePathData.basePath] Namespaced path to witch `relativeFilePath` is relative.
26389
+ * @param {string} [basePathData.basePath] Namespaced path to which `relativeFilePath` is relative.
26053
26390
  * @param {PathImpl} [basePathData.path] Path-handling implementation.
26054
26391
  * @returns {boolean} True if the path should be ignored and false if not.
26055
26392
  */
@@ -26118,7 +26455,7 @@ function requireCjs () {
26118
26455
  * @param {string} filePath The unprocessed file path to check.
26119
26456
  * @param {string} relativeFilePath The path of the file to check relative to the base path,
26120
26457
  * using forward slash (`"/"`) as a separator.
26121
- * @param {Object} config The config object to check.
26458
+ * @param {ConfigObject & { files: FilesMatcher[] }} config The config object to check.
26122
26459
  * @returns {boolean} True if the file path is matched by the config,
26123
26460
  * false if not.
26124
26461
  */
@@ -26181,21 +26518,23 @@ function requireCjs () {
26181
26518
 
26182
26519
  /**
26183
26520
  * Ensures that config types are valid.
26184
- * @param {Array<string>} extraConfigTypes The config types to check.
26521
+ * @param {ReadonlyArray<ExtraConfigType>} extraConfigTypes The config types to check.
26185
26522
  * @returns {void}
26186
26523
  * @throws {TypeError} When the config types array is invalid.
26187
26524
  */
26188
26525
  function assertExtraConfigTypes(extraConfigTypes) {
26526
+ if (!Array.isArray(extraConfigTypes)) {
26527
+ throw new TypeError("extraConfigTypes must be an array.");
26528
+ }
26529
+
26189
26530
  if (extraConfigTypes.length > 2) {
26190
- throw new TypeError(
26191
- "configTypes must be an array with at most two items.",
26192
- );
26531
+ throw new TypeError("extraConfigTypes must contain at most two items.");
26193
26532
  }
26194
26533
 
26195
26534
  for (const configType of extraConfigTypes) {
26196
26535
  if (!CONFIG_TYPES.has(configType)) {
26197
26536
  throw new TypeError(
26198
- `Unexpected config type "${configType}" found. Expected one of: "object", "array", "function".`,
26537
+ `Unexpected config type "${configType}" in extraConfigTypes. Expected one of: "array", "function".`,
26199
26538
  );
26200
26539
  }
26201
26540
  }
@@ -26266,9 +26605,9 @@ function requireCjs () {
26266
26605
  * Defaults to `"/"`.
26267
26606
  * @param {boolean} [options.normalized=false] Flag indicating if the
26268
26607
  * configs have already been normalized.
26269
- * @param {Object} [options.schema] The additional schema
26608
+ * @param {ObjectDefinition} [options.schema] The additional schema
26270
26609
  * definitions to use for the ConfigArray schema.
26271
- * @param {Array<string>} [options.extraConfigTypes] List of config types supported.
26610
+ * @param {ReadonlyArray<ExtraConfigType>} [options.extraConfigTypes] List of config types supported.
26272
26611
  * @throws {TypeError} When the `basePath` is not a non-empty string,
26273
26612
  */
26274
26613
  constructor(
@@ -26316,7 +26655,7 @@ function requireCjs () {
26316
26655
 
26317
26656
  /**
26318
26657
  * The supported config types.
26319
- * @type {Array<string>}
26658
+ * @type {ReadonlyArray<ExtraConfigType>}
26320
26659
  */
26321
26660
  this.extraConfigTypes = [...extraConfigTypes];
26322
26661
  Object.freeze(this.extraConfigTypes);
@@ -26369,7 +26708,7 @@ function requireCjs () {
26369
26708
  * This can be used to determine which files will be matched by a
26370
26709
  * config array or to use as a glob pattern when no patterns are provided
26371
26710
  * for a command line interface.
26372
- * @returns {Array<string|Function>} An array of matchers.
26711
+ * @returns {Array<FilesMatcher>} An array of matchers.
26373
26712
  */
26374
26713
  get files() {
26375
26714
  assertNormalized(this);
@@ -26405,7 +26744,7 @@ function requireCjs () {
26405
26744
  * the matching `files` fields in any configs. This is necessary to mimic
26406
26745
  * the behavior of things like .gitignore and .eslintignore, allowing a
26407
26746
  * globbing operation to be faster.
26408
- * @returns {Object[]} An array of config objects representing global ignores.
26747
+ * @returns {Array<{ basePath?: string, name?: string, ignores: FileMatcher[] }>} An array of config objects representing global ignores.
26409
26748
  */
26410
26749
  get ignores() {
26411
26750
  assertNormalized(this);
@@ -26424,7 +26763,7 @@ function requireCjs () {
26424
26763
  for (const config of this) {
26425
26764
  /*
26426
26765
  * We only count ignores if there are no other keys in the object.
26427
- * In this case, it acts list a globally ignored pattern. If there
26766
+ * In this case, it acts like a globally ignored pattern. If there
26428
26767
  * are additional keys, then ignores act like exclusions.
26429
26768
  */
26430
26769
  if (
@@ -44771,24 +45110,24 @@ function requireEspree () {
44771
45110
  * Normalize sourceType from the initial config
44772
45111
  * @param {string} sourceType to normalize
44773
45112
  * @throws {Error} throw an error if sourceType is invalid
44774
- * @returns {"script"|"module"} normalized sourceType
45113
+ * @returns {"script"|"module"|"commonjs"} normalized sourceType
44775
45114
  */
44776
45115
  function normalizeSourceType(sourceType = "script") {
44777
- if (sourceType === "script" || sourceType === "module") {
45116
+ if (
45117
+ sourceType === "script" ||
45118
+ sourceType === "module" ||
45119
+ sourceType === "commonjs"
45120
+ ) {
44778
45121
  return sourceType;
44779
45122
  }
44780
45123
 
44781
- if (sourceType === "commonjs") {
44782
- return "script";
44783
- }
44784
-
44785
45124
  throw new Error("Invalid sourceType.");
44786
45125
  }
44787
45126
 
44788
45127
  /**
44789
45128
  * @typedef {{
44790
45129
  * ecmaVersion: NormalizedEcmaVersion,
44791
- * sourceType: "script"|"module",
45130
+ * sourceType: "script"|"module"|"commonjs",
44792
45131
  * range?: boolean,
44793
45132
  * loc?: boolean,
44794
45133
  * allowReserved: boolean | "never",
@@ -45593,7 +45932,7 @@ function requireEspree () {
45593
45932
  //------------------------------------------------------------------------------
45594
45933
 
45595
45934
  /** @type {string} */
45596
- const version = "11.1.1"; // x-release-please-version
45935
+ const version = "11.2.0"; // x-release-please-version
45597
45936
  const name = "espree";
45598
45937
 
45599
45938
  // Derive node types from VisitorKeys
@@ -46079,9 +46418,9 @@ function requireAstUtils () {
46079
46418
  if (left.regex || right.regex) {
46080
46419
  return Boolean(
46081
46420
  left.regex &&
46082
- right.regex &&
46083
- left.regex.pattern === right.regex.pattern &&
46084
- left.regex.flags === right.regex.flags,
46421
+ right.regex &&
46422
+ left.regex.pattern === right.regex.pattern &&
46423
+ left.regex.flags === right.regex.flags,
46085
46424
  );
46086
46425
  }
46087
46426
 
@@ -46722,9 +47061,9 @@ function requireAstUtils () {
46722
47061
 
46723
47062
  return Boolean(
46724
47063
  reference &&
46725
- reference.resolved &&
46726
- reference.resolved.scope.type === "global" &&
46727
- reference.resolved.defs.length === 0,
47064
+ reference.resolved &&
47065
+ reference.resolved.scope.type === "global" &&
47066
+ reference.resolved.defs.length === 0,
46728
47067
  );
46729
47068
  }
46730
47069
 
@@ -52814,9 +53153,9 @@ function requireCapitalizedComments () {
52814
53153
 
52815
53154
  return Boolean(
52816
53155
  previousToken &&
52817
- nextToken &&
52818
- comment.loc.start.line === previousToken.loc.end.line &&
52819
- 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,
52820
53159
  );
52821
53160
  }
52822
53161
 
@@ -52832,7 +53171,7 @@ function requireCapitalizedComments () {
52832
53171
 
52833
53172
  return Boolean(
52834
53173
  previousTokenOrComment &&
52835
- ["Block", "Line"].includes(previousTokenOrComment.type),
53174
+ ["Block", "Line"].includes(previousTokenOrComment.type),
52836
53175
  );
52837
53176
  }
52838
53177
 
@@ -82018,11 +82357,11 @@ function requireNoExtendNative () {
82018
82357
  function isPrototypePropertyAccessed(identifierNode) {
82019
82358
  return Boolean(
82020
82359
  identifierNode &&
82021
- identifierNode.parent &&
82022
- identifierNode.parent.type === "MemberExpression" &&
82023
- identifierNode.parent.object === identifierNode &&
82024
- astUtils.getStaticPropertyName(identifierNode.parent) ===
82025
- "prototype",
82360
+ identifierNode.parent &&
82361
+ identifierNode.parent.type === "MemberExpression" &&
82362
+ identifierNode.parent.object === identifierNode &&
82363
+ astUtils.getStaticPropertyName(identifierNode.parent) ===
82364
+ "prototype",
82026
82365
  );
82027
82366
  }
82028
82367
 
@@ -88985,10 +89324,10 @@ function requireIsCombiningCharacter () {
88985
89324
  /**
88986
89325
  * Check whether a given character is a combining mark or not.
88987
89326
  * @param {number} codePoint The character code to check.
88988
- * @returns {boolean} `true` if the character belongs to the category, any of `Mc`, `Me`, and `Mn`.
89327
+ * @returns {boolean} `true` if the character has the General Category of Combining Mark (M), consisting of `Mc`, `Me`, and `Mn`.
88989
89328
  */
88990
89329
  isCombiningCharacter = function isCombiningCharacter(codePoint) {
88991
- return /^[\p{Mc}\p{Me}\p{Mn}]$/u.test(String.fromCodePoint(codePoint));
89330
+ return /^\p{M}$/u.test(String.fromCodePoint(codePoint));
88992
89331
  };
88993
89332
  return isCombiningCharacter;
88994
89333
  }
@@ -99383,9 +99722,7 @@ function requireNoThisBeforeSuper () {
99383
99722
  isConstructor: true,
99384
99723
  hasExtends: Boolean(
99385
99724
  classNode.superClass &&
99386
- !astUtils.isNullOrUndefined(
99387
- classNode.superClass,
99388
- ),
99725
+ !astUtils.isNullOrUndefined(classNode.superClass),
99389
99726
  ),
99390
99727
  codePath,
99391
99728
  currentSegments: new Set(),
@@ -100938,11 +101275,11 @@ function requireNoUnmodifiedLoopCondition () {
100938
101275
  condition.isInLoop(modifier) ||
100939
101276
  Boolean(
100940
101277
  (funcNode = getEncloseFunctionDeclaration(modifier)) &&
100941
- (funcVar = astUtils.getVariableByName(
100942
- modifier.from.upper,
100943
- funcNode.id.name,
100944
- )) &&
100945
- funcVar.references.some(condition.isInLoop),
101278
+ (funcVar = astUtils.getVariableByName(
101279
+ modifier.from.upper,
101280
+ funcNode.id.name,
101281
+ )) &&
101282
+ funcVar.references.some(condition.isInLoop),
100946
101283
  );
100947
101284
 
100948
101285
  condition.modified = inLoop;
@@ -105404,7 +105741,7 @@ function requireNoUselessAssignment () {
105404
105741
 
105405
105742
  messages: {
105406
105743
  unnecessaryAssignment:
105407
- "This assigned value is not used in subsequent statements.",
105744
+ "The value assigned to '{{name}}' is not used in subsequent statements.",
105408
105745
  },
105409
105746
  },
105410
105747
 
@@ -105752,6 +106089,7 @@ function requireNoUselessAssignment () {
105752
106089
  context.report({
105753
106090
  node: targetAssignment.identifier,
105754
106091
  messageId: "unnecessaryAssignment",
106092
+ data: { name: targetAssignment.identifier.name },
105755
106093
  });
105756
106094
  }
105757
106095
 
@@ -108217,6 +108555,28 @@ function requireNoVar () {
108217
108555
  return variable.name === "let";
108218
108556
  }
108219
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
+
108220
108580
  //------------------------------------------------------------------------------
108221
108581
  // Rule Definition
108222
108582
  //------------------------------------------------------------------------------
@@ -108270,6 +108630,7 @@ function requireNoVar () {
108270
108630
  * - A variable is used from a closure within a loop.
108271
108631
  * - A variable might be used before it is assigned within a loop.
108272
108632
  * - A variable might be used in TDZ.
108633
+ * - A variable is referenced before its declaration.
108273
108634
  * - A variable is declared in statement position (e.g. a single-line `IfStatement`)
108274
108635
  * - A variable has name that is disallowed for `let` declarations.
108275
108636
  *
@@ -108314,6 +108675,10 @@ function requireNoVar () {
108314
108675
  function canFix(node) {
108315
108676
  const variables = sourceCode.getDeclaredVariables(node);
108316
108677
  const scopeNode = getScopeNode(node);
108678
+ const parentStatementList = new Set([
108679
+ ...astUtils.STATEMENT_LIST_PARENTS,
108680
+ "TSModuleBlock",
108681
+ ]);
108317
108682
 
108318
108683
  if (
108319
108684
  node.parent.type === "SwitchCase" ||
@@ -108321,7 +108686,8 @@ function requireNoVar () {
108321
108686
  variables.some(isGlobal) ||
108322
108687
  variables.some(isRedeclared) ||
108323
108688
  variables.some(isUsedFromOutsideOf(scopeNode)) ||
108324
- variables.some(hasNameDisallowedForLetDeclarations)
108689
+ variables.some(hasNameDisallowedForLetDeclarations) ||
108690
+ variables.some(hasReferenceBeforeDeclaration)
108325
108691
  ) {
108326
108692
  return false;
108327
108693
  }
@@ -108341,7 +108707,7 @@ function requireNoVar () {
108341
108707
  node.parent.type === "ForStatement" &&
108342
108708
  node.parent.init === node
108343
108709
  ) &&
108344
- !astUtils.STATEMENT_LIST_PARENTS.has(node.parent.type)
108710
+ !parentStatementList.has(node.parent.type)
108345
108711
  ) {
108346
108712
  // If the declaration is not in a block, e.g. `if (foo) var bar = 1;`, then it can't be fixed.
108347
108713
  return false;
@@ -112644,11 +113010,11 @@ function requirePaddingLineBetweenStatements () {
112644
113010
  const nextToken = sourceCode.getTokenAfter(semiToken);
112645
113011
  const isSemicolonLessStyle = Boolean(
112646
113012
  prevToken &&
112647
- nextToken &&
112648
- prevToken.range[0] >= node.range[0] &&
112649
- astUtils.isSemicolonToken(semiToken) &&
112650
- semiToken.loc.start.line !== prevToken.loc.end.line &&
112651
- 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,
112652
113018
  );
112653
113019
 
112654
113020
  return isSemicolonLessStyle ? prevToken : semiToken;