@bigbinary/eslint-plugin-neeto 1.5.0 → 1.5.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 (3) hide show
  1. package/README.md +3 -1
  2. package/dist/index.js +1915 -28
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@
42
42
  var commonResolve$2 = loadJS$2("node_modules/@bigbinary/neeto-commons-frontend/configs/webpack/resolve.js");
43
43
  var resolve$2 = ramda.mergeDeepLeft(projectResolve$2, commonResolve$2);
44
44
  var rules = {
45
+ "@bigbinary/neeto/use-neetoui-action-block-in-formik-forms": "warn",
45
46
  "@bigbinary/neeto/no-unnecessary-classnames": "error",
46
47
  "@bigbinary/neeto/no-snake-case-destructuring-for-use-query-params-and-get-query-params": "warn",
47
48
  "@bigbinary/neeto/no-local-storage": "error",
@@ -135,7 +136,7 @@
135
136
  "@bigbinary/neeto/use-create-subscription-util-function": "error",
136
137
  "@bigbinary/neeto/use-i18next-plurals": "error",
137
138
  "@bigbinary/neeto/use-inline-svg-for-render": "error",
138
- "@bigbinary/neeto/use-neeto-in-strings": "warn",
139
+ "@bigbinary/neeto/use-title-case-neeto-in-strings": "warn",
139
140
  "@bigbinary/neeto/use-neetoui-classes": "warn",
140
141
  "@bigbinary/neeto/use-permissions-prop-in-private-route": "warn",
141
142
  "@bigbinary/neeto/use-pluralize-package": "error",
@@ -166,7 +167,8 @@
166
167
  "@bigbinary/neeto/prefer-function-reference": "warn",
167
168
  "@bigbinary/neeto/jsx-prefer-guard-clause": "warn",
168
169
  "@bigbinary/neeto/ensure-usestate-has-initial-value": "error",
169
- "@bigbinary/neeto/use-show-thumbs-up-toastr": "error"
170
+ "@bigbinary/neeto/use-show-thumbs-up-toastr": "error",
171
+ "@bigbinary/neeto/ensure-peer-dependencies-are-in-sync": "warn"
170
172
  };
171
173
 
172
174
  var recommended = {
@@ -507,6 +509,9 @@
507
509
  var maxAllowedNoOfLines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;
508
510
  return "Avoid inline functions that exceed ".concat(maxAllowedNoOfLines, " lines directly inside JSX. Extract the function outside of JSX.");
509
511
  };
512
+ var reportVersionMismatch = function reportVersionMismatch(packageName, depType, peerVersion, correctVersion) {
513
+ return "Version mismatch for '".concat(packageName, "': peerDependencies (").concat(peerVersion, ") should be in sync with ").concat(depType, " (").concat(correctVersion, ")");
514
+ };
510
515
  var suggestCommonConstants = function suggestCommonConstants(constantName, repository) {
511
516
  return "Use \"".concat(constantName, "\" from \"@bigbinary/").concat(repository, "\"");
512
517
  };
@@ -544,7 +549,7 @@
544
549
  var USE_ANCHOR_FOR_NAVIGATION = "Use Anchor element (<a>) for click-navigation instead of onClick handler";
545
550
  var USE_BUTTON_TO_FOR_LINK_NAVIGATION = "Use `to` prop of Button (<Button to='path'>) for click-navigation instead of onClick handler";
546
551
  var USE_BUTTON_TO_FOR_ANCHOR_NAVIGATION = "Use `href` prop of Button (<Button href='path'>) for click-navigation instead of onClick handler";
547
- var USE_NEETO_SMALLER_CASE = "Use 'neeto' instead of 'Neeto' in strings";
552
+ var USE_TITLE_CASE_NEETO = "Use 'Neeto' instead of 'neeto' in strings";
548
553
  var USE_NEETOUI_BORDER_COLOR = "Use neetoUI border color. Refer https://bit.ly/neeto-ui-border-colors for more details.";
549
554
  var USE_NEETOUI_BORDER_RADIUS = "Use neetoUI border radius. Refer https://bit.ly/neeto-ui-border-radius for more details.";
550
555
  var USE_NEETOUI_BOX_SHADOW = "Use neetoUI border shadow. Refer https://bit.ly/neeto-ui-box-shadows for more details.";
@@ -588,6 +593,7 @@
588
593
  var USE_SHOW_THUMBS_UP_TOASTR_FUNCTION = "Use 'showThumbsUpToastr' function from '@bigbinary/neeto-commons-frontend/utils' for displaying thumbs up toast message.";
589
594
  var NO_UNNECESSARY_CLASSNAMES = "classnames usage is unnecessary";
590
595
  var USESTATE_DECLARATIONS_SHOULD_HAVE_INITIAL_VALUE = '"useState" declarations should have an initial value.';
596
+ var USE_NEETOUI_ACTION_BLOCK_IN_FORMIK_FORMS = 'Prefer using neetoui "ActionBlock" instead of "Button" for consistent behavior and appearance.';
591
597
 
592
598
  var PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
593
599
 
@@ -2360,6 +2366,1761 @@
2360
2366
  }
2361
2367
  };
2362
2368
 
2369
+ var DEPENDENCY_TYPE = {
2370
+ dependencies: "dependencies",
2371
+ peerDependencies: "peerDependencies",
2372
+ devDependencies: "devDependencies"
2373
+ };
2374
+
2375
+ var semver$1 = {exports: {}};
2376
+
2377
+ (function (module, exports) {
2378
+ exports = module.exports = SemVer;
2379
+
2380
+ var debug;
2381
+ /* istanbul ignore next */
2382
+ if (typeof process === 'object' &&
2383
+ process.env &&
2384
+ process.env.NODE_DEBUG &&
2385
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
2386
+ debug = function () {
2387
+ var args = Array.prototype.slice.call(arguments, 0);
2388
+ args.unshift('SEMVER');
2389
+ console.log.apply(console, args);
2390
+ };
2391
+ } else {
2392
+ debug = function () {};
2393
+ }
2394
+
2395
+ // Note: this is the semver.org version of the spec that it implements
2396
+ // Not necessarily the package version of this code.
2397
+ exports.SEMVER_SPEC_VERSION = '2.0.0';
2398
+
2399
+ var MAX_LENGTH = 256;
2400
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
2401
+ /* istanbul ignore next */ 9007199254740991;
2402
+
2403
+ // Max safe segment length for coercion.
2404
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
2405
+
2406
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
2407
+
2408
+ // The actual regexps go on exports.re
2409
+ var re = exports.re = [];
2410
+ var safeRe = exports.safeRe = [];
2411
+ var src = exports.src = [];
2412
+ var t = exports.tokens = {};
2413
+ var R = 0;
2414
+
2415
+ function tok (n) {
2416
+ t[n] = R++;
2417
+ }
2418
+
2419
+ var LETTERDASHNUMBER = '[a-zA-Z0-9-]';
2420
+
2421
+ // Replace some greedy regex tokens to prevent regex dos issues. These regex are
2422
+ // used internally via the safeRe object since all inputs in this library get
2423
+ // normalized first to trim and collapse all extra whitespace. The original
2424
+ // regexes are exported for userland consumption and lower level usage. A
2425
+ // future breaking change could export the safer regex only with a note that
2426
+ // all input should have extra whitespace removed.
2427
+ var safeRegexReplacements = [
2428
+ ['\\s', 1],
2429
+ ['\\d', MAX_LENGTH],
2430
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
2431
+ ];
2432
+
2433
+ function makeSafeRe (value) {
2434
+ for (var i = 0; i < safeRegexReplacements.length; i++) {
2435
+ var token = safeRegexReplacements[i][0];
2436
+ var max = safeRegexReplacements[i][1];
2437
+ value = value
2438
+ .split(token + '*').join(token + '{0,' + max + '}')
2439
+ .split(token + '+').join(token + '{1,' + max + '}');
2440
+ }
2441
+ return value
2442
+ }
2443
+
2444
+ // The following Regular Expressions can be used for tokenizing,
2445
+ // validating, and parsing SemVer version strings.
2446
+
2447
+ // ## Numeric Identifier
2448
+ // A single `0`, or a non-zero digit followed by zero or more digits.
2449
+
2450
+ tok('NUMERICIDENTIFIER');
2451
+ src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
2452
+ tok('NUMERICIDENTIFIERLOOSE');
2453
+ src[t.NUMERICIDENTIFIERLOOSE] = '\\d+';
2454
+
2455
+ // ## Non-numeric Identifier
2456
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
2457
+ // more letters, digits, or hyphens.
2458
+
2459
+ tok('NONNUMERICIDENTIFIER');
2460
+ src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-]' + LETTERDASHNUMBER + '*';
2461
+
2462
+ // ## Main Version
2463
+ // Three dot-separated numeric identifiers.
2464
+
2465
+ tok('MAINVERSION');
2466
+ src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
2467
+ '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
2468
+ '(' + src[t.NUMERICIDENTIFIER] + ')';
2469
+
2470
+ tok('MAINVERSIONLOOSE');
2471
+ src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
2472
+ '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
2473
+ '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
2474
+
2475
+ // ## Pre-release Version Identifier
2476
+ // A numeric identifier, or a non-numeric identifier.
2477
+
2478
+ tok('PRERELEASEIDENTIFIER');
2479
+ src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
2480
+ '|' + src[t.NONNUMERICIDENTIFIER] + ')';
2481
+
2482
+ tok('PRERELEASEIDENTIFIERLOOSE');
2483
+ src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
2484
+ '|' + src[t.NONNUMERICIDENTIFIER] + ')';
2485
+
2486
+ // ## Pre-release Version
2487
+ // Hyphen, followed by one or more dot-separated pre-release version
2488
+ // identifiers.
2489
+
2490
+ tok('PRERELEASE');
2491
+ src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
2492
+ '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
2493
+
2494
+ tok('PRERELEASELOOSE');
2495
+ src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
2496
+ '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
2497
+
2498
+ // ## Build Metadata Identifier
2499
+ // Any combination of digits, letters, or hyphens.
2500
+
2501
+ tok('BUILDIDENTIFIER');
2502
+ src[t.BUILDIDENTIFIER] = LETTERDASHNUMBER + '+';
2503
+
2504
+ // ## Build Metadata
2505
+ // Plus sign, followed by one or more period-separated build metadata
2506
+ // identifiers.
2507
+
2508
+ tok('BUILD');
2509
+ src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
2510
+ '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
2511
+
2512
+ // ## Full Version String
2513
+ // A main version, followed optionally by a pre-release version and
2514
+ // build metadata.
2515
+
2516
+ // Note that the only major, minor, patch, and pre-release sections of
2517
+ // the version string are capturing groups. The build metadata is not a
2518
+ // capturing group, because it should not ever be used in version
2519
+ // comparison.
2520
+
2521
+ tok('FULL');
2522
+ tok('FULLPLAIN');
2523
+ src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
2524
+ src[t.PRERELEASE] + '?' +
2525
+ src[t.BUILD] + '?';
2526
+
2527
+ src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
2528
+
2529
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
2530
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
2531
+ // common in the npm registry.
2532
+ tok('LOOSEPLAIN');
2533
+ src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
2534
+ src[t.PRERELEASELOOSE] + '?' +
2535
+ src[t.BUILD] + '?';
2536
+
2537
+ tok('LOOSE');
2538
+ src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
2539
+
2540
+ tok('GTLT');
2541
+ src[t.GTLT] = '((?:<|>)?=?)';
2542
+
2543
+ // Something like "2.*" or "1.2.x".
2544
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
2545
+ // Only the first item is strictly required.
2546
+ tok('XRANGEIDENTIFIERLOOSE');
2547
+ src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
2548
+ tok('XRANGEIDENTIFIER');
2549
+ src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
2550
+
2551
+ tok('XRANGEPLAIN');
2552
+ src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
2553
+ '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
2554
+ '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
2555
+ '(?:' + src[t.PRERELEASE] + ')?' +
2556
+ src[t.BUILD] + '?' +
2557
+ ')?)?';
2558
+
2559
+ tok('XRANGEPLAINLOOSE');
2560
+ src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
2561
+ '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
2562
+ '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
2563
+ '(?:' + src[t.PRERELEASELOOSE] + ')?' +
2564
+ src[t.BUILD] + '?' +
2565
+ ')?)?';
2566
+
2567
+ tok('XRANGE');
2568
+ src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
2569
+ tok('XRANGELOOSE');
2570
+ src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
2571
+
2572
+ // Coercion.
2573
+ // Extract anything that could conceivably be a part of a valid semver
2574
+ tok('COERCE');
2575
+ src[t.COERCE] = '(^|[^\\d])' +
2576
+ '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
2577
+ '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
2578
+ '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
2579
+ '(?:$|[^\\d])';
2580
+ tok('COERCERTL');
2581
+ re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
2582
+ safeRe[t.COERCERTL] = new RegExp(makeSafeRe(src[t.COERCE]), 'g');
2583
+
2584
+ // Tilde ranges.
2585
+ // Meaning is "reasonably at or greater than"
2586
+ tok('LONETILDE');
2587
+ src[t.LONETILDE] = '(?:~>?)';
2588
+
2589
+ tok('TILDETRIM');
2590
+ src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
2591
+ re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
2592
+ safeRe[t.TILDETRIM] = new RegExp(makeSafeRe(src[t.TILDETRIM]), 'g');
2593
+ var tildeTrimReplace = '$1~';
2594
+
2595
+ tok('TILDE');
2596
+ src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
2597
+ tok('TILDELOOSE');
2598
+ src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
2599
+
2600
+ // Caret ranges.
2601
+ // Meaning is "at least and backwards compatible with"
2602
+ tok('LONECARET');
2603
+ src[t.LONECARET] = '(?:\\^)';
2604
+
2605
+ tok('CARETTRIM');
2606
+ src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
2607
+ re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
2608
+ safeRe[t.CARETTRIM] = new RegExp(makeSafeRe(src[t.CARETTRIM]), 'g');
2609
+ var caretTrimReplace = '$1^';
2610
+
2611
+ tok('CARET');
2612
+ src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
2613
+ tok('CARETLOOSE');
2614
+ src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
2615
+
2616
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
2617
+ tok('COMPARATORLOOSE');
2618
+ src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
2619
+ tok('COMPARATOR');
2620
+ src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
2621
+
2622
+ // An expression to strip any whitespace between the gtlt and the thing
2623
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
2624
+ tok('COMPARATORTRIM');
2625
+ src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
2626
+ '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
2627
+
2628
+ // this one has to use the /g flag
2629
+ re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
2630
+ safeRe[t.COMPARATORTRIM] = new RegExp(makeSafeRe(src[t.COMPARATORTRIM]), 'g');
2631
+ var comparatorTrimReplace = '$1$2$3';
2632
+
2633
+ // Something like `1.2.3 - 1.2.4`
2634
+ // Note that these all use the loose form, because they'll be
2635
+ // checked against either the strict or loose comparator form
2636
+ // later.
2637
+ tok('HYPHENRANGE');
2638
+ src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
2639
+ '\\s+-\\s+' +
2640
+ '(' + src[t.XRANGEPLAIN] + ')' +
2641
+ '\\s*$';
2642
+
2643
+ tok('HYPHENRANGELOOSE');
2644
+ src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
2645
+ '\\s+-\\s+' +
2646
+ '(' + src[t.XRANGEPLAINLOOSE] + ')' +
2647
+ '\\s*$';
2648
+
2649
+ // Star ranges basically just allow anything at all.
2650
+ tok('STAR');
2651
+ src[t.STAR] = '(<|>)?=?\\s*\\*';
2652
+
2653
+ // Compile to actual regexp objects.
2654
+ // All are flag-free, unless they were created above with a flag.
2655
+ for (var i = 0; i < R; i++) {
2656
+ debug(i, src[i]);
2657
+ if (!re[i]) {
2658
+ re[i] = new RegExp(src[i]);
2659
+
2660
+ // Replace all greedy whitespace to prevent regex dos issues. These regex are
2661
+ // used internally via the safeRe object since all inputs in this library get
2662
+ // normalized first to trim and collapse all extra whitespace. The original
2663
+ // regexes are exported for userland consumption and lower level usage. A
2664
+ // future breaking change could export the safer regex only with a note that
2665
+ // all input should have extra whitespace removed.
2666
+ safeRe[i] = new RegExp(makeSafeRe(src[i]));
2667
+ }
2668
+ }
2669
+
2670
+ exports.parse = parse;
2671
+ function parse (version, options) {
2672
+ if (!options || typeof options !== 'object') {
2673
+ options = {
2674
+ loose: !!options,
2675
+ includePrerelease: false
2676
+ };
2677
+ }
2678
+
2679
+ if (version instanceof SemVer) {
2680
+ return version
2681
+ }
2682
+
2683
+ if (typeof version !== 'string') {
2684
+ return null
2685
+ }
2686
+
2687
+ if (version.length > MAX_LENGTH) {
2688
+ return null
2689
+ }
2690
+
2691
+ var r = options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL];
2692
+ if (!r.test(version)) {
2693
+ return null
2694
+ }
2695
+
2696
+ try {
2697
+ return new SemVer(version, options)
2698
+ } catch (er) {
2699
+ return null
2700
+ }
2701
+ }
2702
+
2703
+ exports.valid = valid;
2704
+ function valid (version, options) {
2705
+ var v = parse(version, options);
2706
+ return v ? v.version : null
2707
+ }
2708
+
2709
+ exports.clean = clean;
2710
+ function clean (version, options) {
2711
+ var s = parse(version.trim().replace(/^[=v]+/, ''), options);
2712
+ return s ? s.version : null
2713
+ }
2714
+
2715
+ exports.SemVer = SemVer;
2716
+
2717
+ function SemVer (version, options) {
2718
+ if (!options || typeof options !== 'object') {
2719
+ options = {
2720
+ loose: !!options,
2721
+ includePrerelease: false
2722
+ };
2723
+ }
2724
+ if (version instanceof SemVer) {
2725
+ if (version.loose === options.loose) {
2726
+ return version
2727
+ } else {
2728
+ version = version.version;
2729
+ }
2730
+ } else if (typeof version !== 'string') {
2731
+ throw new TypeError('Invalid Version: ' + version)
2732
+ }
2733
+
2734
+ if (version.length > MAX_LENGTH) {
2735
+ throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
2736
+ }
2737
+
2738
+ if (!(this instanceof SemVer)) {
2739
+ return new SemVer(version, options)
2740
+ }
2741
+
2742
+ debug('SemVer', version, options);
2743
+ this.options = options;
2744
+ this.loose = !!options.loose;
2745
+
2746
+ var m = version.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]);
2747
+
2748
+ if (!m) {
2749
+ throw new TypeError('Invalid Version: ' + version)
2750
+ }
2751
+
2752
+ this.raw = version;
2753
+
2754
+ // these are actually numbers
2755
+ this.major = +m[1];
2756
+ this.minor = +m[2];
2757
+ this.patch = +m[3];
2758
+
2759
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
2760
+ throw new TypeError('Invalid major version')
2761
+ }
2762
+
2763
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
2764
+ throw new TypeError('Invalid minor version')
2765
+ }
2766
+
2767
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
2768
+ throw new TypeError('Invalid patch version')
2769
+ }
2770
+
2771
+ // numberify any prerelease numeric ids
2772
+ if (!m[4]) {
2773
+ this.prerelease = [];
2774
+ } else {
2775
+ this.prerelease = m[4].split('.').map(function (id) {
2776
+ if (/^[0-9]+$/.test(id)) {
2777
+ var num = +id;
2778
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
2779
+ return num
2780
+ }
2781
+ }
2782
+ return id
2783
+ });
2784
+ }
2785
+
2786
+ this.build = m[5] ? m[5].split('.') : [];
2787
+ this.format();
2788
+ }
2789
+
2790
+ SemVer.prototype.format = function () {
2791
+ this.version = this.major + '.' + this.minor + '.' + this.patch;
2792
+ if (this.prerelease.length) {
2793
+ this.version += '-' + this.prerelease.join('.');
2794
+ }
2795
+ return this.version
2796
+ };
2797
+
2798
+ SemVer.prototype.toString = function () {
2799
+ return this.version
2800
+ };
2801
+
2802
+ SemVer.prototype.compare = function (other) {
2803
+ debug('SemVer.compare', this.version, this.options, other);
2804
+ if (!(other instanceof SemVer)) {
2805
+ other = new SemVer(other, this.options);
2806
+ }
2807
+
2808
+ return this.compareMain(other) || this.comparePre(other)
2809
+ };
2810
+
2811
+ SemVer.prototype.compareMain = function (other) {
2812
+ if (!(other instanceof SemVer)) {
2813
+ other = new SemVer(other, this.options);
2814
+ }
2815
+
2816
+ return compareIdentifiers(this.major, other.major) ||
2817
+ compareIdentifiers(this.minor, other.minor) ||
2818
+ compareIdentifiers(this.patch, other.patch)
2819
+ };
2820
+
2821
+ SemVer.prototype.comparePre = function (other) {
2822
+ if (!(other instanceof SemVer)) {
2823
+ other = new SemVer(other, this.options);
2824
+ }
2825
+
2826
+ // NOT having a prerelease is > having one
2827
+ if (this.prerelease.length && !other.prerelease.length) {
2828
+ return -1
2829
+ } else if (!this.prerelease.length && other.prerelease.length) {
2830
+ return 1
2831
+ } else if (!this.prerelease.length && !other.prerelease.length) {
2832
+ return 0
2833
+ }
2834
+
2835
+ var i = 0;
2836
+ do {
2837
+ var a = this.prerelease[i];
2838
+ var b = other.prerelease[i];
2839
+ debug('prerelease compare', i, a, b);
2840
+ if (a === undefined && b === undefined) {
2841
+ return 0
2842
+ } else if (b === undefined) {
2843
+ return 1
2844
+ } else if (a === undefined) {
2845
+ return -1
2846
+ } else if (a === b) {
2847
+ continue
2848
+ } else {
2849
+ return compareIdentifiers(a, b)
2850
+ }
2851
+ } while (++i)
2852
+ };
2853
+
2854
+ SemVer.prototype.compareBuild = function (other) {
2855
+ if (!(other instanceof SemVer)) {
2856
+ other = new SemVer(other, this.options);
2857
+ }
2858
+
2859
+ var i = 0;
2860
+ do {
2861
+ var a = this.build[i];
2862
+ var b = other.build[i];
2863
+ debug('prerelease compare', i, a, b);
2864
+ if (a === undefined && b === undefined) {
2865
+ return 0
2866
+ } else if (b === undefined) {
2867
+ return 1
2868
+ } else if (a === undefined) {
2869
+ return -1
2870
+ } else if (a === b) {
2871
+ continue
2872
+ } else {
2873
+ return compareIdentifiers(a, b)
2874
+ }
2875
+ } while (++i)
2876
+ };
2877
+
2878
+ // preminor will bump the version up to the next minor release, and immediately
2879
+ // down to pre-release. premajor and prepatch work the same way.
2880
+ SemVer.prototype.inc = function (release, identifier) {
2881
+ switch (release) {
2882
+ case 'premajor':
2883
+ this.prerelease.length = 0;
2884
+ this.patch = 0;
2885
+ this.minor = 0;
2886
+ this.major++;
2887
+ this.inc('pre', identifier);
2888
+ break
2889
+ case 'preminor':
2890
+ this.prerelease.length = 0;
2891
+ this.patch = 0;
2892
+ this.minor++;
2893
+ this.inc('pre', identifier);
2894
+ break
2895
+ case 'prepatch':
2896
+ // If this is already a prerelease, it will bump to the next version
2897
+ // drop any prereleases that might already exist, since they are not
2898
+ // relevant at this point.
2899
+ this.prerelease.length = 0;
2900
+ this.inc('patch', identifier);
2901
+ this.inc('pre', identifier);
2902
+ break
2903
+ // If the input is a non-prerelease version, this acts the same as
2904
+ // prepatch.
2905
+ case 'prerelease':
2906
+ if (this.prerelease.length === 0) {
2907
+ this.inc('patch', identifier);
2908
+ }
2909
+ this.inc('pre', identifier);
2910
+ break
2911
+
2912
+ case 'major':
2913
+ // If this is a pre-major version, bump up to the same major version.
2914
+ // Otherwise increment major.
2915
+ // 1.0.0-5 bumps to 1.0.0
2916
+ // 1.1.0 bumps to 2.0.0
2917
+ if (this.minor !== 0 ||
2918
+ this.patch !== 0 ||
2919
+ this.prerelease.length === 0) {
2920
+ this.major++;
2921
+ }
2922
+ this.minor = 0;
2923
+ this.patch = 0;
2924
+ this.prerelease = [];
2925
+ break
2926
+ case 'minor':
2927
+ // If this is a pre-minor version, bump up to the same minor version.
2928
+ // Otherwise increment minor.
2929
+ // 1.2.0-5 bumps to 1.2.0
2930
+ // 1.2.1 bumps to 1.3.0
2931
+ if (this.patch !== 0 || this.prerelease.length === 0) {
2932
+ this.minor++;
2933
+ }
2934
+ this.patch = 0;
2935
+ this.prerelease = [];
2936
+ break
2937
+ case 'patch':
2938
+ // If this is not a pre-release version, it will increment the patch.
2939
+ // If it is a pre-release it will bump up to the same patch version.
2940
+ // 1.2.0-5 patches to 1.2.0
2941
+ // 1.2.0 patches to 1.2.1
2942
+ if (this.prerelease.length === 0) {
2943
+ this.patch++;
2944
+ }
2945
+ this.prerelease = [];
2946
+ break
2947
+ // This probably shouldn't be used publicly.
2948
+ // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
2949
+ case 'pre':
2950
+ if (this.prerelease.length === 0) {
2951
+ this.prerelease = [0];
2952
+ } else {
2953
+ var i = this.prerelease.length;
2954
+ while (--i >= 0) {
2955
+ if (typeof this.prerelease[i] === 'number') {
2956
+ this.prerelease[i]++;
2957
+ i = -2;
2958
+ }
2959
+ }
2960
+ if (i === -1) {
2961
+ // didn't increment anything
2962
+ this.prerelease.push(0);
2963
+ }
2964
+ }
2965
+ if (identifier) {
2966
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
2967
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
2968
+ if (this.prerelease[0] === identifier) {
2969
+ if (isNaN(this.prerelease[1])) {
2970
+ this.prerelease = [identifier, 0];
2971
+ }
2972
+ } else {
2973
+ this.prerelease = [identifier, 0];
2974
+ }
2975
+ }
2976
+ break
2977
+
2978
+ default:
2979
+ throw new Error('invalid increment argument: ' + release)
2980
+ }
2981
+ this.format();
2982
+ this.raw = this.version;
2983
+ return this
2984
+ };
2985
+
2986
+ exports.inc = inc;
2987
+ function inc (version, release, loose, identifier) {
2988
+ if (typeof (loose) === 'string') {
2989
+ identifier = loose;
2990
+ loose = undefined;
2991
+ }
2992
+
2993
+ try {
2994
+ return new SemVer(version, loose).inc(release, identifier).version
2995
+ } catch (er) {
2996
+ return null
2997
+ }
2998
+ }
2999
+
3000
+ exports.diff = diff;
3001
+ function diff (version1, version2) {
3002
+ if (eq(version1, version2)) {
3003
+ return null
3004
+ } else {
3005
+ var v1 = parse(version1);
3006
+ var v2 = parse(version2);
3007
+ var prefix = '';
3008
+ if (v1.prerelease.length || v2.prerelease.length) {
3009
+ prefix = 'pre';
3010
+ var defaultResult = 'prerelease';
3011
+ }
3012
+ for (var key in v1) {
3013
+ if (key === 'major' || key === 'minor' || key === 'patch') {
3014
+ if (v1[key] !== v2[key]) {
3015
+ return prefix + key
3016
+ }
3017
+ }
3018
+ }
3019
+ return defaultResult // may be undefined
3020
+ }
3021
+ }
3022
+
3023
+ exports.compareIdentifiers = compareIdentifiers;
3024
+
3025
+ var numeric = /^[0-9]+$/;
3026
+ function compareIdentifiers (a, b) {
3027
+ var anum = numeric.test(a);
3028
+ var bnum = numeric.test(b);
3029
+
3030
+ if (anum && bnum) {
3031
+ a = +a;
3032
+ b = +b;
3033
+ }
3034
+
3035
+ return a === b ? 0
3036
+ : (anum && !bnum) ? -1
3037
+ : (bnum && !anum) ? 1
3038
+ : a < b ? -1
3039
+ : 1
3040
+ }
3041
+
3042
+ exports.rcompareIdentifiers = rcompareIdentifiers;
3043
+ function rcompareIdentifiers (a, b) {
3044
+ return compareIdentifiers(b, a)
3045
+ }
3046
+
3047
+ exports.major = major;
3048
+ function major (a, loose) {
3049
+ return new SemVer(a, loose).major
3050
+ }
3051
+
3052
+ exports.minor = minor;
3053
+ function minor (a, loose) {
3054
+ return new SemVer(a, loose).minor
3055
+ }
3056
+
3057
+ exports.patch = patch;
3058
+ function patch (a, loose) {
3059
+ return new SemVer(a, loose).patch
3060
+ }
3061
+
3062
+ exports.compare = compare;
3063
+ function compare (a, b, loose) {
3064
+ return new SemVer(a, loose).compare(new SemVer(b, loose))
3065
+ }
3066
+
3067
+ exports.compareLoose = compareLoose;
3068
+ function compareLoose (a, b) {
3069
+ return compare(a, b, true)
3070
+ }
3071
+
3072
+ exports.compareBuild = compareBuild;
3073
+ function compareBuild (a, b, loose) {
3074
+ var versionA = new SemVer(a, loose);
3075
+ var versionB = new SemVer(b, loose);
3076
+ return versionA.compare(versionB) || versionA.compareBuild(versionB)
3077
+ }
3078
+
3079
+ exports.rcompare = rcompare;
3080
+ function rcompare (a, b, loose) {
3081
+ return compare(b, a, loose)
3082
+ }
3083
+
3084
+ exports.sort = sort;
3085
+ function sort (list, loose) {
3086
+ return list.sort(function (a, b) {
3087
+ return exports.compareBuild(a, b, loose)
3088
+ })
3089
+ }
3090
+
3091
+ exports.rsort = rsort;
3092
+ function rsort (list, loose) {
3093
+ return list.sort(function (a, b) {
3094
+ return exports.compareBuild(b, a, loose)
3095
+ })
3096
+ }
3097
+
3098
+ exports.gt = gt;
3099
+ function gt (a, b, loose) {
3100
+ return compare(a, b, loose) > 0
3101
+ }
3102
+
3103
+ exports.lt = lt;
3104
+ function lt (a, b, loose) {
3105
+ return compare(a, b, loose) < 0
3106
+ }
3107
+
3108
+ exports.eq = eq;
3109
+ function eq (a, b, loose) {
3110
+ return compare(a, b, loose) === 0
3111
+ }
3112
+
3113
+ exports.neq = neq;
3114
+ function neq (a, b, loose) {
3115
+ return compare(a, b, loose) !== 0
3116
+ }
3117
+
3118
+ exports.gte = gte;
3119
+ function gte (a, b, loose) {
3120
+ return compare(a, b, loose) >= 0
3121
+ }
3122
+
3123
+ exports.lte = lte;
3124
+ function lte (a, b, loose) {
3125
+ return compare(a, b, loose) <= 0
3126
+ }
3127
+
3128
+ exports.cmp = cmp;
3129
+ function cmp (a, op, b, loose) {
3130
+ switch (op) {
3131
+ case '===':
3132
+ if (typeof a === 'object')
3133
+ a = a.version;
3134
+ if (typeof b === 'object')
3135
+ b = b.version;
3136
+ return a === b
3137
+
3138
+ case '!==':
3139
+ if (typeof a === 'object')
3140
+ a = a.version;
3141
+ if (typeof b === 'object')
3142
+ b = b.version;
3143
+ return a !== b
3144
+
3145
+ case '':
3146
+ case '=':
3147
+ case '==':
3148
+ return eq(a, b, loose)
3149
+
3150
+ case '!=':
3151
+ return neq(a, b, loose)
3152
+
3153
+ case '>':
3154
+ return gt(a, b, loose)
3155
+
3156
+ case '>=':
3157
+ return gte(a, b, loose)
3158
+
3159
+ case '<':
3160
+ return lt(a, b, loose)
3161
+
3162
+ case '<=':
3163
+ return lte(a, b, loose)
3164
+
3165
+ default:
3166
+ throw new TypeError('Invalid operator: ' + op)
3167
+ }
3168
+ }
3169
+
3170
+ exports.Comparator = Comparator;
3171
+ function Comparator (comp, options) {
3172
+ if (!options || typeof options !== 'object') {
3173
+ options = {
3174
+ loose: !!options,
3175
+ includePrerelease: false
3176
+ };
3177
+ }
3178
+
3179
+ if (comp instanceof Comparator) {
3180
+ if (comp.loose === !!options.loose) {
3181
+ return comp
3182
+ } else {
3183
+ comp = comp.value;
3184
+ }
3185
+ }
3186
+
3187
+ if (!(this instanceof Comparator)) {
3188
+ return new Comparator(comp, options)
3189
+ }
3190
+
3191
+ comp = comp.trim().split(/\s+/).join(' ');
3192
+ debug('comparator', comp, options);
3193
+ this.options = options;
3194
+ this.loose = !!options.loose;
3195
+ this.parse(comp);
3196
+
3197
+ if (this.semver === ANY) {
3198
+ this.value = '';
3199
+ } else {
3200
+ this.value = this.operator + this.semver.version;
3201
+ }
3202
+
3203
+ debug('comp', this);
3204
+ }
3205
+
3206
+ var ANY = {};
3207
+ Comparator.prototype.parse = function (comp) {
3208
+ var r = this.options.loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR];
3209
+ var m = comp.match(r);
3210
+
3211
+ if (!m) {
3212
+ throw new TypeError('Invalid comparator: ' + comp)
3213
+ }
3214
+
3215
+ this.operator = m[1] !== undefined ? m[1] : '';
3216
+ if (this.operator === '=') {
3217
+ this.operator = '';
3218
+ }
3219
+
3220
+ // if it literally is just '>' or '' then allow anything.
3221
+ if (!m[2]) {
3222
+ this.semver = ANY;
3223
+ } else {
3224
+ this.semver = new SemVer(m[2], this.options.loose);
3225
+ }
3226
+ };
3227
+
3228
+ Comparator.prototype.toString = function () {
3229
+ return this.value
3230
+ };
3231
+
3232
+ Comparator.prototype.test = function (version) {
3233
+ debug('Comparator.test', version, this.options.loose);
3234
+
3235
+ if (this.semver === ANY || version === ANY) {
3236
+ return true
3237
+ }
3238
+
3239
+ if (typeof version === 'string') {
3240
+ try {
3241
+ version = new SemVer(version, this.options);
3242
+ } catch (er) {
3243
+ return false
3244
+ }
3245
+ }
3246
+
3247
+ return cmp(version, this.operator, this.semver, this.options)
3248
+ };
3249
+
3250
+ Comparator.prototype.intersects = function (comp, options) {
3251
+ if (!(comp instanceof Comparator)) {
3252
+ throw new TypeError('a Comparator is required')
3253
+ }
3254
+
3255
+ if (!options || typeof options !== 'object') {
3256
+ options = {
3257
+ loose: !!options,
3258
+ includePrerelease: false
3259
+ };
3260
+ }
3261
+
3262
+ var rangeTmp;
3263
+
3264
+ if (this.operator === '') {
3265
+ if (this.value === '') {
3266
+ return true
3267
+ }
3268
+ rangeTmp = new Range(comp.value, options);
3269
+ return satisfies(this.value, rangeTmp, options)
3270
+ } else if (comp.operator === '') {
3271
+ if (comp.value === '') {
3272
+ return true
3273
+ }
3274
+ rangeTmp = new Range(this.value, options);
3275
+ return satisfies(comp.semver, rangeTmp, options)
3276
+ }
3277
+
3278
+ var sameDirectionIncreasing =
3279
+ (this.operator === '>=' || this.operator === '>') &&
3280
+ (comp.operator === '>=' || comp.operator === '>');
3281
+ var sameDirectionDecreasing =
3282
+ (this.operator === '<=' || this.operator === '<') &&
3283
+ (comp.operator === '<=' || comp.operator === '<');
3284
+ var sameSemVer = this.semver.version === comp.semver.version;
3285
+ var differentDirectionsInclusive =
3286
+ (this.operator === '>=' || this.operator === '<=') &&
3287
+ (comp.operator === '>=' || comp.operator === '<=');
3288
+ var oppositeDirectionsLessThan =
3289
+ cmp(this.semver, '<', comp.semver, options) &&
3290
+ ((this.operator === '>=' || this.operator === '>') &&
3291
+ (comp.operator === '<=' || comp.operator === '<'));
3292
+ var oppositeDirectionsGreaterThan =
3293
+ cmp(this.semver, '>', comp.semver, options) &&
3294
+ ((this.operator === '<=' || this.operator === '<') &&
3295
+ (comp.operator === '>=' || comp.operator === '>'));
3296
+
3297
+ return sameDirectionIncreasing || sameDirectionDecreasing ||
3298
+ (sameSemVer && differentDirectionsInclusive) ||
3299
+ oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
3300
+ };
3301
+
3302
+ exports.Range = Range;
3303
+ function Range (range, options) {
3304
+ if (!options || typeof options !== 'object') {
3305
+ options = {
3306
+ loose: !!options,
3307
+ includePrerelease: false
3308
+ };
3309
+ }
3310
+
3311
+ if (range instanceof Range) {
3312
+ if (range.loose === !!options.loose &&
3313
+ range.includePrerelease === !!options.includePrerelease) {
3314
+ return range
3315
+ } else {
3316
+ return new Range(range.raw, options)
3317
+ }
3318
+ }
3319
+
3320
+ if (range instanceof Comparator) {
3321
+ return new Range(range.value, options)
3322
+ }
3323
+
3324
+ if (!(this instanceof Range)) {
3325
+ return new Range(range, options)
3326
+ }
3327
+
3328
+ this.options = options;
3329
+ this.loose = !!options.loose;
3330
+ this.includePrerelease = !!options.includePrerelease;
3331
+
3332
+ // First reduce all whitespace as much as possible so we do not have to rely
3333
+ // on potentially slow regexes like \s*. This is then stored and used for
3334
+ // future error messages as well.
3335
+ this.raw = range
3336
+ .trim()
3337
+ .split(/\s+/)
3338
+ .join(' ');
3339
+
3340
+ // First, split based on boolean or ||
3341
+ this.set = this.raw.split('||').map(function (range) {
3342
+ return this.parseRange(range.trim())
3343
+ }, this).filter(function (c) {
3344
+ // throw out any that are not relevant for whatever reason
3345
+ return c.length
3346
+ });
3347
+
3348
+ if (!this.set.length) {
3349
+ throw new TypeError('Invalid SemVer Range: ' + this.raw)
3350
+ }
3351
+
3352
+ this.format();
3353
+ }
3354
+
3355
+ Range.prototype.format = function () {
3356
+ this.range = this.set.map(function (comps) {
3357
+ return comps.join(' ').trim()
3358
+ }).join('||').trim();
3359
+ return this.range
3360
+ };
3361
+
3362
+ Range.prototype.toString = function () {
3363
+ return this.range
3364
+ };
3365
+
3366
+ Range.prototype.parseRange = function (range) {
3367
+ var loose = this.options.loose;
3368
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
3369
+ var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE];
3370
+ range = range.replace(hr, hyphenReplace);
3371
+ debug('hyphen replace', range);
3372
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
3373
+ range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace);
3374
+ debug('comparator trim', range, safeRe[t.COMPARATORTRIM]);
3375
+
3376
+ // `~ 1.2.3` => `~1.2.3`
3377
+ range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace);
3378
+
3379
+ // `^ 1.2.3` => `^1.2.3`
3380
+ range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace);
3381
+
3382
+ // normalize spaces
3383
+ range = range.split(/\s+/).join(' ');
3384
+
3385
+ // At this point, the range is completely trimmed and
3386
+ // ready to be split into comparators.
3387
+
3388
+ var compRe = loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR];
3389
+ var set = range.split(' ').map(function (comp) {
3390
+ return parseComparator(comp, this.options)
3391
+ }, this).join(' ').split(/\s+/);
3392
+ if (this.options.loose) {
3393
+ // in loose mode, throw out any that are not valid comparators
3394
+ set = set.filter(function (comp) {
3395
+ return !!comp.match(compRe)
3396
+ });
3397
+ }
3398
+ set = set.map(function (comp) {
3399
+ return new Comparator(comp, this.options)
3400
+ }, this);
3401
+
3402
+ return set
3403
+ };
3404
+
3405
+ Range.prototype.intersects = function (range, options) {
3406
+ if (!(range instanceof Range)) {
3407
+ throw new TypeError('a Range is required')
3408
+ }
3409
+
3410
+ return this.set.some(function (thisComparators) {
3411
+ return (
3412
+ isSatisfiable(thisComparators, options) &&
3413
+ range.set.some(function (rangeComparators) {
3414
+ return (
3415
+ isSatisfiable(rangeComparators, options) &&
3416
+ thisComparators.every(function (thisComparator) {
3417
+ return rangeComparators.every(function (rangeComparator) {
3418
+ return thisComparator.intersects(rangeComparator, options)
3419
+ })
3420
+ })
3421
+ )
3422
+ })
3423
+ )
3424
+ })
3425
+ };
3426
+
3427
+ // take a set of comparators and determine whether there
3428
+ // exists a version which can satisfy it
3429
+ function isSatisfiable (comparators, options) {
3430
+ var result = true;
3431
+ var remainingComparators = comparators.slice();
3432
+ var testComparator = remainingComparators.pop();
3433
+
3434
+ while (result && remainingComparators.length) {
3435
+ result = remainingComparators.every(function (otherComparator) {
3436
+ return testComparator.intersects(otherComparator, options)
3437
+ });
3438
+
3439
+ testComparator = remainingComparators.pop();
3440
+ }
3441
+
3442
+ return result
3443
+ }
3444
+
3445
+ // Mostly just for testing and legacy API reasons
3446
+ exports.toComparators = toComparators;
3447
+ function toComparators (range, options) {
3448
+ return new Range(range, options).set.map(function (comp) {
3449
+ return comp.map(function (c) {
3450
+ return c.value
3451
+ }).join(' ').trim().split(' ')
3452
+ })
3453
+ }
3454
+
3455
+ // comprised of xranges, tildes, stars, and gtlt's at this point.
3456
+ // already replaced the hyphen ranges
3457
+ // turn into a set of JUST comparators.
3458
+ function parseComparator (comp, options) {
3459
+ debug('comp', comp, options);
3460
+ comp = replaceCarets(comp, options);
3461
+ debug('caret', comp);
3462
+ comp = replaceTildes(comp, options);
3463
+ debug('tildes', comp);
3464
+ comp = replaceXRanges(comp, options);
3465
+ debug('xrange', comp);
3466
+ comp = replaceStars(comp, options);
3467
+ debug('stars', comp);
3468
+ return comp
3469
+ }
3470
+
3471
+ function isX (id) {
3472
+ return !id || id.toLowerCase() === 'x' || id === '*'
3473
+ }
3474
+
3475
+ // ~, ~> --> * (any, kinda silly)
3476
+ // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
3477
+ // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
3478
+ // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
3479
+ // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
3480
+ // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
3481
+ function replaceTildes (comp, options) {
3482
+ return comp.trim().split(/\s+/).map(function (comp) {
3483
+ return replaceTilde(comp, options)
3484
+ }).join(' ')
3485
+ }
3486
+
3487
+ function replaceTilde (comp, options) {
3488
+ var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE];
3489
+ return comp.replace(r, function (_, M, m, p, pr) {
3490
+ debug('tilde', comp, _, M, m, p, pr);
3491
+ var ret;
3492
+
3493
+ if (isX(M)) {
3494
+ ret = '';
3495
+ } else if (isX(m)) {
3496
+ ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
3497
+ } else if (isX(p)) {
3498
+ // ~1.2 == >=1.2.0 <1.3.0
3499
+ ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
3500
+ } else if (pr) {
3501
+ debug('replaceTilde pr', pr);
3502
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
3503
+ ' <' + M + '.' + (+m + 1) + '.0';
3504
+ } else {
3505
+ // ~1.2.3 == >=1.2.3 <1.3.0
3506
+ ret = '>=' + M + '.' + m + '.' + p +
3507
+ ' <' + M + '.' + (+m + 1) + '.0';
3508
+ }
3509
+
3510
+ debug('tilde return', ret);
3511
+ return ret
3512
+ })
3513
+ }
3514
+
3515
+ // ^ --> * (any, kinda silly)
3516
+ // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
3517
+ // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
3518
+ // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
3519
+ // ^1.2.3 --> >=1.2.3 <2.0.0
3520
+ // ^1.2.0 --> >=1.2.0 <2.0.0
3521
+ function replaceCarets (comp, options) {
3522
+ return comp.trim().split(/\s+/).map(function (comp) {
3523
+ return replaceCaret(comp, options)
3524
+ }).join(' ')
3525
+ }
3526
+
3527
+ function replaceCaret (comp, options) {
3528
+ debug('caret', comp, options);
3529
+ var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET];
3530
+ return comp.replace(r, function (_, M, m, p, pr) {
3531
+ debug('caret', comp, _, M, m, p, pr);
3532
+ var ret;
3533
+
3534
+ if (isX(M)) {
3535
+ ret = '';
3536
+ } else if (isX(m)) {
3537
+ ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
3538
+ } else if (isX(p)) {
3539
+ if (M === '0') {
3540
+ ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
3541
+ } else {
3542
+ ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
3543
+ }
3544
+ } else if (pr) {
3545
+ debug('replaceCaret pr', pr);
3546
+ if (M === '0') {
3547
+ if (m === '0') {
3548
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
3549
+ ' <' + M + '.' + m + '.' + (+p + 1);
3550
+ } else {
3551
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
3552
+ ' <' + M + '.' + (+m + 1) + '.0';
3553
+ }
3554
+ } else {
3555
+ ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
3556
+ ' <' + (+M + 1) + '.0.0';
3557
+ }
3558
+ } else {
3559
+ debug('no pr');
3560
+ if (M === '0') {
3561
+ if (m === '0') {
3562
+ ret = '>=' + M + '.' + m + '.' + p +
3563
+ ' <' + M + '.' + m + '.' + (+p + 1);
3564
+ } else {
3565
+ ret = '>=' + M + '.' + m + '.' + p +
3566
+ ' <' + M + '.' + (+m + 1) + '.0';
3567
+ }
3568
+ } else {
3569
+ ret = '>=' + M + '.' + m + '.' + p +
3570
+ ' <' + (+M + 1) + '.0.0';
3571
+ }
3572
+ }
3573
+
3574
+ debug('caret return', ret);
3575
+ return ret
3576
+ })
3577
+ }
3578
+
3579
+ function replaceXRanges (comp, options) {
3580
+ debug('replaceXRanges', comp, options);
3581
+ return comp.split(/\s+/).map(function (comp) {
3582
+ return replaceXRange(comp, options)
3583
+ }).join(' ')
3584
+ }
3585
+
3586
+ function replaceXRange (comp, options) {
3587
+ comp = comp.trim();
3588
+ var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE];
3589
+ return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
3590
+ debug('xRange', comp, ret, gtlt, M, m, p, pr);
3591
+ var xM = isX(M);
3592
+ var xm = xM || isX(m);
3593
+ var xp = xm || isX(p);
3594
+ var anyX = xp;
3595
+
3596
+ if (gtlt === '=' && anyX) {
3597
+ gtlt = '';
3598
+ }
3599
+
3600
+ // if we're including prereleases in the match, then we need
3601
+ // to fix this to -0, the lowest possible prerelease value
3602
+ pr = options.includePrerelease ? '-0' : '';
3603
+
3604
+ if (xM) {
3605
+ if (gtlt === '>' || gtlt === '<') {
3606
+ // nothing is allowed
3607
+ ret = '<0.0.0-0';
3608
+ } else {
3609
+ // nothing is forbidden
3610
+ ret = '*';
3611
+ }
3612
+ } else if (gtlt && anyX) {
3613
+ // we know patch is an x, because we have any x at all.
3614
+ // replace X with 0
3615
+ if (xm) {
3616
+ m = 0;
3617
+ }
3618
+ p = 0;
3619
+
3620
+ if (gtlt === '>') {
3621
+ // >1 => >=2.0.0
3622
+ // >1.2 => >=1.3.0
3623
+ // >1.2.3 => >= 1.2.4
3624
+ gtlt = '>=';
3625
+ if (xm) {
3626
+ M = +M + 1;
3627
+ m = 0;
3628
+ p = 0;
3629
+ } else {
3630
+ m = +m + 1;
3631
+ p = 0;
3632
+ }
3633
+ } else if (gtlt === '<=') {
3634
+ // <=0.7.x is actually <0.8.0, since any 0.7.x should
3635
+ // pass. Similarly, <=7.x is actually <8.0.0, etc.
3636
+ gtlt = '<';
3637
+ if (xm) {
3638
+ M = +M + 1;
3639
+ } else {
3640
+ m = +m + 1;
3641
+ }
3642
+ }
3643
+
3644
+ ret = gtlt + M + '.' + m + '.' + p + pr;
3645
+ } else if (xm) {
3646
+ ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
3647
+ } else if (xp) {
3648
+ ret = '>=' + M + '.' + m + '.0' + pr +
3649
+ ' <' + M + '.' + (+m + 1) + '.0' + pr;
3650
+ }
3651
+
3652
+ debug('xRange return', ret);
3653
+
3654
+ return ret
3655
+ })
3656
+ }
3657
+
3658
+ // Because * is AND-ed with everything else in the comparator,
3659
+ // and '' means "any version", just remove the *s entirely.
3660
+ function replaceStars (comp, options) {
3661
+ debug('replaceStars', comp, options);
3662
+ // Looseness is ignored here. star is always as loose as it gets!
3663
+ return comp.trim().replace(safeRe[t.STAR], '')
3664
+ }
3665
+
3666
+ // This function is passed to string.replace(re[t.HYPHENRANGE])
3667
+ // M, m, patch, prerelease, build
3668
+ // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
3669
+ // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
3670
+ // 1.2 - 3.4 => >=1.2.0 <3.5.0
3671
+ function hyphenReplace ($0,
3672
+ from, fM, fm, fp, fpr, fb,
3673
+ to, tM, tm, tp, tpr, tb) {
3674
+ if (isX(fM)) {
3675
+ from = '';
3676
+ } else if (isX(fm)) {
3677
+ from = '>=' + fM + '.0.0';
3678
+ } else if (isX(fp)) {
3679
+ from = '>=' + fM + '.' + fm + '.0';
3680
+ } else {
3681
+ from = '>=' + from;
3682
+ }
3683
+
3684
+ if (isX(tM)) {
3685
+ to = '';
3686
+ } else if (isX(tm)) {
3687
+ to = '<' + (+tM + 1) + '.0.0';
3688
+ } else if (isX(tp)) {
3689
+ to = '<' + tM + '.' + (+tm + 1) + '.0';
3690
+ } else if (tpr) {
3691
+ to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
3692
+ } else {
3693
+ to = '<=' + to;
3694
+ }
3695
+
3696
+ return (from + ' ' + to).trim()
3697
+ }
3698
+
3699
+ // if ANY of the sets match ALL of its comparators, then pass
3700
+ Range.prototype.test = function (version) {
3701
+ if (!version) {
3702
+ return false
3703
+ }
3704
+
3705
+ if (typeof version === 'string') {
3706
+ try {
3707
+ version = new SemVer(version, this.options);
3708
+ } catch (er) {
3709
+ return false
3710
+ }
3711
+ }
3712
+
3713
+ for (var i = 0; i < this.set.length; i++) {
3714
+ if (testSet(this.set[i], version, this.options)) {
3715
+ return true
3716
+ }
3717
+ }
3718
+ return false
3719
+ };
3720
+
3721
+ function testSet (set, version, options) {
3722
+ for (var i = 0; i < set.length; i++) {
3723
+ if (!set[i].test(version)) {
3724
+ return false
3725
+ }
3726
+ }
3727
+
3728
+ if (version.prerelease.length && !options.includePrerelease) {
3729
+ // Find the set of versions that are allowed to have prereleases
3730
+ // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
3731
+ // That should allow `1.2.3-pr.2` to pass.
3732
+ // However, `1.2.4-alpha.notready` should NOT be allowed,
3733
+ // even though it's within the range set by the comparators.
3734
+ for (i = 0; i < set.length; i++) {
3735
+ debug(set[i].semver);
3736
+ if (set[i].semver === ANY) {
3737
+ continue
3738
+ }
3739
+
3740
+ if (set[i].semver.prerelease.length > 0) {
3741
+ var allowed = set[i].semver;
3742
+ if (allowed.major === version.major &&
3743
+ allowed.minor === version.minor &&
3744
+ allowed.patch === version.patch) {
3745
+ return true
3746
+ }
3747
+ }
3748
+ }
3749
+
3750
+ // Version has a -pre, but it's not one of the ones we like.
3751
+ return false
3752
+ }
3753
+
3754
+ return true
3755
+ }
3756
+
3757
+ exports.satisfies = satisfies;
3758
+ function satisfies (version, range, options) {
3759
+ try {
3760
+ range = new Range(range, options);
3761
+ } catch (er) {
3762
+ return false
3763
+ }
3764
+ return range.test(version)
3765
+ }
3766
+
3767
+ exports.maxSatisfying = maxSatisfying;
3768
+ function maxSatisfying (versions, range, options) {
3769
+ var max = null;
3770
+ var maxSV = null;
3771
+ try {
3772
+ var rangeObj = new Range(range, options);
3773
+ } catch (er) {
3774
+ return null
3775
+ }
3776
+ versions.forEach(function (v) {
3777
+ if (rangeObj.test(v)) {
3778
+ // satisfies(v, range, options)
3779
+ if (!max || maxSV.compare(v) === -1) {
3780
+ // compare(max, v, true)
3781
+ max = v;
3782
+ maxSV = new SemVer(max, options);
3783
+ }
3784
+ }
3785
+ });
3786
+ return max
3787
+ }
3788
+
3789
+ exports.minSatisfying = minSatisfying;
3790
+ function minSatisfying (versions, range, options) {
3791
+ var min = null;
3792
+ var minSV = null;
3793
+ try {
3794
+ var rangeObj = new Range(range, options);
3795
+ } catch (er) {
3796
+ return null
3797
+ }
3798
+ versions.forEach(function (v) {
3799
+ if (rangeObj.test(v)) {
3800
+ // satisfies(v, range, options)
3801
+ if (!min || minSV.compare(v) === 1) {
3802
+ // compare(min, v, true)
3803
+ min = v;
3804
+ minSV = new SemVer(min, options);
3805
+ }
3806
+ }
3807
+ });
3808
+ return min
3809
+ }
3810
+
3811
+ exports.minVersion = minVersion;
3812
+ function minVersion (range, loose) {
3813
+ range = new Range(range, loose);
3814
+
3815
+ var minver = new SemVer('0.0.0');
3816
+ if (range.test(minver)) {
3817
+ return minver
3818
+ }
3819
+
3820
+ minver = new SemVer('0.0.0-0');
3821
+ if (range.test(minver)) {
3822
+ return minver
3823
+ }
3824
+
3825
+ minver = null;
3826
+ for (var i = 0; i < range.set.length; ++i) {
3827
+ var comparators = range.set[i];
3828
+
3829
+ comparators.forEach(function (comparator) {
3830
+ // Clone to avoid manipulating the comparator's semver object.
3831
+ var compver = new SemVer(comparator.semver.version);
3832
+ switch (comparator.operator) {
3833
+ case '>':
3834
+ if (compver.prerelease.length === 0) {
3835
+ compver.patch++;
3836
+ } else {
3837
+ compver.prerelease.push(0);
3838
+ }
3839
+ compver.raw = compver.format();
3840
+ /* fallthrough */
3841
+ case '':
3842
+ case '>=':
3843
+ if (!minver || gt(minver, compver)) {
3844
+ minver = compver;
3845
+ }
3846
+ break
3847
+ case '<':
3848
+ case '<=':
3849
+ /* Ignore maximum versions */
3850
+ break
3851
+ /* istanbul ignore next */
3852
+ default:
3853
+ throw new Error('Unexpected operation: ' + comparator.operator)
3854
+ }
3855
+ });
3856
+ }
3857
+
3858
+ if (minver && range.test(minver)) {
3859
+ return minver
3860
+ }
3861
+
3862
+ return null
3863
+ }
3864
+
3865
+ exports.validRange = validRange;
3866
+ function validRange (range, options) {
3867
+ try {
3868
+ // Return '*' instead of '' so that truthiness works.
3869
+ // This will throw if it's invalid anyway
3870
+ return new Range(range, options).range || '*'
3871
+ } catch (er) {
3872
+ return null
3873
+ }
3874
+ }
3875
+
3876
+ // Determine if version is less than all the versions possible in the range
3877
+ exports.ltr = ltr;
3878
+ function ltr (version, range, options) {
3879
+ return outside(version, range, '<', options)
3880
+ }
3881
+
3882
+ // Determine if version is greater than all the versions possible in the range.
3883
+ exports.gtr = gtr;
3884
+ function gtr (version, range, options) {
3885
+ return outside(version, range, '>', options)
3886
+ }
3887
+
3888
+ exports.outside = outside;
3889
+ function outside (version, range, hilo, options) {
3890
+ version = new SemVer(version, options);
3891
+ range = new Range(range, options);
3892
+
3893
+ var gtfn, ltefn, ltfn, comp, ecomp;
3894
+ switch (hilo) {
3895
+ case '>':
3896
+ gtfn = gt;
3897
+ ltefn = lte;
3898
+ ltfn = lt;
3899
+ comp = '>';
3900
+ ecomp = '>=';
3901
+ break
3902
+ case '<':
3903
+ gtfn = lt;
3904
+ ltefn = gte;
3905
+ ltfn = gt;
3906
+ comp = '<';
3907
+ ecomp = '<=';
3908
+ break
3909
+ default:
3910
+ throw new TypeError('Must provide a hilo val of "<" or ">"')
3911
+ }
3912
+
3913
+ // If it satisifes the range it is not outside
3914
+ if (satisfies(version, range, options)) {
3915
+ return false
3916
+ }
3917
+
3918
+ // From now on, variable terms are as if we're in "gtr" mode.
3919
+ // but note that everything is flipped for the "ltr" function.
3920
+
3921
+ for (var i = 0; i < range.set.length; ++i) {
3922
+ var comparators = range.set[i];
3923
+
3924
+ var high = null;
3925
+ var low = null;
3926
+
3927
+ comparators.forEach(function (comparator) {
3928
+ if (comparator.semver === ANY) {
3929
+ comparator = new Comparator('>=0.0.0');
3930
+ }
3931
+ high = high || comparator;
3932
+ low = low || comparator;
3933
+ if (gtfn(comparator.semver, high.semver, options)) {
3934
+ high = comparator;
3935
+ } else if (ltfn(comparator.semver, low.semver, options)) {
3936
+ low = comparator;
3937
+ }
3938
+ });
3939
+
3940
+ // If the edge version comparator has a operator then our version
3941
+ // isn't outside it
3942
+ if (high.operator === comp || high.operator === ecomp) {
3943
+ return false
3944
+ }
3945
+
3946
+ // If the lowest version comparator has an operator and our version
3947
+ // is less than it then it isn't higher than the range
3948
+ if ((!low.operator || low.operator === comp) &&
3949
+ ltefn(version, low.semver)) {
3950
+ return false
3951
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
3952
+ return false
3953
+ }
3954
+ }
3955
+ return true
3956
+ }
3957
+
3958
+ exports.prerelease = prerelease;
3959
+ function prerelease (version, options) {
3960
+ var parsed = parse(version, options);
3961
+ return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
3962
+ }
3963
+
3964
+ exports.intersects = intersects;
3965
+ function intersects (r1, r2, options) {
3966
+ r1 = new Range(r1, options);
3967
+ r2 = new Range(r2, options);
3968
+ return r1.intersects(r2)
3969
+ }
3970
+
3971
+ exports.coerce = coerce;
3972
+ function coerce (version, options) {
3973
+ if (version instanceof SemVer) {
3974
+ return version
3975
+ }
3976
+
3977
+ if (typeof version === 'number') {
3978
+ version = String(version);
3979
+ }
3980
+
3981
+ if (typeof version !== 'string') {
3982
+ return null
3983
+ }
3984
+
3985
+ options = options || {};
3986
+
3987
+ var match = null;
3988
+ if (!options.rtl) {
3989
+ match = version.match(safeRe[t.COERCE]);
3990
+ } else {
3991
+ // Find the right-most coercible string that does not share
3992
+ // a terminus with a more left-ward coercible string.
3993
+ // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
3994
+ //
3995
+ // Walk through the string checking with a /g regexp
3996
+ // Manually set the index so as to pick up overlapping matches.
3997
+ // Stop when we get a match that ends at the string end, since no
3998
+ // coercible string can be more right-ward without the same terminus.
3999
+ var next;
4000
+ while ((next = safeRe[t.COERCERTL].exec(version)) &&
4001
+ (!match || match.index + match[0].length !== version.length)
4002
+ ) {
4003
+ if (!match ||
4004
+ next.index + next[0].length !== match.index + match[0].length) {
4005
+ match = next;
4006
+ }
4007
+ safeRe[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
4008
+ }
4009
+ // leave it in a clean state
4010
+ safeRe[t.COERCERTL].lastIndex = -1;
4011
+ }
4012
+
4013
+ if (match === null) {
4014
+ return null
4015
+ }
4016
+
4017
+ return parse(match[2] +
4018
+ '.' + (match[3] || '0') +
4019
+ '.' + (match[4] || '0'), options)
4020
+ }
4021
+ } (semver$1, semver$1.exports));
4022
+
4023
+ var semver = semver$1.exports;
4024
+
4025
+ var getPkgVersion = function getPkgVersion(pkgName, dependencies) {
4026
+ var pkg = neetoCist._findBy({
4027
+ key: {
4028
+ value: pkgName
4029
+ }
4030
+ }, dependencies === null || dependencies === void 0 ? void 0 : dependencies.value.properties);
4031
+ return pkg && pkg.value.value;
4032
+ };
4033
+ var findDependencies = function findDependencies(node, key) {
4034
+ return neetoCist.findBy({
4035
+ key: {
4036
+ value: key
4037
+ }
4038
+ }, node.parent.properties);
4039
+ };
4040
+ var getLatestVersion = function getLatestVersion(packageName, dependencies, devDependencies) {
4041
+ var depPkgVersion = getPkgVersion(packageName, dependencies);
4042
+ var devDepPkgVersion = getPkgVersion(packageName, devDependencies);
4043
+ if (!depPkgVersion && !devDepPkgVersion) {
4044
+ return {
4045
+ latestVersion: null,
4046
+ depType: null
4047
+ };
4048
+ }
4049
+ if (depPkgVersion && devDepPkgVersion) {
4050
+ if (semver.gt(semver.minVersion(depPkgVersion), semver.minVersion(devDepPkgVersion))) {
4051
+ return {
4052
+ latestVersion: depPkgVersion,
4053
+ depType: DEPENDENCY_TYPE.dependencies
4054
+ };
4055
+ }
4056
+ return {
4057
+ latestVersion: devDepPkgVersion,
4058
+ depType: DEPENDENCY_TYPE.devDependencies
4059
+ };
4060
+ }
4061
+ if (depPkgVersion) {
4062
+ return {
4063
+ latestVersion: depPkgVersion,
4064
+ depType: DEPENDENCY_TYPE.dependencies
4065
+ };
4066
+ }
4067
+ return {
4068
+ latestVersion: devDepPkgVersion,
4069
+ depType: DEPENDENCY_TYPE.devDependencies
4070
+ };
4071
+ };
4072
+
4073
+ var ensurePeerDependenciesAreInSync = {
4074
+ meta: {
4075
+ type: "problem",
4076
+ docs: {
4077
+ url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/ensure-peer-dependencies-are-in-sync.md",
4078
+ description: "Ensure that peerDependencies versions are in sync with the latest versions in dependencies or devDependencies."
4079
+ },
4080
+ fixable: "code"
4081
+ },
4082
+ create: function create(context) {
4083
+ return {
4084
+ Property: function Property(node) {
4085
+ if (!context.getFilename().endsWith("package.json") || node.key.value !== DEPENDENCY_TYPE.peerDependencies) {
4086
+ return;
4087
+ }
4088
+ var peerDependencies = findDependencies(node, DEPENDENCY_TYPE.peerDependencies);
4089
+ if (!peerDependencies) return;
4090
+ var dependencies = findDependencies(node, DEPENDENCY_TYPE.dependencies);
4091
+ var devDependencies = findDependencies(node, DEPENDENCY_TYPE.devDependencies);
4092
+ peerDependencies.value.properties.forEach(function (peerDepProperty) {
4093
+ var packageName = peerDepProperty.key.value;
4094
+ var peerVersion = peerDepProperty.value.value;
4095
+ var _getLatestVersion = getLatestVersion(packageName, dependencies, devDependencies),
4096
+ latestVersion = _getLatestVersion.latestVersion,
4097
+ depType = _getLatestVersion.depType;
4098
+ if (latestVersion && latestVersion !== peerVersion) {
4099
+ context.report({
4100
+ node: peerDepProperty,
4101
+ message: reportVersionMismatch(packageName, depType, peerVersion, latestVersion),
4102
+ fix: function fix(fixer) {
4103
+ var fixes = [fixer.replaceText(peerDepProperty.value, "\"".concat(latestVersion, "\""))];
4104
+ var outdatedDepType = depType === DEPENDENCY_TYPE.dependencies ? devDependencies : dependencies;
4105
+ if (!outdatedDepType) return fixes;
4106
+ var outdatedDepProperty = neetoCist.findBy({
4107
+ key: {
4108
+ value: packageName
4109
+ }
4110
+ }, outdatedDepType === null || outdatedDepType === void 0 ? void 0 : outdatedDepType.value.properties);
4111
+ if (outdatedDepProperty) {
4112
+ fixes.push(fixer.replaceText(outdatedDepProperty.value, "\"".concat(latestVersion, "\"")));
4113
+ }
4114
+ return fixes;
4115
+ }
4116
+ });
4117
+ }
4118
+ });
4119
+ }
4120
+ };
4121
+ }
4122
+ };
4123
+
2363
4124
  var USESTATE_WITHOUT_ARGUMENTS_PATTERN = {
2364
4125
  callee: {
2365
4126
  type: TYPES.IDENTIFIER,
@@ -9297,41 +11058,124 @@
9297
11058
  }
9298
11059
  };
9299
11060
 
9300
- var isNeetoPresent = function isNeetoPresent(value) {
9301
- return typeof value === "string" && /\bNeeto\b/.test(value);
11061
+ var CANCEL_BUTTON_STYLES = ["secondary", "text"];
11062
+ var SUBMIT_BUTTON_PATTERN = {
11063
+ type: TYPES.JSX_ELEMENT,
11064
+ openingElement: {
11065
+ name: {
11066
+ name: function name(_name) {
11067
+ var _name$toLowerCase;
11068
+ return _name === null || _name === void 0 ? void 0 : (_name$toLowerCase = _name.toLowerCase) === null || _name$toLowerCase === void 0 ? void 0 : _name$toLowerCase.call(_name).includes("button");
11069
+ }
11070
+ },
11071
+ attributes: neetoCist.existsBy({
11072
+ name: {
11073
+ name: "type"
11074
+ },
11075
+ value: {
11076
+ value: "submit"
11077
+ }
11078
+ })
11079
+ }
9302
11080
  };
9303
- var reportNeetoInChildren = function reportNeetoInChildren(array, context) {
9304
- array.forEach(function (item) {
9305
- return item.type === "JSXText" && isNeetoPresent(item.value) && context.report({
9306
- node: item,
9307
- message: USE_NEETO_SMALLER_CASE
9308
- });
9309
- });
11081
+ var CANCEL_BUTTON_PATTERN = {
11082
+ type: TYPES.JSX_ELEMENT,
11083
+ openingElement: {
11084
+ name: {
11085
+ name: function name(_name2) {
11086
+ var _name2$toLowerCase;
11087
+ return _name2 === null || _name2 === void 0 ? void 0 : (_name2$toLowerCase = _name2.toLowerCase) === null || _name2$toLowerCase === void 0 ? void 0 : _name2$toLowerCase.call(_name2).includes("button");
11088
+ }
11089
+ },
11090
+ attributes: neetoCist.existsBy({
11091
+ name: {
11092
+ name: "style"
11093
+ },
11094
+ value: {
11095
+ value: function value(_value) {
11096
+ return CANCEL_BUTTON_STYLES.includes(_value);
11097
+ }
11098
+ }
11099
+ })
11100
+ }
9310
11101
  };
11102
+ var BUTTON_NODE_PATTERN = {
11103
+ type: TYPES.JSX_EXPRESSION_CONTAINER,
11104
+ expression: matchesAny([{
11105
+ type: TYPES.LOGICAL_EXPRESSION,
11106
+ right: matchesAny([SUBMIT_BUTTON_PATTERN, CANCEL_BUTTON_PATTERN])
11107
+ }, {
11108
+ type: TYPES.CONDITIONAL_EXPRESSION,
11109
+ consequent: matchesAny([SUBMIT_BUTTON_PATTERN, CANCEL_BUTTON_PATTERN])
11110
+ }])
11111
+ };
11112
+ var CONDITIONAL_NODE_TYPES = [TYPES.LOGICAL_EXPRESSION, TYPES.CONDITIONAL_EXPRESSION];
11113
+ var NODE_TYPES = [TYPES.JSX_ELEMENT, TYPES.JSX_EXPRESSION_CONTAINER];
9311
11114
 
9312
- var useNeetoInStrings = {
11115
+ var isFormActionButton = function isFormActionButton(node) {
11116
+ return matchesAny([BUTTON_NODE_PATTERN, SUBMIT_BUTTON_PATTERN, CANCEL_BUTTON_PATTERN], node);
11117
+ };
11118
+ var isFormSubmitButton = function isFormSubmitButton(node) {
11119
+ return neetoCist.matches(SUBMIT_BUTTON_PATTERN, node);
11120
+ };
11121
+ var isAlternateNode = function isAlternateNode(node) {
11122
+ return neetoCist.matches({
11123
+ alternate: {
11124
+ loc: {
11125
+ start: {
11126
+ line: node.loc.start.line
11127
+ }
11128
+ }
11129
+ }
11130
+ }, node.parent);
11131
+ };
11132
+ var getAdjacentActionNode = function getAdjacentActionNode(node) {
11133
+ var _node$parent, _node$parent$parent, _filterBy2, _findIndexBy2;
11134
+ var isSucceedingNode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
11135
+ var parentNode = CONDITIONAL_NODE_TYPES.includes(node.parent.type) ? (_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : (_node$parent$parent = _node$parent.parent) === null || _node$parent$parent === void 0 ? void 0 : _node$parent$parent.parent : node.parent;
11136
+ if (neetoCist.isNotPresent(parentNode)) return null;
11137
+ var jsxElementsInCurrentContainer = (_filterBy2 = neetoCist._filterBy({
11138
+ type: function type(_type) {
11139
+ return NODE_TYPES.includes(_type);
11140
+ }
11141
+ }, parentNode.children)) !== null && _filterBy2 !== void 0 ? _filterBy2 : [];
11142
+ var nodeStartLineNumber = CONDITIONAL_NODE_TYPES.includes(node.parent.type) ? node.parent.loc.start.line : node.loc.start.line;
11143
+ var currentNodeIndex = (_findIndexBy2 = neetoCist._findIndexBy({
11144
+ loc: {
11145
+ start: {
11146
+ line: nodeStartLineNumber
11147
+ }
11148
+ }
11149
+ }, jsxElementsInCurrentContainer)) !== null && _findIndexBy2 !== void 0 ? _findIndexBy2 : -1;
11150
+ var adjacentNodeIndex = isSucceedingNode ? currentNodeIndex + 1 : currentNodeIndex - 1;
11151
+ var adjacentNode = jsxElementsInCurrentContainer[adjacentNodeIndex];
11152
+ return isFormActionButton(adjacentNode) ? adjacentNode : null;
11153
+ };
11154
+
11155
+ var useNeetouiActionBlockInFormikForms = {
9313
11156
  meta: {
9314
11157
  type: "suggestion",
9315
11158
  docs: {
9316
- url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/use-neeto-in-strings.md",
9317
- description: "Enforces the usage of neeto over Neeto in strings."
11159
+ url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/use-neetoui-action-block-in-formik-forms.md",
11160
+ description: "Enforces the usage of neetoui `ActionBlock` component in Formik forms instead of custom buttons for submit and cancel actions."
9318
11161
  }
9319
11162
  },
9320
11163
  create: function create(context) {
9321
11164
  return {
9322
- Literal: function Literal(node) {
9323
- isNeetoPresent(node.value) && context.report({
9324
- node: node,
9325
- message: USE_NEETO_SMALLER_CASE
9326
- });
9327
- },
9328
11165
  JSXElement: function JSXElement(node) {
9329
- reportNeetoInChildren(node.children, context);
9330
- },
9331
- TemplateElement: function TemplateElement(node) {
9332
- isNeetoPresent(node.value.raw) && context.report({
9333
- node: node,
9334
- message: USE_NEETO_SMALLER_CASE
11166
+ if (!isFormSubmitButton(node) || isAlternateNode(node)) return;
11167
+ var succeedingButton = getAdjacentActionNode(node, true);
11168
+ var precedingButton = getAdjacentActionNode(node);
11169
+ var start = node.loc.start;
11170
+ var end = node.loc.end;
11171
+ if (neetoCist.isPresent(precedingButton)) start = precedingButton.loc.start;
11172
+ if (neetoCist.isPresent(succeedingButton)) end = succeedingButton.loc.end;
11173
+ context.report({
11174
+ loc: {
11175
+ start: start,
11176
+ end: end
11177
+ },
11178
+ message: USE_NEETOUI_ACTION_BLOCK_IN_FORMIK_FORMS
9335
11179
  });
9336
11180
  }
9337
11181
  };
@@ -9665,6 +11509,47 @@
9665
11509
  }
9666
11510
  };
9667
11511
 
11512
+ var isNeetoPresent = function isNeetoPresent(value) {
11513
+ return typeof value === "string" && /\bneeto\b(?![-\w])/.test(value);
11514
+ };
11515
+ var reportNeetoInChildren = function reportNeetoInChildren(array, context) {
11516
+ array.forEach(function (item) {
11517
+ return item.type === "JSXText" && isNeetoPresent(item.value) && context.report({
11518
+ node: item,
11519
+ message: USE_TITLE_CASE_NEETO
11520
+ });
11521
+ });
11522
+ };
11523
+
11524
+ var useNeetoInStrings = {
11525
+ meta: {
11526
+ type: "suggestion",
11527
+ docs: {
11528
+ url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/use-title-case-neeto-in-strings.md",
11529
+ description: "Enforces the usage of Neeto over neeto in strings."
11530
+ }
11531
+ },
11532
+ create: function create(context) {
11533
+ return {
11534
+ Literal: function Literal(node) {
11535
+ isNeetoPresent(node.value) && context.report({
11536
+ node: node,
11537
+ message: USE_TITLE_CASE_NEETO
11538
+ });
11539
+ },
11540
+ JSXElement: function JSXElement(node) {
11541
+ reportNeetoInChildren(node.children, context);
11542
+ },
11543
+ TemplateElement: function TemplateElement(node) {
11544
+ isNeetoPresent(node.value.raw) && context.report({
11545
+ node: node,
11546
+ message: USE_TITLE_CASE_NEETO
11547
+ });
11548
+ }
11549
+ };
11550
+ }
11551
+ };
11552
+
9668
11553
  var ONSUCCESS_OPTION = {
9669
11554
  type: TYPES.PROPERTY,
9670
11555
  key: {
@@ -10620,6 +12505,7 @@
10620
12505
 
10621
12506
  var index = {
10622
12507
  rules: {
12508
+ "use-neetoui-action-block-in-formik-forms": useNeetouiActionBlockInFormikForms,
10623
12509
  "no-unnecessary-classnames": noUnnecessaryClassnames,
10624
12510
  "no-snake-case-destructuring-for-use-query-params-and-get-query-params": noSnakeCaseDestructuringForUseQueryParamsAndGetQueryParams,
10625
12511
  "no-local-storage": noLocalStorage,
@@ -10672,7 +12558,7 @@
10672
12558
  "use-create-subscription-util-function": useCreateSubscriptionUtilFunction,
10673
12559
  "use-i18next-plurals": useI18nextPlurals,
10674
12560
  "use-inline-svg-for-render": useInlineSvgForRender,
10675
- "use-neeto-in-strings": useNeetoInStrings,
12561
+ "use-title-case-neeto-in-strings": useNeetoInStrings,
10676
12562
  "use-neetoui-classes": useNeetouiClasses,
10677
12563
  "use-permissions-prop-in-private-route": usePermissionsPropInPrivateRoute,
10678
12564
  "use-pluralize-package": usePluralizePackage,
@@ -10696,6 +12582,7 @@
10696
12582
  "no-unnecessary-if-condition": noUnnecessaryIfCondition,
10697
12583
  "zustand-use-with-immutable-actions-wrapper-inside-create": useWithImmutableActionsWrapperInsideCreate,
10698
12584
  "add-required-peer-dependencies": addRequiredPeerDependencies,
12585
+ "ensure-peer-dependencies-are-in-sync": ensurePeerDependenciesAreInSync,
10699
12586
  "use-common-constants": useCommonConstants,
10700
12587
  "move-spread-attributes-to-top-position": moveSpreadAttributesToTopPosition,
10701
12588
  "prefer-function-reference": preferFunctionReference,