@bigbinary/eslint-plugin-neeto 1.0.15 → 1.0.16

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 +5 -1
  2. package/dist/index.js +316 -40
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@ neeto.
8
8
  Install the plugin from npm:
9
9
 
10
10
  ```bash
11
- yarn add -D "@bigbinary/eslint-plugin-neeto@1.0.15"
11
+ yarn add -D "@bigbinary/eslint-plugin-neeto@1.0.16"
12
12
  ```
13
13
 
14
14
  In your eslintrc.js file, add `neeto` in the `plugins` list and add the required
@@ -34,6 +34,8 @@ module.exports = {
34
34
  - [api-connector-should-use-default-export](./docs/src/rules/api-connector-should-use-default-export.md)
35
35
  - [combine-multiple-independent-awaits](./docs/src/rules/combine-multiple-independent-awaits.md)
36
36
  - [consistent-button-link-anchor](./docs/src/rules/consistent-button-link-anchor.md)
37
+ - [ensure-zustand-stores-are-type-annotated](./docs/src/rules/ensure-zustand-stores-are-type-annotated.md)
38
+ - [ensure-zustand-import-names-are-consistent](./docs/src/rules/ensure-zustand-import-names-are-consistent.md)
37
39
  - [file-name-and-export-name-standards](./docs/src/rules/file-name-and-export-name-standards.md)
38
40
  - [minimize-zustand-store-access-scope](./docs/src/rules/minimize-zustand-store-access-scope.md)
39
41
  - [neetocommons-tips](./docs/src/rules/neetocommons-tips.md)
@@ -60,6 +62,8 @@ module.exports = {
60
62
  - [use-snake-case-for-api-connector-filename](./docs/src/rules/use-snake-case-for-api-connector-filename.md)
61
63
  - [use-webpack-alias](./docs/src/rules/use-webpack-alias.md)
62
64
  - [webpack-aliases-and-jsconfig-paths-should-be-in-sync](./docs/src/rules/webpack-aliases-and-jsconfig-paths-should-be-in-sync.md)
65
+ - [zustand-recommend-comparator-function-usage](./docs/src/rules/zustand-recommend-comparator-function-usage.md)
66
+ - [zustand-use-prop-to-pick-single-item](./docs/src/rules/zustand-use-prop-to-pick-single-item.md)
63
67
 
64
68
  ## Development setup
65
69
 
package/dist/index.js CHANGED
@@ -175,7 +175,7 @@
175
175
  });
176
176
 
177
177
  const APIS_DIRECTORY = "app/javascript/src/apis";
178
- const ROUTES_FILE_PATH = "app/javascript/src/common/routes.js";
178
+ const ROUTES_FILE_PATHS = ["app/javascript/src/routes.js", "app/javascript/src/common/routes.js"];
179
179
  const BLACKLISTED_PACKAGES = ["moment", "bootstrap", "blueprint", "react-spinners", "react-table", "remixicon", "mjml", "react-select", "antd", "@bigbinary/neeto-utils"];
180
180
  const TYPES = {
181
181
  ARRAY_EXPRESSION: "ArrayExpression",
@@ -426,6 +426,15 @@
426
426
  const USE_NEETOUI_BOX_SHADOW = "Use neetoUI border shadow. Refer https://bit.ly/box-shadows-page for more details.";
427
427
  const USE_NEETOUI_TEXT_COLOR = "Use neetoUI text color. Refer https://bit.ly/text-color-page for more details.";
428
428
  const DONT_USE_ZUSTAND_STORE_WITHOUT_SELECTOR = "Don't use zustand store hook without a selector function. It will impact the performance";
429
+ const DONT_USE_ZUSTAND_STORE_WITHOUT_COMPARATOR_FUNCTION = "Don't pick multiple zustand state items without comparator function";
430
+ const USE_PROP_FOR_PICKING_SINGLE_ITEM = "Use prop instead of pick when picking single item";
431
+ const ENSURE_ZUSTAND_STORES_ARE_TYPE_ANNOTATED = `
432
+ Zustand stores should be type annotated like this:
433
+ /** @type {import(”neetocommons/react-utils”).ZustandStoreHook} */
434
+ const useUserStore = create(...)
435
+ `;
436
+ const ENSURE_ZUSTAND_CREATE_IMPORT_ARE_CONSISTENT = "default import from zustand should always be named create";
437
+ const ENSURE_ZUSTAND_SHALLOW_IMPORT_ARE_CONSISTENT = "default import from zustand/shallow should always be named shallow";
429
438
 
430
439
  const toCamelCase = text => {
431
440
  const capitalized = text.split(/[^0-9a-z]/i).map(part => `${part[0].toUpperCase()}${part.slice(1)}`).join("");
@@ -606,13 +615,13 @@
606
615
  })
607
616
  };
608
617
 
609
- const SPECIAL_KEYS = ["home", "index", "show"]; // import routes from "common/routes", import routes from "routes"
618
+ const SPECIAL_KEYS = ["home", "index", "show"]; // import routes from "routes"
610
619
 
611
620
  const ROUTES_IMPORT_PATTERN = {
612
621
  type: TYPES.IMPORT_DECLARATION,
613
622
  source: {
614
623
  type: TYPES.LITERAL,
615
- value: matchesAny(["routes", "common/routes"])
624
+ value: matchesAny(["routes", "src/routes", "common/routes"])
616
625
  },
617
626
  specifiers: [{
618
627
  type: TYPES.IMPORT_DEFAULT_SPECIFIER,
@@ -623,7 +632,7 @@
623
632
  }]
624
633
  }; // const routes = { home: "/" }, const routes = "/", const routes = ["/"] etc
625
634
 
626
- const DECALARATION_PATTERN = {
635
+ const DECALARATION_PATTERN$1 = {
627
636
  type: TYPES.VARIABLE_DECLARATION,
628
637
  declarations: [{
629
638
  type: TYPES.VARIABLE_DECLARATOR,
@@ -636,7 +645,7 @@
636
645
 
637
646
  const OBJECT_DECALARATION_PATTERN = ramda.assocPath(["declarations", 0, "init"], {
638
647
  type: TYPES.OBJECT_EXPRESSION
639
- }, DECALARATION_PATTERN); // export const routes = { home: "/" }
648
+ }, DECALARATION_PATTERN$1); // export const routes = { home: "/" }
640
649
 
641
650
  const EXPORT_NAMED_DECLARATION_PATTERN = {
642
651
  type: TYPES.EXPORT_NAMED_DECLARATION,
@@ -755,7 +764,7 @@
755
764
  },
756
765
  create: context => ({
757
766
  VariableDeclaration(node) {
758
- if (matches(DECALARATION_PATTERN, node) && isRoutesImportPresent(context)) {
767
+ if (matches(DECALARATION_PATTERN$1, node) && isRoutesImportPresent(context)) {
759
768
  context.report(node, ROUTES_HAS_ALREADY_BEEN_DECLARED);
760
769
  }
761
770
  },
@@ -777,14 +786,14 @@
777
786
 
778
787
  const isInsideRoutesFile$1 = context => {
779
788
  const filename = context.getFilename();
780
- return filename.endsWith(ROUTES_FILE_PATH);
789
+ return ramda.any(ramda.endsWith(ramda.__, filename), ROUTES_FILE_PATHS);
781
790
  };
782
791
 
783
792
  var routesShouldBeDeclaredAndDefaultExported = {
784
793
  meta: {
785
794
  type: "problem",
786
795
  docs: {
787
- description: "common/routes.js file should declare a constant named routes and should be exported using default export"
796
+ description: "routes.js file should declare a constant named routes and should be exported using default export"
788
797
  }
789
798
  },
790
799
  create: context => ({
@@ -811,7 +820,7 @@
811
820
 
812
821
  const isInsideRoutesFile = context => {
813
822
  const filename = context.getFilename();
814
- return filename.endsWith(ROUTES_FILE_PATH);
823
+ return ramda.any(ramda.endsWith(ramda.__, filename), ROUTES_FILE_PATHS);
815
824
  };
816
825
 
817
826
  const isParam = e => e === null || e === void 0 ? void 0 : e.startsWith(":");
@@ -865,7 +874,7 @@
865
874
  },
866
875
  create: context => ({
867
876
  VariableDeclaration(node) {
868
- if (isInsideRoutesFile(context) && matches(DECALARATION_PATTERN, node)) {
877
+ if (isInsideRoutesFile(context) && matches(DECALARATION_PATTERN$1, node)) {
869
878
  const object = node.declarations[0].init;
870
879
  checkObjectPath(context, object);
871
880
  }
@@ -1121,7 +1130,7 @@
1121
1130
  };
1122
1131
 
1123
1132
  const CONSTANT_CASE_PATTERN = /^[A-Z0-9_]*$/;
1124
- const CONSTANTS_FILES = [/.*constants.(js|jsx)$/i, /app\/javascript\/src\/common\/urls.js$/];
1133
+ const CONSTANTS_FILES = [/constants\//, /.*constants.(js|jsx)$/i, /app\/javascript\/src\/common\/urls.js$/];
1125
1134
  const CONSTANT_DECALARATION_PATTERN = {
1126
1135
  kind: "const",
1127
1136
  declarations: [{
@@ -1193,6 +1202,117 @@
1193
1202
  })
1194
1203
  };
1195
1204
 
1205
+ const ZUSTAND_CREATE_IMPORT_PATTERN = {
1206
+ specifiers: [{
1207
+ type: TYPES.IMPORT_DEFAULT_SPECIFIER,
1208
+ local: {
1209
+ type: TYPES.IDENTIFIER,
1210
+ name: name => name !== "create"
1211
+ }
1212
+ }],
1213
+ source: {
1214
+ type: TYPES.LITERAL,
1215
+ value: "zustand"
1216
+ }
1217
+ }; // import somethingOtherThan_shallow from "zustand/shallow";
1218
+
1219
+ const ZUSTAND_SHALLOW_IMPORT_PATTERN = {
1220
+ specifiers: [{
1221
+ type: TYPES.IMPORT_DEFAULT_SPECIFIER,
1222
+ local: {
1223
+ type: TYPES.IDENTIFIER,
1224
+ name: name => name !== "shallow"
1225
+ }
1226
+ }],
1227
+ source: {
1228
+ type: TYPES.LITERAL,
1229
+ value: "zustand/shallow"
1230
+ }
1231
+ };
1232
+
1233
+ var ensureZustandImportNamesAreConsistent = {
1234
+ meta: {
1235
+ type: "error",
1236
+ docs: {
1237
+ description: "Throw error if zustand import names are not consistent"
1238
+ }
1239
+ },
1240
+ create: context => ({
1241
+ ImportDeclaration(node) {
1242
+ if (matches(ZUSTAND_CREATE_IMPORT_PATTERN, node)) {
1243
+ context.report({
1244
+ node,
1245
+ message: ENSURE_ZUSTAND_CREATE_IMPORT_ARE_CONSISTENT
1246
+ });
1247
+ } else if (matches(ZUSTAND_SHALLOW_IMPORT_PATTERN, node)) {
1248
+ context.report({
1249
+ node,
1250
+ message: ENSURE_ZUSTAND_SHALLOW_IMPORT_ARE_CONSISTENT
1251
+ });
1252
+ }
1253
+ }
1254
+
1255
+ })
1256
+ };
1257
+
1258
+ const storeImportPattern = () => ({
1259
+ specifiers: [{
1260
+ type: TYPES.IMPORT_DEFAULT_SPECIFIER,
1261
+ local: {
1262
+ type: TYPES.IDENTIFIER
1263
+ }
1264
+ }],
1265
+ source: {
1266
+ type: TYPES.LITERAL,
1267
+ value: "zustand"
1268
+ }
1269
+ });
1270
+
1271
+ const DECALARATION_PATTERN = [{
1272
+ type: TYPES.VARIABLE_DECLARATOR,
1273
+ init: {
1274
+ type: TYPES.CALL_EXPRESSION,
1275
+ callee: {
1276
+ type: TYPES.IDENTIFIER,
1277
+ name: (name, root) => name === "create" && existsBy$1(storeImportPattern(), getAllImports(root))
1278
+ },
1279
+ optional: false
1280
+ }
1281
+ }];
1282
+ const TYPE_ANNOTATION_COMMENT_PATTERN = [{
1283
+ type: "Block",
1284
+ value: "* @type {import(”neetocommons/react-utils”).ZustandStoreHook} "
1285
+ }]; // .....
1286
+ // const useCurrentUserStore = create(....);
1287
+
1288
+ const ZUSTAND_STORE_CREATE_PATTERN = {
1289
+ kind: "const",
1290
+ declarations: DECALARATION_PATTERN,
1291
+ parent: {
1292
+ type: TYPES.PROGRAM,
1293
+ comments: comments => !matches(TYPE_ANNOTATION_COMMENT_PATTERN, comments)
1294
+ }
1295
+ };
1296
+
1297
+ var ensureZustandStoresAreTypeAnnotated = {
1298
+ meta: {
1299
+ type: "error",
1300
+ docs: {
1301
+ description: "Throw error if zustand stores are not type annotated via JSDoc comments"
1302
+ }
1303
+ },
1304
+ create: context => ({
1305
+ VariableDeclaration(node) {
1306
+ if (!matches(ZUSTAND_STORE_CREATE_PATTERN, node)) return;
1307
+ context.report({
1308
+ node,
1309
+ message: ENSURE_ZUSTAND_STORES_ARE_TYPE_ANNOTATED
1310
+ });
1311
+ }
1312
+
1313
+ })
1314
+ };
1315
+
1196
1316
  const isWindows = typeof process === 'object' &&
1197
1317
  process &&
1198
1318
  process.platform === 'win32';
@@ -2402,10 +2522,11 @@
2402
2522
 
2403
2523
  const findMatchedConfig = (context, configs) => {
2404
2524
  const fullFilePath = context.getFilename();
2525
+ const basePath = context.options[0].basePath;
2405
2526
  const matchedConfig = configs.find(config => {
2406
- const isIncluded = asArray(config.includes).some(pathPattern => minimatch$1(fullFilePath, pathPattern));
2527
+ const isIncluded = asArray(config.includes).some(pathPattern => minimatch$1(fullFilePath, basePath + pathPattern));
2407
2528
  if (config.includes && !isIncluded) return false;
2408
- const isExcluded = asArray(config.excludes).some(pathPattern => minimatch$1(fullFilePath, pathPattern));
2529
+ const isExcluded = asArray(config.excludes).some(pathPattern => minimatch$1(fullFilePath, basePath + pathPattern));
2409
2530
  if (config.excludes && isExcluded) return false;
2410
2531
  return true;
2411
2532
  });
@@ -2647,24 +2768,7 @@
2647
2768
  })
2648
2769
  };
2649
2770
 
2650
- const storeImportPattern = name => ({
2651
- specifiers: [{
2652
- type: "ImportDefaultSpecifier",
2653
- local: {
2654
- type: TYPES.IDENTIFIER,
2655
- name
2656
- }
2657
- }],
2658
- source: {
2659
- type: TYPES.LITERAL,
2660
- value: ramda.startsWith("stores/")
2661
- }
2662
- }); // import useSampleStore from "stores/sampleStore";
2663
- // .....
2664
- // const { order } = useSampleStore();
2665
-
2666
-
2667
- const ZUSTAND_HOOK_USAGE_PATTERN = {
2771
+ const ZUSTAND_HOOK_USAGE_PATTERN$1 = {
2668
2772
  kind: "const",
2669
2773
  declarations: [{
2670
2774
  type: TYPES.VARIABLE_DECLARATOR,
@@ -2672,7 +2776,7 @@
2672
2776
  type: TYPES.CALL_EXPRESSION,
2673
2777
  callee: {
2674
2778
  type: TYPES.IDENTIFIER,
2675
- name: (name, root) => name.match(/use[a-zA-z0-9].+Store/) && existsBy$1(storeImportPattern(name), getAllImports(root))
2779
+ name: name => name.match(/use[a-zA-z0-9].+Store/)
2676
2780
  },
2677
2781
  arguments: ramda.isEmpty,
2678
2782
  optional: false
@@ -2689,7 +2793,7 @@
2689
2793
  },
2690
2794
  create: context => ({
2691
2795
  VariableDeclaration(node) {
2692
- if (!matches(ZUSTAND_HOOK_USAGE_PATTERN, node)) return;
2796
+ if (!matches(ZUSTAND_HOOK_USAGE_PATTERN$1, node)) return;
2693
2797
  context.report({
2694
2798
  node,
2695
2799
  message: DONT_USE_ZUSTAND_STORE_WITHOUT_SELECTOR
@@ -4458,9 +4562,9 @@
4458
4562
  return name === ((_root$params$9 = root.params[0]) === null || _root$params$9 === void 0 ? void 0 : _root$params$9.name);
4459
4563
  }
4460
4564
  },
4461
- property: {
4462
- type: TYPES.IDENTIFIER
4463
- }
4565
+ property: property => matches({
4566
+ type: ramda.includes(ramda.__, [TYPES.IDENTIFIER, TYPES.LITERAL])
4567
+ }, property)
4464
4568
  }
4465
4569
  },
4466
4570
  DESTRUCTURE: {
@@ -4557,7 +4661,7 @@
4557
4661
  value: 0
4558
4662
  }]
4559
4663
  };
4560
- const RAMDA_IMPORT_PATTERN = {
4664
+ const RAMDA_IMPORT_PATTERN$1 = {
4561
4665
  type: TYPES.IMPORT_DECLARATION,
4562
4666
  source: {
4563
4667
  type: TYPES.LITERAL,
@@ -4610,7 +4714,7 @@
4610
4714
  }
4611
4715
  }];
4612
4716
 
4613
- const replacer = nodeReplacerWithImports(RAMDA_IMPORT_PATTERN);
4717
+ const replacer = nodeReplacerWithImports(RAMDA_IMPORT_PATTERN$1);
4614
4718
  const reportSuggestion = ({
4615
4719
  context,
4616
4720
  node,
@@ -4799,7 +4903,9 @@
4799
4903
  let fix = null;
4800
4904
 
4801
4905
  if (matches(PLUCK_PATTERNS.IDENTIFIER, func)) {
4802
- fix = `${callee}("${func.body.property.name}", ${code})`;
4906
+ const property = func.body.property;
4907
+ const subtitute = property.type === TYPES.IDENTIFIER && func.body.computed ? property.name : `"${func.body.computed ? property.value : property.name}"`;
4908
+ fix = `${callee}(${subtitute}, ${code})`;
4803
4909
  } else if (matches(PLUCK_PATTERNS.DESTRUCTURE, func)) {
4804
4910
  const propertyName = func.params[0].properties[0].value.name;
4805
4911
  fix = `${callee}("${propertyName}", ${code})`;
@@ -5274,6 +5380,172 @@
5274
5380
  })
5275
5381
  };
5276
5382
 
5383
+ const PICK_PATTERN$1 = [{
5384
+ type: TYPES.CALL_EXPRESSION,
5385
+ callee: {
5386
+ type: TYPES.IDENTIFIER,
5387
+ name: "pick"
5388
+ },
5389
+ optional: false
5390
+ }]; // const { order, user } = useSampleStore((state) => ({ order: state.order, user: state.user }));
5391
+ // const [ order, user ] = useSampleStore((state) => [state.order, state.user]);
5392
+
5393
+ const ARROW_FUNCTION_PATTERN = [{
5394
+ type: TYPES.ARROW_FUNCTION_EXPRESSION,
5395
+ params: [{
5396
+ type: TYPES.IDENTIFIER
5397
+ }]
5398
+ }];
5399
+ const ZUSTAND_HOOK_USAGE_PATTERN = {
5400
+ kind: "const",
5401
+ declarations: [{
5402
+ type: TYPES.VARIABLE_DECLARATOR,
5403
+ init: {
5404
+ type: TYPES.CALL_EXPRESSION,
5405
+ callee: {
5406
+ type: TYPES.IDENTIFIER,
5407
+ name: name => name.match(/use[a-zA-z0-9].+Store/)
5408
+ },
5409
+ arguments: args => args.length === 1 && (matches(PICK_PATTERN$1, args) || matches(ARROW_FUNCTION_PATTERN, args))
5410
+ }
5411
+ }]
5412
+ };
5413
+
5414
+ var zustandRecommendComparatorFunctionUsage = {
5415
+ meta: {
5416
+ type: "warn",
5417
+ docs: {
5418
+ description: "Warn about the usage of picking multiple state items without comparator function from inside zustand store hooks"
5419
+ }
5420
+ },
5421
+ create: context => ({
5422
+ VariableDeclaration(node) {
5423
+ if (!matches(ZUSTAND_HOOK_USAGE_PATTERN, node)) return;
5424
+ context.report({
5425
+ node,
5426
+ message: DONT_USE_ZUSTAND_STORE_WITHOUT_COMPARATOR_FUNCTION
5427
+ });
5428
+ }
5429
+
5430
+ })
5431
+ };
5432
+
5433
+ // const order = useSampleStore(pick(["order"]), shallow);
5434
+ // const order = useSampleStore(pick([order]));
5435
+ // const order = useSampleStore(pick([order]), shallow);
5436
+
5437
+ const PICK_PATTERN = [{
5438
+ type: TYPES.CALL_EXPRESSION,
5439
+ callee: {
5440
+ type: TYPES.IDENTIFIER,
5441
+ name: "pick"
5442
+ },
5443
+ arguments: [{
5444
+ type: TYPES.ARRAY_EXPRESSION,
5445
+ elements: elements => elements.length === 1 && (matches([{
5446
+ type: TYPES.LITERAL
5447
+ }], elements) || matches([{
5448
+ type: TYPES.IDENTIFIER
5449
+ }], elements))
5450
+ }]
5451
+ }];
5452
+ const ZUSTAND_PICK_USAGE_PATTERN = {
5453
+ init: {
5454
+ type: TYPES.CALL_EXPRESSION,
5455
+ callee: {
5456
+ type: TYPES.IDENTIFIER,
5457
+ name: name => name.match(/use[a-zA-z0-9].+Store/)
5458
+ },
5459
+ arguments: PICK_PATTERN,
5460
+ optional: false
5461
+ }
5462
+ }; // import { ... } from 'ramda';
5463
+
5464
+ const RAMDA_IMPORT_PATTERN = {
5465
+ type: TYPES.IMPORT_DECLARATION,
5466
+ specifiers: [{
5467
+ type: TYPES.IMPORT_SPECIFIER,
5468
+ local: {
5469
+ type: TYPES.IDENTIFIER
5470
+ }
5471
+ }],
5472
+ source: {
5473
+ type: TYPES.LITERAL,
5474
+ value: "ramda"
5475
+ }
5476
+ }; // pick()
5477
+
5478
+ const PICK_PATTERN_SHORT = {
5479
+ type: TYPES.CALL_EXPRESSION,
5480
+ callee: {
5481
+ type: TYPES.IDENTIFIER,
5482
+ name: "pick"
5483
+ }
5484
+ }; // import { prop }
5485
+
5486
+ const PROP_IMPORT_PATTERN = {
5487
+ type: TYPES.IMPORT_SPECIFIER,
5488
+ imported: {
5489
+ type: TYPES.IDENTIFIER,
5490
+ name: "prop"
5491
+ }
5492
+ }; // useCurrentUserStore()
5493
+
5494
+ const findProgramNode = node => {
5495
+ const parentNode = node === null || node === void 0 ? void 0 : node.parent;
5496
+ if ((parentNode === null || parentNode === void 0 ? void 0 : parentNode.type) === TYPES.PROGRAM) return parentNode;
5497
+ return findProgramNode(parentNode);
5498
+ };
5499
+ const findRamdaSpecifiers = programNode => {
5500
+ const ramdaImportDeclaration = programNode.body.find(matches(RAMDA_IMPORT_PATTERN));
5501
+ const {
5502
+ specifiers: specifiersNode
5503
+ } = ramdaImportDeclaration;
5504
+ return specifiersNode[0];
5505
+ };
5506
+
5507
+ var zustandUsePropToPickSingleItem = {
5508
+ meta: {
5509
+ type: "error",
5510
+ docs: {
5511
+ description: "Throw error if pick function is used to pick a single item"
5512
+ },
5513
+ fixable: "code"
5514
+ },
5515
+ create: context => ({
5516
+ VariableDeclarator(node) {
5517
+ if (!matches(ZUSTAND_PICK_USAGE_PATTERN, node)) return;
5518
+ const pickNode = findMatchingNodesDeep(node, PICK_PATTERN_SHORT)[0];
5519
+ const item = pickNode.arguments[0].elements[0];
5520
+ const substitute = item.type === TYPES.IDENTIFIER ? item.name : `"${item.value}"`;
5521
+ const fix = `prop(${substitute})`;
5522
+ const programNode = findProgramNode(node);
5523
+ const importSpecifierNode = findRamdaSpecifiers(programNode);
5524
+ const comparatorFunctionNode = node.init.arguments[1];
5525
+ const propImportNode = findMatchingNodesDeep(context.getSourceCode().ast.body, PROP_IMPORT_PATTERN);
5526
+ context.report({
5527
+ node,
5528
+ message: USE_PROP_FOR_PICKING_SINGLE_ITEM,
5529
+ fix: fixer => {
5530
+ const fixerArray = [];
5531
+ fixerArray.push(fixer.replaceText(pickNode, fix));
5532
+
5533
+ if (propImportNode.length === 0) {
5534
+ fixerArray.push(fixer.insertTextAfter(importSpecifierNode, ", prop"));
5535
+ }
5536
+
5537
+ if (comparatorFunctionNode) {
5538
+ fixerArray.push(fixer.remove(comparatorFunctionNode));
5539
+ }
5540
+
5541
+ return fixerArray;
5542
+ }
5543
+ });
5544
+ }
5545
+
5546
+ })
5547
+ };
5548
+
5277
5549
  var index = {
5278
5550
  rules: {
5279
5551
  "minimize-zustand-store-access-scope": minimizeZustandStoreAccessScope,
@@ -5281,6 +5553,8 @@
5281
5553
  "api-connector-should-use-default-export": apiConnectorShouldUseDefaultExport,
5282
5554
  "combine-multiple-independent-awaits": combineMultipleIndependentAwaits,
5283
5555
  "consistent-button-link-anchor": consistentButtonLinkAnchor,
5556
+ "ensure-zustand-stores-are-type-annotated": ensureZustandStoresAreTypeAnnotated,
5557
+ "ensure-zustand-import-names-are-consistent": ensureZustandImportNamesAreConsistent,
5284
5558
  "file-name-and-export-name-standards": fileNameAndExportNameStandards,
5285
5559
  "neetocommons-tips": neetocommonsTips,
5286
5560
  "no-blacklisted-imports": noBlacklistedImports,
@@ -5305,7 +5579,9 @@
5305
5579
  "use-neetoui-classes": useNeetouiClasses,
5306
5580
  "use-snake-case-for-api-connector-filename": useSnakeCaseForApiConnectorFilename,
5307
5581
  "use-webpack-alias": useWebpackAlias,
5308
- "webpack-aliases-and-jsconfig-paths-should-be-in-sync": webpackAliasesAndJsconfigPathsShouldBeInSync
5582
+ "webpack-aliases-and-jsconfig-paths-should-be-in-sync": webpackAliasesAndJsconfigPathsShouldBeInSync,
5583
+ "zustand-recommend-comparator-function-usage": zustandRecommendComparatorFunctionUsage,
5584
+ "zustand-use-prop-to-pick-single-item": zustandUsePropToPickSingleItem
5309
5585
  }
5310
5586
  };
5311
5587
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/eslint-plugin-neeto",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "main": "dist/index.js",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {