@bigbinary/eslint-plugin-neeto 1.0.11 → 1.0.13

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 +68 -39
  2. package/dist/index.js +2077 -654
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2,177 +2,11 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('path'), require('ramda')) :
3
3
  typeof define === 'function' && define.amd ? define(['path', 'ramda'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["@bigbinary/eslint-plugin-neeto"] = factory(global.path, global.ramda));
5
- })(this, (function (path, require$$0) { 'use strict';
5
+ })(this, (function (path, ramda) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
10
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
11
-
12
- const APIS_DIRECTORY = "app/javascript/src/apis";
13
- const BLACKLISTED_PACKAGES = ["moment", "bootstrap", "blueprint", "react-spinners", "react-table", "remixicon", "mjml", "react-select", "antd"];
14
- const TYPES = {
15
- ARRAY_EXPRESSION: "ArrayExpression",
16
- ASSIGNMENT_PATTERN: "AssignmentPattern",
17
- AWAIT_EXPRESSION: "AwaitExpression",
18
- EXPORT_NAMED_DECLARATION: "ExportNamedDeclaration",
19
- IDENTIFIER: "Identifier",
20
- LITERAL: "Literal",
21
- MEMBER_EXPRESSION: "MemberExpression",
22
- OBJECT_EXPRESSION: "ObjectExpression",
23
- OBJECT_PATTERN: "ObjectPattern",
24
- PROGRAM: "Program",
25
- PROPERTY: "Property",
26
- SPREAD_ELEMENT: "SpreadElement",
27
- TEMPLATE_LITERAL: "TemplateLiteral",
28
- VARIABLE_DECLARATOR: "VariableDeclarator",
29
- JSX_ATTRIBUTE: "JSXAttribute",
30
- JSX_ELEMENT: "JSXElement",
31
- JSX_EXPRESSION_CONTAINER: "JSXExpressionContainer"
32
- };
33
-
34
- /**
35
- * @param {Object} context - ESLint context
36
- * @param {Object} node - AST node
37
- * @returns the source code corresponding to the supplied node.
38
- */
39
-
40
- const getCode = (context, node) => context.getSourceCode().text.substr(node.range[0], node.range[1] - node.range[0]);
41
- /**
42
- * Checks if the specified package is imported or not
43
- * using the package name or any alias
44
- * @param {Object} context eslint context
45
- * @returns an array containing the filename and the extension
46
- */
47
-
48
- const getFilenameAndExtension = context => {
49
- const fullFilename = context.getFilename().replace(/.*\//, "");
50
- const splitFilename = fullFilename.split(".");
51
- const extension = splitFilename.pop();
52
- return [splitFilename.join("."), extension];
53
- };
54
- /**
55
- * @param {Object} context eslint context
56
- * @param {string[]} packages list of npm packages to check
57
- * @returns the supplied list of packages and all aliases pointing to
58
- * those packages or their subdirectories.
59
- */
60
-
61
- const getPackagesAndAliases = (context, packages) => Object.entries(context.options[0] ?? {}).reduce((acc, [key, value]) => packages.some(pckg => value === pckg || value.startsWith(`${pckg}/`)) ? require$$0.append(key, acc) : acc, packages);
62
- /**
63
- * Checks if the file is inside the `apis` directory or not
64
- * @param {Object} context eslint context
65
- * @returns true if file is inside the `apis` directory
66
- */
67
-
68
- const isInsideApisDirectory = context => {
69
- const filename = context.getFilename();
70
- const apisDirectory = path__default["default"].resolve(APIS_DIRECTORY);
71
- return filename.startsWith(apisDirectory) && filename !== `${apisDirectory}/axios.js`;
72
- };
73
- /**
74
- * Checks if the specified package is imported or not
75
- * using the package name or any alias
76
- * @param {Object} context eslint context
77
- * @param {Object} node ImportDeclaration node to be checked
78
- * @param {string} packageName name of the package to be checked
79
- * @returns true if the specified package is imported
80
- */
81
-
82
- const isPackageImported = (context, node, packageName) => getPackagesAndAliases(context, [packageName]).includes(node.source.value);
83
-
84
- const ARGUMENT_LIMIT = 3;
85
- const API_ACTIONS_ARGUMENT_LIMIT = 2;
86
- const FIXABLE_PARAMETER_TYPES = [TYPES.IDENTIFIER, TYPES.ASSIGNMENT_PATTERN];
87
-
88
- const canBeReplacedWith = fix => `Can be replaced with: ${fix}`;
89
- const disallowUse = packageName => `Do not use the package ${packageName}`;
90
- const moveToConstantsJs = constantName => `Move the constant ${constantName} to a constants.js file.`;
91
- const renameFile = filename => `Rename this file to ${filename}`;
92
- const replaceWith = fix => `Replace this with: ${fix}`;
93
- const unableToResolveKey = ({
94
- key,
95
- fileName
96
- }) => `Unable to resolve localized string '${key}' in ${fileName}`;
97
- const useConstantCaseFor = constantName => `Use constant-case for naming the constant - ${constantName}.`;
98
- const API_CONNECTOR_SHOULD_USE_DEFAULT_EXPORT_MESSAGE = "API Connector should be exported using the default export method";
99
- const COMBINE_MULTIPLE_INDEPENDENT_AWAITS_MESSAGE = "Combine independent awaits to a single `Promise.all` call.";
100
- const GLOBALPROPS_NO_ASSIGNMENT_MESSAGE = "globalProps should not be assigned to other variables";
101
- const NESTED_GLOBALPROPS_NO_ASSIGNMENT_MESSAGE = "Nested properties of globalProps should not be assigned to other variables";
102
- const NO_AXIOS_IMPORT_OUTSIDE_APIS_MESSAGE = "Do not use axios outside `app/javascript/src/apis`";
103
- const NO_DANGLING_FUNCTIONS_MESSAGE = "Exporting functions from this file is not allowed.";
104
- const NO_EXCESS_API_ACTION_ARGUMENTS_MESSAGE = `API actions should use named parameters for more than ${API_ACTIONS_ARGUMENT_LIMIT} parameters`;
105
- const NO_EXCESS_FUNCTION_ARGUMENTS_MESSAGE = `Functions should use named parameters for more than ${ARGUMENT_LIMIT} parameters`;
106
- const NO_GLOBALPROPS_REASSIGNMENT_MESSAGE = "globalProps or its nested properties should not be re-assigned.";
107
- const NO_NAMESPACE_SPECIFIER_IMPORT_FOR_RAMDA_MESSAGE = 'Use `import { methodsToImport } from "ramda"` instead';
108
- const PREFIX_NEETO_UI_IMPORT_ALIAS_MESSAGE = "Aliases for anything imported from neetoUI or neetoIcons should start with `NeetoUI`";
109
- const USE_AXIOS_CONFIG_FOR_PASSING_QUERY_PARAMETERS_MESSAGE = "Use 'params attribute in axios configuration' to pass query parameters.";
110
-
111
- const toCamelCase = text => {
112
- const capitalized = text.split(/[^0-9a-z]/i).map(part => `${part[0].toUpperCase()}${part.slice(1)}`).join("");
113
- return `${capitalized[0].toLowerCase()}${capitalized.slice(1)}`;
114
- };
115
-
116
- var apiConnectorNameShouldMatchFilename = {
117
- meta: {
118
- type: "problem",
119
- docs: {
120
- description: "API Connector should be named after the filename"
121
- },
122
- fixable: "code"
123
- },
124
- create: context => ({
125
- ExportDefaultDeclaration(node) {
126
- if (!isInsideApisDirectory(context)) return;
127
- const {
128
- declaration
129
- } = node;
130
- const [fileName] = getFilenameAndExtension(context);
131
- const validApiConnectorName = `${toCamelCase(fileName)}Api`;
132
- if (validApiConnectorName === declaration.name) return;
133
- context.report({
134
- node: declaration,
135
- message: replaceWith(validApiConnectorName),
136
- fix: fixer => fixer.replaceText(declaration, validApiConnectorName)
137
- });
138
- }
139
-
140
- })
141
- };
142
-
143
- const checkAndReport$5 = (context, node) => {
144
- if (!isInsideApisDirectory(context)) return;
145
- context.report({
146
- node,
147
- message: API_CONNECTOR_SHOULD_USE_DEFAULT_EXPORT_MESSAGE
148
- });
149
- };
150
-
151
- var apiConnectorShouldUseDefaultExport = {
152
- meta: {
153
- type: "problem",
154
- docs: {
155
- description: "API Connector should be exported using the default export method"
156
- }
157
- },
158
- create: context => ({
159
- ExportNamedDeclaration(node) {
160
- checkAndReport$5(context, node);
161
- },
162
-
163
- ExportDefaultDeclaration(node) {
164
- if (node.declaration.type !== TYPES.OBJECT_EXPRESSION) return;
165
- checkAndReport$5(context, node);
166
- }
167
-
168
- })
169
- };
170
-
171
- var pure = {};
172
-
173
- Object.defineProperty(pure, '__esModule', { value: true });
174
-
175
- var ramda = require$$0__default["default"];
176
10
 
177
11
  function _arrayWithHoles(arr) {
178
12
  if (Array.isArray(arr)) return arr;
@@ -244,104 +78,21 @@
244
78
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
245
79
  }, _typeof(obj);
246
80
  }
247
-
248
- var slugify = function slugify(string) {
249
- return string.toString().toLowerCase().replace(/\s+/g, "-") // Replace spaces with -
250
- .replace(/&/g, "-and-") // Replace & with 'and'
251
- .replace(/[^\w-]+/g, "") // Remove all non-word characters
252
- .replace(/--+/g, "-") // Replace multiple - with single -
253
- .replace(/^-+/, "") // Trim - from start of text
254
- .replace(/-+$/, "");
255
- }; // Trim - from end of text
256
-
257
- var humanize = function humanize(string) {
258
- string = string.replace(/[_-]+/g, " ").replace(/\s{2,}/g, " ").replace(/([a-z\d])([A-Z])/g, "$1" + " " + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + " " + "$2").toLowerCase().trim();
259
- string = string.charAt(0).toUpperCase() + string.slice(1);
260
- return string;
261
- };
262
- var snakeToCamelCase = function snakeToCamelCase(string) {
263
- return string.replace(/(_\w)/g, function (letter) {
264
- return letter[1].toUpperCase();
265
- });
266
- };
267
- var camelToSnakeCase = function camelToSnakeCase(string) {
268
- return string.replace(/[A-Z]/g, function (letter) {
269
- return "_".concat(letter.toLowerCase());
270
- });
271
- };
272
- var capitalize = function capitalize(string) {
273
- return string.charAt(0).toUpperCase() + string.slice(1);
274
- };
275
- var truncate = function truncate() {
276
- var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
277
- var length = arguments.length > 1 ? arguments[1] : undefined;
278
- return string.length > length ? ramda.concat(ramda.slice(0, length, string), "...") : string;
279
- };
280
-
281
- var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
282
- if (Array.isArray(object)) {
283
- return object.map(function (obj) {
284
- return transformObjectDeep(obj, keyValueTransformer);
285
- });
286
- } else if (object === null || _typeof(object) !== "object") {
287
- return object;
288
- }
289
-
290
- return Object.fromEntries(Object.entries(object).map(function (_ref) {
291
- var _ref2 = _slicedToArray(_ref, 2),
292
- key = _ref2[0],
293
- value = _ref2[1];
294
-
295
- return keyValueTransformer(key, transformObjectDeep(value, keyValueTransformer));
296
- }));
297
- };
298
- var keysToCamelCase = function keysToCamelCase(object) {
299
- return transformObjectDeep(object, function (key, value) {
300
- return [snakeToCamelCase(key), value];
301
- });
302
- };
303
- var keysToSnakeCase = function keysToSnakeCase(object) {
304
- return transformObjectDeep(object, function (key, value) {
305
- return [camelToSnakeCase(key), value];
306
- });
307
- };
308
- var deepFreezeObject = function deepFreezeObject(object) {
309
- if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
310
- Object.keys(object).forEach(function (property) {
311
- return deepFreezeObject(object[property]);
312
- });
313
- Object.freeze(object);
314
- }
315
-
316
- return object;
317
- };
318
81
  var matches = ramda.curry(function (pattern, object) {
82
+ var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
83
+
319
84
  if (object === pattern) return true;
320
- if (typeof pattern === "function" && pattern(object)) return true;
85
+ if (typeof pattern === "function" && pattern(object, __parent)) return true;
321
86
  if (ramda.isNil(pattern) || ramda.isNil(object)) return false;
322
87
  if (_typeof(pattern) !== "object") return false;
323
- return Object.entries(pattern).every(function (_ref3) {
324
- var _ref4 = _slicedToArray(_ref3, 2),
325
- key = _ref4[0],
326
- value = _ref4[1];
88
+ return Object.entries(pattern).every(function (_ref5) {
89
+ var _ref6 = _slicedToArray(_ref5, 2),
90
+ key = _ref6[0],
91
+ value = _ref6[1];
327
92
 
328
- return matches(value, object[key]);
93
+ return matches(value, object[key], __parent);
329
94
  });
330
95
  });
331
- var filterNonNull = function filterNonNull(object) {
332
- return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
333
- var _ref6 = _slicedToArray(_ref5, 2),
334
- v = _ref6[1];
335
-
336
- return !ramda.isNil(v);
337
- }).map(function (_ref7) {
338
- var _ref8 = _slicedToArray(_ref7, 2),
339
- k = _ref8[0],
340
- v = _ref8[1];
341
-
342
- return [k, _typeof(v) === "object" && !Array.isArray(v) ? filterNonNull(v) : v];
343
- }));
344
- };
345
96
 
346
97
  function _defineProperty(obj, key, value) {
347
98
  if (key in obj) {
@@ -361,71 +112,71 @@
361
112
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
362
113
 
363
114
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
364
- var removeById = ramda.curry(function (id, array) {
115
+ ramda.curry(function (id, array) {
365
116
  return array.filter(function (item) {
366
117
  return item.id !== id;
367
118
  });
368
119
  });
369
- var findById = ramda.curry(function (id, array) {
120
+ ramda.curry(function (id, array) {
370
121
  return array.find(function (item) {
371
122
  return item.id === id;
372
123
  });
373
124
  });
374
- var replaceById = ramda.curry(function (id, newItem, array) {
125
+ ramda.curry(function (id, newItem, array) {
375
126
  return array.map(function (item) {
376
127
  return item.id === id ? newItem : item;
377
128
  });
378
129
  });
379
- var modifyById = ramda.curry(function (id, modifier, array) {
130
+ ramda.curry(function (id, modifier, array) {
380
131
  return array.map(function (item) {
381
132
  return item.id === id ? modifier(item) : item;
382
133
  });
383
134
  });
384
- var findBy = ramda.curry(function (pattern, array) {
135
+ ramda.curry(function (pattern, array) {
385
136
  return array.find(matches(pattern));
386
137
  });
387
- var removeBy = ramda.curry(function (pattern, array) {
138
+ ramda.curry(function (pattern, array) {
388
139
  return array.filter(ramda.complement(matches(pattern)));
389
140
  });
390
- var replaceBy = ramda.curry(function (pattern, newItem, array) {
141
+ ramda.curry(function (pattern, newItem, array) {
391
142
  return array.map(function (item) {
392
143
  return matches(pattern, item) ? newItem : item;
393
144
  });
394
145
  });
395
- var modifyBy = ramda.curry(function (pattern, modifier, array) {
146
+ ramda.curry(function (pattern, modifier, array) {
396
147
  return array.map(function (item) {
397
148
  return matches(pattern, item) ? modifier(item) : item;
398
149
  });
399
150
  });
400
- var existsById = ramda.curry(function (id, array) {
151
+ ramda.curry(function (id, array) {
401
152
  return array.some(function (item) {
402
153
  return item.id === id;
403
154
  });
404
155
  });
405
- var existsBy = ramda.curry(function (pattern, array) {
156
+ var existsBy$1 = ramda.curry(function (pattern, array) {
406
157
  return array.some(matches(pattern));
407
158
  });
408
- var findLastBy = ramda.curry(function (pattern, array) {
159
+ ramda.curry(function (pattern, array) {
409
160
  return ramda.findLast(matches(pattern), array);
410
161
  });
411
- var findIndexById = ramda.curry(function (id, array) {
162
+ ramda.curry(function (id, array) {
412
163
  return array.findIndex(function (item) {
413
164
  return item.id === id;
414
165
  });
415
166
  });
416
- var findIndexBy = ramda.curry(function (pattern, array) {
167
+ ramda.curry(function (pattern, array) {
417
168
  return array.findIndex(matches(pattern));
418
169
  });
419
- var findLastIndexBy = ramda.curry(function (pattern, array) {
170
+ ramda.curry(function (pattern, array) {
420
171
  return ramda.findLastIndex(matches(pattern), array);
421
172
  });
422
- var filterBy = ramda.curry(function (pattern, array) {
173
+ ramda.curry(function (pattern, array) {
423
174
  return array.filter(matches(pattern));
424
175
  });
425
- var countBy = ramda.curry(function (pattern, array) {
176
+ ramda.curry(function (pattern, array) {
426
177
  return ramda.count(matches(pattern), array);
427
178
  });
428
- var copyKeys = ramda.curry(function (keyMap, objectArray) {
179
+ ramda.curry(function (keyMap, objectArray) {
429
180
  return objectArray.map(function (object) {
430
181
  var shallowCopy = _objectSpread({}, object);
431
182
 
@@ -436,7 +187,7 @@
436
187
  return shallowCopy;
437
188
  });
438
189
  });
439
- var renameKeys = ramda.curry(function (keyMap, objectArray) {
190
+ ramda.curry(function (keyMap, objectArray) {
440
191
  return objectArray.map(function (object) {
441
192
  var shallowCopy = _objectSpread({}, object);
442
193
 
@@ -448,7 +199,7 @@
448
199
  return shallowCopy;
449
200
  });
450
201
  });
451
- var copyKeysDeep = ramda.curry(function (keyMap, objectArray) {
202
+ ramda.curry(function (keyMap, objectArray) {
452
203
  var copyKeysSingleObject = function copyKeysSingleObject(object, keyMap) {
453
204
  var root = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
454
205
  return _objectSpread(_objectSpread({}, object), ramda.fromPairs(ramda.toPairs(keyMap).map(function (_ref) {
@@ -472,122 +223,262 @@
472
223
  return copyKeysSingleObject(object, keyMap);
473
224
  });
474
225
  });
475
-
476
- var noop = function noop() {};
477
- var toLabelAndValue = function toLabelAndValue(string) {
478
- return {
479
- label: string,
480
- value: string
481
- };
482
- };
483
- var getRandomInt = function getRandomInt() {
484
- var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Number.MAX_SAFE_INTEGER;
485
- var b = arguments.length > 1 ? arguments[1] : undefined;
486
-
487
- if (b) {
488
- a = Math.ceil(a);
489
- b = Math.floor(b);
490
- } else {
491
- b = a;
492
- a = 0;
493
- }
494
-
495
- return Math.floor(Math.random() * (b - a) + a);
496
- };
497
- var randomPick = function randomPick() {
498
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
499
- args[_key] = arguments[_key];
500
- }
501
-
502
- var randomNumber = getRandomInt(0, args.length);
503
- return args[randomNumber];
504
- };
505
- var dynamicArray = function dynamicArray(count, elementGenerator) {
506
- return Array.from({
507
- length: count
508
- }, function (_, index) {
509
- return elementGenerator(index);
510
- });
511
- };
512
- var isNotNil = ramda.complement(ramda.isNil);
513
- var isNotEmpty = ramda.complement(ramda.isEmpty);
226
+ ramda.complement(ramda.isNil);
227
+ var isNotEmpty$1 = ramda.complement(ramda.isEmpty);
514
228
  var notEquals = ramda.curry(function (x, y) {
515
229
  return x !== y;
516
230
  });
517
- var isNot = notEquals;
518
- var notEqualsDeep = ramda.complement(ramda.equals);
519
- var isNotEqualDeep = notEqualsDeep;
520
-
521
- pure.camelToSnakeCase = camelToSnakeCase;
522
- pure.capitalize = capitalize;
523
- pure.copyKeys = copyKeys;
524
- pure.copyKeysDeep = copyKeysDeep;
525
- pure.countBy = countBy;
526
- pure.deepFreezeObject = deepFreezeObject;
527
- pure.dynamicArray = dynamicArray;
528
- pure.existsBy = existsBy;
529
- pure.existsById = existsById;
530
- pure.filterBy = filterBy;
531
- pure.filterNonNull = filterNonNull;
532
- pure.findBy = findBy;
533
- pure.findById = findById;
534
- pure.findIndexBy = findIndexBy;
535
- pure.findIndexById = findIndexById;
536
- pure.findLastBy = findLastBy;
537
- pure.findLastIndexBy = findLastIndexBy;
538
- pure.getRandomInt = getRandomInt;
539
- pure.humanize = humanize;
540
- pure.isNot = isNot;
541
- pure.isNotEmpty = isNotEmpty;
542
- pure.isNotEqualDeep = isNotEqualDeep;
543
- pure.isNotNil = isNotNil;
544
- pure.keysToCamelCase = keysToCamelCase;
545
- pure.keysToSnakeCase = keysToSnakeCase;
546
- var matches_1 = pure.matches = matches;
547
- pure.modifyBy = modifyBy;
548
- pure.modifyById = modifyById;
549
- pure.noop = noop;
550
- pure.notEquals = notEquals;
551
- pure.notEqualsDeep = notEqualsDeep;
552
- pure.randomPick = randomPick;
553
- pure.removeBy = removeBy;
554
- pure.removeById = removeById;
555
- pure.renameKeys = renameKeys;
556
- pure.replaceBy = replaceBy;
557
- pure.replaceById = replaceById;
558
- pure.slugify = slugify;
559
- pure.snakeToCamelCase = snakeToCamelCase;
560
- pure.toLabelAndValue = toLabelAndValue;
561
- pure.transformObjectDeep = transformObjectDeep;
562
- pure.truncate = truncate;
231
+ var isNot$1 = notEquals;
232
+ ramda.complement(ramda.equals);
233
+
234
+ const APIS_DIRECTORY = "app/javascript/src/apis";
235
+ const ROUTES_FILE_PATH = "app/javascript/src/common/routes.js";
236
+ const BLACKLISTED_PACKAGES = ["moment", "bootstrap", "blueprint", "react-spinners", "react-table", "remixicon", "mjml", "react-select", "antd"];
237
+ const TYPES = {
238
+ ARRAY_EXPRESSION: "ArrayExpression",
239
+ ARROW_FUNCTION_EXPRESSION: "ArrowFunctionExpression",
240
+ ASSIGNMENT_PATTERN: "AssignmentPattern",
241
+ AWAIT_EXPRESSION: "AwaitExpression",
242
+ BINARY_EXPRESSION: "BinaryExpression",
243
+ CALL_EXPRESSION: "CallExpression",
244
+ EXPORT_NAMED_DECLARATION: "ExportNamedDeclaration",
245
+ EXPORT_DEFAULT_DECLARATION: "ExportDefaultDeclaration",
246
+ IDENTIFIER: "Identifier",
247
+ IF_STATEMENT: "IfStatement",
248
+ IMPORT_DECLARATION: "ImportDeclaration",
249
+ IMPORT_DEFAULT_SPECIFIER: "ImportDefaultSpecifier",
250
+ LITERAL: "Literal",
251
+ LOGICAL_EXPRESSION: "LogicalExpression",
252
+ MEMBER_EXPRESSION: "MemberExpression",
253
+ OBJECT_EXPRESSION: "ObjectExpression",
254
+ OBJECT_PATTERN: "ObjectPattern",
255
+ PROGRAM: "Program",
256
+ PROPERTY: "Property",
257
+ SPREAD_ELEMENT: "SpreadElement",
258
+ TEMPLATE_LITERAL: "TemplateLiteral",
259
+ UNARY_EXPRESSION: "UnaryExpression",
260
+ VARIABLE_DECLARATION: "VariableDeclaration",
261
+ VARIABLE_DECLARATOR: "VariableDeclarator",
262
+ WHILE_STATEMENT: "WhileStatement",
263
+ JSX_ATTRIBUTE: "JSXAttribute",
264
+ JSX_ELEMENT: "JSXElement",
265
+ JSX_EXPRESSION_CONTAINER: "JSXExpressionContainer",
266
+ JSX_IDENTIFIER: "JSXIdentifier"
267
+ };
268
+ const IMPORT_DECLARATION = {
269
+ type: "ImportDeclaration",
270
+ source: {
271
+ type: "Literal"
272
+ },
273
+ specifiers: [{
274
+ type: "ImportSpecifier"
275
+ }]
276
+ };
563
277
 
564
278
  /**
565
- * Returns a list of nodes that matches the pattern
566
- * somewhere deep inside the given object-tree by
567
- * partial object matching.
568
- *
569
- * @param {Object} obj the object tree to check
570
- * @param {Object} pattern the pattern to match partially
571
- * @param {Array} res list of nodes that matches the pattern
279
+ * @param {Object} context - ESLint context
280
+ * @param {Object} node - AST node
281
+ * @returns the source code corresponding to the supplied node.
572
282
  */
573
283
 
574
- const findMatchingNodesDeep = (obj, pattern, res = []) => {
575
- if (typeof obj !== "object" || require$$0.isNil(obj)) return res;
576
- if (matches_1(pattern, obj)) return require$$0.append(obj, res);
577
- return Object.entries(obj).reduce((acc, [key, value]) => {
578
- if (key === "parent") return acc;
579
- return findMatchingNodesDeep(value, pattern, acc);
580
- }, res);
581
- };
284
+ const getCode$1 = (context, node) => context.getSourceCode().text.substr(node.range[0], node.range[1] - node.range[0]);
582
285
  /**
583
- * Checks if any of the given pattern matches the object.
584
- * @param {Object} obj The object tree to check.
585
- * @param {Object[]} list The list of patterns to compare against.
586
- * also @see matches
286
+ * Checks if the specified package is imported or not
287
+ * using the package name or any alias
288
+ * @param {Object} context eslint context
289
+ * @returns an array containing the filename and the extension
587
290
  */
588
291
 
589
- const matchesAny = require$$0.curry((obj, list) => list.some(matches_1(require$$0.__, obj)));
590
- /**
292
+ const getFilenameAndExtension = context => {
293
+ const fullFilename = context.getFilename().replace(/.*\//, "");
294
+ const splitFilename = fullFilename.split(".");
295
+ const extension = splitFilename.pop();
296
+ return [splitFilename.join("."), extension];
297
+ };
298
+ /**
299
+ * @param {Object} context eslint context
300
+ * @param {string[]} packages list of npm packages to check
301
+ * @returns the supplied list of packages and all aliases pointing to
302
+ * those packages or their subdirectories.
303
+ */
304
+
305
+ const getPackagesAndAliases = (context, packages) => Object.entries(context.options[0] ?? {}).reduce((acc, [key, value]) => packages.some(pckg => value === pckg || value.startsWith(`${pckg}/`)) ? ramda.append(key, acc) : acc, packages);
306
+ /**
307
+ * Checks if the file is inside the `apis` directory or not
308
+ * @param {Object} context eslint context
309
+ * @returns true if file is inside the `apis` directory
310
+ */
311
+
312
+ const isInsideApisDirectory = context => {
313
+ const filename = context.getFilename();
314
+ const apisDirectory = path__default["default"].resolve(APIS_DIRECTORY);
315
+ return filename.startsWith(apisDirectory) && filename !== `${apisDirectory}/axios.js`;
316
+ };
317
+ /**
318
+ * Checks if the specified package is imported or not
319
+ * using the package name or any alias
320
+ * @param {Object} context eslint context
321
+ * @param {Object} node ImportDeclaration node to be checked
322
+ * @param {string} packageName name of the package to be checked
323
+ * @returns true if the specified package is imported
324
+ */
325
+
326
+ const isPackageImported = (context, node, packageName) => getPackagesAndAliases(context, [packageName]).includes(node.source.value);
327
+ const nodeReplacerWithImports = importPattern => {
328
+ const addFunctionImport = (context, fixer, functions) => {
329
+ const root = context.getAncestors()[0];
330
+ const packageImport = root.body.find(node => matches(importPattern, node));
331
+
332
+ if (packageImport) {
333
+ const extraImports = functions.filter(func => !packageImport.specifiers.some(ramda.pathEq(["imported", "name"], func)));
334
+ if (ramda.isEmpty(extraImports)) return undefined;
335
+ return fixer.insertTextBefore(packageImport.specifiers[0], `${extraImports.join(", ")}, `);
336
+ }
337
+
338
+ const packageName = importPattern.source.value;
339
+ return fixer.insertTextBefore(root.body[0], `import { ${functions.join(", ")} } from "${packageName}";\n`);
340
+ };
341
+
342
+ return {
343
+ replaceNode: ({
344
+ context,
345
+ node,
346
+ fix,
347
+ functions
348
+ }) => function* (fixer) {
349
+ const imports = addFunctionImport(context, fixer, Array.isArray(functions) ? functions : [functions]);
350
+ if (imports) yield imports;
351
+ yield fixer.replaceText(node, fix);
352
+ }
353
+ };
354
+ };
355
+ const arrayFuncParam = root => root.arguments[0].params[0];
356
+
357
+ const ARGUMENT_LIMIT = 3;
358
+ const API_ACTIONS_ARGUMENT_LIMIT = 2;
359
+ const FIXABLE_PARAMETER_TYPES = [TYPES.IDENTIFIER, TYPES.ASSIGNMENT_PATTERN];
360
+
361
+ const canBeReplacedWith = fix => `Can be replaced with: ${fix}`;
362
+ const disallowUse = packageName => `Do not use the package ${packageName}`;
363
+ const moveToConstantsJs = constantName => `Move the constant ${constantName} to a constants.js file.`;
364
+ const renameFile = filename => `Rename this file to ${filename}`;
365
+ const replaceWith = fix => `Replace this with: ${fix}`;
366
+ const unableToResolveKey = ({
367
+ key,
368
+ fileName
369
+ }) => `Unable to resolve localized string '${key}' in ${fileName}`;
370
+ const useConstantCaseFor = constantName => `Use constant-case for naming the constant - ${constantName}.`;
371
+ const API_CONNECTOR_SHOULD_USE_DEFAULT_EXPORT_MESSAGE = "API Connector should be exported using the default export method";
372
+ const COMBINE_MULTIPLE_INDEPENDENT_AWAITS_MESSAGE = "Combine independent awaits to a single `Promise.all` call.";
373
+ const GLOBALPROPS_NO_ASSIGNMENT_MESSAGE = "globalProps should not be assigned to other variables";
374
+ const NESTED_GLOBALPROPS_NO_ASSIGNMENT_MESSAGE = "Nested properties of globalProps should not be assigned to other variables";
375
+ const NO_AXIOS_IMPORT_OUTSIDE_APIS_MESSAGE = "Do not use axios outside `app/javascript/src/apis`";
376
+ const NO_DANGLING_FUNCTIONS_MESSAGE = "Exporting functions from this file is not allowed.";
377
+ const NO_EXCESS_API_ACTION_ARGUMENTS_MESSAGE = `API actions should use named parameters for more than ${API_ACTIONS_ARGUMENT_LIMIT} parameters`;
378
+ const NO_EXCESS_FUNCTION_ARGUMENTS_MESSAGE = `Functions should use named parameters for more than ${ARGUMENT_LIMIT} parameters`;
379
+ const NO_GLOBALPROPS_REASSIGNMENT_MESSAGE = "globalProps or its nested properties should not be re-assigned.";
380
+ const NO_ROUTES_ASSIGNMENT = "`routes` or its nested properties should not be assigned to other variables.";
381
+ const NO_ROUTES_REASSIGNMENT = "`routes` or its nested properties should not be re-assigned.";
382
+ const NO_NAMESPACE_SPECIFIER_IMPORT_FOR_RAMDA_MESSAGE = 'Use `import { methodsToImport } from "ramda"` instead';
383
+ const PREFIX_NEETO_UI_IMPORT_ALIAS_MESSAGE = "Aliases for anything imported from neetoUI or neetoIcons should start with `NeetoUI`";
384
+ const ROUTE_SHOULD_BE_A_STRING = "Route should be a plain string literal.";
385
+ const ROUTE_SHOULD_MATCH_OBJECT_PATH = "Route string should match with its object path.";
386
+ const ROUTES_HAS_ALREADY_BEEN_DECLARED = "Identifier `routes` has already been declared";
387
+ const ROUTES_CONSTANT_SHOULD_BE_DECLARED = "A constant object named `routes` should be declared inside routes.js";
388
+ const ROUTES_SHOULD_USE_DEFAULT_EXPORT = "`routes` should be exported using the default export method.";
389
+ const USE_AXIOS_CONFIG_FOR_PASSING_QUERY_PARAMETERS_MESSAGE = "Use 'params attribute in axios configuration' to pass query parameters.";
390
+ const USE_LINK_FOR_NAVIGATION = "Use Link or NavLink component from 'react-router-dom' for click-navigation instead of onClick handler";
391
+ const USE_ANCHOR_FOR_NAVIGATION = "Use Anchor element (<a>) for click-navigation instead of onClick handler";
392
+ const USE_BUTTON_TO_FOR_LINK_NAVIGATION = "Use `to` prop of Button (<Button to='path'>) for click-navigation instead of onClick handler";
393
+ const USE_BUTTON_TO_FOR_ANCHOR_NAVIGATION = "Use `href` prop of Button (<Button href='path'>) for click-navigation instead of onClick handler";
394
+
395
+ const toCamelCase = text => {
396
+ const capitalized = text.split(/[^0-9a-z]/i).map(part => `${part[0].toUpperCase()}${part.slice(1)}`).join("");
397
+ return `${capitalized[0].toLowerCase()}${capitalized.slice(1)}`;
398
+ };
399
+
400
+ var apiConnectorNameShouldMatchFilename = {
401
+ meta: {
402
+ type: "problem",
403
+ docs: {
404
+ description: "API Connector should be named after the filename"
405
+ },
406
+ fixable: "code"
407
+ },
408
+ create: context => ({
409
+ ExportDefaultDeclaration(node) {
410
+ if (!isInsideApisDirectory(context)) return;
411
+ const {
412
+ declaration
413
+ } = node;
414
+ const [fileName] = getFilenameAndExtension(context);
415
+ const validApiConnectorName = `${toCamelCase(fileName)}Api`;
416
+ if (validApiConnectorName === declaration.name) return;
417
+ context.report({
418
+ node: declaration,
419
+ message: replaceWith(validApiConnectorName),
420
+ fix: fixer => fixer.replaceText(declaration, validApiConnectorName)
421
+ });
422
+ }
423
+
424
+ })
425
+ };
426
+
427
+ const checkAndReport$5 = (context, node) => {
428
+ if (!isInsideApisDirectory(context)) return;
429
+ context.report({
430
+ node,
431
+ message: API_CONNECTOR_SHOULD_USE_DEFAULT_EXPORT_MESSAGE
432
+ });
433
+ };
434
+
435
+ var apiConnectorShouldUseDefaultExport = {
436
+ meta: {
437
+ type: "problem",
438
+ docs: {
439
+ description: "API Connector should be exported using the default export method"
440
+ }
441
+ },
442
+ create: context => ({
443
+ ExportNamedDeclaration(node) {
444
+ checkAndReport$5(context, node);
445
+ },
446
+
447
+ ExportDefaultDeclaration(node) {
448
+ if (node.declaration.type !== TYPES.OBJECT_EXPRESSION) return;
449
+ checkAndReport$5(context, node);
450
+ }
451
+
452
+ })
453
+ };
454
+
455
+ /**
456
+ * Returns a list of nodes that matches the pattern
457
+ * somewhere deep inside the given object-tree by
458
+ * partial object matching.
459
+ *
460
+ * @param {Object} obj the object tree to check
461
+ * @param {Object} pattern the pattern to match partially
462
+ * @param {Array} res list of nodes that matches the pattern
463
+ */
464
+
465
+ const findMatchingNodesDeep = (obj, pattern, res = []) => {
466
+ if (typeof obj !== "object" || ramda.isNil(obj)) return res;
467
+ if (matches(pattern, obj)) return ramda.append(obj, res);
468
+ return Object.entries(obj).reduce((acc, [key, value]) => {
469
+ if (key === "parent") return acc;
470
+ return findMatchingNodesDeep(value, pattern, acc);
471
+ }, res);
472
+ };
473
+ /**
474
+ * Checks if any of the given pattern matches the object.
475
+ * @param {Object} obj The object tree to check.
476
+ * @param {Object[]} list The list of patterns to compare against.
477
+ * also @see matches
478
+ */
479
+
480
+ const matchesAny = ramda.curry((list, obj) => list.some(matches(ramda.__, obj)));
481
+ /**
591
482
  * Checks if the given pattern exists somewhere deep inside
592
483
  * the given object-tree by partial object matching.
593
484
  *
@@ -595,14 +486,14 @@
595
486
  * @param {Object} pattern the pattern to match partially
596
487
  */
597
488
 
598
- const patternExistsDeep = (obj, pattern) => {
599
- if (typeof obj !== "object" || require$$0.isNil(obj)) return false;
600
- if (matches_1(pattern, obj)) return true;
489
+ const patternExistsDeep = ramda.curry((pattern, obj) => {
490
+ if (typeof obj !== "object" || ramda.isNil(obj)) return false;
491
+ if (matches(pattern, obj)) return true;
601
492
  return Object.entries(obj).some(([key, value]) => {
602
493
  if (key === "parent") return false;
603
- return patternExistsDeep(value, pattern);
494
+ return patternExistsDeep(pattern, value);
604
495
  });
605
- };
496
+ });
606
497
 
607
498
  const AWAIT_DECLARATION_PATTERN = {
608
499
  type: TYPES.VARIABLE_DECLARATOR,
@@ -610,7 +501,7 @@
610
501
  type: TYPES.AWAIT_EXPRESSION
611
502
  }
612
503
  };
613
- const IDENTIFIER_PATTERN = {
504
+ const IDENTIFIER_PATTERN$1 = {
614
505
  type: TYPES.IDENTIFIER
615
506
  };
616
507
 
@@ -620,8 +511,8 @@
620
511
  return ((_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : (_node$parent$right = _node$parent.right) === null || _node$parent$right === void 0 ? void 0 : _node$parent$right.name) === node.name;
621
512
  };
622
513
 
623
- const getChildCode = (context, nodes, pathArray) => nodes.map(node => getCode(context, require$$0.path(pathArray, node))).join(", ");
624
- const getIdentifiersInNode = node => findMatchingNodesDeep(node, IDENTIFIER_PATTERN).filter(node => !(isKeyNode(node) || isDefaultValueNode(node) || node.parent.computed)); // id from const { id : orgID } = ...
514
+ const getChildCode = (context, nodes, pathArray) => nodes.map(node => getCode$1(context, ramda.path(pathArray, node))).join(", ");
515
+ const getIdentifiersInNode = node => findMatchingNodesDeep(node, IDENTIFIER_PATTERN$1).filter(node => !(isKeyNode(node) || isDefaultValueNode(node) || node.parent.computed)); // id from const { id : orgID } = ...
625
516
 
626
517
  const isKeyNode = node => {
627
518
  var _node$parent2;
@@ -634,13 +525,13 @@
634
525
 
635
526
  if (subsequentAwaits.length === 0) return false;
636
527
  const currentNodeIndex = functionBody.findIndex(item => item === awaitParent);
637
- const isPrevLineSameAsLastAwait = functionBody[currentNodeIndex - 1] === ((_last = require$$0.last(subsequentAwaits)) === null || _last === void 0 ? void 0 : _last.parent); // In case of const a = await xf(), b = await yf()
528
+ const isPrevLineSameAsLastAwait = functionBody[currentNodeIndex - 1] === ((_last = ramda.last(subsequentAwaits)) === null || _last === void 0 ? void 0 : _last.parent); // In case of const a = await xf(), b = await yf()
638
529
 
639
- const areBothAwaitsInSameLine = functionBody[currentNodeIndex] === ((_last2 = require$$0.last(subsequentAwaits)) === null || _last2 === void 0 ? void 0 : _last2.parent);
530
+ const areBothAwaitsInSameLine = functionBody[currentNodeIndex] === ((_last2 = ramda.last(subsequentAwaits)) === null || _last2 === void 0 ? void 0 : _last2.parent);
640
531
  return isPrevLineSameAsLastAwait || areBothAwaitsInSameLine;
641
532
  };
642
533
 
643
- const identifiersUsed = (node, identifiers) => identifiers.length > 0 && identifiers.some(identifier => findMatchingNodesDeep(node, { ...IDENTIFIER_PATTERN,
534
+ const identifiersUsed = (node, identifiers) => identifiers.length > 0 && identifiers.some(identifier => findMatchingNodesDeep(node, { ...IDENTIFIER_PATTERN$1,
644
535
  name: identifier.name
645
536
  }).some(node => !isKeyNode(node)));
646
537
 
@@ -678,11 +569,11 @@
678
569
  const calls = getChildCode(context, nodes, ["init", "argument"]);
679
570
  const ids = getChildCode(context, nodes, ["id"]);
680
571
  const fix = `[${ids}] = await Promise.all([${calls}])`;
681
- const fixRange = [nodes[0].range[0], require$$0.last(nodes).range[1]];
572
+ const fixRange = [nodes[0].range[0], ramda.last(nodes).range[1]];
682
573
  context.report({
683
574
  loc: {
684
575
  start: nodes[0].parent.loc.start,
685
- end: require$$0.last(nodes).loc.end
576
+ end: ramda.last(nodes).loc.end
686
577
  },
687
578
  message: COMBINE_MULTIPLE_INDEPENDENT_AWAITS_MESSAGE,
688
579
  fix: fixer => fixer.replaceTextRange(fixRange, fix)
@@ -723,246 +614,1682 @@
723
614
  })
724
615
  };
725
616
 
726
- const CONSTANT_CASE_PATTERN = /^[A-Z0-9_]*$/;
727
- const CONSTANTS_FILES = [/.*constants.js$/i, /app\/javascript\/src\/common\/urls.js$/];
617
+ const SPECIAL_KEYS = ["home", "index", "show"]; // import routes from "common/routes", import routes from "routes"
728
618
 
729
- const isConstantsFile = context => CONSTANTS_FILES.some(filePath => filePath.test(path__default["default"].resolve(context.getFilename())));
619
+ const ROUTES_IMPORT_PATTERN = {
620
+ type: TYPES.IMPORT_DECLARATION,
621
+ source: {
622
+ type: TYPES.LITERAL,
623
+ value: matchesAny(["routes", "common/routes"])
624
+ },
625
+ specifiers: [{
626
+ type: TYPES.IMPORT_DEFAULT_SPECIFIER,
627
+ local: {
628
+ type: TYPES.IDENTIFIER,
629
+ name: "routes"
630
+ }
631
+ }]
632
+ }; // const routes = { home: "/" }, const routes = "/", const routes = ["/"] etc
633
+
634
+ const DECALARATION_PATTERN = {
635
+ type: TYPES.VARIABLE_DECLARATION,
636
+ declarations: [{
637
+ type: TYPES.VARIABLE_DECLARATOR,
638
+ id: {
639
+ type: TYPES.IDENTIFIER,
640
+ name: "routes"
641
+ }
642
+ }]
643
+ }; // const routes = { home: "/" }
644
+
645
+ const OBJECT_DECALARATION_PATTERN = ramda.assocPath(["declarations", 0, "init"], {
646
+ type: TYPES.OBJECT_EXPRESSION
647
+ }, DECALARATION_PATTERN); // export const routes = { home: "/" }
648
+
649
+ const EXPORT_NAMED_DECLARATION_PATTERN = {
650
+ type: TYPES.EXPORT_NAMED_DECLARATION,
651
+ declaration: matches(OBJECT_DECALARATION_PATTERN)
652
+ }; // export default routes, export default deepFreezeObject(routes)
653
+
654
+ const DEFAULT_EXPORT_PATTERN = {
655
+ type: TYPES.EXPORT_DEFAULT_DECLARATION,
656
+ declaration: matchesAny([{
657
+ type: TYPES.IDENTIFIER,
658
+ name: "routes"
659
+ }, {
660
+ type: TYPES.CALL_EXPRESSION,
661
+ callee: {
662
+ name: "deepFreezeObject"
663
+ },
664
+ arguments: [{
665
+ name: "routes"
666
+ }]
667
+ }])
668
+ };
669
+ const IDENTIFIER_PATTERN = {
670
+ type: TYPES.IDENTIFIER,
671
+ name: "routes"
672
+ };
673
+ const MEMBER_EXPRESSION_PATTERN = {
674
+ type: TYPES.MEMBER_EXPRESSION,
675
+ object: {
676
+ type: TYPES.IDENTIFIER,
677
+ name: "routes"
678
+ }
679
+ }; // const { home } = routes, const homeRoute = routes.home
730
680
 
731
- var noDanglingConstants = {
681
+ const ASSIGNMENT_PATTERN = {
682
+ id: {
683
+ type: matchesAny([TYPES.IDENTIFIER, TYPES.OBJECT_PATTERN])
684
+ },
685
+ init: matchesAny([IDENTIFIER_PATTERN, MEMBER_EXPRESSION_PATTERN])
686
+ }; // const routes = { home: "/" }, const routes.home = "/"
687
+
688
+ const REASSIGNMENT_PATTERN = {
689
+ left: matchesAny([IDENTIFIER_PATTERN, MEMBER_EXPRESSION_PATTERN])
690
+ }; // path={string | template literals}, to={string | template literals}
691
+
692
+ const PATH_OR_TO_PROP_PATTERN = {
693
+ type: TYPES.JSX_ATTRIBUTE,
694
+ name: {
695
+ type: TYPES.JSX_IDENTIFIER,
696
+ name: ramda.includes(ramda.__, ["to", "path"])
697
+ },
698
+ value: matchesAny([{
699
+ type: TYPES.JSX_EXPRESSION_CONTAINER,
700
+ expression: {
701
+ type: ramda.includes(ramda.__, [TYPES.LITERAL, TYPES.TEMPLATE_LITERAL]),
702
+ value: notEquals("*")
703
+ }
704
+ }, {
705
+ type: TYPES.LITERAL,
706
+ value: notEquals("*")
707
+ }])
708
+ };
709
+ /*
710
+ <Route path={string | template literals} />, <Redirect to={string | template literals} />
711
+ <Link to={string | template literals} />, <NavLink to={string | template literals} />
712
+ */
713
+
714
+ const NAVIGATION_COMPONENTS_PATTERN = {
715
+ name: {
716
+ type: TYPES.JSX_IDENTIFIER,
717
+ name: ramda.includes(ramda.__, ["Route", "Redirect", "Link", "NavLink"])
718
+ },
719
+ attributes: ramda.any(matches(PATH_OR_TO_PROP_PATTERN))
720
+ }; // history.push(string| | template literal), history.replace(string | template literal)
721
+
722
+ const HISTORY_PATTERN = {
723
+ callee: {
724
+ type: TYPES.MEMBER_EXPRESSION,
725
+ object: {
726
+ name: "history"
727
+ },
728
+ property: {
729
+ name: ramda.includes(ramda.__, ["push", "replace"])
730
+ }
731
+ },
732
+ arguments: [{
733
+ type: ramda.includes(ramda.__, [TYPES.LITERAL, TYPES.TEMPLATE_LITERAL])
734
+ }]
735
+ };
736
+ /*
737
+ `${routes.home.projects}/find?id=123`, `home/${routes.projects}/find?id=322`
738
+ `${routes.projects}/{routes.user.show}?name=john&&age=21`
739
+ */
740
+
741
+ const QUERY_PARAMS_PATTERN = {
742
+ type: TYPES.TEMPLATE_LITERAL,
743
+ expressions: ramda.any(patternExistsDeep({
744
+ type: TYPES.MEMBER_EXPRESSION,
745
+ object: {
746
+ type: TYPES.IDENTIFIER,
747
+ name: "routes"
748
+ }
749
+ })),
750
+ quasis: ramda.any(({
751
+ value
752
+ }) => value.cooked.includes("?"))
753
+ };
754
+
755
+ const isRoutesImportPresent = context => context.getAncestors()[0].body.some(matches(ROUTES_IMPORT_PATTERN));
756
+
757
+ var noRoutesDestructureAndReassignment = {
732
758
  meta: {
733
- type: "suggestion",
759
+ type: "problem",
734
760
  docs: {
735
- description: "Indicates that any constant outside a constant.js file should be moved to a constant.js file."
761
+ description: "Disallow destructuring and re-assignment of routes"
736
762
  }
737
763
  },
738
764
  create: context => ({
739
765
  VariableDeclaration(node) {
740
- if (node.kind !== "const") return;
741
- if (isConstantsFile(context)) return;
742
- const constantName = node.declarations[0].id.name;
766
+ if (matches(DECALARATION_PATTERN, node) && isRoutesImportPresent(context)) {
767
+ context.report(node, ROUTES_HAS_ALREADY_BEEN_DECLARED);
768
+ }
769
+ },
743
770
 
744
- if (CONSTANT_CASE_PATTERN.test(constantName)) {
745
- context.report(node, moveToConstantsJs(constantName));
771
+ VariableDeclarator(node) {
772
+ if (matches(ASSIGNMENT_PATTERN, node) && isRoutesImportPresent(context)) {
773
+ context.report(node, NO_ROUTES_ASSIGNMENT);
774
+ }
775
+ },
776
+
777
+ AssignmentExpression(node) {
778
+ if (matches(REASSIGNMENT_PATTERN, node) && isRoutesImportPresent(context)) {
779
+ context.report(node, NO_ROUTES_REASSIGNMENT);
746
780
  }
747
781
  }
748
782
 
749
783
  })
750
784
  };
751
785
 
752
- const isDefinedInFile = (node, levels) => [TYPES.PROGRAM, TYPES.EXPORT_NAMED_DECLARATION].includes(require$$0.path(require$$0.repeat("parent", levels), node).type);
753
-
754
- const checkAndReport$3 = (context, node, levels = 3) => {
755
- if (!(isConstantsFile(context) && isDefinedInFile(node, levels))) return;
756
- context.report({
757
- node,
758
- message: NO_DANGLING_FUNCTIONS_MESSAGE
759
- });
786
+ const isInsideRoutesFile$1 = context => {
787
+ const filename = context.getFilename();
788
+ return filename.endsWith(ROUTES_FILE_PATH);
760
789
  };
761
790
 
762
- var noDanglingFunctions = {
791
+ var routesShouldBeDeclaredAndDefaultExported = {
763
792
  meta: {
764
793
  type: "problem",
765
794
  docs: {
766
- description: "Prevents exporting functions from the constants files."
795
+ description: "common/routes.js file should declare a constant named routes and should be exported using default export"
767
796
  }
768
797
  },
769
798
  create: context => ({
770
- // const sum = (a, b) => a + b;
771
- ArrowFunctionExpression(node) {
772
- checkAndReport$3(context, node);
773
- },
774
-
775
- // const sum = function (a, b) { return a + b };
776
- FunctionExpression(node) {
777
- checkAndReport$3(context, node);
778
- },
779
-
780
- // function sum (a, b) { return a + b };
781
- FunctionDeclaration(node) {
782
- checkAndReport$3(context, node, 1);
783
- },
784
-
785
- // const sum = Function("a", "b", "return a + b");
786
- CallExpression(node) {
787
- if (node.callee.name !== "Function") return;
788
- checkAndReport$3(context, node);
799
+ Program(node) {
800
+ if (!isInsideRoutesFile$1(context)) return;
801
+ const isDeclarationPresent = node.body.some(matchesAny([OBJECT_DECALARATION_PATTERN, EXPORT_NAMED_DECLARATION_PATTERN]));
802
+
803
+ if (isDeclarationPresent) {
804
+ const isDefaultExportPresent = node.body.some(matches(DEFAULT_EXPORT_PATTERN));
805
+ if (isDefaultExportPresent) return;
806
+ context.report(node, ROUTES_SHOULD_USE_DEFAULT_EXPORT);
807
+ } else {
808
+ context.report(node, ROUTES_CONSTANT_SHOULD_BE_DECLARED);
809
+ }
789
810
  }
790
811
 
791
812
  })
792
813
  };
793
814
 
794
- const toConstantCase = text => text.replace(/([A-Z0-9][a-z])/g, "_$1").replace(/([a-z0-9])([A-Z0-9])/g, "$1_$2").toUpperCase().replace(/[^A-Z0-9_]/g, "").replace(/^_/g, "");
815
+ const camelize = text => {
816
+ text = text.replace(/[-_\s.]+(.)?/g, (_, c) => c ? c.toUpperCase() : "");
817
+ return text.substring(0, 1).toLowerCase() + text.substring(1);
818
+ };
819
+
820
+ const isInsideRoutesFile = context => {
821
+ const filename = context.getFilename();
822
+ return filename.endsWith(ROUTES_FILE_PATH);
823
+ };
824
+
825
+ const isParam = e => e === null || e === void 0 ? void 0 : e.startsWith(":");
826
+
827
+ const isNotParam = e => !isParam(e);
828
+
829
+ const checkObjectPath = (context, object, objectPath = []) => {
830
+ if (object.type === TYPES.OBJECT_EXPRESSION) {
831
+ object.properties.forEach(property => checkObjectPath(context, property, objectPath));
832
+ } else if (object.type === TYPES.PROPERTY) {
833
+ if (object.value.type === TYPES.LITERAL) {
834
+ const routeKeys = object.value.value.split("/").filter(isNotEmpty$1);
835
+ const routeNonParams = routeKeys.filter(isNotParam).map(camelize);
836
+ if (isNotEmpty$1(routeKeys) && ramda.isEmpty(routeNonParams)) return;
837
+ let updatedObjectPath = SPECIAL_KEYS.includes(object.key.name) ? objectPath : [...objectPath, object.key.name];
838
+
839
+ if (isParam(routeKeys[0])) {
840
+ updatedObjectPath = ramda.remove(0, 1, updatedObjectPath);
841
+ }
842
+
843
+ const lastNonParamIndex = ramda.findLastIndex(isNotParam, routeKeys);
844
+ const consecutiveParamsCount = routeKeys.length - (lastNonParamIndex + 1);
845
+ const keyDiff = updatedObjectPath.length - routeNonParams.length;
846
+
847
+ if (matches(routeNonParams, updatedObjectPath) && [0, consecutiveParamsCount, consecutiveParamsCount - 1].includes(keyDiff)) {
848
+ return;
849
+ }
850
+
851
+ context.report({
852
+ node: object.value,
853
+ message: ROUTE_SHOULD_MATCH_OBJECT_PATH
854
+ });
855
+ } else if (object.value.type === TYPES.OBJECT_EXPRESSION) {
856
+ const updatedObjectPath = [...objectPath, object.key.name];
857
+ checkObjectPath(context, object.value, updatedObjectPath);
858
+ } else {
859
+ context.report({
860
+ node: object.value,
861
+ message: ROUTE_SHOULD_BE_A_STRING
862
+ });
863
+ }
864
+ }
865
+ };
866
+
867
+ var routesShouldMatchObjectPath = {
868
+ meta: {
869
+ type: "problem",
870
+ docs: {
871
+ description: "Each route string defined in the `routes` object should match with its object path."
872
+ }
873
+ },
874
+ create: context => ({
875
+ VariableDeclaration(node) {
876
+ if (isInsideRoutesFile(context) && matches(DECALARATION_PATTERN, node)) {
877
+ const object = node.declarations[0].init;
878
+ checkObjectPath(context, object);
879
+ }
880
+ }
881
+
882
+ })
883
+ };
884
+
885
+ const getCode = (context, start, length) => context.getSourceCode().text.substr(start, length);
886
+
887
+ const replacer$2 = nodeReplacerWithImports(ramda.assocPath(["source", "value"], "neetocommons/utils", IMPORT_DECLARATION));
888
+ var useCommonRoutes = {
889
+ meta: {
890
+ type: "problem",
891
+ fixable: "code",
892
+ docs: {
893
+ description: "Prevent usage of strings and template literals in Route, Redirect, Link, NavLink, history.push() and history.replace()"
894
+ }
895
+ },
896
+ create: context => ({
897
+ JSXOpeningElement(node) {
898
+ if (!matches(NAVIGATION_COMPONENTS_PATTERN, node)) return;
899
+ const componentName = node.name.name;
900
+ const valueNode = findMatchingNodesDeep(node, PATH_OR_TO_PROP_PATTERN)[0].value;
901
+ if (matches(QUERY_PARAMS_PATTERN, valueNode)) return;
902
+ const message = componentName === "Route" ? canBeReplacedWith("routes.*") : canBeReplacedWith("routes.* or buildUrl(routes.*)");
903
+ context.report(valueNode, message);
904
+ },
905
+
906
+ CallExpression(node) {
907
+ if (!matches(HISTORY_PATTERN, node)) return;
908
+ const argumentNode = node.arguments[0];
909
+ if (matches(QUERY_PARAMS_PATTERN, argumentNode)) return;
910
+ const message = canBeReplacedWith("routes.* or buildUrl(routes.*)");
911
+ context.report(argumentNode, message);
912
+ },
913
+
914
+ TemplateLiteral(node) {
915
+ if (!matches(QUERY_PARAMS_PATTERN, node)) return;
916
+ const quasiWithQuestionMark = node.quasis.find(({
917
+ value
918
+ }) => value.cooked.includes("?"));
919
+ const questionMarkIndex = quasiWithQuestionMark.range[0] + quasiWithQuestionMark.value.cooked.indexOf("?") + 1;
920
+ const textBeforeQuestionMark = getCode(context, node.range[0] + 1, questionMarkIndex - (node.range[0] + 1));
921
+ const textAfterQuestionMark = getCode(context, questionMarkIndex + 1, node.range[1] - (questionMarkIndex + 2));
922
+ if (ramda.isEmpty(textAfterQuestionMark)) return;
923
+
924
+ if (textAfterQuestionMark.indexOf("${") > -1) {
925
+ context.report({
926
+ node,
927
+ message: canBeReplacedWith("buildUrl()")
928
+ });
929
+ } else {
930
+ const queryParams = JSON.stringify(Object.fromEntries(new URLSearchParams(textAfterQuestionMark)));
931
+ const fix = `buildUrl(\`${textBeforeQuestionMark}\`, ${queryParams})`;
932
+ context.report({
933
+ node,
934
+ message: canBeReplacedWith(fix),
935
+ fix: replacer$2.replaceNode({
936
+ context,
937
+ node,
938
+ fix,
939
+ functions: "buildUrl"
940
+ })
941
+ });
942
+ }
943
+ }
944
+
945
+ })
946
+ };
947
+
948
+ // () => { <expression> }
949
+
950
+ const wrappedInBlockPattern = expression => ({
951
+ type: "BlockStatement",
952
+ body: body => body.length === 1 && matches({
953
+ type: "ExpressionStatement",
954
+ expression
955
+ }, body[0])
956
+ }); // everything except this style
957
+ // history.push({ state: something, path: somethingElse })
958
+
959
+
960
+ const HISTORY_PUSH_PATTERN = {
961
+ type: "CallExpression",
962
+ callee: {
963
+ type: "MemberExpression",
964
+ object: {
965
+ type: "Identifier",
966
+ name: "history"
967
+ },
968
+ property: {
969
+ type: "Identifier",
970
+ name: "push"
971
+ }
972
+ },
973
+ arguments: args => args.length === 1 && matches([{
974
+ type: isNot$1("ObjectExpression")
975
+ }], args)
976
+ };
977
+ const WINDOW_LOCATION_PATTERNS = [// window.location.href = "/path"
978
+ {
979
+ type: "AssignmentExpression",
980
+ operator: "=",
981
+ left: {
982
+ type: "MemberExpression",
983
+ object: {
984
+ type: "MemberExpression",
985
+ object: {
986
+ type: "Identifier",
987
+ name: "window"
988
+ },
989
+ property: {
990
+ type: "Identifier",
991
+ name: "location"
992
+ },
993
+ computed: false,
994
+ optional: false
995
+ },
996
+ property: {
997
+ type: "Identifier",
998
+ name: "href"
999
+ },
1000
+ computed: false,
1001
+ optional: false
1002
+ }
1003
+ }, // window.location.assign("/path")
1004
+ {
1005
+ type: "CallExpression",
1006
+ callee: {
1007
+ type: "MemberExpression",
1008
+ object: {
1009
+ type: "MemberExpression",
1010
+ object: {
1011
+ type: "Identifier",
1012
+ name: "window"
1013
+ },
1014
+ property: {
1015
+ type: "Identifier",
1016
+ name: "location"
1017
+ },
1018
+ computed: false,
1019
+ optional: false
1020
+ },
1021
+ property: {
1022
+ type: "Identifier",
1023
+ name: "assign"
1024
+ },
1025
+ computed: false,
1026
+ optional: false
1027
+ },
1028
+ optional: false
1029
+ }]; // onClick={() => <expression>}
1030
+
1031
+ const ONCLICK_ATTRIBUTE_PATTERN = {
1032
+ type: "JSXAttribute",
1033
+ name: {
1034
+ type: "JSXIdentifier",
1035
+ name: "onClick"
1036
+ },
1037
+ value: {
1038
+ type: "JSXExpressionContainer",
1039
+ expression: {
1040
+ type: "ArrowFunctionExpression",
1041
+ params: ramda.isEmpty,
1042
+ generator: false,
1043
+ async: false
1044
+ }
1045
+ }
1046
+ }; // <div onClick={() => history.push("/path")} />
1047
+
1048
+ const LINK_REPLACEABLE_PATTERN = {
1049
+ name: {
1050
+ type: "JSXIdentifier",
1051
+ name: ramda.includes(ramda.__, ["Button", "button", "span", "div", "a"])
1052
+ },
1053
+ attributes: ramda.any(matches(ramda.assocPath(["value", "expression", "body"], matchesAny([HISTORY_PUSH_PATTERN, wrappedInBlockPattern(HISTORY_PUSH_PATTERN)]), ONCLICK_ATTRIBUTE_PATTERN)))
1054
+ }; // <div onClick={() => window.location.href = "/path"} />
1055
+
1056
+ const ANCHOR_REPLACEABLE_PATTERN = {
1057
+ name: {
1058
+ type: "JSXIdentifier",
1059
+ name: ramda.includes(ramda.__, ["Button", "button", "span", "div"])
1060
+ },
1061
+ attributes: ramda.any(matches(ramda.assocPath(["value", "expression", "body"], matchesAny([WINDOW_LOCATION_PATTERNS, WINDOW_LOCATION_PATTERNS.map(wrappedInBlockPattern)].flat()), ONCLICK_ATTRIBUTE_PATTERN)))
1062
+ };
1063
+
1064
+ const getFixer = ({
1065
+ context,
1066
+ node,
1067
+ attribute,
1068
+ findPathNode
1069
+ }) => fixer => {
1070
+ const onClickAttributeNode = node.attributes.find(matches(ONCLICK_ATTRIBUTE_PATTERN));
1071
+ const pathNode = findPathNode(onClickAttributeNode);
1072
+ const navigateAttr = pathNode.type === "Literal" ? `${attribute}="${pathNode.value}"` : `${attribute}={${getCode$1(context, pathNode)}}`;
1073
+ return fixer.replaceText(onClickAttributeNode, navigateAttr);
1074
+ };
1075
+
1076
+ const findLinkPathNode = node => findMatchingNodesDeep(node, HISTORY_PUSH_PATTERN)[0].arguments[0];
1077
+
1078
+ const findAnchorPathNode = node => {
1079
+ let expressionNode = findMatchingNodesDeep(node, WINDOW_LOCATION_PATTERNS[0]);
1080
+ if (!ramda.isEmpty(expressionNode)) return expressionNode[0].right;
1081
+ expressionNode = findMatchingNodesDeep(node, WINDOW_LOCATION_PATTERNS[1]);
1082
+ return expressionNode[0].arguments[0];
1083
+ };
1084
+
1085
+ var consistentButtonLinkAnchor = {
1086
+ meta: {
1087
+ type: "suggestion",
1088
+ docs: {
1089
+ description: "Warns when button, div, span etc. are used with an onClick handler " + "instead of link or anchor tag to navigate to other pages."
1090
+ },
1091
+ fixable: "code"
1092
+ },
1093
+ create: context => ({
1094
+ JSXOpeningElement(node) {
1095
+ let message, fix;
1096
+
1097
+ if (matches(LINK_REPLACEABLE_PATTERN, node)) {
1098
+ if (node.name.name === "Button") {
1099
+ message = USE_BUTTON_TO_FOR_LINK_NAVIGATION;
1100
+ const findPathNode = findLinkPathNode;
1101
+ fix = getFixer({
1102
+ context,
1103
+ node,
1104
+ attribute: "to",
1105
+ findPathNode
1106
+ });
1107
+ } else message = USE_LINK_FOR_NAVIGATION;
1108
+ } else if (matches(ANCHOR_REPLACEABLE_PATTERN, node)) {
1109
+ if (node.name.name === "Button") {
1110
+ message = USE_BUTTON_TO_FOR_ANCHOR_NAVIGATION;
1111
+ const findPathNode = findAnchorPathNode;
1112
+ fix = getFixer({
1113
+ context,
1114
+ node,
1115
+ attribute: "href",
1116
+ findPathNode
1117
+ });
1118
+ } else message = USE_ANCHOR_FOR_NAVIGATION;
1119
+ } else return;
1120
+
1121
+ context.report({
1122
+ node,
1123
+ message,
1124
+ fix
1125
+ });
1126
+ }
1127
+
1128
+ })
1129
+ };
1130
+
1131
+ const CONSTANT_CASE_PATTERN = /^[A-Z0-9_]*$/;
1132
+ const CONSTANTS_FILES = [/.*constants.js$/i, /app\/javascript\/src\/common\/urls.js$/];
1133
+
1134
+ const isConstantsFile = context => CONSTANTS_FILES.some(filePath => filePath.test(path__default["default"].resolve(context.getFilename())));
1135
+
1136
+ var noDanglingConstants = {
1137
+ meta: {
1138
+ type: "suggestion",
1139
+ docs: {
1140
+ description: "Indicates that any constant outside a constant.js file should be moved to a constant.js file."
1141
+ }
1142
+ },
1143
+ create: context => ({
1144
+ VariableDeclaration(node) {
1145
+ if (node.kind !== "const") return;
1146
+ if (isConstantsFile(context)) return;
1147
+ const constantName = node.declarations[0].id.name;
1148
+
1149
+ if (CONSTANT_CASE_PATTERN.test(constantName)) {
1150
+ context.report(node, moveToConstantsJs(constantName));
1151
+ }
1152
+ }
1153
+
1154
+ })
1155
+ };
1156
+
1157
+ const isDefinedInFile = (node, levels) => [TYPES.PROGRAM, TYPES.EXPORT_NAMED_DECLARATION].includes(ramda.path(ramda.repeat("parent", levels), node).type);
1158
+
1159
+ const checkAndReport$3 = (context, node, levels = 3) => {
1160
+ if (!(isConstantsFile(context) && isDefinedInFile(node, levels))) return;
1161
+ context.report({
1162
+ node,
1163
+ message: NO_DANGLING_FUNCTIONS_MESSAGE
1164
+ });
1165
+ };
1166
+
1167
+ var noDanglingFunctions = {
1168
+ meta: {
1169
+ type: "problem",
1170
+ docs: {
1171
+ description: "Prevents exporting functions from the constants files."
1172
+ }
1173
+ },
1174
+ create: context => ({
1175
+ // const sum = (a, b) => a + b;
1176
+ ArrowFunctionExpression(node) {
1177
+ checkAndReport$3(context, node);
1178
+ },
1179
+
1180
+ // const sum = function (a, b) { return a + b };
1181
+ FunctionExpression(node) {
1182
+ checkAndReport$3(context, node);
1183
+ },
1184
+
1185
+ // function sum (a, b) { return a + b };
1186
+ FunctionDeclaration(node) {
1187
+ checkAndReport$3(context, node, 1);
1188
+ },
1189
+
1190
+ // const sum = Function("a", "b", "return a + b");
1191
+ CallExpression(node) {
1192
+ if (node.callee.name !== "Function") return;
1193
+ checkAndReport$3(context, node);
1194
+ }
1195
+
1196
+ })
1197
+ };
1198
+
1199
+ const toConstantCase = text => text.replace(/([A-Z0-9][a-z])/g, "_$1").replace(/([a-z0-9])([A-Z0-9])/g, "$1_$2").toUpperCase().replace(/[^A-Z0-9_]/g, "").replace(/^_/g, "");
1200
+
1201
+ const checkCaseAndReport = ({
1202
+ context,
1203
+ name,
1204
+ node
1205
+ }) => {
1206
+ if (CONSTANT_CASE_PATTERN.test(name)) return;
1207
+ context.report({
1208
+ node,
1209
+ message: useConstantCaseFor(name),
1210
+ suggest: [{
1211
+ desc: `Replace ${getCode$1(context, node)} with ${toConstantCase(name)}`,
1212
+ fix: fixer => fixer.replaceText(node, toConstantCase(name))
1213
+ }]
1214
+ });
1215
+ };
1216
+
1217
+ const checkExportAndReport = ({
1218
+ context,
1219
+ exported,
1220
+ local,
1221
+ node,
1222
+ statement
1223
+ }) => {
1224
+ if (CONSTANT_CASE_PATTERN.test(exported.name)) return;
1225
+ context.report({
1226
+ node,
1227
+ message: useConstantCaseFor(exported.name),
1228
+ suggest: [{
1229
+ desc: `Replace ${getCode$1(context, node)} with ${toConstantCase(exported.name)}`,
1230
+ fix: fixer => {
1231
+ const newName = toConstantCase(exported.name);
1232
+
1233
+ if (local.name === exported.name) {
1234
+ return fixer.replaceText(statement, newName);
1235
+ }
1236
+
1237
+ if (local.name === newName) {
1238
+ return fixer.replaceText(statement, local.name);
1239
+ }
1240
+
1241
+ return fixer.replaceText(exported, newName);
1242
+ }
1243
+ }]
1244
+ });
1245
+ };
1246
+
1247
+ var useConstantCase = {
1248
+ meta: {
1249
+ type: "suggestion",
1250
+ docs: {
1251
+ description: "Enforces constants in constants.js file to be named using constant-case."
1252
+ },
1253
+ hasSuggestions: true
1254
+ },
1255
+ create: context => ({
1256
+ ExportNamedDeclaration(node) {
1257
+ var _node$declaration;
1258
+
1259
+ if (!isConstantsFile(context)) return;
1260
+
1261
+ if (((_node$declaration = node.declaration) === null || _node$declaration === void 0 ? void 0 : _node$declaration.kind) === "const") {
1262
+ var _node$declaration2;
1263
+
1264
+ (_node$declaration2 = node.declaration) === null || _node$declaration2 === void 0 ? void 0 : _node$declaration2.declarations.forEach(({
1265
+ id
1266
+ }) => {
1267
+ if (id.type !== TYPES.OBJECT_PATTERN) {
1268
+ checkCaseAndReport({
1269
+ context,
1270
+ name: id.name,
1271
+ node: id
1272
+ });
1273
+ return;
1274
+ }
1275
+
1276
+ id.properties.forEach(statement => {
1277
+ checkExportAndReport({
1278
+ context,
1279
+ exported: statement.value,
1280
+ local: statement.key,
1281
+ node,
1282
+ statement
1283
+ });
1284
+ });
1285
+ });
1286
+ } else {
1287
+ node.specifiers.forEach(statement => {
1288
+ const {
1289
+ exported,
1290
+ local
1291
+ } = statement;
1292
+ checkExportAndReport({
1293
+ context,
1294
+ exported,
1295
+ local,
1296
+ node,
1297
+ statement
1298
+ });
1299
+ });
1300
+ }
1301
+ }
1302
+
1303
+ })
1304
+ };
1305
+
1306
+ const ASSIGNMENT_PATTERNS = [{
1307
+ id: {
1308
+ type: "ObjectPattern"
1309
+ }
1310
+ }, {
1311
+ id: {
1312
+ type: "Identifier"
1313
+ }
1314
+ }];
1315
+ const IDENTIFIER_INITIALIZATION_PATTERN = {
1316
+ type: "Identifier",
1317
+ name: "globalProps"
1318
+ };
1319
+ const MEMBER_EXPRESSION_INITIALIZATION_PATTERN = {
1320
+ type: "MemberExpression",
1321
+ object: {
1322
+ type: "Identifier",
1323
+ name: "globalProps"
1324
+ }
1325
+ };
1326
+ const GLOBALPROPS_REASSIGNMENT_PATTERN = {
1327
+ type: "Identifier",
1328
+ name: "globalProps"
1329
+ };
1330
+
1331
+ const checkAssignment = (context, node) => {
1332
+ if (matches(IDENTIFIER_INITIALIZATION_PATTERN, node)) {
1333
+ context.report(node, GLOBALPROPS_NO_ASSIGNMENT_MESSAGE);
1334
+ } else if (matches(MEMBER_EXPRESSION_INITIALIZATION_PATTERN, node)) {
1335
+ context.report(node, NESTED_GLOBALPROPS_NO_ASSIGNMENT_MESSAGE);
1336
+ }
1337
+ };
1338
+
1339
+ var noGlobalPropsDestructure = {
1340
+ meta: {
1341
+ type: "problem",
1342
+ docs: {
1343
+ description: "Disallows destructuring of globalProps."
1344
+ }
1345
+ },
1346
+ create: context => ({
1347
+ VariableDeclarator(node) {
1348
+ if (!matchesAny(ASSIGNMENT_PATTERNS, node)) return;
1349
+ checkAssignment(context, node.init);
1350
+ },
1351
+
1352
+ AssignmentExpression: node => checkAssignment(context, node.right)
1353
+ })
1354
+ };
1355
+
1356
+ var noGlobalPropsReassignment = {
1357
+ meta: {
1358
+ type: "problem",
1359
+ docs: {
1360
+ description: "Disallows re-assignment of globalProps."
1361
+ }
1362
+ },
1363
+ create: context => ({
1364
+ AssignmentExpression(node) {
1365
+ if (patternExistsDeep(GLOBALPROPS_REASSIGNMENT_PATTERN, node.left)) {
1366
+ context.report(node, NO_GLOBALPROPS_REASSIGNMENT_MESSAGE);
1367
+ }
1368
+ }
1369
+
1370
+ })
1371
+ };
1372
+
1373
+ const reportSuggestion = ({
1374
+ context,
1375
+ node,
1376
+ fix,
1377
+ func,
1378
+ message = ""
1379
+ }) => context.report({
1380
+ node,
1381
+ message: message || canBeReplacedWith(fix),
1382
+ suggest: [{
1383
+ desc: `Replace with ${fix}`,
1384
+ fix: replacer$1.replaceNode({
1385
+ context,
1386
+ node,
1387
+ fix,
1388
+ functions: func
1389
+ })
1390
+ }]
1391
+ });
1392
+ const replacer$1 = nodeReplacerWithImports(ramda.assocPath(["source", "value"], "neetocommons/pure", IMPORT_DECLARATION)); // checks the given logical/binary expression uses only the parameters of the function for comparison
1393
+ // (a) => a.x === 1;
1394
+ // (a) => a.x === b.x && a.y === 100; // allowed
1395
+ // (a) => a.x.y === 1; // not allowed
1396
+
1397
+ const areAllChecksWithParams = (expression, param, operators) => {
1398
+ const isBinaryExpressionValid = pattern => {
1399
+ const binaryExpressionPattern = {
1400
+ type: TYPES.BINARY_EXPRESSION,
1401
+ operator: operators.compare // ===, !==
1402
+
1403
+ };
1404
+ return matches(binaryExpressionPattern, expression) && (matches(pattern, expression.left) || matches(pattern, expression.right));
1405
+ };
1406
+
1407
+ const logicalExpressionPattern = {
1408
+ type: TYPES.LOGICAL_EXPRESSION,
1409
+ operator: operators.join
1410
+ };
1411
+
1412
+ if (matches(logicalExpressionPattern, expression)) {
1413
+ return areAllChecksWithParams(expression.left, param, operators) && areAllChecksWithParams(expression.right, param, operators);
1414
+ } else if (param.type === TYPES.IDENTIFIER) {
1415
+ const expressionPattern = {
1416
+ type: TYPES.MEMBER_EXPRESSION,
1417
+ object: {
1418
+ name: param.name
1419
+ }
1420
+ };
1421
+ if (isBinaryExpressionValid(expressionPattern)) return true;
1422
+ } else if (param.type === TYPES.OBJECT_PATTERN) {
1423
+ const identifierPattern = {
1424
+ type: TYPES.IDENTIFIER,
1425
+ name: name => existsBy$1({
1426
+ value: {
1427
+ name
1428
+ }
1429
+ }, param.properties)
1430
+ };
1431
+ if (isBinaryExpressionValid(identifierPattern)) return true;
1432
+ }
1433
+
1434
+ return false;
1435
+ };
1436
+ const canBeShortenedWithCommons = replacement => `It may be possible to shorten this code using ${replacement} from neetocommons/pure`;
1437
+
1438
+ const NOT_NIL_BINARY_EXP_PATTERN = {
1439
+ type: TYPES.BINARY_EXPRESSION,
1440
+ operator: "!==",
1441
+ right: matchesAny([{
1442
+ type: TYPES.LITERAL,
1443
+ value: null
1444
+ }, {
1445
+ type: TYPES.IDENTIFIER,
1446
+ name: "undefined"
1447
+ }])
1448
+ };
1449
+ const NOT_EQUALS_DEEP_CALL_EXP_PATTERN = {
1450
+ type: TYPES.CALL_EXPRESSION,
1451
+ callee: {
1452
+ type: TYPES.MEMBER_EXPRESSION,
1453
+ object: {
1454
+ type: TYPES.IDENTIFIER,
1455
+ name: "JSON"
1456
+ },
1457
+ property: {
1458
+ type: TYPES.IDENTIFIER,
1459
+ name: "stringify"
1460
+ }
1461
+ }
1462
+ };
1463
+ const ARRAY_LENGTH_PATTERN$1 = {
1464
+ type: TYPES.MEMBER_EXPRESSION,
1465
+ property: {
1466
+ type: TYPES.IDENTIFIER,
1467
+ name: "length"
1468
+ }
1469
+ };
1470
+ const OBJ_KEY_LENGTH_PATTERN$1 = {
1471
+ type: TYPES.MEMBER_EXPRESSION,
1472
+ object: {
1473
+ type: TYPES.CALL_EXPRESSION,
1474
+ callee: {
1475
+ type: TYPES.MEMBER_EXPRESSION,
1476
+ object: {
1477
+ type: TYPES.IDENTIFIER,
1478
+ name: "Object"
1479
+ },
1480
+ property: {
1481
+ type: TYPES.IDENTIFIER,
1482
+ name: "keys"
1483
+ }
1484
+ }
1485
+ },
1486
+ property: {
1487
+ type: TYPES.IDENTIFIER,
1488
+ name: "length"
1489
+ }
1490
+ };
1491
+ const NOOP_PATTERN = {
1492
+ generator: false,
1493
+ async: false,
1494
+ expression: false,
1495
+ body: {
1496
+ type: "BlockStatement",
1497
+ body: body => ramda.isEmpty(body)
1498
+ }
1499
+ };
1500
+ const LABEL_AND_VALUE_PATTERN = {
1501
+ properties: props => props.length === 2 && props.every(matches({
1502
+ type: "Property",
1503
+ computed: false,
1504
+ key: {
1505
+ type: "Identifier"
1506
+ },
1507
+ value: {
1508
+ type: ramda.includes(ramda.__, ["Literal", "Identifier", "MemberExpression"])
1509
+ }
1510
+ })) && ramda.equals(["label", "value"], props.map(ramda.path(["key", "name"])).sort())
1511
+ };
1512
+ const DYNAMIC_ARRAY_PATTERN = {
1513
+ callee: {
1514
+ type: "MemberExpression",
1515
+ object: {
1516
+ type: "Identifier",
1517
+ name: "Array"
1518
+ },
1519
+ property: {
1520
+ type: "Identifier",
1521
+ name: "from"
1522
+ }
1523
+ },
1524
+ arguments: args => args.length === 2 && matches({
1525
+ 0: {
1526
+ type: "ObjectExpression",
1527
+ properties: props => props.length === 1 && props[0].key.name === "length"
1528
+ },
1529
+ 1: {
1530
+ type: "ArrowFunctionExpression"
1531
+ }
1532
+ }, args)
1533
+ };
1534
+ const NOT_NIL_PATTERNS = [// x !== null && x !== undefined
1535
+ {
1536
+ type: TYPES.LOGICAL_EXPRESSION,
1537
+ operator: "&&",
1538
+ left: NOT_NIL_BINARY_EXP_PATTERN,
1539
+ right: NOT_NIL_BINARY_EXP_PATTERN
1540
+ }, // x => !isNil(x)
1541
+ {
1542
+ type: TYPES.ARROW_FUNCTION_EXPRESSION,
1543
+ params: params => params.length === 1 && params[0].type === TYPES.IDENTIFIER,
1544
+ body: {
1545
+ type: TYPES.UNARY_EXPRESSION,
1546
+ operator: "!",
1547
+ prefix: true,
1548
+ argument: {
1549
+ type: TYPES.CALL_EXPRESSION,
1550
+ callee: {
1551
+ type: TYPES.IDENTIFIER,
1552
+ name: "isNil"
1553
+ },
1554
+ arguments: args => args.length === 1 && args[0].type === TYPES.IDENTIFIER
1555
+ }
1556
+ }
1557
+ }];
1558
+ const NOT_EMPTY_PATTERNS = {
1559
+ /*
1560
+ array.length !== 0, array.length > 0, Object.keys(obj).length !== 0, Object.keys(obj).length > 0 ,
1561
+ if(array.length !== 0), while(Object.keys(obj).length > 0) etc
1562
+ */
1563
+ BINARY_EXP: {
1564
+ type: TYPES.BINARY_EXPRESSION,
1565
+ operator: opr => opr === "!==" || opr === ">",
1566
+ left: matchesAny([ARRAY_LENGTH_PATTERN$1, OBJ_KEY_LENGTH_PATTERN$1]),
1567
+ right: {
1568
+ type: TYPES.LITERAL,
1569
+ value: 0
1570
+ }
1571
+ },
1572
+ // if(array.length), if(Object.keys(obj).length), while(array.length), while(Object.keys(obj).length)
1573
+ CONDT_STAT: {
1574
+ type: matchesAny([TYPES.IF_STATEMENT, TYPES.WHILE_STATEMENT]),
1575
+ test: matchesAny([ARRAY_LENGTH_PATTERN$1, OBJ_KEY_LENGTH_PATTERN$1])
1576
+ },
1577
+ // x => !isEmpty(x)
1578
+ ARROW_FUNC: {
1579
+ type: TYPES.ARROW_FUNCTION_EXPRESSION,
1580
+ params: params => params.length === 1 && params[0].type === TYPES.IDENTIFIER,
1581
+ body: {
1582
+ type: TYPES.UNARY_EXPRESSION,
1583
+ operator: "!",
1584
+ prefix: true,
1585
+ argument: {
1586
+ type: TYPES.CALL_EXPRESSION,
1587
+ callee: {
1588
+ type: TYPES.IDENTIFIER,
1589
+ name: "isEmpty"
1590
+ },
1591
+ arguments: (args, root) => args.length === 1 && args[0].type === TYPES.IDENTIFIER && args[0].name === root.params[0].name
1592
+ }
1593
+ }
1594
+ }
1595
+ };
1596
+ const REPLACE_BY_PATTERN = {
1597
+ callee: {
1598
+ type: "MemberExpression",
1599
+ property: {
1600
+ type: "Identifier",
1601
+ name: "map"
1602
+ }
1603
+ },
1604
+ arguments: [{
1605
+ type: "ArrowFunctionExpression",
1606
+ generator: false,
1607
+ async: false,
1608
+ expression: true,
1609
+ params: params => params.length === 1 && params[0].type === "Identifier",
1610
+ body: {
1611
+ type: "ConditionalExpression",
1612
+ test: (test, root) => areAllChecksWithParams(test, arrayFuncParam(root), {
1613
+ compare: "===",
1614
+ join: "&&"
1615
+ }),
1616
+ alternate: {
1617
+ type: "Identifier",
1618
+ name: (name, root) => name === arrayFuncParam(root).name
1619
+ }
1620
+ }
1621
+ }]
1622
+ };
1623
+ const REPLACE_BY_NEGATED_PATTERN = ramda.assocPath(["arguments", 0, "body"], {
1624
+ type: "ConditionalExpression",
1625
+ test: (test, root) => areAllChecksWithParams(test, arrayFuncParam(root), {
1626
+ compare: "!==",
1627
+ join: "||"
1628
+ }),
1629
+ consequent: {
1630
+ type: "Identifier",
1631
+ name: (name, root) => name === arrayFuncParam(root).name
1632
+ }
1633
+ }, REPLACE_BY_PATTERN);
1634
+ const COPY_KEYS_PATTERN = {
1635
+ properties: props => props.length > 1 && matches({
1636
+ type: "SpreadElement",
1637
+ argument: {
1638
+ type: "Identifier"
1639
+ }
1640
+ }, props[0]) && props.slice(1).every(matches({
1641
+ type: "Property",
1642
+ kind: "init",
1643
+ method: false,
1644
+ computed: false,
1645
+ shorthand: false,
1646
+ key: {
1647
+ type: "Identifier"
1648
+ },
1649
+ value: {
1650
+ type: "MemberExpression",
1651
+ computed: false,
1652
+ optional: false,
1653
+ object: {
1654
+ type: "Identifier",
1655
+ name: props[0].argument.name
1656
+ },
1657
+ property: {
1658
+ type: "Identifier"
1659
+ }
1660
+ }
1661
+ }))
1662
+ };
1663
+ const NOT_EQUALS_PATTERNS = {
1664
+ // !Object.is(item1, item2)
1665
+ UNARY_EXP: {
1666
+ type: TYPES.UNARY_EXPRESSION,
1667
+ operator: "!",
1668
+ prefix: true,
1669
+ argument: {
1670
+ type: TYPES.CALL_EXPRESSION,
1671
+ callee: {
1672
+ type: TYPES.MEMBER_EXPRESSION,
1673
+ object: {
1674
+ type: TYPES.IDENTIFIER,
1675
+ name: "Object"
1676
+ },
1677
+ property: {
1678
+ type: TYPES.IDENTIFIER,
1679
+ name: "is"
1680
+ }
1681
+ },
1682
+ arguments: args => args.length === 2
1683
+ }
1684
+ },
1685
+ // x => x !== y
1686
+ ARROW_FUNC: {
1687
+ type: TYPES.ARROW_FUNCTION_EXPRESSION,
1688
+ params: p => p.length === 1 && matches([{
1689
+ type: TYPES.IDENTIFIER
1690
+ }], p),
1691
+ body: {
1692
+ type: TYPES.BINARY_EXPRESSION,
1693
+ operator: "!=="
1694
+ }
1695
+ }
1696
+ };
1697
+ const NOT_EQUALS_DEEP_PATTERNS = {
1698
+ BINARY_EXP: {
1699
+ // JSON.stringify(x) !== JSON.stringify(y)
1700
+ type: TYPES.BINARY_EXPRESSION,
1701
+ left: NOT_EQUALS_DEEP_CALL_EXP_PATTERN,
1702
+ right: NOT_EQUALS_DEEP_CALL_EXP_PATTERN,
1703
+ operator: "!=="
1704
+ },
1705
+ // x => JSON.stringify(x) !== JSON.stringify(y)
1706
+ ARROW_FUNC: {
1707
+ type: TYPES.ARROW_FUNCTION_EXPRESSION,
1708
+ params: p => p.length === 1 && matches([{
1709
+ type: TYPES.IDENTIFIER
1710
+ }], p),
1711
+ body: {
1712
+ type: TYPES.BINARY_EXPRESSION,
1713
+ left: NOT_EQUALS_DEEP_CALL_EXP_PATTERN,
1714
+ right: NOT_EQUALS_DEEP_CALL_EXP_PATTERN
1715
+ }
1716
+ }
1717
+ };
1718
+ const CAPITALIZE_PATTERN = {
1719
+ // string.charAt(0).toUpperCase() + string.slice(1)
1720
+ type: TYPES.BINARY_EXPRESSION,
1721
+ operator: "+",
1722
+ left: {
1723
+ type: TYPES.CALL_EXPRESSION,
1724
+ callee: {
1725
+ type: TYPES.MEMBER_EXPRESSION,
1726
+ object: {
1727
+ type: TYPES.CALL_EXPRESSION,
1728
+ callee: {
1729
+ type: TYPES.MEMBER_EXPRESSION,
1730
+ object: {
1731
+ type: TYPES.IDENTIFIER,
1732
+ name: (name, root) => {
1733
+ var _root$right$callee, _root$right$callee$ob;
1734
+
1735
+ return name === ((_root$right$callee = root.right.callee) === null || _root$right$callee === void 0 ? void 0 : (_root$right$callee$ob = _root$right$callee.object) === null || _root$right$callee$ob === void 0 ? void 0 : _root$right$callee$ob.name);
1736
+ }
1737
+ },
1738
+ property: {
1739
+ type: TYPES.IDENTIFIER,
1740
+ name: "charAt"
1741
+ }
1742
+ },
1743
+ arguments: args => args.length === 1 && matches([{
1744
+ type: TYPES.LITERAL,
1745
+ value: 0
1746
+ }], args)
1747
+ },
1748
+ property: {
1749
+ type: TYPES.IDENTIFIER,
1750
+ name: "toUpperCase"
1751
+ }
1752
+ }
1753
+ },
1754
+ right: {
1755
+ type: TYPES.CALL_EXPRESSION,
1756
+ callee: {
1757
+ type: TYPES.MEMBER_EXPRESSION,
1758
+ object: {
1759
+ type: TYPES.IDENTIFIER
1760
+ },
1761
+ property: {
1762
+ type: TYPES.IDENTIFIER,
1763
+ name: "slice"
1764
+ }
1765
+ },
1766
+ arguments: args => args.length === 1 && matches([{
1767
+ type: TYPES.LITERAL,
1768
+ value: 1
1769
+ }], args)
1770
+ }
1771
+ };
1772
+ const COUNT_BY_PATTERN = {
1773
+ type: "MemberExpression",
1774
+ computed: false,
1775
+ optional: false,
1776
+ property: {
1777
+ type: "Identifier",
1778
+ name: "length"
1779
+ }
1780
+ };
1781
+
1782
+ const getObjectParamIdUsagePattern = root => ({
1783
+ type: TYPES.IDENTIFIER,
1784
+ name: root.params[0].properties[0].value.name
1785
+ });
1786
+
1787
+ const getIdentifierIdUsagePattern = root => ({
1788
+ type: TYPES.MEMBER_EXPRESSION,
1789
+ object: {
1790
+ type: TYPES.IDENTIFIER,
1791
+ name: root.params[0].name
1792
+ },
1793
+ property: {
1794
+ type: TYPES.IDENTIFIER,
1795
+ name: "id"
1796
+ }
1797
+ });
1798
+
1799
+ const matchesIdOperatorCheck = (operator, type) => (node, root) => {
1800
+ const pattern = type === "identifier" ? getIdentifierIdUsagePattern(root) : getObjectParamIdUsagePattern(root);
1801
+ return matches({
1802
+ type: TYPES.BINARY_EXPRESSION,
1803
+ operator
1804
+ }, node) && (matches(pattern, node.left) || matches(pattern, node.right));
1805
+ };
1806
+
1807
+ const checkByFunc = (context, node, {
1808
+ genericPatterns,
1809
+ byIdPattern,
1810
+ functions
1811
+ }) => {
1812
+ let array = null;
1813
+
1814
+ if (matches(genericPatterns.VANILLA, node)) {
1815
+ array = getCode$1(context, node.callee.object);
1816
+ } else if (matches(genericPatterns.RAMDA, node)) {
1817
+ array = getCode$1(context, node.arguments[1]);
1818
+ } else return; // arr.filter(x => x.prop === something).length
1819
+
1820
+
1821
+ if (functions.by === "filterBy" && matches(COUNT_BY_PATTERN, node.parent)) {
1822
+ const message = canBeShortenedWithCommons("countBy");
1823
+ context.report({
1824
+ node: node.parent,
1825
+ message
1826
+ });
1827
+ return;
1828
+ }
1829
+
1830
+ if (byIdPattern) {
1831
+ const predicate = node.arguments[0];
1832
+ let idUsagePattern = null;
1833
+
1834
+ if (matches(byIdPattern.IDENTIFIER, predicate)) {
1835
+ idUsagePattern = getIdentifierIdUsagePattern(predicate);
1836
+ } else if (matches(byIdPattern.OBJECT_PARAM, predicate)) {
1837
+ idUsagePattern = getObjectParamIdUsagePattern(predicate);
1838
+ }
1839
+
1840
+ if (idUsagePattern) {
1841
+ const id = matches(idUsagePattern, predicate.body.left) ? getCode$1(context, predicate.body.right) : getCode$1(context, predicate.body.left);
1842
+ const fix = `${functions.byId}(${id}, ${array})`;
1843
+ reportSuggestion({
1844
+ context,
1845
+ node,
1846
+ fix,
1847
+ func: functions.byId
1848
+ });
1849
+ } else {
1850
+ const message = canBeShortenedWithCommons(functions.by);
1851
+ context.report({
1852
+ node,
1853
+ message
1854
+ });
1855
+ }
1856
+ } else {
1857
+ context.report({
1858
+ node,
1859
+ message: canBeShortenedWithCommons(functions.by)
1860
+ });
1861
+ }
1862
+ };
1863
+
1864
+ const getArrowFuncPattern = (operators, root) => ({
1865
+ type: TYPES.ARROW_FUNCTION_EXPRESSION,
1866
+ generator: false,
1867
+ async: false,
1868
+ params: params => params.length === 1 && [TYPES.IDENTIFIER, TYPES.OBJECT_PATTERN].includes(params[0].type),
1869
+ body: node => areAllChecksWithParams(node, arrayFuncParam(root), operators)
1870
+ });
1871
+
1872
+ const getPatternsOfByFunc = (funcName, operators) => ({
1873
+ VANILLA: {
1874
+ callee: {
1875
+ type: TYPES.MEMBER_EXPRESSION,
1876
+ property: {
1877
+ type: TYPES.IDENTIFIER,
1878
+ name: funcName
1879
+ }
1880
+ },
1881
+ arguments: (args, root) => args.length === 1 && matches([getArrowFuncPattern(operators, root)], args)
1882
+ },
1883
+ RAMDA: {
1884
+ type: TYPES.CALL_EXPRESSION,
1885
+ callee: {
1886
+ type: TYPES.IDENTIFIER,
1887
+ name: funcName
1888
+ },
1889
+ arguments: (args, root) => args.length === 2 && matches([getArrowFuncPattern(operators, root)], args)
1890
+ }
1891
+ });
1892
+
1893
+ const getPatternOfByIdFunc = operator => ({
1894
+ IDENTIFIER: {
1895
+ params: [{
1896
+ type: TYPES.IDENTIFIER
1897
+ }],
1898
+ body: matchesIdOperatorCheck(operator, "identifier")
1899
+ },
1900
+ OBJECT_PARAM: {
1901
+ params: [{
1902
+ type: TYPES.OBJECT_PATTERN,
1903
+ properties: [{
1904
+ type: TYPES.PROPERTY,
1905
+ key: {
1906
+ type: TYPES.IDENTIFIER,
1907
+ name: "id"
1908
+ }
1909
+ }]
1910
+ }],
1911
+ body: matchesIdOperatorCheck(operator, "objectParam")
1912
+ }
1913
+ });
1914
+
1915
+ const buildChecksForByFunc = (functions, pattern) => ({
1916
+ operateOn: TYPES.CALL_EXPRESSION,
1917
+ check: (context, node) => checkByFunc(context, node, {
1918
+ genericPatterns: pattern.GENERIC,
1919
+ byIdPattern: pattern.BY_ID,
1920
+ functions
1921
+ })
1922
+ });
1923
+
1924
+ const findBy = buildChecksForByFunc({
1925
+ by: "findBy",
1926
+ byId: "findById"
1927
+ }, {
1928
+ GENERIC: getPatternsOfByFunc("find", {
1929
+ compare: "===",
1930
+ join: "&&"
1931
+ }),
1932
+ BY_ID: getPatternOfByIdFunc("===")
1933
+ });
1934
+ const removeBy = buildChecksForByFunc({
1935
+ by: "removeBy",
1936
+ byId: "removeById"
1937
+ }, {
1938
+ GENERIC: getPatternsOfByFunc("filter", {
1939
+ compare: "!==",
1940
+ join: "||"
1941
+ }),
1942
+ BY_ID: getPatternOfByIdFunc("!==")
1943
+ });
1944
+ const existsBy = buildChecksForByFunc({
1945
+ by: "existsBy",
1946
+ byId: "existsById"
1947
+ }, {
1948
+ GENERIC: getPatternsOfByFunc("some", {
1949
+ compare: "===",
1950
+ join: "&&"
1951
+ }),
1952
+ BY_ID: getPatternOfByIdFunc("===")
1953
+ });
1954
+ const findIndexBy = buildChecksForByFunc({
1955
+ by: "findIndexBy",
1956
+ byId: "findIndexById"
1957
+ }, {
1958
+ GENERIC: getPatternsOfByFunc("findIndex", {
1959
+ compare: "===",
1960
+ join: "&&"
1961
+ }),
1962
+ BY_ID: getPatternOfByIdFunc("===")
1963
+ });
1964
+ const findLastBy = buildChecksForByFunc({
1965
+ by: "findLastBy"
1966
+ }, {
1967
+ GENERIC: getPatternsOfByFunc("findLast", {
1968
+ compare: "===",
1969
+ join: "&&"
1970
+ })
1971
+ });
1972
+ const findLastIndexBy = buildChecksForByFunc({
1973
+ by: "findLastIndexBy"
1974
+ }, {
1975
+ GENERIC: getPatternsOfByFunc("findLastIndex", {
1976
+ compare: "===",
1977
+ join: "&&"
1978
+ })
1979
+ });
1980
+ const filterBy = buildChecksForByFunc({
1981
+ by: "filterBy"
1982
+ }, {
1983
+ GENERIC: getPatternsOfByFunc("filter", {
1984
+ compare: "===",
1985
+ join: "&&"
1986
+ })
1987
+ });
1988
+
1989
+ var capitalize = {
1990
+ operateOn: TYPES.BINARY_EXPRESSION,
1991
+ check: (context, node) => {
1992
+ if (!matches(CAPITALIZE_PATTERN, node)) return;
1993
+ const fix = `capitalize(${getCode$1(context, node.right.callee.object)})`;
1994
+ reportSuggestion({
1995
+ context,
1996
+ node,
1997
+ fix,
1998
+ func: "capitalize"
1999
+ });
2000
+ }
2001
+ };
2002
+
2003
+ var copyKeys = {
2004
+ operateOn: TYPES.OBJECT_EXPRESSION,
2005
+ check: (context, node) => {
2006
+ if (!matches(COPY_KEYS_PATTERN, node)) return;
2007
+ const keyValuePairs = node.properties.slice(1).map(prop => [prop.value.property.name, prop.key.name]);
2008
+ const keyMap = JSON.stringify(ramda.fromPairs(keyValuePairs));
2009
+ const sourceObject = getCode$1(context, node.properties[0].argument);
2010
+ const fix = `copyKeys(${keyMap}, ${sourceObject})`;
2011
+ reportSuggestion({
2012
+ context,
2013
+ node,
2014
+ fix,
2015
+ func: "copyKeys"
2016
+ });
2017
+ }
2018
+ };
2019
+
2020
+ var dynamicArray = {
2021
+ operateOn: "CallExpression",
2022
+ check: (context, node) => {
2023
+ var _node$arguments$1$par;
2024
+
2025
+ if (!matches(DYNAMIC_ARRAY_PATTERN, node)) return;
2026
+ const length = getCode$1(context, node.arguments[0].properties[0].value);
2027
+ const elementGenIndexParam = (_node$arguments$1$par = node.arguments[1].params[1]) === null || _node$arguments$1$par === void 0 ? void 0 : _node$arguments$1$par.name;
2028
+ const elementGenBody = getCode$1(context, node.arguments[1].body);
2029
+ const fix = `dynamicArray(${length}, ${elementGenIndexParam || "()"} => ${elementGenBody})`;
2030
+ reportSuggestion({
2031
+ context,
2032
+ node,
2033
+ fix,
2034
+ func: "dynamicArray"
2035
+ });
2036
+ }
2037
+ };
2038
+
2039
+ var isNot = {
2040
+ operateOn: [TYPES.UNARY_EXPRESSION, TYPES.ARROW_FUNCTION_EXPRESSION],
2041
+ check: (context, node) => {
2042
+ let fix = null;
795
2043
 
796
- const checkCaseAndReport = ({
797
- context,
798
- name,
799
- node
800
- }) => {
801
- if (CONSTANT_CASE_PATTERN.test(name)) return;
802
- context.report({
803
- node,
804
- message: useConstantCaseFor(name),
805
- suggest: [{
806
- desc: `Replace ${getCode(context, node)} with ${toConstantCase(name)}`,
807
- fix: fixer => fixer.replaceText(node, toConstantCase(name))
808
- }]
809
- });
810
- };
2044
+ if (node.type === TYPES.UNARY_EXPRESSION) {
2045
+ if (!matches(NOT_EQUALS_PATTERNS.UNARY_EXP, node)) return;
2046
+ const first = getCode$1(context, node.argument.arguments[0]);
2047
+ const second = getCode$1(context, node.argument.arguments[1]);
2048
+ fix = `isNot(${first}, ${second})`;
2049
+ } else {
2050
+ if (!matches(NOT_EQUALS_PATTERNS.ARROW_FUNC, node)) return;
2051
+ const argumentName = node.params[0].name;
2052
+ let externalValueNode = null;
2053
+
2054
+ if (argumentName === node.body.left.name) {
2055
+ externalValueNode = node.body.right;
2056
+ } else if (argumentName === node.body.right.name) {
2057
+ externalValueNode = node.body.left;
2058
+ } else return;
2059
+
2060
+ const externalValue = getCode$1(context, externalValueNode);
2061
+ fix = `isNot(${externalValue})`;
2062
+ }
811
2063
 
812
- const checkExportAndReport = ({
813
- context,
814
- exported,
815
- local,
816
- node,
817
- statement
818
- }) => {
819
- if (CONSTANT_CASE_PATTERN.test(exported.name)) return;
820
- context.report({
821
- node,
822
- message: useConstantCaseFor(exported.name),
823
- suggest: [{
824
- desc: `Replace ${getCode(context, node)} with ${toConstantCase(exported.name)}`,
825
- fix: fixer => {
826
- const newName = toConstantCase(exported.name);
2064
+ reportSuggestion({
2065
+ context,
2066
+ node,
2067
+ fix,
2068
+ func: "isNot"
2069
+ });
2070
+ }
2071
+ };
827
2072
 
828
- if (local.name === exported.name) {
829
- return fixer.replaceText(statement, newName);
830
- }
2073
+ var isNotEmpty = {
2074
+ operateOn: [TYPES.IF_STATEMENT, TYPES.WHILE_STATEMENT, TYPES.BINARY_EXPRESSION, TYPES.ARROW_FUNCTION_EXPRESSION],
2075
+ check: (context, node) => {
2076
+ const isBinaryExp = node.type === TYPES.BINARY_EXPRESSION;
2077
+ const isArrowFunc = node.type === TYPES.ARROW_FUNCTION_EXPRESSION;
2078
+ const isCondStat = node.type === TYPES.IF_STATEMENT || node.type === TYPES.WHILE_STATEMENT;
2079
+ if (isBinaryExp && !matches(NOT_EMPTY_PATTERNS.BINARY_EXP, node)) return;
2080
+ if (isArrowFunc && !matches(NOT_EMPTY_PATTERNS.ARROW_FUNC, node)) return;
2081
+ if (isCondStat && !matches(NOT_EMPTY_PATTERNS.CONDT_STAT, node)) return;
2082
+ let fix = null;
2083
+ let message = "";
2084
+ let nodeToBeReplaced = node;
831
2085
 
832
- if (local.name === newName) {
833
- return fixer.replaceText(statement, local.name);
834
- }
2086
+ if (isArrowFunc) {
2087
+ fix = "isNotEmpty";
2088
+ } else {
2089
+ const expNode = isBinaryExp ? node.left : node.test;
2090
+ const isObjLenCheck = matches(OBJ_KEY_LENGTH_PATTERN$1, expNode);
2091
+ nodeToBeReplaced = isBinaryExp ? node : node.test;
835
2092
 
836
- return fixer.replaceText(exported, newName);
2093
+ if (isObjLenCheck) {
2094
+ const objName = getCode$1(context, expNode.object.arguments[0]);
2095
+ fix = `isNotEmpty(${objName})`;
2096
+ } else {
2097
+ const arrName = getCode$1(context, expNode.object);
2098
+ fix = `isNotEmpty(${arrName})`;
2099
+ message = `Can be replaced with: ${fix}, if '${arrName}' is an array or string.`;
837
2100
  }
838
- }]
839
- });
2101
+ }
2102
+
2103
+ reportSuggestion({
2104
+ context,
2105
+ node: nodeToBeReplaced,
2106
+ fix,
2107
+ func: "isNotEmpty",
2108
+ message
2109
+ });
2110
+ }
840
2111
  };
841
2112
 
842
- var useConstantCase = {
843
- meta: {
844
- type: "suggestion",
845
- docs: {
846
- description: "Enforces constants in constants.js file to be named using constant-case."
847
- },
848
- hasSuggestions: true
849
- },
850
- create: context => ({
851
- ExportNamedDeclaration(node) {
852
- var _node$declaration;
2113
+ var isNotEqualDeep = {
2114
+ operateOn: [TYPES.BINARY_EXPRESSION, TYPES.ARROW_FUNCTION_EXPRESSION],
2115
+ check: (context, node) => {
2116
+ let fix = null;
853
2117
 
854
- if (!isConstantsFile(context)) return;
2118
+ if (node.type === TYPES.BINARY_EXPRESSION) {
2119
+ if (!matches(NOT_EQUALS_DEEP_PATTERNS.BINARY_EXP, node)) return;
2120
+ const first = getCode$1(context, node.left.arguments[0]);
2121
+ const second = getCode$1(context, node.right.arguments[0]);
2122
+ fix = `isNotEqualDeep(${first}, ${second})`;
2123
+ } else {
2124
+ if (!matches(NOT_EQUALS_DEEP_PATTERNS.ARROW_FUNC, node)) return;
2125
+ const argumentName = node.params[0].name;
2126
+ let externalValueNode = null;
2127
+
2128
+ if (argumentName === node.body.left.arguments[0].name) {
2129
+ externalValueNode = node.body.right.arguments[0];
2130
+ } else if (argumentName === node.body.right.arguments[0].name) {
2131
+ externalValueNode = node.body.left.arguments[0];
2132
+ } else return;
2133
+
2134
+ const externalValue = getCode$1(context, externalValueNode);
2135
+ fix = `isNotEqualDeep(${externalValue})`;
2136
+ }
855
2137
 
856
- if (((_node$declaration = node.declaration) === null || _node$declaration === void 0 ? void 0 : _node$declaration.kind) === "const") {
857
- var _node$declaration2;
2138
+ reportSuggestion({
2139
+ context,
2140
+ node,
2141
+ fix,
2142
+ func: "isNotEqualDeep"
2143
+ });
2144
+ }
2145
+ };
858
2146
 
859
- (_node$declaration2 = node.declaration) === null || _node$declaration2 === void 0 ? void 0 : _node$declaration2.declarations.forEach(({
860
- id
861
- }) => {
862
- if (id.type !== TYPES.OBJECT_PATTERN) {
863
- checkCaseAndReport({
864
- context,
865
- name: id.name,
866
- node: id
867
- });
868
- return;
869
- }
2147
+ var isNotNil = {
2148
+ operateOn: [TYPES.LOGICAL_EXPRESSION, TYPES.ARROW_FUNCTION_EXPRESSION],
2149
+ check: (context, node) => {
2150
+ if (!matchesAny(NOT_NIL_PATTERNS, node)) return;
2151
+ let fix = null;
870
2152
 
871
- id.properties.forEach(statement => {
872
- checkExportAndReport({
873
- context,
874
- exported: statement.value,
875
- local: statement.key,
876
- node,
877
- statement
878
- });
879
- });
880
- });
881
- } else {
882
- node.specifiers.forEach(statement => {
883
- const {
884
- exported,
885
- local
886
- } = statement;
887
- checkExportAndReport({
888
- context,
889
- exported,
890
- local,
891
- node,
892
- statement
893
- });
894
- });
895
- }
2153
+ if (node.type === TYPES.ARROW_FUNCTION_EXPRESSION) {
2154
+ if (node.params[0].name !== node.body.argument.arguments[0].name) return;
2155
+ fix = `isNotNil`;
2156
+ } else if (node.type === TYPES.LOGICAL_EXPRESSION) {
2157
+ if (node.left.left.name !== node.right.left.name) return;
2158
+ fix = `isNotNil(${node.left.left.name})`;
896
2159
  }
897
2160
 
898
- })
2161
+ reportSuggestion({
2162
+ context,
2163
+ node,
2164
+ fix,
2165
+ func: "isNotNil"
2166
+ });
2167
+ }
899
2168
  };
900
2169
 
901
- const ASSIGNMENT_PATTERNS = [{
902
- id: {
903
- type: "ObjectPattern"
904
- }
905
- }, {
906
- id: {
907
- type: "Identifier"
2170
+ var noop = {
2171
+ operateOn: ["FunctionExpression", "ArrowFunctionExpression", "FunctionDeclaration"],
2172
+ check: (context, node) => {
2173
+ if (matches(NOOP_PATTERN, node)) {
2174
+ reportSuggestion({
2175
+ context,
2176
+ node,
2177
+ fix: "noop",
2178
+ func: "noop"
2179
+ });
2180
+ }
908
2181
  }
909
- }];
910
- const IDENTIFIER_INITIALIZATION_PATTERN = {
911
- type: "Identifier",
912
- name: "globalProps"
913
2182
  };
914
- const MEMBER_EXPRESSION_INITIALIZATION_PATTERN = {
915
- type: "MemberExpression",
2183
+
2184
+ const getMemberIdPattern = paramName => ({
2185
+ type: TYPES.MEMBER_EXPRESSION,
916
2186
  object: {
917
- type: "Identifier",
918
- name: "globalProps"
919
- }
920
- };
921
- const GLOBALPROPS_REASSIGNMENT_PATTERN = {
922
- type: "Identifier",
923
- name: "globalProps"
924
- };
2187
+ type: TYPES.IDENTIFIER,
2188
+ name: name => name === paramName
2189
+ },
2190
+ computed: false,
2191
+ property: {
2192
+ type: TYPES.IDENTIFIER,
2193
+ name: "id"
2194
+ },
2195
+ optional: false
2196
+ });
925
2197
 
926
- const checkAssignment = (context, node) => {
927
- if (matches_1(IDENTIFIER_INITIALIZATION_PATTERN, node)) {
928
- context.report(node, GLOBALPROPS_NO_ASSIGNMENT_MESSAGE);
929
- } else if (matches_1(MEMBER_EXPRESSION_INITIALIZATION_PATTERN, node)) {
930
- context.report(node, NESTED_GLOBALPROPS_NO_ASSIGNMENT_MESSAGE);
2198
+ var replaceBy = {
2199
+ operateOn: TYPES.CALL_EXPRESSION,
2200
+ check: (context, node) => {
2201
+ var _node$arguments;
2202
+
2203
+ const {
2204
+ body: conditional
2205
+ } = ((_node$arguments = node.arguments) === null || _node$arguments === void 0 ? void 0 : _node$arguments[0]) ?? {};
2206
+ let comparison = null,
2207
+ replaceNode = null,
2208
+ binaryExpressionPattern = null;
2209
+
2210
+ if (matches(REPLACE_BY_PATTERN, node)) {
2211
+ binaryExpressionPattern = {
2212
+ type: TYPES.BINARY_EXPRESSION,
2213
+ operator: "==="
2214
+ };
2215
+ replaceNode = conditional.consequent;
2216
+ comparison = conditional.test;
2217
+ } else if (matches(REPLACE_BY_NEGATED_PATTERN, node)) {
2218
+ binaryExpressionPattern = {
2219
+ type: TYPES.BINARY_EXPRESSION,
2220
+ operator: "!=="
2221
+ };
2222
+ replaceNode = conditional.alternate;
2223
+ comparison = conditional.test;
2224
+ } else return;
2225
+
2226
+ if (!matches(binaryExpressionPattern, comparison)) {
2227
+ context.report({
2228
+ node,
2229
+ message: canBeShortenedWithCommons("replaceBy")
2230
+ });
2231
+ return;
2232
+ }
2233
+
2234
+ const argumentName = arrayFuncParam(node).name;
2235
+ const memberIdPattern = getMemberIdPattern(argumentName);
2236
+ let externalId = null;
2237
+
2238
+ if (matches(memberIdPattern, comparison.left)) {
2239
+ externalId = comparison.right;
2240
+ } else if (matches(memberIdPattern, comparison.right)) {
2241
+ externalId = comparison.left;
2242
+ } else return;
2243
+
2244
+ const id = getCode$1(context, externalId);
2245
+ const replacement = getCode$1(context, replaceNode);
2246
+ const array = getCode$1(context, node.callee.object);
2247
+ const fix = `replaceById(${id}, ${replacement}, ${array})`;
2248
+ reportSuggestion({
2249
+ context,
2250
+ node,
2251
+ fix,
2252
+ func: "replaceById"
2253
+ });
931
2254
  }
932
2255
  };
933
2256
 
934
- var noGlobalPropsDestructure = {
935
- meta: {
936
- type: "problem",
937
- docs: {
938
- description: "Disallows destructuring of globalProps."
939
- }
940
- },
941
- create: context => ({
942
- VariableDeclarator(node) {
943
- if (!matchesAny(node, ASSIGNMENT_PATTERNS)) return;
944
- checkAssignment(context, node.init);
945
- },
2257
+ var toLabelAndValue = {
2258
+ operateOn: "ObjectExpression",
2259
+ check: (context, node) => {
2260
+ if (!matches(LABEL_AND_VALUE_PATTERN, node)) return;
2261
+ const [label, value] = ramda.pluck("value", node.properties).map(node => getCode$1(context, node)); // order doesn't matter here
946
2262
 
947
- AssignmentExpression: node => checkAssignment(context, node.right)
948
- })
2263
+ if (label !== value) return;
2264
+ const fix = `toLabelAndValue(${label})`;
2265
+ reportSuggestion({
2266
+ context,
2267
+ node,
2268
+ fix,
2269
+ func: "toLabelAndValue"
2270
+ });
2271
+ }
949
2272
  };
950
2273
 
951
- var noGlobalPropsReassignment = {
2274
+ var neetocommonsTips = {
952
2275
  meta: {
953
- type: "problem",
2276
+ type: "suggestion",
954
2277
  docs: {
955
- description: "Disallows re-assignment of globalProps."
956
- }
2278
+ description: "Provides suggestions on pieces of code that can be imported from neeto-commons-frontend rather than reinventing the wheel"
2279
+ },
2280
+ hasSuggestions: true
957
2281
  },
958
- create: context => ({
959
- AssignmentExpression(node) {
960
- if (patternExistsDeep(node.left, GLOBALPROPS_REASSIGNMENT_PATTERN)) {
961
- context.report(node, NO_GLOBALPROPS_REASSIGNMENT_MESSAGE);
962
- }
963
- }
964
-
965
- })
2282
+ create: context => {
2283
+ const operationsArr = [noop, toLabelAndValue, findBy, removeBy, existsBy, filterBy, findIndexBy, findLastBy, findLastIndexBy, replaceBy, copyKeys, dynamicArray, capitalize, isNotNil, isNotEqualDeep, isNot, isNotEmpty].map(op => {
2284
+ if (!Array.isArray(op.operateOn)) return op;
2285
+ return op.operateOn.map(operateOn => ({
2286
+ operateOn,
2287
+ check: op.check
2288
+ }));
2289
+ }).flat();
2290
+ const operations = ramda.groupBy(ramda.prop("operateOn"), operationsArr);
2291
+ return ramda.fromPairs(ramda.toPairs(operations).map(([operateOn, operations]) => [operateOn, node => operations.forEach(op => op.check(context, node))]));
2292
+ }
966
2293
  };
967
2294
 
968
2295
  var noAxiosImportOutsideApis = {
@@ -1010,18 +2337,18 @@
1010
2337
  }) => type !== TYPES.ASSIGNMENT_PATTERN;
1011
2338
 
1012
2339
  const containsExcessArguments = (params, isApiAction) => {
1013
- const noOfParams = require$$0.count(nonDefaultParam, params);
2340
+ const noOfParams = ramda.count(nonDefaultParam, params);
1014
2341
  return isApiAction ? noOfParams > API_ACTIONS_ARGUMENT_LIMIT : noOfParams > ARGUMENT_LIMIT;
1015
2342
  };
1016
2343
 
1017
- const getParamList = (context, params) => params.map(param => getCode(context, param)).join(", ");
2344
+ const getParamList = (context, params) => params.map(param => getCode$1(context, param)).join(", ");
1018
2345
 
1019
2346
  const checkAndReport$2 = (context, params) => {
1020
2347
  const isApiAction = isInsideApisDirectory(context);
1021
2348
  if (!containsExcessArguments(params, isApiAction)) return;
1022
2349
  const loc = {
1023
2350
  start: params[0].loc.start,
1024
- end: require$$0.last(params).loc.end
2351
+ end: ramda.last(params).loc.end
1025
2352
  };
1026
2353
  const messages = isApiAction ? [NO_EXCESS_API_ACTION_ARGUMENTS_MESSAGE] : [NO_EXCESS_FUNCTION_ARGUMENTS_MESSAGE];
1027
2354
  const containsUnfixableParam = params.some(({
@@ -1085,7 +2412,7 @@
1085
2412
  }]
1086
2413
  }];
1087
2414
 
1088
- const i18next = require$$0.memoizeWith(() => "", () => require("i18next"));
2415
+ const i18next = ramda.memoizeWith(() => "", () => require("i18next"));
1089
2416
 
1090
2417
  const isKeyMissing = ({
1091
2418
  config,
@@ -1095,7 +2422,7 @@
1095
2422
  const translationExists = i18next().exists(key, config);
1096
2423
  if (!translationExists) return true;
1097
2424
  const translation = i18next().t(key, config);
1098
- return typeof require$$0.path(translation.exactUsedKey.split("."), content) !== "string";
2425
+ return typeof ramda.path(translation.exactUsedKey.split("."), content) !== "string";
1099
2426
  };
1100
2427
 
1101
2428
  const checkAndReport$1 = ({
@@ -1174,7 +2501,7 @@
1174
2501
  CallExpression(node) {
1175
2502
  var _node$arguments$;
1176
2503
 
1177
- if (!matchesAny(node, LOCALIZATION_CALL_PATTERNS)) return;
2504
+ if (!matchesAny(LOCALIZATION_CALL_PATTERNS, node)) return;
1178
2505
  const config = {};
1179
2506
 
1180
2507
  if (((_node$arguments$ = node.arguments[1]) === null || _node$arguments$ === void 0 ? void 0 : _node$arguments$.type) === TYPES.OBJECT_EXPRESSION) {
@@ -1240,12 +2567,12 @@
1240
2567
  if (!node || typeof node !== "object") return acc;
1241
2568
  return Object.entries(node).reduce((acc, [key, value]) => {
1242
2569
  if (key === "parent") return acc;
1243
- if (matches_1(ramdaUsage(identifierName), value)) return [...acc, value];
2570
+ if (matches(ramdaUsage(identifierName), value)) return [...acc, value];
1244
2571
  return findAllRamdaUsage(value, identifierName, acc);
1245
2572
  }, acc);
1246
2573
  };
1247
2574
 
1248
- const gatherMethods = require$$0.pipe(require$$0.map(require$$0.path(["property", "name"])), require$$0.sortBy(require$$0.identity), require$$0.uniq, require$$0.join(", "));
2575
+ const gatherMethods = ramda.pipe(ramda.map(ramda.path(["property", "name"])), ramda.sortBy(ramda.identity), ramda.uniq, ramda.join(", "));
1249
2576
  var noNamespaceSpecifierImportForRamda = {
1250
2577
  meta: {
1251
2578
  type: "problem",
@@ -1256,7 +2583,7 @@
1256
2583
  },
1257
2584
  create: context => ({
1258
2585
  ImportDeclaration: node => {
1259
- if (matches_1(RAMDA_NAMESPACE_IMPORT_PATTERN, node)) {
2586
+ if (matches(RAMDA_NAMESPACE_IMPORT_PATTERN, node)) {
1260
2587
  const allRUsages = findAllRamdaUsage(node.parent.body, node.specifiers[0].local.name);
1261
2588
  const ramdaMethodsUsed = gatherMethods(allRUsages);
1262
2589
  context.report({
@@ -1321,14 +2648,14 @@
1321
2648
  expressions,
1322
2649
  quasis
1323
2650
  }) => expressions.reduce((acc, expression, index) => {
1324
- const expressionCode = getCode(context, expression);
2651
+ const expressionCode = getCode$1(context, expression);
1325
2652
  const quasi = quasis[index + 1].value.cooked;
1326
2653
  return `${acc}{${expressionCode}}${quasi}`;
1327
2654
  }, `${quasis[0].value.cooked}`);
1328
2655
 
1329
2656
  const isExpressionOnly = node => node.expressions.length === 1 && node.quasis.length === 2 && node.quasis[0].value.cooked === "" && node.quasis[1].value.cooked === "";
1330
2657
 
1331
- const isInsideJSXElement = node => node.parent.type === TYPES.JSX_EXPRESSION_CONTAINER && node.parent.parent.type === TYPES.JSX_ELEMENT && !node.quasis[0].value.cooked.match(STARTS_WITH_SPACES_PATTERN) && !require$$0.last(node.quasis).value.cooked.match(ENDS_WITH_SPACES_PATTERN);
2658
+ const isInsideJSXElement = node => node.parent.type === TYPES.JSX_EXPRESSION_CONTAINER && node.parent.parent.type === TYPES.JSX_ELEMENT && !node.quasis[0].value.cooked.match(STARTS_WITH_SPACES_PATTERN) && !ramda.last(node.quasis).value.cooked.match(ENDS_WITH_SPACES_PATTERN);
1332
2659
 
1333
2660
  const isReplaceableQuasiOnly = node => node.expressions.length === 0 && node.quasis.length === 1 && !node.quasis[0].value.cooked.match(STARTS_OR_ENDS_WITH_SPACES_PATTERN);
1334
2661
 
@@ -1345,7 +2672,7 @@
1345
2672
  if (doQusisHaveSpecialCharacters(node)) return;
1346
2673
 
1347
2674
  if (isExpressionOnly(node)) {
1348
- const fix = getCode(context, node.expressions[0]);
2675
+ const fix = getCode$1(context, node.expressions[0]);
1349
2676
  context.report({
1350
2677
  node,
1351
2678
  message: canBeReplacedWith(fix),
@@ -1405,6 +2732,45 @@
1405
2732
  })
1406
2733
  };
1407
2734
 
2735
+ const NIL_BINARY_EXP_PATTERN = {
2736
+ type: TYPES.BINARY_EXPRESSION,
2737
+ operator: "===",
2738
+ right: matchesAny([{
2739
+ type: TYPES.LITERAL,
2740
+ value: null
2741
+ }, {
2742
+ type: TYPES.IDENTIFIER,
2743
+ name: "undefined"
2744
+ }])
2745
+ };
2746
+ const ARRAY_LENGTH_PATTERN = {
2747
+ type: TYPES.MEMBER_EXPRESSION,
2748
+ property: {
2749
+ type: TYPES.IDENTIFIER,
2750
+ name: "length"
2751
+ }
2752
+ };
2753
+ const OBJ_KEY_LENGTH_PATTERN = {
2754
+ type: TYPES.MEMBER_EXPRESSION,
2755
+ object: {
2756
+ type: TYPES.CALL_EXPRESSION,
2757
+ callee: {
2758
+ type: TYPES.MEMBER_EXPRESSION,
2759
+ object: {
2760
+ type: TYPES.IDENTIFIER,
2761
+ name: "Object"
2762
+ },
2763
+ property: {
2764
+ type: TYPES.IDENTIFIER,
2765
+ name: "keys"
2766
+ }
2767
+ }
2768
+ },
2769
+ property: {
2770
+ type: TYPES.IDENTIFIER,
2771
+ name: "length"
2772
+ }
2773
+ };
1408
2774
  const ARRAY_INSERTS_PATTERN = {
1409
2775
  APPEND: {
1410
2776
  // x => [...x, y]
@@ -1701,29 +3067,29 @@
1701
3067
  }
1702
3068
  }
1703
3069
  };
1704
-
1705
- const addFunctionImport = (context, fixer, functions) => {
1706
- const root = context.getAncestors()[0];
1707
- const ramdaImport = root.body.find(node => matches_1(RAMDA_IMPORT_PATTERN, node));
1708
-
1709
- if (ramdaImport) {
1710
- const extraImports = functions.filter(func => !ramdaImport.specifiers.some(require$$0.pathEq(["imported", "name"], func)));
1711
- if (require$$0.isEmpty(extraImports)) return undefined;
1712
- return fixer.insertTextBefore(ramdaImport.specifiers[0], `${extraImports.join(", ")}, `);
3070
+ const NIL_PATTERN = // x === null || x === undefined
3071
+ {
3072
+ operator: "||",
3073
+ left: NIL_BINARY_EXP_PATTERN,
3074
+ right: NIL_BINARY_EXP_PATTERN
3075
+ };
3076
+ const EMPTY_PATTERN = [// array.length === 0, Object.keys(obj).length === 0, if(array.length === 0), while(array.length === 0)
3077
+ {
3078
+ type: TYPES.BINARY_EXPRESSION,
3079
+ operator: "===",
3080
+ left: matchesAny([ARRAY_LENGTH_PATTERN, OBJ_KEY_LENGTH_PATTERN]),
3081
+ right: {
3082
+ type: TYPES.LITERAL,
3083
+ value: 0
1713
3084
  }
1714
-
1715
- return fixer.insertTextBefore(root.body[0], `import { ${functions.join(", ")} } from "ramda";\n`);
1716
- };
1717
- const replaceNodeWithImports = ({
1718
- context,
1719
- node,
1720
- fix,
1721
- functions
1722
- }) => function* (fixer) {
1723
- const imports = addFunctionImport(context, fixer, Array.isArray(functions) ? functions : [functions]);
1724
- if (imports) yield imports;
1725
- yield fixer.replaceText(node, fix);
1726
- };
3085
+ }, // if(!array.length), if(!Object.keys(obj).length), while(!array.length), while(!Object.keys(obj).length)
3086
+ {
3087
+ type: TYPES.UNARY_EXPRESSION,
3088
+ operator: "!",
3089
+ prefix: true,
3090
+ argument: matchesAny([ARRAY_LENGTH_PATTERN, OBJ_KEY_LENGTH_PATTERN])
3091
+ }];
3092
+ const replacer = nodeReplacerWithImports(RAMDA_IMPORT_PATTERN);
1727
3093
 
1728
3094
  var arrayInsertsLintCheck = {
1729
3095
  operateOn: "ArrowFunctionExpression",
@@ -1742,12 +3108,12 @@
1742
3108
  } = body;
1743
3109
  let fix = null;
1744
3110
 
1745
- if (matches_1(ARRAY_INSERTS_PATTERN.APPEND, node) && elements[1].type !== TYPES.SPREAD_ELEMENT && params[0].name === elements[0].argument.name) {
1746
- fix = `append(${getCode(context, elements[1])})`;
1747
- } else if (matches_1(ARRAY_INSERTS_PATTERN.PREPEND, node) && elements[0].type !== TYPES.SPREAD_ELEMENT && params[0].name === elements[1].argument.name) {
1748
- fix = `prepend(${getCode(context, elements[0])})`;
1749
- } else if (matches_1(ARRAY_INSERTS_PATTERN.CONCAT, node) && params[0].name === elements[0].argument.name) {
1750
- fix = `concat(${getCode(context, elements[1].argument)})`;
3111
+ if (matches(ARRAY_INSERTS_PATTERN.APPEND, node) && elements[1].type !== TYPES.SPREAD_ELEMENT && params[0].name === elements[0].argument.name) {
3112
+ fix = `append(${getCode$1(context, elements[1])})`;
3113
+ } else if (matches(ARRAY_INSERTS_PATTERN.PREPEND, node) && elements[0].type !== TYPES.SPREAD_ELEMENT && params[0].name === elements[1].argument.name) {
3114
+ fix = `prepend(${getCode$1(context, elements[0])})`;
3115
+ } else if (matches(ARRAY_INSERTS_PATTERN.CONCAT, node) && params[0].name === elements[0].argument.name) {
3116
+ fix = `concat(${getCode$1(context, elements[1].argument)})`;
1751
3117
  }
1752
3118
 
1753
3119
  if (!fix) return;
@@ -1757,7 +3123,7 @@
1757
3123
  message: canBeReplacedWith(fix),
1758
3124
  suggest: [{
1759
3125
  desc: `Replace with ${funcName} function`,
1760
- fix: replaceNodeWithImports({
3126
+ fix: replacer.replaceNode({
1761
3127
  context,
1762
3128
  node,
1763
3129
  fix,
@@ -1770,15 +3136,15 @@
1770
3136
 
1771
3137
  const convertToAssoc = (context, node) => {
1772
3138
  const property = node.body.properties[1];
1773
- const key = property.computed ? getCode(context, property.key) : `"${property.key.name}"`;
1774
- return `assoc(${key}, ${getCode(context, property.value)})`;
3139
+ const key = property.computed ? getCode$1(context, property.key) : `"${property.key.name}"`;
3140
+ return `assoc(${key}, ${getCode$1(context, property.value)})`;
1775
3141
  };
1776
3142
 
1777
3143
  var assocLintCheck = {
1778
3144
  operateOn: "ArrowFunctionExpression",
1779
3145
  check: (context, node) => {
1780
3146
  if (node.params.length !== 1) return;
1781
- if (!matches_1(ASSOC_PATTERN, node)) return;
3147
+ if (!matches(ASSOC_PATTERN, node)) return;
1782
3148
  if (node.body.properties.length !== 2) return;
1783
3149
  if (node.body.properties[0].argument.name !== node.params[0].name) return;
1784
3150
  const property = node.body.properties[1];
@@ -1786,14 +3152,14 @@
1786
3152
  type: "Identifier",
1787
3153
  name: node.params[0].name
1788
3154
  };
1789
- if (patternExistsDeep(property.value, selfReferencingPattern)) return;
3155
+ if (patternExistsDeep(selfReferencingPattern, property.value)) return;
1790
3156
  const fix = convertToAssoc(context, node);
1791
3157
  context.report({
1792
3158
  node,
1793
3159
  message: canBeReplacedWith(fix),
1794
3160
  suggest: [{
1795
3161
  desc: "Replace with assoc function",
1796
- fix: replaceNodeWithImports({
3162
+ fix: replacer.replaceNode({
1797
3163
  context,
1798
3164
  node,
1799
3165
  fix,
@@ -1807,14 +3173,14 @@
1807
3173
  var equalsLintCheck = {
1808
3174
  operateOn: "BinaryExpression",
1809
3175
  check: (context, node) => {
1810
- if (matches_1(JSON_EQUALS_PATTERN, node)) {
1811
- const fix = `equals(${getCode(context, node.left.arguments[0])}, ${getCode(context, node.right.arguments[0])})`;
3176
+ if (matches(JSON_EQUALS_PATTERN, node)) {
3177
+ const fix = `equals(${getCode$1(context, node.left.arguments[0])}, ${getCode$1(context, node.right.arguments[0])})`;
1812
3178
  context.report({
1813
3179
  node,
1814
3180
  message: canBeReplacedWith(fix),
1815
3181
  suggest: [{
1816
3182
  desc: "Replace with equals function",
1817
- fix: replaceNodeWithImports({
3183
+ fix: replacer.replaceNode({
1818
3184
  context,
1819
3185
  node,
1820
3186
  fix,
@@ -1829,13 +3195,13 @@
1829
3195
  var identityLintCheck = {
1830
3196
  operateOn: "ArrowFunctionExpression",
1831
3197
  check: (context, node) => {
1832
- if (matches_1(IDENTITY_PATTERN, node) && node.params[0].name === node.body.name) {
3198
+ if (matches(IDENTITY_PATTERN, node) && node.params[0].name === node.body.name) {
1833
3199
  context.report({
1834
3200
  node,
1835
3201
  message: canBeReplacedWith("identity"),
1836
3202
  suggest: [{
1837
3203
  desc: "Replace with identity function",
1838
- fix: replaceNodeWithImports({
3204
+ fix: replacer.replaceNode({
1839
3205
  context,
1840
3206
  node,
1841
3207
  fix: "identity",
@@ -1847,13 +3213,57 @@
1847
3213
  }
1848
3214
  };
1849
3215
 
1850
- const findPatternIndex = node => MERGE_PATTERNS.findIndex(matches_1(require$$0.__, node));
3216
+ var isEmptyCheck = {
3217
+ operateOn: [TYPES.BINARY_EXPRESSION, TYPES.UNARY_EXPRESSION],
3218
+ check: (context, node) => {
3219
+ if (!matchesAny(EMPTY_PATTERN, node)) return;
3220
+ let fix = null;
3221
+ let message = "";
3222
+ const isBinaryExp = node.type === TYPES.BINARY_EXPRESSION;
3223
+ const expNode = isBinaryExp ? node.left : node.argument;
3224
+ const isObjLenCheck = matches(OBJ_KEY_LENGTH_PATTERN, expNode);
3225
+
3226
+ if (isObjLenCheck) {
3227
+ const objName = getCode$1(context, expNode.object.arguments[0]);
3228
+ fix = `isEmpty(${objName})`;
3229
+ } else {
3230
+ const arrName = getCode$1(context, expNode.object);
3231
+ fix = `isEmpty(${arrName})`;
3232
+ message = `Can be replaced with: ${fix}, if '${arrName}' is an array or string.`;
3233
+ }
3234
+
3235
+ reportSuggestion({
3236
+ context,
3237
+ node,
3238
+ fix,
3239
+ func: "isEmpty",
3240
+ message
3241
+ });
3242
+ }
3243
+ };
3244
+
3245
+ var isNilCheck = {
3246
+ operateOn: TYPES.LOGICAL_EXPRESSION,
3247
+ check: (context, node) => {
3248
+ if (!matches(NIL_PATTERN, node)) return;
3249
+ if (node.left.left.name !== node.right.left.name) return;
3250
+ const fix = `isNil(${node.left.left.name})`;
3251
+ reportSuggestion({
3252
+ context,
3253
+ node,
3254
+ fix,
3255
+ func: "isNil"
3256
+ });
3257
+ }
3258
+ };
3259
+
3260
+ const findPatternIndex = node => MERGE_PATTERNS.findIndex(matches(ramda.__, node));
1851
3261
 
1852
3262
  const convertToMergeLeft = (context, node) => {
1853
3263
  const properties = node.body.properties.slice(1);
1854
3264
  const matchIndex = findPatternIndex(node);
1855
- return matchIndex === 2 && properties.length === 1 ? `mergeLeft(${getCode(context, properties[0].argument)})` : `mergeLeft({ ${getCode(context, {
1856
- range: [properties[0].range[0], require$$0.last(properties).range[1]]
3265
+ return matchIndex === 2 && properties.length === 1 ? `mergeLeft(${getCode$1(context, properties[0].argument)})` : `mergeLeft({ ${getCode$1(context, {
3266
+ range: [properties[0].range[0], ramda.last(properties).range[1]]
1857
3267
  })} })`;
1858
3268
  };
1859
3269
 
@@ -1869,14 +3279,14 @@
1869
3279
  name: node.params[0].name
1870
3280
  };
1871
3281
  const properties = node.body.properties.slice(1);
1872
- if (patternExistsDeep(properties, selfReferencingPattern)) return;
3282
+ if (patternExistsDeep(selfReferencingPattern, properties)) return;
1873
3283
  const fix = convertToMergeLeft(context, node);
1874
3284
  context.report({
1875
3285
  node,
1876
3286
  message: canBeReplacedWith(fix),
1877
3287
  suggest: [{
1878
3288
  desc: "Replace with mergeLeft function",
1879
- fix: replaceNodeWithImports({
3289
+ fix: replacer.replaceNode({
1880
3290
  context,
1881
3291
  node,
1882
3292
  fix,
@@ -1892,7 +3302,7 @@
1892
3302
  message: canBeReplacedWith(fix),
1893
3303
  suggest: [{
1894
3304
  desc: "Replace with pluck function",
1895
- fix: replaceNodeWithImports({
3305
+ fix: replacer.replaceNode({
1896
3306
  context,
1897
3307
  node,
1898
3308
  fix,
@@ -1904,15 +3314,15 @@
1904
3314
  var pluckLintCheck = {
1905
3315
  operateOn: "CallExpression",
1906
3316
  check: (context, node) => {
1907
- if (matches_1(PLUCK_PATTERNS.OBJECT_ARROW_FUNCTION, node)) {
1908
- const code = getCode(context, node.callee.object);
3317
+ if (matches(PLUCK_PATTERNS.OBJECT_ARROW_FUNCTION, node)) {
3318
+ const code = getCode$1(context, node.callee.object);
1909
3319
  const func = node.arguments[0];
1910
3320
 
1911
- if (matches_1(PLUCK_PATTERNS.IDENTIFIER, func)) {
3321
+ if (matches(PLUCK_PATTERNS.IDENTIFIER, func)) {
1912
3322
  if (func.params[0].name !== func.body.object.name) return;
1913
3323
  const fix = `pluck("${func.body.property.name}", ${code})`;
1914
3324
  reportViolation(context, node, fix);
1915
- } else if (matches_1(PLUCK_PATTERNS.DESTRUCTURE, func)) {
3325
+ } else if (matches(PLUCK_PATTERNS.DESTRUCTURE, func)) {
1916
3326
  const propertyName = func.params[0].properties[0].value.name;
1917
3327
  if (propertyName !== func.body.name) return;
1918
3328
  const fix = `pluck("${propertyName}", ${code})`;
@@ -1926,11 +3336,11 @@
1926
3336
  operateOn: "ArrowFunctionExpression",
1927
3337
  check: (context, node) => {
1928
3338
  let fix = null;
1929
- if (matches_1(PROP_IGNORE_PATTERN, node.parent)) return;
3339
+ if (matches(PROP_IGNORE_PATTERN, node.parent)) return;
1930
3340
 
1931
- if (matches_1(PROP_PATTERNS.OBJECT, node) && node.params[0].properties[0].value.name === node.body.name) {
3341
+ if (matches(PROP_PATTERNS.OBJECT, node) && node.params[0].properties[0].value.name === node.body.name) {
1932
3342
  fix = `prop("${node.body.name}")`;
1933
- } else if (matches_1(PROP_PATTERNS.IDENTITY, node) && node.params[0].name === node.body.object.name) {
3343
+ } else if (matches(PROP_PATTERNS.IDENTITY, node) && node.params[0].name === node.body.object.name) {
1934
3344
  fix = `prop("${node.body.property.name}")`;
1935
3345
  } else {
1936
3346
  return;
@@ -1941,7 +3351,7 @@
1941
3351
  message: canBeReplacedWith(fix),
1942
3352
  suggest: [{
1943
3353
  desc: "Replace with prop function",
1944
- fix: replaceNodeWithImports({
3354
+ fix: replacer.replaceNode({
1945
3355
  context,
1946
3356
  node,
1947
3357
  fix,
@@ -1975,7 +3385,7 @@
1975
3385
  var sumLintCheck = {
1976
3386
  operateOn: "CallExpression",
1977
3387
  check: (context, node) => {
1978
- if (!matches_1(SUM_PATTERN, node)) return;
3388
+ if (!matches(SUM_PATTERN, node)) return;
1979
3389
  const reduceFunc = node.arguments[0];
1980
3390
  const {
1981
3391
  accumulator,
@@ -1986,12 +3396,12 @@
1986
3396
  let functions = ["sum"];
1987
3397
 
1988
3398
  if (reduceFunc.params[1].type === TYPES.IDENTIFIER && delta.type === TYPES.IDENTIFIER && delta.name === reduceFunc.params[1].name) {
1989
- fix = `sum(${getCode(context, node.callee.object)})`;
3399
+ fix = `sum(${getCode$1(context, node.callee.object)})`;
1990
3400
  } else if (reduceFunc.params[1].type === TYPES.OBJECT_PATTERN && delta.type === TYPES.IDENTIFIER && delta.name === reduceFunc.params[1].properties[0].value.name) {
1991
- fix = `sum(pluck("${delta.name}", ${getCode(context, node.callee.object)}))`;
3401
+ fix = `sum(pluck("${delta.name}", ${getCode$1(context, node.callee.object)}))`;
1992
3402
  functions = ["sum", "pluck"];
1993
3403
  } else if (reduceFunc.params[1].type === TYPES.IDENTIFIER && delta.type === TYPES.MEMBER_EXPRESSION && delta.property.type === TYPES.IDENTIFIER && delta.object.name === reduceFunc.params[1].name) {
1994
- fix = `sum(pluck("${delta.property.name}", ${getCode(context, node.callee.object)}))`;
3404
+ fix = `sum(pluck("${delta.property.name}", ${getCode$1(context, node.callee.object)}))`;
1995
3405
  functions = ["sum", "pluck"];
1996
3406
  } else {
1997
3407
  return;
@@ -2002,7 +3412,7 @@
2002
3412
  message: canBeReplacedWith(fix),
2003
3413
  suggest: [{
2004
3414
  desc: "Replace with sum function",
2005
- fix: replaceNodeWithImports({
3415
+ fix: replacer.replaceNode({
2006
3416
  context,
2007
3417
  node,
2008
3418
  fix,
@@ -2022,8 +3432,15 @@
2022
3432
  }
2023
3433
  },
2024
3434
  create: context => {
2025
- const operations = require$$0.groupBy(require$$0.prop("operateOn"), [arrayInsertsLintCheck, assocLintCheck, equalsLintCheck, identityLintCheck, mergeLintCheck, pluckLintCheck, propLintCheck, sumLintCheck]);
2026
- return require$$0.fromPairs(require$$0.toPairs(operations).map(([operateOn, operations]) => [operateOn, node => operations.forEach(op => op.check(context, node))]));
3435
+ const operationsArr = [arrayInsertsLintCheck, assocLintCheck, equalsLintCheck, identityLintCheck, mergeLintCheck, pluckLintCheck, propLintCheck, sumLintCheck, isNilCheck, isEmptyCheck].map(op => {
3436
+ if (!Array.isArray(op.operateOn)) return op;
3437
+ return op.operateOn.map(operateOn => ({
3438
+ operateOn,
3439
+ check: op.check
3440
+ }));
3441
+ }).flat();
3442
+ const operations = ramda.groupBy(ramda.prop("operateOn"), operationsArr);
3443
+ return ramda.fromPairs(ramda.toPairs(operations).map(([operateOn, operations]) => [operateOn, node => operations.forEach(op => op.check(context, node))]));
2027
3444
  }
2028
3445
  };
2029
3446
 
@@ -2087,14 +3504,14 @@
2087
3504
  },
2088
3505
  create: context => ({
2089
3506
  CallExpression(node) {
2090
- if (matches_1(AXIOS_GET_PATTERN, node)) {
3507
+ if (matches(AXIOS_GET_PATTERN, node)) {
2091
3508
  if (!VALID_URL_TYPES.includes(node.arguments[0].type)) return;
2092
3509
  checkAndReport({
2093
3510
  context,
2094
3511
  node,
2095
3512
  urlNode: node.arguments[0]
2096
3513
  });
2097
- } else if (matches_1(AXIOS_PATTERN, node)) {
3514
+ } else if (matches(AXIOS_PATTERN, node)) {
2098
3515
  var _methodNode;
2099
3516
 
2100
3517
  let methodNode = null;
@@ -2173,7 +3590,7 @@
2173
3590
  create: context => ({
2174
3591
  ImportDeclaration(node) {
2175
3592
  const aliases = context.options[0];
2176
- if (require$$0.isEmpty(aliases) || require$$0.isNil(aliases)) return;
3593
+ if (ramda.isEmpty(aliases) || ramda.isNil(aliases)) return;
2177
3594
  const importPath = node.source.value;
2178
3595
  if (!importPath.startsWith("../")) return;
2179
3596
  const filename = context.getFilename();
@@ -2200,6 +3617,8 @@
2200
3617
  "api-connector-name-should-match-filename": apiConnectorNameShouldMatchFilename,
2201
3618
  "api-connector-should-use-default-export": apiConnectorShouldUseDefaultExport,
2202
3619
  "combine-multiple-independent-awaits": combineMultipleIndependentAwaits,
3620
+ "consistent-button-link-anchor": consistentButtonLinkAnchor,
3621
+ "neetocommons-tips": neetocommonsTips,
2203
3622
  "no-blacklisted-imports": noBlacklistedImports,
2204
3623
  "no-axios-import-outside-apis": noAxiosImportOutsideApis,
2205
3624
  "no-excess-function-arguments": noExcessFunctionArguments,
@@ -2211,10 +3630,14 @@
2211
3630
  "no-namespace-specifier-import-for-ramda": noNamespaceSpecifierImportForRamda,
2212
3631
  "no-redundant-jsx-expression": noRedundantJsxExpression,
2213
3632
  "no-redundant-string-templates": noRedundantStringTemplates,
3633
+ "no-routes-destructure-and-reassignment": noRoutesDestructureAndReassignment,
2214
3634
  "prefix-neeto-ui-import-alias": prefixNeetoUIImportAlias,
2215
3635
  "ramda-tips": ramdaTips,
3636
+ "routes-should-be-declared-and-default-exported": routesShouldBeDeclaredAndDefaultExported,
3637
+ "routes-should-match-object-path": routesShouldMatchObjectPath,
2216
3638
  "use-axios-config-for-passing-query-parameters": useAxiosConfigForPassingQueryParameters,
2217
3639
  "use-constant-case": useConstantCase,
3640
+ "use-common-routes": useCommonRoutes,
2218
3641
  "use-snake-case-for-api-connector-filename": useSnakeCaseForApiConnectorFilename,
2219
3642
  "use-webpack-alias": useWebpackAlias
2220
3643
  }