@bigbinary/eslint-plugin-neeto 1.8.1 → 1.8.2

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 (2) hide show
  1. package/dist/index.js +281 -302
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -285,114 +285,9 @@
285
285
  }
286
286
  });
287
287
 
288
- var name = "@bigbinary/eslint-plugin-neeto";
289
- var version = "1.8.0";
290
- var main = "dist/index.js";
291
- var license = "UNLICENSED";
292
- var scripts = {
293
- prepare: "husky install",
294
- test: "npm run build && jest dist/util-tests.spec.js && node dist/rule-tests.js",
295
- build: "rollup --bundleConfigAsCjs -c rollup.config.js",
296
- watch: "rollup --bundleConfigAsCjs -c rollup.config.js --watch"
297
- };
298
- var files = [
299
- "dist/index.js",
300
- "dist/resolveConfigWorker.js"
301
- ];
302
- var engines = {
303
- node: ">=22.13",
304
- npm: ">=9",
305
- yarn: ">=1.22"
306
- };
307
- var dependencies = {
308
- };
309
- var devDependencies = {
310
- "@babel/core": "^7.19.1",
311
- "@babel/eslint-parser": "^7.27.5",
312
- "@babel/plugin-transform-runtime": "^7.19.1",
313
- "@babel/preset-env": "7.17.10",
314
- "@babel/preset-react": "7.16.7",
315
- "@babel/preset-typescript": "^7.18.6",
316
- "@babel/runtime": "^7.19.0",
317
- "@bigbinary/babel-preset-neeto": "^1.0.3",
318
- "@bigbinary/eslint-plugin-neeto": "^1.7.2",
319
- "@bigbinary/neeto-cist": "^1.0.3",
320
- "@bigbinary/neeto-commons-frontend": "^4.13.42",
321
- "@rollup/plugin-alias": "^3.1.9",
322
- "@rollup/plugin-babel": "^6.0.4",
323
- "@rollup/plugin-commonjs": "^22.0.0",
324
- "@rollup/plugin-json": "^4.1.0",
325
- "@rollup/plugin-node-resolve": "^15.3.0",
326
- "babel-loader": "^8.2.5",
327
- "babel-plugin-dynamic-import-node": "^2.3.3",
328
- "babel-plugin-istanbul": "^6.1.1",
329
- "babel-plugin-js-logger": "1.0.17",
330
- "babel-plugin-macros": "3.1.0",
331
- "babel-plugin-module-resolver": "^5.0.0",
332
- "babel-plugin-preval": "^5.1.0",
333
- "babel-plugin-transform-imports": "^2.0.0",
334
- "babel-plugin-transform-react-remove-prop-types": "0.4.24",
335
- "babel-preset-react": "6.24.1",
336
- "babel-preset-typescript": "^7.0.0-alpha.19",
337
- cheerio: "^1.0.0-rc.12",
338
- "command-line-args": "^5.2.1",
339
- eslint: "^9.25.1",
340
- "eslint-config-prettier": "^10.1.2",
341
- "eslint-plugin-import": "^2.31.0",
342
- "eslint-plugin-jam3": "^0.2.3",
343
- "eslint-plugin-json": "^4.0.1",
344
- "eslint-plugin-prettier": "^5.2.6",
345
- "eslint-plugin-promise": "^7.2.1",
346
- "eslint-plugin-react": "^7.37.5",
347
- "eslint-plugin-react-hooks": "^5.2.0",
348
- "eslint-plugin-security": "^3.0.1",
349
- "eslint-plugin-sonarjs": "^3.0.2",
350
- "eslint-plugin-unused-imports": "^4.1.4",
351
- globals: "^16.0.0",
352
- husky: "7.0.4",
353
- i18next: "21.7.0",
354
- jest: "27.5.1",
355
- "lint-staged": "12.4.1",
356
- minimatch: "^5.1.0",
357
- "mock-fs": "^5.2.0",
358
- prettier: "2.6.2",
359
- ramda: "0.29.0",
360
- rollup: "^4.24.0",
361
- "rollup-plugin-analyzer": "^4.0.0",
362
- "rollup-plugin-cleaner": "^1.0.0",
363
- "rollup-plugin-copy": "^3.5.0",
364
- "rollup-plugin-peer-deps-external": "^2.2.4",
365
- synckit: "^0.9.0"
366
- };
367
- var peerDependencies = {
368
- "@bigbinary/neeto-cist": "^1.0.3",
369
- "@bigbinary/neeto-commons-frontend": "4.13.38",
370
- eslint: "^9.25.1",
371
- i18next: "21.7.0",
372
- ramda: "0.29.0"
373
- };
288
+ var version = "1.8.1";
374
289
  var packageJson = {
375
- name: name,
376
- version: version,
377
- main: main,
378
- license: license,
379
- scripts: scripts,
380
- "lint-staged": {
381
- "{package.json}": [
382
- "prettier --write",
383
- "eslint --fix --no-warn-ignored"
384
- ],
385
- "**/*.js": [
386
- "prettier --write",
387
- "eslint --fix --no-warn-ignored"
388
- ]
389
- },
390
- files: files,
391
- engines: engines,
392
- dependencies: dependencies,
393
- devDependencies: devDependencies,
394
- peerDependencies: peerDependencies
395
- };
290
+ version: version};
396
291
 
397
292
  const prefix = "export default ";
398
293
  var jsonProcessor = {
@@ -459,7 +354,6 @@
459
354
  PROPERTY: "Property",
460
355
  RETURN_STATEMENT: "ReturnStatement",
461
356
  SPREAD_ELEMENT: "SpreadElement",
462
- TEMPLATE_ELEMENT: "TemplateElement",
463
357
  TEMPLATE_LITERAL: "TemplateLiteral",
464
358
  UNARY_EXPRESSION: "UnaryExpression",
465
359
  VARIABLE_DECLARATION: "VariableDeclaration",
@@ -1865,8 +1759,8 @@
1865
1759
 
1866
1760
  var semver$1 = {exports: {}};
1867
1761
 
1868
- (function (module, exports) {
1869
- exports = module.exports = SemVer;
1762
+ (function (module, exports$1) {
1763
+ exports$1 = module.exports = SemVer;
1870
1764
 
1871
1765
  var debug;
1872
1766
  /* istanbul ignore next */
@@ -1885,7 +1779,7 @@
1885
1779
 
1886
1780
  // Note: this is the semver.org version of the spec that it implements
1887
1781
  // Not necessarily the package version of this code.
1888
- exports.SEMVER_SPEC_VERSION = '2.0.0';
1782
+ exports$1.SEMVER_SPEC_VERSION = '2.0.0';
1889
1783
 
1890
1784
  var MAX_LENGTH = 256;
1891
1785
  var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
@@ -1897,10 +1791,10 @@
1897
1791
  var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
1898
1792
 
1899
1793
  // The actual regexps go on exports.re
1900
- var re = exports.re = [];
1901
- var safeRe = exports.safeRe = [];
1902
- var src = exports.src = [];
1903
- var t = exports.tokens = {};
1794
+ var re = exports$1.re = [];
1795
+ var safeRe = exports$1.safeRe = [];
1796
+ var src = exports$1.src = [];
1797
+ var t = exports$1.tokens = {};
1904
1798
  var R = 0;
1905
1799
 
1906
1800
  function tok (n) {
@@ -2158,7 +2052,7 @@
2158
2052
  }
2159
2053
  }
2160
2054
 
2161
- exports.parse = parse;
2055
+ exports$1.parse = parse;
2162
2056
  function parse (version, options) {
2163
2057
  if (!options || typeof options !== 'object') {
2164
2058
  options = {
@@ -2191,19 +2085,19 @@
2191
2085
  }
2192
2086
  }
2193
2087
 
2194
- exports.valid = valid;
2088
+ exports$1.valid = valid;
2195
2089
  function valid (version, options) {
2196
2090
  var v = parse(version, options);
2197
2091
  return v ? v.version : null
2198
2092
  }
2199
2093
 
2200
- exports.clean = clean;
2094
+ exports$1.clean = clean;
2201
2095
  function clean (version, options) {
2202
2096
  var s = parse(version.trim().replace(/^[=v]+/, ''), options);
2203
2097
  return s ? s.version : null
2204
2098
  }
2205
2099
 
2206
- exports.SemVer = SemVer;
2100
+ exports$1.SemVer = SemVer;
2207
2101
 
2208
2102
  function SemVer (version, options) {
2209
2103
  if (!options || typeof options !== 'object') {
@@ -2474,7 +2368,7 @@
2474
2368
  return this
2475
2369
  };
2476
2370
 
2477
- exports.inc = inc;
2371
+ exports$1.inc = inc;
2478
2372
  function inc (version, release, loose, identifier) {
2479
2373
  if (typeof (loose) === 'string') {
2480
2374
  identifier = loose;
@@ -2488,7 +2382,7 @@
2488
2382
  }
2489
2383
  }
2490
2384
 
2491
- exports.diff = diff;
2385
+ exports$1.diff = diff;
2492
2386
  function diff (version1, version2) {
2493
2387
  if (eq(version1, version2)) {
2494
2388
  return null
@@ -2511,7 +2405,7 @@
2511
2405
  }
2512
2406
  }
2513
2407
 
2514
- exports.compareIdentifiers = compareIdentifiers;
2408
+ exports$1.compareIdentifiers = compareIdentifiers;
2515
2409
 
2516
2410
  var numeric = /^[0-9]+$/;
2517
2411
  function compareIdentifiers (a, b) {
@@ -2530,93 +2424,93 @@
2530
2424
  : 1
2531
2425
  }
2532
2426
 
2533
- exports.rcompareIdentifiers = rcompareIdentifiers;
2427
+ exports$1.rcompareIdentifiers = rcompareIdentifiers;
2534
2428
  function rcompareIdentifiers (a, b) {
2535
2429
  return compareIdentifiers(b, a)
2536
2430
  }
2537
2431
 
2538
- exports.major = major;
2432
+ exports$1.major = major;
2539
2433
  function major (a, loose) {
2540
2434
  return new SemVer(a, loose).major
2541
2435
  }
2542
2436
 
2543
- exports.minor = minor;
2437
+ exports$1.minor = minor;
2544
2438
  function minor (a, loose) {
2545
2439
  return new SemVer(a, loose).minor
2546
2440
  }
2547
2441
 
2548
- exports.patch = patch;
2442
+ exports$1.patch = patch;
2549
2443
  function patch (a, loose) {
2550
2444
  return new SemVer(a, loose).patch
2551
2445
  }
2552
2446
 
2553
- exports.compare = compare;
2447
+ exports$1.compare = compare;
2554
2448
  function compare (a, b, loose) {
2555
2449
  return new SemVer(a, loose).compare(new SemVer(b, loose))
2556
2450
  }
2557
2451
 
2558
- exports.compareLoose = compareLoose;
2452
+ exports$1.compareLoose = compareLoose;
2559
2453
  function compareLoose (a, b) {
2560
2454
  return compare(a, b, true)
2561
2455
  }
2562
2456
 
2563
- exports.compareBuild = compareBuild;
2457
+ exports$1.compareBuild = compareBuild;
2564
2458
  function compareBuild (a, b, loose) {
2565
2459
  var versionA = new SemVer(a, loose);
2566
2460
  var versionB = new SemVer(b, loose);
2567
2461
  return versionA.compare(versionB) || versionA.compareBuild(versionB)
2568
2462
  }
2569
2463
 
2570
- exports.rcompare = rcompare;
2464
+ exports$1.rcompare = rcompare;
2571
2465
  function rcompare (a, b, loose) {
2572
2466
  return compare(b, a, loose)
2573
2467
  }
2574
2468
 
2575
- exports.sort = sort;
2469
+ exports$1.sort = sort;
2576
2470
  function sort (list, loose) {
2577
2471
  return list.sort(function (a, b) {
2578
- return exports.compareBuild(a, b, loose)
2472
+ return exports$1.compareBuild(a, b, loose)
2579
2473
  })
2580
2474
  }
2581
2475
 
2582
- exports.rsort = rsort;
2476
+ exports$1.rsort = rsort;
2583
2477
  function rsort (list, loose) {
2584
2478
  return list.sort(function (a, b) {
2585
- return exports.compareBuild(b, a, loose)
2479
+ return exports$1.compareBuild(b, a, loose)
2586
2480
  })
2587
2481
  }
2588
2482
 
2589
- exports.gt = gt;
2483
+ exports$1.gt = gt;
2590
2484
  function gt (a, b, loose) {
2591
2485
  return compare(a, b, loose) > 0
2592
2486
  }
2593
2487
 
2594
- exports.lt = lt;
2488
+ exports$1.lt = lt;
2595
2489
  function lt (a, b, loose) {
2596
2490
  return compare(a, b, loose) < 0
2597
2491
  }
2598
2492
 
2599
- exports.eq = eq;
2493
+ exports$1.eq = eq;
2600
2494
  function eq (a, b, loose) {
2601
2495
  return compare(a, b, loose) === 0
2602
2496
  }
2603
2497
 
2604
- exports.neq = neq;
2498
+ exports$1.neq = neq;
2605
2499
  function neq (a, b, loose) {
2606
2500
  return compare(a, b, loose) !== 0
2607
2501
  }
2608
2502
 
2609
- exports.gte = gte;
2503
+ exports$1.gte = gte;
2610
2504
  function gte (a, b, loose) {
2611
2505
  return compare(a, b, loose) >= 0
2612
2506
  }
2613
2507
 
2614
- exports.lte = lte;
2508
+ exports$1.lte = lte;
2615
2509
  function lte (a, b, loose) {
2616
2510
  return compare(a, b, loose) <= 0
2617
2511
  }
2618
2512
 
2619
- exports.cmp = cmp;
2513
+ exports$1.cmp = cmp;
2620
2514
  function cmp (a, op, b, loose) {
2621
2515
  switch (op) {
2622
2516
  case '===':
@@ -2658,7 +2552,7 @@
2658
2552
  }
2659
2553
  }
2660
2554
 
2661
- exports.Comparator = Comparator;
2555
+ exports$1.Comparator = Comparator;
2662
2556
  function Comparator (comp, options) {
2663
2557
  if (!options || typeof options !== 'object') {
2664
2558
  options = {
@@ -2790,7 +2684,7 @@
2790
2684
  oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
2791
2685
  };
2792
2686
 
2793
- exports.Range = Range;
2687
+ exports$1.Range = Range;
2794
2688
  function Range (range, options) {
2795
2689
  if (!options || typeof options !== 'object') {
2796
2690
  options = {
@@ -2934,7 +2828,7 @@
2934
2828
  }
2935
2829
 
2936
2830
  // Mostly just for testing and legacy API reasons
2937
- exports.toComparators = toComparators;
2831
+ exports$1.toComparators = toComparators;
2938
2832
  function toComparators (range, options) {
2939
2833
  return new Range(range, options).set.map(function (comp) {
2940
2834
  return comp.map(function (c) {
@@ -3245,7 +3139,7 @@
3245
3139
  return true
3246
3140
  }
3247
3141
 
3248
- exports.satisfies = satisfies;
3142
+ exports$1.satisfies = satisfies;
3249
3143
  function satisfies (version, range, options) {
3250
3144
  try {
3251
3145
  range = new Range(range, options);
@@ -3255,7 +3149,7 @@
3255
3149
  return range.test(version)
3256
3150
  }
3257
3151
 
3258
- exports.maxSatisfying = maxSatisfying;
3152
+ exports$1.maxSatisfying = maxSatisfying;
3259
3153
  function maxSatisfying (versions, range, options) {
3260
3154
  var max = null;
3261
3155
  var maxSV = null;
@@ -3277,7 +3171,7 @@
3277
3171
  return max
3278
3172
  }
3279
3173
 
3280
- exports.minSatisfying = minSatisfying;
3174
+ exports$1.minSatisfying = minSatisfying;
3281
3175
  function minSatisfying (versions, range, options) {
3282
3176
  var min = null;
3283
3177
  var minSV = null;
@@ -3299,7 +3193,7 @@
3299
3193
  return min
3300
3194
  }
3301
3195
 
3302
- exports.minVersion = minVersion;
3196
+ exports$1.minVersion = minVersion;
3303
3197
  function minVersion (range, loose) {
3304
3198
  range = new Range(range, loose);
3305
3199
 
@@ -3353,7 +3247,7 @@
3353
3247
  return null
3354
3248
  }
3355
3249
 
3356
- exports.validRange = validRange;
3250
+ exports$1.validRange = validRange;
3357
3251
  function validRange (range, options) {
3358
3252
  try {
3359
3253
  // Return '*' instead of '' so that truthiness works.
@@ -3365,18 +3259,18 @@
3365
3259
  }
3366
3260
 
3367
3261
  // Determine if version is less than all the versions possible in the range
3368
- exports.ltr = ltr;
3262
+ exports$1.ltr = ltr;
3369
3263
  function ltr (version, range, options) {
3370
3264
  return outside(version, range, '<', options)
3371
3265
  }
3372
3266
 
3373
3267
  // Determine if version is greater than all the versions possible in the range.
3374
- exports.gtr = gtr;
3268
+ exports$1.gtr = gtr;
3375
3269
  function gtr (version, range, options) {
3376
3270
  return outside(version, range, '>', options)
3377
3271
  }
3378
3272
 
3379
- exports.outside = outside;
3273
+ exports$1.outside = outside;
3380
3274
  function outside (version, range, hilo, options) {
3381
3275
  version = new SemVer(version, options);
3382
3276
  range = new Range(range, options);
@@ -3446,20 +3340,20 @@
3446
3340
  return true
3447
3341
  }
3448
3342
 
3449
- exports.prerelease = prerelease;
3343
+ exports$1.prerelease = prerelease;
3450
3344
  function prerelease (version, options) {
3451
3345
  var parsed = parse(version, options);
3452
3346
  return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
3453
3347
  }
3454
3348
 
3455
- exports.intersects = intersects;
3349
+ exports$1.intersects = intersects;
3456
3350
  function intersects (r1, r2, options) {
3457
3351
  r1 = new Range(r1, options);
3458
3352
  r2 = new Range(r2, options);
3459
3353
  return r1.intersects(r2)
3460
3354
  }
3461
3355
 
3462
- exports.coerce = coerce;
3356
+ exports$1.coerce = coerce;
3463
3357
  function coerce (version, options) {
3464
3358
  if (version instanceof SemVer) {
3465
3359
  return version
@@ -3822,7 +3716,7 @@
3822
3716
  var isOptions = m.body.indexOf(',') >= 0;
3823
3717
  if (!isSequence && !isOptions) {
3824
3718
  // {a},b}
3825
- if (m.post.match(/,.*\}/)) {
3719
+ if (m.post.match(/,(?!,).*\}/)) {
3826
3720
  str = m.pre + '{' + m.body + escClose + m.post;
3827
3721
  return expand$1(str);
3828
3722
  }
@@ -4066,7 +3960,9 @@
4066
3960
 
4067
3961
  // replace stuff like \* with *
4068
3962
  const globUnescape = s => s.replace(/\\(.)/g, '$1');
3963
+ const charUnescape = s => s.replace(/\\([^-\]])/g, '$1');
4069
3964
  const regExpEscape = s => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
3965
+ const braExpEscape = s => s.replace(/[[\]\\]/g, '\\$&');
4070
3966
 
4071
3967
  class Minimatch {
4072
3968
  constructor (pattern, options) {
@@ -4075,6 +3971,8 @@
4075
3971
  if (!options) options = {};
4076
3972
 
4077
3973
  this.options = options;
3974
+ this.maxGlobstarRecursion = options.maxGlobstarRecursion !== undefined
3975
+ ? options.maxGlobstarRecursion : 200;
4078
3976
  this.set = [];
4079
3977
  this.pattern = pattern;
4080
3978
  this.windowsPathsNoEscape = !!options.windowsPathsNoEscape ||
@@ -4152,7 +4050,7 @@
4152
4050
  negateOffset++;
4153
4051
  }
4154
4052
 
4155
- if (negateOffset) this.pattern = pattern.substr(negateOffset);
4053
+ if (negateOffset) this.pattern = pattern.slice(negateOffset);
4156
4054
  this.negate = negate;
4157
4055
  }
4158
4056
 
@@ -4162,114 +4060,172 @@
4162
4060
  // out of pattern, then that's fine, as long as all
4163
4061
  // the parts match.
4164
4062
  matchOne (file, pattern, partial) {
4165
- var options = this.options;
4063
+ if (pattern.indexOf(GLOBSTAR) !== -1) {
4064
+ return this._matchGlobstar(file, pattern, partial, 0, 0)
4065
+ }
4066
+ return this._matchOne(file, pattern, partial, 0, 0)
4067
+ }
4166
4068
 
4167
- this.debug('matchOne',
4168
- { 'this': this, file: file, pattern: pattern });
4069
+ _matchGlobstar (file, pattern, partial, fileIndex, patternIndex) {
4070
+ // find first globstar from patternIndex
4071
+ let firstgs = -1;
4072
+ for (let i = patternIndex; i < pattern.length; i++) {
4073
+ if (pattern[i] === GLOBSTAR) { firstgs = i; break }
4074
+ }
4169
4075
 
4170
- this.debug('matchOne', file.length, pattern.length);
4076
+ // find last globstar
4077
+ let lastgs = -1;
4078
+ for (let i = pattern.length - 1; i >= 0; i--) {
4079
+ if (pattern[i] === GLOBSTAR) { lastgs = i; break }
4080
+ }
4171
4081
 
4172
- for (var fi = 0,
4173
- pi = 0,
4174
- fl = file.length,
4175
- pl = pattern.length
4176
- ; (fi < fl) && (pi < pl)
4177
- ; fi++, pi++) {
4178
- this.debug('matchOne loop');
4179
- var p = pattern[pi];
4180
- var f = file[fi];
4082
+ const head = pattern.slice(patternIndex, firstgs);
4083
+ const body = partial ? pattern.slice(firstgs + 1) : pattern.slice(firstgs + 1, lastgs);
4084
+ const tail = partial ? [] : pattern.slice(lastgs + 1);
4181
4085
 
4182
- this.debug(pattern, p, f);
4086
+ // check the head
4087
+ if (head.length) {
4088
+ const fileHead = file.slice(fileIndex, fileIndex + head.length);
4089
+ if (!this._matchOne(fileHead, head, partial, 0, 0)) {
4090
+ return false
4091
+ }
4092
+ fileIndex += head.length;
4093
+ }
4183
4094
 
4184
- // should be impossible.
4185
- // some invalid regexp stuff in the set.
4186
- /* istanbul ignore if */
4187
- if (p === false) return false
4188
-
4189
- if (p === GLOBSTAR) {
4190
- this.debug('GLOBSTAR', [pattern, p, f]);
4191
-
4192
- // "**"
4193
- // a/**/b/**/c would match the following:
4194
- // a/b/x/y/z/c
4195
- // a/x/y/z/b/c
4196
- // a/b/x/b/x/c
4197
- // a/b/c
4198
- // To do this, take the rest of the pattern after
4199
- // the **, and see if it would match the file remainder.
4200
- // If so, return success.
4201
- // If not, the ** "swallows" a segment, and try again.
4202
- // This is recursively awful.
4203
- //
4204
- // a/**/b/**/c matching a/b/x/y/z/c
4205
- // - a matches a
4206
- // - doublestar
4207
- // - matchOne(b/x/y/z/c, b/**/c)
4208
- // - b matches b
4209
- // - doublestar
4210
- // - matchOne(x/y/z/c, c) -> no
4211
- // - matchOne(y/z/c, c) -> no
4212
- // - matchOne(z/c, c) -> no
4213
- // - matchOne(c, c) yes, hit
4214
- var fr = fi;
4215
- var pr = pi + 1;
4216
- if (pr === pl) {
4217
- this.debug('** at the end');
4218
- // a ** at the end will just swallow the rest.
4219
- // We have found a match.
4220
- // however, it will not swallow /.x, unless
4221
- // options.dot is set.
4222
- // . and .. are *never* matched by **, for explosively
4223
- // exponential reasons.
4224
- for (; fi < fl; fi++) {
4225
- if (file[fi] === '.' || file[fi] === '..' ||
4226
- (!options.dot && file[fi].charAt(0) === '.')) return false
4227
- }
4228
- return true
4095
+ // check the tail
4096
+ let fileTailMatch = 0;
4097
+ if (tail.length) {
4098
+ if (tail.length + fileIndex > file.length) return false
4099
+
4100
+ const tailStart = file.length - tail.length;
4101
+ if (this._matchOne(file, tail, partial, tailStart, 0)) {
4102
+ fileTailMatch = tail.length;
4103
+ } else {
4104
+ // affordance for stuff like a/**/* matching a/b/
4105
+ if (file[file.length - 1] !== '' ||
4106
+ fileIndex + tail.length === file.length) {
4107
+ return false
4229
4108
  }
4109
+ if (!this._matchOne(file, tail, partial, tailStart - 1, 0)) {
4110
+ return false
4111
+ }
4112
+ fileTailMatch = tail.length + 1;
4113
+ }
4114
+ }
4230
4115
 
4231
- // ok, let's see if we can swallow whatever we can.
4232
- while (fr < fl) {
4233
- var swallowee = file[fr];
4116
+ // if body is empty (single ** between head and tail)
4117
+ if (!body.length) {
4118
+ let sawSome = !!fileTailMatch;
4119
+ for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
4120
+ const f = String(file[i]);
4121
+ sawSome = true;
4122
+ if (f === '.' || f === '..' ||
4123
+ (!this.options.dot && f.charAt(0) === '.')) {
4124
+ return false
4125
+ }
4126
+ }
4127
+ return partial || sawSome
4128
+ }
4129
+
4130
+ // split body into segments at each GLOBSTAR
4131
+ const bodySegments = [[[], 0]];
4132
+ let currentBody = bodySegments[0];
4133
+ let nonGsParts = 0;
4134
+ const nonGsPartsSums = [0];
4135
+ for (const b of body) {
4136
+ if (b === GLOBSTAR) {
4137
+ nonGsPartsSums.push(nonGsParts);
4138
+ currentBody = [[], 0];
4139
+ bodySegments.push(currentBody);
4140
+ } else {
4141
+ currentBody[0].push(b);
4142
+ nonGsParts++;
4143
+ }
4144
+ }
4234
4145
 
4235
- this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
4146
+ let idx = bodySegments.length - 1;
4147
+ const fileLength = file.length - fileTailMatch;
4148
+ for (const b of bodySegments) {
4149
+ b[1] = fileLength - (nonGsPartsSums[idx--] + b[0].length);
4150
+ }
4236
4151
 
4237
- // XXX remove this slice. Just pass the start index.
4238
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
4239
- this.debug('globstar found match!', fr, fl, swallowee);
4240
- // found a match.
4241
- return true
4242
- } else {
4243
- // can't swallow "." or ".." ever.
4244
- // can only swallow ".foo" when explicitly asked.
4245
- if (swallowee === '.' || swallowee === '..' ||
4246
- (!options.dot && swallowee.charAt(0) === '.')) {
4247
- this.debug('dot detected!', file, fr, pattern, pr);
4248
- break
4249
- }
4152
+ return !!this._matchGlobStarBodySections(
4153
+ file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch
4154
+ )
4155
+ }
4250
4156
 
4251
- // ** swallows a segment, and continue.
4252
- this.debug('globstar swallow a segment, and continue');
4253
- fr++;
4254
- }
4157
+ // return false for "nope, not matching"
4158
+ // return null for "not matching, cannot keep trying"
4159
+ _matchGlobStarBodySections (
4160
+ file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail
4161
+ ) {
4162
+ const bs = bodySegments[bodyIndex];
4163
+ if (!bs) {
4164
+ // just make sure there are no bad dots
4165
+ for (let i = fileIndex; i < file.length; i++) {
4166
+ sawTail = true;
4167
+ const f = file[i];
4168
+ if (f === '.' || f === '..' ||
4169
+ (!this.options.dot && f.charAt(0) === '.')) {
4170
+ return false
4255
4171
  }
4256
-
4257
- // no match was found.
4258
- // However, in partial mode, we can't say this is necessarily over.
4259
- // If there's more *pattern* left, then
4260
- /* istanbul ignore if */
4261
- if (partial) {
4262
- // ran out of file
4263
- this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
4264
- if (fr === fl) return true
4172
+ }
4173
+ return sawTail
4174
+ }
4175
+
4176
+ const [body, after] = bs;
4177
+ while (fileIndex <= after) {
4178
+ const m = this._matchOne(
4179
+ file.slice(0, fileIndex + body.length),
4180
+ body,
4181
+ partial,
4182
+ fileIndex,
4183
+ 0
4184
+ );
4185
+ // if limit exceeded, no match. intentional false negative,
4186
+ // acceptable break in correctness for security.
4187
+ if (m && globStarDepth < this.maxGlobstarRecursion) {
4188
+ const sub = this._matchGlobStarBodySections(
4189
+ file, bodySegments,
4190
+ fileIndex + body.length, bodyIndex + 1,
4191
+ partial, globStarDepth + 1, sawTail
4192
+ );
4193
+ if (sub !== false) {
4194
+ return sub
4265
4195
  }
4196
+ }
4197
+ const f = file[fileIndex];
4198
+ if (f === '.' || f === '..' ||
4199
+ (!this.options.dot && f.charAt(0) === '.')) {
4266
4200
  return false
4267
4201
  }
4202
+ fileIndex++;
4203
+ }
4204
+ return partial || null
4205
+ }
4206
+
4207
+ _matchOne (file, pattern, partial, fileIndex, patternIndex) {
4208
+ let fi, pi, fl, pl;
4209
+ for (
4210
+ fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length
4211
+ ; (fi < fl) && (pi < pl)
4212
+ ; fi++, pi++
4213
+ ) {
4214
+ this.debug('matchOne loop');
4215
+ const p = pattern[pi];
4216
+ const f = file[fi];
4217
+
4218
+ this.debug(pattern, p, f);
4219
+
4220
+ // should be impossible.
4221
+ // some invalid regexp stuff in the set.
4222
+ /* istanbul ignore if */
4223
+ if (p === false || p === GLOBSTAR) return false
4268
4224
 
4269
4225
  // something other than **
4270
4226
  // non-magic patterns just have to match exactly
4271
4227
  // patterns with magic have been turned into regexps.
4272
- var hit;
4228
+ let hit;
4273
4229
  if (typeof p === 'string') {
4274
4230
  hit = f === p;
4275
4231
  this.debug('string match', p, f, hit);
@@ -4281,17 +4237,6 @@
4281
4237
  if (!hit) return false
4282
4238
  }
4283
4239
 
4284
- // Note: ending in / means that we'll get a final ""
4285
- // at the end of the pattern. This can only match a
4286
- // corresponding "" at the end of the file.
4287
- // If the file ends in /, then it can only match a
4288
- // a pattern that ends in /, unless the pattern just
4289
- // doesn't have any more for it. But, a/b/ should *not*
4290
- // match "a/b/*", even though "" matches against the
4291
- // [^/]*? pattern, except in partial mode, where it might
4292
- // simply not be reached yet.
4293
- // However, a/b/ should still satisfy a/*
4294
-
4295
4240
  // now either we fell off the end of the pattern, or we're done.
4296
4241
  if (fi === fl && pi === pl) {
4297
4242
  // ran out of pattern and filename at the same time.
@@ -4334,7 +4279,7 @@
4334
4279
  if (pattern === '') return ''
4335
4280
 
4336
4281
  let re = '';
4337
- let hasMagic = !!options.nocase;
4282
+ let hasMagic = false;
4338
4283
  let escaping = false;
4339
4284
  // ? => one single character
4340
4285
  const patternListStack = [];
@@ -4347,11 +4292,23 @@
4347
4292
  let pl;
4348
4293
  let sp;
4349
4294
  // . and .. never match anything that doesn't start with .,
4350
- // even when options.dot is set.
4351
- const patternStart = pattern.charAt(0) === '.' ? '' // anything
4352
- // not (start or / followed by . or .. followed by / or end)
4353
- : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
4354
- : '(?!\\.)';
4295
+ // even when options.dot is set. However, if the pattern
4296
+ // starts with ., then traversal patterns can match.
4297
+ let dotTravAllowed = pattern.charAt(0) === '.';
4298
+ let dotFileAllowed = options.dot || dotTravAllowed;
4299
+ const patternStart = () =>
4300
+ dotTravAllowed
4301
+ ? ''
4302
+ : dotFileAllowed
4303
+ ? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
4304
+ : '(?!\\.)';
4305
+ const subPatternStart = (p) =>
4306
+ p.charAt(0) === '.'
4307
+ ? ''
4308
+ : options.dot
4309
+ ? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
4310
+ : '(?!\\.)';
4311
+
4355
4312
 
4356
4313
  const clearStateChar = () => {
4357
4314
  if (stateChar) {
@@ -4401,6 +4358,11 @@
4401
4358
  }
4402
4359
 
4403
4360
  case '\\':
4361
+ if (inClass && pattern.charAt(i + 1) === '-') {
4362
+ re += c;
4363
+ continue
4364
+ }
4365
+
4404
4366
  clearStateChar();
4405
4367
  escaping = true;
4406
4368
  continue
@@ -4423,6 +4385,9 @@
4423
4385
  continue
4424
4386
  }
4425
4387
 
4388
+ // coalesce consecutive non-globstar * characters
4389
+ if (c === '*' && stateChar === '*') continue
4390
+
4426
4391
  // if we already have a stateChar, then it means
4427
4392
  // that there was something like ** or +? in there.
4428
4393
  // Handle the stateChar, then proceed with this one.
@@ -4435,7 +4400,7 @@
4435
4400
  if (options.noext) clearStateChar();
4436
4401
  continue
4437
4402
 
4438
- case '(':
4403
+ case '(': {
4439
4404
  if (inClass) {
4440
4405
  re += '(';
4441
4406
  continue
@@ -4446,46 +4411,64 @@
4446
4411
  continue
4447
4412
  }
4448
4413
 
4449
- patternListStack.push({
4414
+ const plEntry = {
4450
4415
  type: stateChar,
4451
4416
  start: i - 1,
4452
4417
  reStart: re.length,
4453
4418
  open: plTypes[stateChar].open,
4454
- close: plTypes[stateChar].close
4455
- });
4456
- // negation is (?:(?!js)[^/]*)
4457
- re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
4419
+ close: plTypes[stateChar].close,
4420
+ };
4421
+ this.debug(this.pattern, '\t', plEntry);
4422
+ patternListStack.push(plEntry);
4423
+ // negation is (?:(?!(?:js)(?:<rest>))[^/]*)
4424
+ re += plEntry.open;
4425
+ // next entry starts with a dot maybe?
4426
+ if (plEntry.start === 0 && plEntry.type !== '!') {
4427
+ dotTravAllowed = true;
4428
+ re += subPatternStart(pattern.slice(i + 1));
4429
+ }
4458
4430
  this.debug('plType %j %j', stateChar, re);
4459
4431
  stateChar = false;
4460
- continue
4432
+ continue
4433
+ }
4461
4434
 
4462
- case ')':
4463
- if (inClass || !patternListStack.length) {
4435
+ case ')': {
4436
+ const plEntry = patternListStack[patternListStack.length - 1];
4437
+ if (inClass || !plEntry) {
4464
4438
  re += '\\)';
4465
4439
  continue
4466
4440
  }
4441
+ patternListStack.pop();
4467
4442
 
4443
+ // closing an extglob
4468
4444
  clearStateChar();
4469
4445
  hasMagic = true;
4470
- pl = patternListStack.pop();
4446
+ pl = plEntry;
4471
4447
  // negation is (?:(?!js)[^/]*)
4472
4448
  // The others are (?:<pattern>)<type>
4473
4449
  re += pl.close;
4474
4450
  if (pl.type === '!') {
4475
- negativeLists.push(pl);
4451
+ negativeLists.push(Object.assign(pl, { reEnd: re.length }));
4476
4452
  }
4477
- pl.reEnd = re.length;
4478
- continue
4453
+ continue
4454
+ }
4479
4455
 
4480
- case '|':
4481
- if (inClass || !patternListStack.length) {
4456
+ case '|': {
4457
+ const plEntry = patternListStack[patternListStack.length - 1];
4458
+ if (inClass || !plEntry) {
4482
4459
  re += '\\|';
4483
4460
  continue
4484
4461
  }
4485
4462
 
4486
4463
  clearStateChar();
4487
4464
  re += '|';
4488
- continue
4465
+ // next subpattern can start with a dot?
4466
+ if (plEntry.start === 0 && plEntry.type !== '!') {
4467
+ dotTravAllowed = true;
4468
+ re += subPatternStart(pattern.slice(i + 1));
4469
+ }
4470
+ continue
4471
+ }
4489
4472
 
4490
4473
  // these are mostly the same in regexp and glob
4491
4474
  case '[':
@@ -4513,8 +4496,6 @@
4513
4496
  continue
4514
4497
  }
4515
4498
 
4516
- // handle the case where we left a class open.
4517
- // "[z-a]" is valid, equivalent to "\[z-a\]"
4518
4499
  // split where the last [ was, make sure we don't have
4519
4500
  // an invalid re. if so, re-walk the contents of the
4520
4501
  // would-be class to re-translate any characters that
@@ -4524,20 +4505,16 @@
4524
4505
  // to do safely. For now, this is safe and works.
4525
4506
  cs = pattern.substring(classStart + 1, i);
4526
4507
  try {
4527
- RegExp('[' + cs + ']');
4508
+ RegExp('[' + braExpEscape(charUnescape(cs)) + ']');
4509
+ // looks good, finish up the class.
4510
+ re += c;
4528
4511
  } catch (er) {
4529
- // not a valid class!
4530
- sp = this.parse(cs, SUBPARSE);
4531
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
4532
- hasMagic = hasMagic || sp[1];
4533
- inClass = false;
4534
- continue
4512
+ // out of order ranges in JS are errors, but in glob syntax,
4513
+ // they're just a range that matches nothing.
4514
+ re = re.substring(0, reClassStart) + '(?:$.)'; // match nothing ever
4535
4515
  }
4536
-
4537
- // finish up the class.
4538
4516
  hasMagic = true;
4539
4517
  inClass = false;
4540
- re += c;
4541
4518
  continue
4542
4519
 
4543
4520
  default:
@@ -4561,9 +4538,9 @@
4561
4538
  // this is a huge pita. We now have to re-walk
4562
4539
  // the contents of the would-be class to re-translate
4563
4540
  // any characters that were passed through as-is
4564
- cs = pattern.substr(classStart + 1);
4541
+ cs = pattern.slice(classStart + 1);
4565
4542
  sp = this.parse(cs, SUBPARSE);
4566
- re = re.substr(0, reClassStart) + '\\[' + sp[0];
4543
+ re = re.substring(0, reClassStart) + '\\[' + sp[0];
4567
4544
  hasMagic = hasMagic || sp[1];
4568
4545
  }
4569
4546
 
@@ -4630,14 +4607,16 @@
4630
4607
  // Handle nested stuff like *(*.js|!(*.json)), where open parens
4631
4608
  // mean that we should *not* include the ) in the bit that is considered
4632
4609
  // "after" the negated section.
4633
- const openParensBefore = nlBefore.split('(').length - 1;
4610
+ const closeParensBefore = nlBefore.split(')').length;
4611
+ const openParensBefore = nlBefore.split('(').length - closeParensBefore;
4634
4612
  let cleanAfter = nlAfter;
4635
4613
  for (let i = 0; i < openParensBefore; i++) {
4636
4614
  cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
4637
4615
  }
4638
4616
  nlAfter = cleanAfter;
4639
4617
 
4640
- const dollar = nlAfter === '' && isSub !== SUBPARSE ? '$' : '';
4618
+ const dollar = nlAfter === '' && isSub !== SUBPARSE ? '(?:$|\\/)' : '';
4619
+
4641
4620
  re = nlBefore + nlFirst + nlAfter + dollar + nlLast;
4642
4621
  }
4643
4622
 
@@ -4649,7 +4628,7 @@
4649
4628
  }
4650
4629
 
4651
4630
  if (addPatternStart) {
4652
- re = patternStart + re;
4631
+ re = patternStart() + re;
4653
4632
  }
4654
4633
 
4655
4634
  // parsing just a piece of a larger pattern.
@@ -4657,6 +4636,11 @@
4657
4636
  return [re, hasMagic]
4658
4637
  }
4659
4638
 
4639
+ // if it's nocase, and the lcase/uppercase don't match, it's magic
4640
+ if (options.nocase && !hasMagic) {
4641
+ hasMagic = pattern.toUpperCase() !== pattern.toLowerCase();
4642
+ }
4643
+
4660
4644
  // skip the regexp for non-magical patterns
4661
4645
  // unescape anything in it, though, so that it'll be
4662
4646
  // an exact match against a file etc.
@@ -7293,7 +7277,6 @@
7293
7277
  };
7294
7278
 
7295
7279
  ({
7296
- type: TYPES.VARIABLE_DECLARATION,
7297
7280
  declarations: [{
7298
7281
  type: TYPES.VARIABLE_DECLARATOR,
7299
7282
  init: {
@@ -7306,11 +7289,8 @@
7306
7289
  }]
7307
7290
  });
7308
7291
  ({
7309
- type: TYPES.EXPRESSION_STATEMENT,
7310
7292
  expression: {
7311
- type: TYPES.CALL_EXPRESSION,
7312
7293
  callee: {
7313
- type: TYPES.IDENTIFIER,
7314
7294
  name: ramda.test(/use[a-zA-z0-9].+/)
7315
7295
  }
7316
7296
  }
@@ -11748,7 +11728,6 @@
11748
11728
  // useCurrentUserStore()
11749
11729
  ({
11750
11730
  callee: {
11751
- type: TYPES.IDENTIFIER,
11752
11731
  name: ramda.test(/use[a-zA-z0-9].+Store/)
11753
11732
  }
11754
11733
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/eslint-plugin-neeto",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "main": "dist/index.js",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {