@bigbinary/eslint-plugin-neeto 1.1.4 → 1.1.6

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 +1 -0
  2. package/dist/index.js +396 -291
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -105,6 +105,7 @@ module.exports = {
105
105
  - [no-repetition-in-prop-key-value-names](./docs/src/rules/no-repetition-in-prop-key-value-names.md)
106
106
  - [use-functions-and-hooks-from-neeto-commons-frontend.md](./docs/src/rules/use-functions-and-hooks-from-neeto-commons-frontend.md)
107
107
  - [zustand-use-with-immutable-actions-wrapper-inside-create](./docs/src/rules/zustand-use-with-immutable-actions-wrapper-inside-create.md)
108
+ - [add-required-peer-dependencies](./docs/src/rules/add-required-peer-dependencies.md)
108
109
 
109
110
  ## Other references
110
111
 
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('path'), require('ramda'), require('fs'), require('@bigbinary/neeto-commons-frontend/pure')) :
3
- typeof define === 'function' && define.amd ? define(['path', 'ramda', 'fs', '@bigbinary/neeto-commons-frontend/pure'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["@bigbinary/eslint-plugin-neeto"] = factory(global.path$2, global.ramda, global.fs, global.pure));
5
- })(this, (function (path$2, ramda, fs, pure) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('path'), require('ramda'), require('@bigbinary/neeto-commons-frontend/pure'), require('fs')) :
3
+ typeof define === 'function' && define.amd ? define(['path', 'ramda', '@bigbinary/neeto-commons-frontend/pure', 'fs'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["@bigbinary/eslint-plugin-neeto"] = factory(global.path$2, global.ramda, global.pure, global.fs));
5
+ })(this, (function (path$2, ramda, pure, fs) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -121,7 +121,11 @@
121
121
  "@bigbinary/neeto/zustand-use-prop-to-pick-single-item": "error",
122
122
  "@bigbinary/neeto/use-functions-and-hooks-from-neeto-commons-frontend": "warn",
123
123
  "@bigbinary/neeto/no-unnecessary-if-condition": "error",
124
- "@bigbinary/neeto/zustand-use-with-immutable-actions-wrapper-inside-create": "error"
124
+ "@bigbinary/neeto/zustand-use-with-immutable-actions-wrapper-inside-create": "error",
125
+ "@bigbinary/neeto/no-repetition-in-prop-key-value-names": "error",
126
+ "@bigbinary/neeto/merge-spread-attributes": "error",
127
+ "@bigbinary/neeto/props-inside-spread-attributes-should-be-sorted": "error",
128
+ "@bigbinary/neeto/props-with-different-key-value-should-be-outside-spread-attribute": "error"
125
129
  };
126
130
 
127
131
  var recommended = {
@@ -200,7 +204,8 @@
200
204
  "@bigbinary/neeto/webpack-aliases-and-jsconfig-paths-should-be-in-sync": ["error", {
201
205
  jsconfigFilePath: path__default["default"].join(rootOfTheProject$1, pathToJsConfigFile),
202
206
  aliasFilePath: path__default["default"].join(rootOfTheProject$1, pathToResolveFile$1)
203
- }]
207
+ }],
208
+ "@bigbinary/neeto/add-required-peer-dependencies": "error"
204
209
  }
205
210
  });
206
211
 
@@ -228,7 +233,343 @@
228
233
  "@bigbinary/neeto/use-neetoui-classes": "off",
229
234
  "@bigbinary/neeto/hard-coded-strings-should-be-localized": "off"
230
235
  }
231
- });
236
+ });
237
+
238
+ function _typeof$1(obj) {
239
+ "@babel/helpers - typeof";
240
+
241
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
242
+ return typeof obj;
243
+ } : function (obj) {
244
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
245
+ }, _typeof$1(obj);
246
+ }
247
+
248
+ function _toPrimitive(input, hint) {
249
+ if (_typeof$1(input) !== "object" || input === null) return input;
250
+ var prim = input[Symbol.toPrimitive];
251
+ if (prim !== undefined) {
252
+ var res = prim.call(input, hint || "default");
253
+ if (_typeof$1(res) !== "object") return res;
254
+ throw new TypeError("@@toPrimitive must return a primitive value.");
255
+ }
256
+ return (hint === "string" ? String : Number)(input);
257
+ }
258
+
259
+ function _toPropertyKey(arg) {
260
+ var key = _toPrimitive(arg, "string");
261
+ return _typeof$1(key) === "symbol" ? key : String(key);
262
+ }
263
+
264
+ function _defineProperty(obj, key, value) {
265
+ key = _toPropertyKey(key);
266
+ if (key in obj) {
267
+ Object.defineProperty(obj, key, {
268
+ value: value,
269
+ enumerable: true,
270
+ configurable: true,
271
+ writable: true
272
+ });
273
+ } else {
274
+ obj[key] = value;
275
+ }
276
+ return obj;
277
+ }
278
+
279
+ function ownKeys$6(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; }
280
+ function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
281
+ var prefix = "export default ";
282
+ var jsonProcessor = {
283
+ _prefix: prefix,
284
+ preprocess: function preprocess(text) {
285
+ return ["".concat(prefix).concat(text)];
286
+ },
287
+ postprocess: function postprocess(messages) {
288
+ return messages.reduce(function (total, next) {
289
+ return total.concat(next.filter(function (error) {
290
+ return error.ruleId && error.ruleId.startsWith("@bigbinary/neeto/");
291
+ }));
292
+ }, []).map(function (message) {
293
+ return message.fix ? _objectSpread$6(_objectSpread$6({}, message), {}, {
294
+ fix: _objectSpread$6(_objectSpread$6({}, message.fix), {}, {
295
+ range: message.fix.range.map(function (rangePart) {
296
+ return Math.max(0, rangePart - prefix.length);
297
+ })
298
+ })
299
+ }) : message;
300
+ });
301
+ },
302
+ supportsAutofix: true
303
+ };
304
+
305
+ var APIS_DIRECTORY = "app/javascript/src/apis";
306
+ var REACT_QUERY_DIRECTORY = "app/javascript/src/hooks/reactQuery";
307
+ var ROUTES_FILE_PATH = "app/javascript/src/routes.js";
308
+ var COMPONENTS_DIRECTORY = "app/javascript/src/components";
309
+ var BLACKLISTED_PACKAGES = ["moment", "bootstrap", "blueprint", "react-spinners", "react-table", "remixicon", "mjml", "react-select", "@bigbinary/neeto-utils"];
310
+ var TYPES = {
311
+ ARRAY_EXPRESSION: "ArrayExpression",
312
+ ARROW_FUNCTION_EXPRESSION: "ArrowFunctionExpression",
313
+ ASSIGNMENT_EXPRESSION: "AssignmentExpression",
314
+ ASSIGNMENT_PATTERN: "AssignmentPattern",
315
+ AWAIT_EXPRESSION: "AwaitExpression",
316
+ BINARY_EXPRESSION: "BinaryExpression",
317
+ BLOCK_STATEMENT: "BlockStatement",
318
+ BREAK_STATEMENT: "BreakStatement",
319
+ CALL_EXPRESSION: "CallExpression",
320
+ CHAIN_EXPRESSION: "ChainExpression",
321
+ CONDITIONAL_EXPRESSION: "ConditionalExpression",
322
+ EXPORT_NAMED_DECLARATION: "ExportNamedDeclaration",
323
+ EXPORT_DEFAULT_DECLARATION: "ExportDefaultDeclaration",
324
+ EXPRESSION_STATEMENT: "ExpressionStatement",
325
+ FUNCTION_DECLARATION: "FunctionDeclaration",
326
+ FUNCTION_EXPRESSION: "FunctionExpression",
327
+ IDENTIFIER: "Identifier",
328
+ IF_STATEMENT: "IfStatement",
329
+ IMPORT_DECLARATION: "ImportDeclaration",
330
+ IMPORT_DEFAULT_SPECIFIER: "ImportDefaultSpecifier",
331
+ IMPORT_SPECIFIER: "ImportSpecifier",
332
+ JSX_ATTRIBUTE: "JSXAttribute",
333
+ JSX_ELEMENT: "JSXElement",
334
+ JSX_EXPRESSION_CONTAINER: "JSXExpressionContainer",
335
+ JSX_IDENTIFIER: "JSXIdentifier",
336
+ JSX_OPENING_ELEMENT: "JSXOpeningElement",
337
+ JSX_SPREAD_ATTRIBUTE: "JSXSpreadAttribute",
338
+ JSX_TEXT: "JSXText",
339
+ LITERAL: "Literal",
340
+ LOGICAL_EXPRESSION: "LogicalExpression",
341
+ MEMBER_EXPRESSION: "MemberExpression",
342
+ OBJECT_EXPRESSION: "ObjectExpression",
343
+ OBJECT_PATTERN: "ObjectPattern",
344
+ PROGRAM: "Program",
345
+ PROPERTY: "Property",
346
+ RETURN_STATEMENT: "ReturnStatement",
347
+ SPREAD_ELEMENT: "SpreadElement",
348
+ TEMPLATE_ELEMENT: "TemplateElement",
349
+ TEMPLATE_LITERAL: "TemplateLiteral",
350
+ UNARY_EXPRESSION: "UnaryExpression",
351
+ VARIABLE_DECLARATION: "VariableDeclaration",
352
+ VARIABLE_DECLARATOR: "VariableDeclarator",
353
+ WHILE_STATEMENT: "WhileStatement",
354
+ NEW_EXPRESSION: "NewExpression"
355
+ };
356
+ var IMPORT_DECLARATION = {
357
+ type: TYPES.IMPORT_DECLARATION,
358
+ source: {
359
+ type: TYPES.LITERAL
360
+ },
361
+ specifiers: [{
362
+ type: TYPES.IMPORT_SPECIFIER
363
+ }]
364
+ };
365
+ var CAMEL_CASE_REGEX = /^[a-z][A-Za-z0-9]*$/;
366
+ var CONSTANT_CASE_REGEX = /^[A-Z0-9_]+$/;
367
+ var PASCAL_CASE_REGEX = /^(?:[A-Z]+[a-z0-9]+[A-Z]*)+$/;
368
+ var SNAKE_CASE_REGEX = /^[a-z0-9_]+$/;
369
+
370
+ // const TestComponent = () => {}
371
+ var COMPONENT_PATTERN = {
372
+ type: TYPES.VARIABLE_DECLARATION,
373
+ kind: "const",
374
+ declarations: [{
375
+ type: TYPES.VARIABLE_DECLARATOR,
376
+ init: {
377
+ type: TYPES.ARROW_FUNCTION_EXPRESSION
378
+ },
379
+ id: {
380
+ type: TYPES.IDENTIFIER,
381
+ name: ramda.test(PASCAL_CASE_REGEX)
382
+ }
383
+ }]
384
+ };
385
+ var NO_OF_LINES_ALLOWED_FOR_MULTIPLE_COMPONENTS_IN_A_FILE = 20;
386
+
387
+ var ARGUMENT_LIMIT = 3;
388
+ var API_ACTIONS_ARGUMENT_LIMIT = 2;
389
+ var FIXABLE_PARAMETER_TYPES = [TYPES.IDENTIFIER, TYPES.ASSIGNMENT_PATTERN];
390
+
391
+ /* eslint-disable @bigbinary/neeto/no-dangling-constants */
392
+ var addInJsconfig = function addInJsconfig(aliasName) {
393
+ return "Add path for \"".concat(aliasName, "\" in jsconfig.json. Refer https://bit.ly/sync-webpack-alias-and-jsconfig-paths for more details.");
394
+ };
395
+ var canBeReplacedWith = function canBeReplacedWith(fix) {
396
+ return "Can be replaced with: ".concat(fix);
397
+ };
398
+ var disallowUse = function disallowUse(packageName) {
399
+ return "Do not use the package ".concat(packageName);
400
+ };
401
+ var exportedObjectShouldBe = function exportedObjectShouldBe(caseStyle) {
402
+ return "Exported object should be in ".concat(caseStyle, ". Refer https://www.youtube.com/watch?v=As9BzWsGJfY");
403
+ };
404
+ var filenameShouldBe = function filenameShouldBe(caseStyle) {
405
+ return "Filename should be in ".concat(caseStyle, ". Refer https://www.youtube.com/watch?v=As9BzWsGJfY");
406
+ };
407
+ var moveToConstantsJs = function moveToConstantsJs(constantName) {
408
+ return "Move the constant ".concat(constantName, " to a constants.js file.");
409
+ };
410
+ var preferSubscriptionUnsubscribe = function preferSubscriptionUnsubscribe(replacerText) {
411
+ return "Prefer to use ".concat(replacerText, ".unsubscribe() to prevent consumer creation boilerplate.");
412
+ };
413
+ var renameFile = function renameFile(filename) {
414
+ return "Rename this file to ".concat(filename);
415
+ };
416
+ var replaceWith$1 = function replaceWith(fix) {
417
+ return "Replace this with: ".concat(fix);
418
+ };
419
+ var unableToResolveKey = function unableToResolveKey(_ref) {
420
+ var key = _ref.key,
421
+ lng = _ref.lng;
422
+ return "Unable to resolve localized string '".concat(key, "' in ").concat(lng, ".json");
423
+ };
424
+ var giveCamelCaseOrPascalCaseNameFor = function giveCamelCaseOrPascalCaseNameFor(functionName) {
425
+ return "Use either camelCase or PascalCase for naming the function - ".concat(functionName, ".");
426
+ };
427
+ var replaceZustandDefaultExportWith = function replaceZustandDefaultExportWith(fix) {
428
+ return "Zustand has deprecated the use of default exports for its functions. Replace this with: ".concat(fix);
429
+ };
430
+ var replaceTailwindClass = function replaceTailwindClass(tailwindClass, neetoUIClass) {
431
+ return "Replace the class \"".concat(tailwindClass, "\" with its neetoui alternative \"").concat(neetoUIClass, "\"");
432
+ };
433
+ var noMultipleComponentsInAFile$1 = function noMultipleComponentsInAFile() {
434
+ var maxAllowedNoOfLines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 20;
435
+ return "Do not have multiple component definitions that exceed ".concat(maxAllowedNoOfLines, " lines in a single file.");
436
+ };
437
+ var suggestNeetoCommonsFunctionsAndHooks = function suggestNeetoCommonsFunctionsAndHooks(functionName, utilType, url) {
438
+ return "Use \"".concat(functionName, "\" from \"@bigbinary/neeto-commons-frontend/").concat(utilType, "\" instead. Refer: ").concat(url);
439
+ };
440
+ var addRequiredPeerDependencies$1 = function addRequiredPeerDependencies(packageName) {
441
+ return "".concat(packageName, " should be added to peerDependencies");
442
+ };
443
+ var API_CONNECTOR_SHOULD_USE_DEFAULT_EXPORT_MESSAGE = "API Connector should be exported using the default export method";
444
+ var CAN_BE_REPLACED_WITH_HANDLE_META_CLICK = "Can be replaced with handleMetaClick function. Refer https://bit.ly/handleMetaClick";
445
+ var COMBINE_MULTIPLE_INDEPENDENT_AWAITS_MESSAGE = "Combine independent awaits to a single `Promise.all` call.";
446
+ var EXPORTED_OBJECT_AND_FILENAME_SHOULD_MATCH_MESSAGE = "Exported object and filename should match.";
447
+ var GLOBALPROPS_NO_ASSIGNMENT_MESSAGE = "globalProps should not be assigned to other variables";
448
+ var NESTED_GLOBALPROPS_NO_ASSIGNMENT_MESSAGE = "Nested properties of globalProps should not be assigned to other variables";
449
+ var NO_AXIOS_IMPORT_OUTSIDE_APIS_MESSAGE = "Do not use axios outside `app/javascript/src/apis`";
450
+ var NO_CONDITIONAL_RENDER_OF_OVERLAYS = "Overlay components should not be rendered conditionally. Use `isOpen` attribute instead.";
451
+ var NO_EXCESS_API_ACTION_ARGUMENTS_MESSAGE = "API actions should use named parameters for more than ".concat(API_ACTIONS_ARGUMENT_LIMIT, " parameters");
452
+ var NO_EXCESS_FUNCTION_ARGUMENTS_MESSAGE = "Functions should use named parameters for more than ".concat(ARGUMENT_LIMIT, " parameters");
453
+ var NO_GLOBALPROPS_REASSIGNMENT_MESSAGE = "globalProps or its nested properties should not be re-assigned.";
454
+ var NO_ROUTES_ASSIGNMENT = "`routes` or its nested properties should not be assigned to other variables.";
455
+ var NO_ROUTES_REASSIGNMENT = "`routes` or its nested properties should not be re-assigned.";
456
+ var NO_NAMESPACE_SPECIFIER_IMPORT_FOR_RAMDA_MESSAGE = 'Use `import { methodsToImport } from "ramda"` instead';
457
+ var PREFER_EAGER_VALIDATION_MESSAGE = "Prefer to use Formik defaults for `validateOnBlur` and `validateOnChange` to ensure eager validation. Refer https://bit.ly/formik-eager-validation";
458
+ var PREFIX_NEETO_UI_IMPORT_ALIAS_MESSAGE = "Aliases for anything imported from neetoUI or neetoIcons should start with `NeetoUI`";
459
+ var REPLACE_WITH_HANDLE_META_CLICK = "Replace with handleMetaClick function";
460
+ var ROUTE_SHOULD_BE_A_STRING = "Route should be a plain string literal.";
461
+ var ROUTE_SHOULD_MATCH_OBJECT_PATH = "Route string should match with its object path.";
462
+ var ROUTES_HAS_ALREADY_BEEN_DECLARED = "Identifier `routes` has already been declared";
463
+ var ROUTES_CONSTANT_SHOULD_BE_DECLARED = "A constant object named `routes` should be declared inside routes.js";
464
+ var ROUTES_SHOULD_USE_DEFAULT_EXPORT = "`routes` should be exported using the default export method.";
465
+ var UNNECESSARY_CREATE_CONSUMER = "`createSubscription` function from `neetocommon/utils` invalidates the need of `createConsumer`";
466
+ var USE_ARRAY_METHODS = "Use array methods (forEach, map, filter, reduce, etc) instead of 'for' loop. Refer 'Advanced Array Methods' section in https://bit.ly/array-methods-page-1";
467
+ var USE_AXIOS_CONFIG_FOR_PASSING_QUERY_PARAMETERS_MESSAGE = "Use 'params attribute in axios configuration' to pass query parameters.";
468
+ var USE_CREATE_SUBSCRIPTION_FROM_NEETO_COMMONS = "Use `createSubscription` from @bigbinary/neeto-commons-frontend/utils instead. Refer: https://github.com/bigbinary/neeto-commons-frontend/blob/main/docs/utils/README.md#createsubscription";
469
+ var USE_INLINE_SVG_FOR_RENDER = "Use inline SVG instead of img tag for rendering SVGs";
470
+ var USE_LINK_FOR_NAVIGATION = "Use Link or NavLink component from 'react-router-dom' for click-navigation instead of onClick handler";
471
+ var USE_ANCHOR_FOR_NAVIGATION = "Use Anchor element (<a>) for click-navigation instead of onClick handler";
472
+ var USE_BUTTON_TO_FOR_LINK_NAVIGATION = "Use `to` prop of Button (<Button to='path'>) for click-navigation instead of onClick handler";
473
+ var USE_BUTTON_TO_FOR_ANCHOR_NAVIGATION = "Use `href` prop of Button (<Button href='path'>) for click-navigation instead of onClick handler";
474
+ var USE_NEETO_SMALLER_CASE = "Use 'neeto' instead of 'Neeto' in strings";
475
+ var USE_NEETOUI_BORDER_COLOR = "Use neetoUI border color. Refer https://bit.ly/neeto-ui-border-colors for more details.";
476
+ var USE_NEETOUI_BORDER_RADIUS = "Use neetoUI border radius. Refer https://bit.ly/neeto-ui-border-radius for more details.";
477
+ var USE_NEETOUI_BOX_SHADOW = "Use neetoUI border shadow. Refer https://bit.ly/neeto-ui-box-shadows for more details.";
478
+ var USE_NEETOUI_TEXT_COLOR = "Use neetoUI text color. Refer https://bit.ly/neeto-ui-text-color for more details.";
479
+ var DONT_USE_ZUSTAND_STORE_WITHOUT_SELECTOR = "Don't use zustand store hook without a selector function. It will impact the performance";
480
+ var DONT_USE_ZUSTAND_STORE_WITHOUT_COMPARATOR_FUNCTION = "Don't pick multiple zustand state items without comparator function";
481
+ var USE_PROP_FOR_PICKING_SINGLE_ITEM = "Use prop instead of pick when picking single item";
482
+ var ENSURE_ZUSTAND_STORES_ARE_TYPE_ANNOTATED = "\n Zustand stores should be type annotated like this:\n /** @type {import(\"neetocommons/react-utils\").ZustandStoreHook} */\n const useUserStore = create(...)\n";
483
+ var USE_REACT_QUERY_FOR_MANAGING_REMOTE_DATA = "API calls should be managed using React Query";
484
+ var FILES_INSIDE_REACT_QUERY_FOLDER_SHOULD_END_WITH_API = "Files inside reactQuery folder should end with Api";
485
+ var USE_ZUSTAND_FOR_GLOBAL_STATE_MANAGEMENT = "Use zustand for global state management";
486
+ var AVOID_T_FUNCTIONS_IN_STRING_INTERPOLATION = "Translation function should not be used in string interpolation. Instead use a single translation key for the entire string. Refer: https://bit.ly/localization-best-practices";
487
+ var AVOID_MULTIPLE_T_FUNCTIONS_UNDER_SAME_PARENT = "Avoid using multiple translation functions under the same JSX parent. Instead use a single translation function with a single key. Refer: https://bit.ly/localization-best-practices";
488
+ var USE_TRANS_COMPONENTS_AND_VALUES_PROPS = "Instead of using numbered tags in translation string use `components` and `values` props of `Trans` to use named tag in translation string. Refer: https://bit.ly/localization-best-practices";
489
+ var USE_TRANSLATION_HOOK_IN_COMPONENTS = "Use translation function from `useTranslation()` hook in components.";
490
+ var USE_COMPONENTS_CHILDREN_PROP_IN_TRANS = "Use components children prop instead of label prop in `Trans` component to avoid multiple translation keys.";
491
+ var USE_I18NEXT_PLURALS = "Use plurals that comes with the `i18next` package for hard-coded strings. Refer: https://bit.ly/i18next-plurals";
492
+ var USE_PLURALIZE_PACKAGE = "Use `pluralize` package for dynamic values. Refer: https://bit.ly/i18next-plurals";
493
+ var USE_COPY_TO_CLIPBOARD_FROM_NEETO_COMMONS = "Use `copyToClipboard` from `@bigbinary/neeto-commons-frontend` package. Refer: https://bit.ly/copy-to-clipboard-utility-function";
494
+ var USE_ZUSTAND_PICK_TRANSFORMER = "Replace the boilerplate with zustand-pick syntax offered by babel-preset-neeto. Refer: https://bit.ly/zustand-pick-transform-doc";
495
+ var HARD_CODED_STRING_SHOULD_BE_LOCALIZED = "Hard-coded string should be localized";
496
+ var PROPS_NOT_SORTED = "Props inside spread attributes should be alphabetically sorted";
497
+ var MERGE_ADJACENT_SPREAD_ATTRIBUTES = "Merge spread attributes";
498
+ var DIFFERENT_PROPS_MUST_BE_OUTSIDE = "Props with different key and value should be outside the spread attribute";
499
+ var PROP_KEY_VALUE_DUPLICATE = "Prop key and value names should not be repeated";
500
+ var USE_WITH_IMMUTABLE_ACTIONS_WRAPPER = 'Use "withImmutableActions" wrapper from "neeto-commons-frontend" inside zustand create. Refer: https://bit.ly/withimmutableactions';
501
+
502
+ var PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
503
+
504
+ // Checks if the passed package is present as a dependency
505
+ // { packageName: "version" }
506
+ var DependencyPattern = function DependencyPattern(packageName) {
507
+ return {
508
+ type: TYPES.PROPERTY,
509
+ key: {
510
+ type: TYPES.LITERAL,
511
+ value: packageName
512
+ }
513
+ };
514
+ };
515
+
516
+ var getIndentation = function getIndentation(node, context) {
517
+ var indentLevel = context.getSourceCode().getFirstToken(node).loc.start.column;
518
+ return " ".repeat(indentLevel);
519
+ };
520
+
521
+ var addRequiredPeerDependencies = {
522
+ meta: {
523
+ type: "problem",
524
+ docs: {
525
+ url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/add-required-peer-dependencies.md",
526
+ description: "Ensures that dependencies like neetoui, neeto-molecules and neeto-commons-frontend are added in peerDependencies, if used."
527
+ },
528
+ fixable: "code"
529
+ },
530
+ create: function create(context) {
531
+ return {
532
+ Property: function Property(node) {
533
+ if (!context.getFilename().endsWith("package.json") || node.key.value !== "devDependencies") {
534
+ return;
535
+ }
536
+ PACKAGES_TO_CHECK.forEach(function (packageName) {
537
+ var dependencyPattern = DependencyPattern(packageName);
538
+ if (pure.findBy(dependencyPattern, node.value.properties)) {
539
+ var peerDependencies = pure.findBy({
540
+ key: {
541
+ value: "peerDependencies"
542
+ }
543
+ }, node.parent.properties);
544
+ var dependencyIndentLevel = getIndentation(node.value.properties[0], context);
545
+ if (peerDependencies) {
546
+ if (pure.findBy(dependencyPattern, peerDependencies.value.properties)) {
547
+ return;
548
+ }
549
+ context.report({
550
+ node: peerDependencies,
551
+ message: addRequiredPeerDependencies$1(packageName),
552
+ fix: function fix(fixer) {
553
+ return fixer.insertTextAfter(ramda.last(peerDependencies.value.properties), ",\n".concat(dependencyIndentLevel, "\"").concat(packageName, "\": \"latest\""));
554
+ }
555
+ });
556
+ } else {
557
+ context.report({
558
+ node: node,
559
+ message: addRequiredPeerDependencies$1(packageName),
560
+ fix: function fix(fixer) {
561
+ var keyIndentLevel = getIndentation(node, context);
562
+ var fixString = ",\n".concat(keyIndentLevel, "\"peerDependencies\": {\n").concat(dependencyIndentLevel, "\"").concat(packageName, "\": \"latest\"\n").concat(keyIndentLevel, "}");
563
+ return fixer.insertTextAfter(node, fixString);
564
+ }
565
+ });
566
+ }
567
+ }
568
+ });
569
+ }
570
+ };
571
+ }
572
+ };
232
573
 
233
574
  function _arrayWithHoles(arr) {
234
575
  if (Array.isArray(arr)) return arr;
@@ -287,7 +628,7 @@
287
628
 
288
629
  var regeneratorRuntime$1 = {exports: {}};
289
630
 
290
- var _typeof$1 = {exports: {}};
631
+ var _typeof = {exports: {}};
291
632
 
292
633
  (function (module) {
293
634
  function _typeof(obj) {
@@ -300,10 +641,10 @@
300
641
  }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
301
642
  }
302
643
  module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
303
- } (_typeof$1));
644
+ } (_typeof));
304
645
 
305
646
  (function (module) {
306
- var _typeof = _typeof$1.exports["default"];
647
+ var _typeof$1 = _typeof.exports["default"];
307
648
  function _regeneratorRuntime() {
308
649
  module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
309
650
  return exports;
@@ -380,7 +721,7 @@
380
721
  if ("throw" !== record.type) {
381
722
  var result = record.arg,
382
723
  value = result.value;
383
- return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
724
+ return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
384
725
  invoke("next", value, resolve, reject);
385
726
  }, function (err) {
386
727
  invoke("throw", err, resolve, reject);
@@ -624,98 +965,6 @@
624
965
  }
625
966
  }
626
967
 
627
- var APIS_DIRECTORY = "app/javascript/src/apis";
628
- var REACT_QUERY_DIRECTORY = "app/javascript/src/hooks/reactQuery";
629
- var ROUTES_FILE_PATH = "app/javascript/src/routes.js";
630
- var COMPONENTS_DIRECTORY = "app/javascript/src/components";
631
- var BLACKLISTED_PACKAGES = ["moment", "bootstrap", "blueprint", "react-spinners", "react-table", "remixicon", "mjml", "react-select", "@bigbinary/neeto-utils"];
632
- var TYPES = {
633
- ARRAY_EXPRESSION: "ArrayExpression",
634
- ARROW_FUNCTION_EXPRESSION: "ArrowFunctionExpression",
635
- ASSIGNMENT_EXPRESSION: "AssignmentExpression",
636
- ASSIGNMENT_PATTERN: "AssignmentPattern",
637
- AWAIT_EXPRESSION: "AwaitExpression",
638
- BINARY_EXPRESSION: "BinaryExpression",
639
- BLOCK_STATEMENT: "BlockStatement",
640
- BREAK_STATEMENT: "BreakStatement",
641
- CALL_EXPRESSION: "CallExpression",
642
- CHAIN_EXPRESSION: "ChainExpression",
643
- CONDITIONAL_EXPRESSION: "ConditionalExpression",
644
- EXPORT_NAMED_DECLARATION: "ExportNamedDeclaration",
645
- EXPORT_DEFAULT_DECLARATION: "ExportDefaultDeclaration",
646
- EXPRESSION_STATEMENT: "ExpressionStatement",
647
- FUNCTION_DECLARATION: "FunctionDeclaration",
648
- FUNCTION_EXPRESSION: "FunctionExpression",
649
- IDENTIFIER: "Identifier",
650
- IF_STATEMENT: "IfStatement",
651
- IMPORT_DECLARATION: "ImportDeclaration",
652
- IMPORT_DEFAULT_SPECIFIER: "ImportDefaultSpecifier",
653
- IMPORT_SPECIFIER: "ImportSpecifier",
654
- JSX_ATTRIBUTE: "JSXAttribute",
655
- JSX_ELEMENT: "JSXElement",
656
- JSX_EXPRESSION_CONTAINER: "JSXExpressionContainer",
657
- JSX_IDENTIFIER: "JSXIdentifier",
658
- JSX_OPENING_ELEMENT: "JSXOpeningElement",
659
- JSX_SPREAD_ATTRIBUTE: "JSXSpreadAttribute",
660
- JSX_TEXT: "JSXText",
661
- LITERAL: "Literal",
662
- LOGICAL_EXPRESSION: "LogicalExpression",
663
- MEMBER_EXPRESSION: "MemberExpression",
664
- OBJECT_EXPRESSION: "ObjectExpression",
665
- OBJECT_PATTERN: "ObjectPattern",
666
- PROGRAM: "Program",
667
- PROPERTY: "Property",
668
- RETURN_STATEMENT: "ReturnStatement",
669
- SPREAD_ELEMENT: "SpreadElement",
670
- TEMPLATE_ELEMENT: "TemplateElement",
671
- TEMPLATE_LITERAL: "TemplateLiteral",
672
- UNARY_EXPRESSION: "UnaryExpression",
673
- VARIABLE_DECLARATION: "VariableDeclaration",
674
- VARIABLE_DECLARATOR: "VariableDeclarator",
675
- WHILE_STATEMENT: "WhileStatement",
676
- NEW_EXPRESSION: "NewExpression"
677
- };
678
- var IMPORT_DECLARATION = {
679
- type: TYPES.IMPORT_DECLARATION,
680
- source: {
681
- type: TYPES.LITERAL
682
- },
683
- specifiers: [{
684
- type: TYPES.IMPORT_SPECIFIER
685
- }]
686
- };
687
- var CAMEL_CASE_REGEX = /^[a-z][A-Za-z0-9]*$/;
688
- var CONSTANT_CASE_REGEX = /^[A-Z0-9_]+$/;
689
- var PASCAL_CASE_REGEX = /^(?:[A-Z]+[a-z0-9]+[A-Z]*)+$/;
690
- var SNAKE_CASE_REGEX = /^[a-z0-9_]+$/;
691
-
692
- // const TestComponent = () => {}
693
- var COMPONENT_PATTERN = {
694
- type: TYPES.VARIABLE_DECLARATION,
695
- kind: "const",
696
- declarations: [{
697
- type: TYPES.VARIABLE_DECLARATOR,
698
- init: {
699
- type: TYPES.ARROW_FUNCTION_EXPRESSION
700
- },
701
- id: {
702
- type: TYPES.IDENTIFIER,
703
- name: ramda.test(PASCAL_CASE_REGEX)
704
- }
705
- }]
706
- };
707
- var NO_OF_LINES_ALLOWED_FOR_MULTIPLE_COMPONENTS_IN_A_FILE = 20;
708
-
709
- function _typeof(obj) {
710
- "@babel/helpers - typeof";
711
-
712
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
713
- return typeof obj;
714
- } : function (obj) {
715
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
716
- }, _typeof(obj);
717
- }
718
-
719
968
  /**
720
969
  * Returns a list of nodes that matches the pattern
721
970
  * somewhere deep inside the given object-tree by
@@ -727,7 +976,7 @@
727
976
  */
728
977
  var findMatchingNodesDeep = function findMatchingNodesDeep(obj, pattern) {
729
978
  var res = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
730
- if (_typeof(obj) !== "object" || ramda.isNil(obj)) return res;
979
+ if (_typeof$1(obj) !== "object" || ramda.isNil(obj)) return res;
731
980
  if (pure.matches(pattern, obj)) return ramda.append(obj, res);
732
981
  return Object.entries(obj).reduce(function (acc, _ref) {
733
982
  var _ref2 = _slicedToArray(_ref, 2),
@@ -756,7 +1005,7 @@
756
1005
  * @param {Object} obj the object tree to check
757
1006
  */
758
1007
  var patternExistsDeep = /*#__PURE__*/ramda.curry(function (pattern, obj) {
759
- if (_typeof(obj) !== "object" || ramda.isNil(obj)) return false;
1008
+ if (_typeof$1(obj) !== "object" || ramda.isNil(obj)) return false;
760
1009
  if (pure.matches(pattern, obj)) return true;
761
1010
  return Object.entries(obj).some(function (_ref3) {
762
1011
  var _ref4 = _slicedToArray(_ref3, 2),
@@ -963,118 +1212,6 @@
963
1212
  }
964
1213
  };
965
1214
 
966
- var ARGUMENT_LIMIT = 3;
967
- var API_ACTIONS_ARGUMENT_LIMIT = 2;
968
- var FIXABLE_PARAMETER_TYPES = [TYPES.IDENTIFIER, TYPES.ASSIGNMENT_PATTERN];
969
-
970
- /* eslint-disable @bigbinary/neeto/no-dangling-constants */
971
- var addInJsconfig = function addInJsconfig(aliasName) {
972
- return "Add path for \"".concat(aliasName, "\" in jsconfig.json. Refer https://bit.ly/sync-webpack-alias-and-jsconfig-paths for more details.");
973
- };
974
- var canBeReplacedWith = function canBeReplacedWith(fix) {
975
- return "Can be replaced with: ".concat(fix);
976
- };
977
- var disallowUse = function disallowUse(packageName) {
978
- return "Do not use the package ".concat(packageName);
979
- };
980
- var exportedObjectShouldBe = function exportedObjectShouldBe(caseStyle) {
981
- return "Exported object should be in ".concat(caseStyle, ". Refer https://www.youtube.com/watch?v=As9BzWsGJfY");
982
- };
983
- var filenameShouldBe = function filenameShouldBe(caseStyle) {
984
- return "Filename should be in ".concat(caseStyle, ". Refer https://www.youtube.com/watch?v=As9BzWsGJfY");
985
- };
986
- var moveToConstantsJs = function moveToConstantsJs(constantName) {
987
- return "Move the constant ".concat(constantName, " to a constants.js file.");
988
- };
989
- var preferSubscriptionUnsubscribe = function preferSubscriptionUnsubscribe(replacerText) {
990
- return "Prefer to use ".concat(replacerText, ".unsubscribe() to prevent consumer creation boilerplate.");
991
- };
992
- var renameFile = function renameFile(filename) {
993
- return "Rename this file to ".concat(filename);
994
- };
995
- var replaceWith$1 = function replaceWith(fix) {
996
- return "Replace this with: ".concat(fix);
997
- };
998
- var unableToResolveKey = function unableToResolveKey(_ref) {
999
- var key = _ref.key,
1000
- lng = _ref.lng;
1001
- return "Unable to resolve localized string '".concat(key, "' in ").concat(lng, ".json");
1002
- };
1003
- var giveCamelCaseOrPascalCaseNameFor = function giveCamelCaseOrPascalCaseNameFor(functionName) {
1004
- return "Use either camelCase or PascalCase for naming the function - ".concat(functionName, ".");
1005
- };
1006
- var replaceZustandDefaultExportWith = function replaceZustandDefaultExportWith(fix) {
1007
- return "Zustand has deprecated the use of default exports for its functions. Replace this with: ".concat(fix);
1008
- };
1009
- var replaceTailwindClass = function replaceTailwindClass(tailwindClass, neetoUIClass) {
1010
- return "Replace the class \"".concat(tailwindClass, "\" with its neetoui alternative \"").concat(neetoUIClass, "\"");
1011
- };
1012
- var noMultipleComponentsInAFile$1 = function noMultipleComponentsInAFile() {
1013
- var maxAllowedNoOfLines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 20;
1014
- return "Do not have multiple component definitions that exceed ".concat(maxAllowedNoOfLines, " lines in a single file.");
1015
- };
1016
- var suggestNeetoCommonsFunctionsAndHooks = function suggestNeetoCommonsFunctionsAndHooks(functionName, utilType, url) {
1017
- return "Use \"".concat(functionName, "\" from \"@bigbinary/neeto-commons-frontend/").concat(utilType, "\" instead. Refer: ").concat(url);
1018
- };
1019
- var API_CONNECTOR_SHOULD_USE_DEFAULT_EXPORT_MESSAGE = "API Connector should be exported using the default export method";
1020
- var CAN_BE_REPLACED_WITH_HANDLE_META_CLICK = "Can be replaced with handleMetaClick function. Refer https://bit.ly/handleMetaClick";
1021
- var COMBINE_MULTIPLE_INDEPENDENT_AWAITS_MESSAGE = "Combine independent awaits to a single `Promise.all` call.";
1022
- var EXPORTED_OBJECT_AND_FILENAME_SHOULD_MATCH_MESSAGE = "Exported object and filename should match.";
1023
- var GLOBALPROPS_NO_ASSIGNMENT_MESSAGE = "globalProps should not be assigned to other variables";
1024
- var NESTED_GLOBALPROPS_NO_ASSIGNMENT_MESSAGE = "Nested properties of globalProps should not be assigned to other variables";
1025
- var NO_AXIOS_IMPORT_OUTSIDE_APIS_MESSAGE = "Do not use axios outside `app/javascript/src/apis`";
1026
- var NO_CONDITIONAL_RENDER_OF_OVERLAYS = "Overlay components should not be rendered conditionally. Use `isOpen` attribute instead.";
1027
- var NO_EXCESS_API_ACTION_ARGUMENTS_MESSAGE = "API actions should use named parameters for more than ".concat(API_ACTIONS_ARGUMENT_LIMIT, " parameters");
1028
- var NO_EXCESS_FUNCTION_ARGUMENTS_MESSAGE = "Functions should use named parameters for more than ".concat(ARGUMENT_LIMIT, " parameters");
1029
- var NO_GLOBALPROPS_REASSIGNMENT_MESSAGE = "globalProps or its nested properties should not be re-assigned.";
1030
- var NO_ROUTES_ASSIGNMENT = "`routes` or its nested properties should not be assigned to other variables.";
1031
- var NO_ROUTES_REASSIGNMENT = "`routes` or its nested properties should not be re-assigned.";
1032
- var NO_NAMESPACE_SPECIFIER_IMPORT_FOR_RAMDA_MESSAGE = 'Use `import { methodsToImport } from "ramda"` instead';
1033
- var PREFER_EAGER_VALIDATION_MESSAGE = "Prefer to use Formik defaults for `validateOnBlur` and `validateOnChange` to ensure eager validation. Refer https://bit.ly/formik-eager-validation";
1034
- var PREFIX_NEETO_UI_IMPORT_ALIAS_MESSAGE = "Aliases for anything imported from neetoUI or neetoIcons should start with `NeetoUI`";
1035
- var REPLACE_WITH_HANDLE_META_CLICK = "Replace with handleMetaClick function";
1036
- var ROUTE_SHOULD_BE_A_STRING = "Route should be a plain string literal.";
1037
- var ROUTE_SHOULD_MATCH_OBJECT_PATH = "Route string should match with its object path.";
1038
- var ROUTES_HAS_ALREADY_BEEN_DECLARED = "Identifier `routes` has already been declared";
1039
- var ROUTES_CONSTANT_SHOULD_BE_DECLARED = "A constant object named `routes` should be declared inside routes.js";
1040
- var ROUTES_SHOULD_USE_DEFAULT_EXPORT = "`routes` should be exported using the default export method.";
1041
- var UNNECESSARY_CREATE_CONSUMER = "`createSubscription` function from `neetocommon/utils` invalidates the need of `createConsumer`";
1042
- var USE_ARRAY_METHODS = "Use array methods (forEach, map, filter, reduce, etc) instead of 'for' loop. Refer 'Advanced Array Methods' section in https://bit.ly/array-methods-page-1";
1043
- var USE_AXIOS_CONFIG_FOR_PASSING_QUERY_PARAMETERS_MESSAGE = "Use 'params attribute in axios configuration' to pass query parameters.";
1044
- var USE_CREATE_SUBSCRIPTION_FROM_NEETO_COMMONS = "Use `createSubscription` from @bigbinary/neeto-commons-frontend/utils instead. Refer: https://github.com/bigbinary/neeto-commons-frontend/blob/main/docs/utils/README.md#createsubscription";
1045
- var USE_INLINE_SVG_FOR_RENDER = "Use inline SVG instead of img tag for rendering SVGs";
1046
- var USE_LINK_FOR_NAVIGATION = "Use Link or NavLink component from 'react-router-dom' for click-navigation instead of onClick handler";
1047
- var USE_ANCHOR_FOR_NAVIGATION = "Use Anchor element (<a>) for click-navigation instead of onClick handler";
1048
- var USE_BUTTON_TO_FOR_LINK_NAVIGATION = "Use `to` prop of Button (<Button to='path'>) for click-navigation instead of onClick handler";
1049
- var USE_BUTTON_TO_FOR_ANCHOR_NAVIGATION = "Use `href` prop of Button (<Button href='path'>) for click-navigation instead of onClick handler";
1050
- var USE_NEETO_SMALLER_CASE = "Use 'neeto' instead of 'Neeto' in strings";
1051
- var USE_NEETOUI_BORDER_COLOR = "Use neetoUI border color. Refer https://bit.ly/neeto-ui-border-colors for more details.";
1052
- var USE_NEETOUI_BORDER_RADIUS = "Use neetoUI border radius. Refer https://bit.ly/neeto-ui-border-radius for more details.";
1053
- var USE_NEETOUI_BOX_SHADOW = "Use neetoUI border shadow. Refer https://bit.ly/neeto-ui-box-shadows for more details.";
1054
- var USE_NEETOUI_TEXT_COLOR = "Use neetoUI text color. Refer https://bit.ly/neeto-ui-text-color for more details.";
1055
- var DONT_USE_ZUSTAND_STORE_WITHOUT_SELECTOR = "Don't use zustand store hook without a selector function. It will impact the performance";
1056
- var DONT_USE_ZUSTAND_STORE_WITHOUT_COMPARATOR_FUNCTION = "Don't pick multiple zustand state items without comparator function";
1057
- var USE_PROP_FOR_PICKING_SINGLE_ITEM = "Use prop instead of pick when picking single item";
1058
- var ENSURE_ZUSTAND_STORES_ARE_TYPE_ANNOTATED = "\n Zustand stores should be type annotated like this:\n /** @type {import(\"neetocommons/react-utils\").ZustandStoreHook} */\n const useUserStore = create(...)\n";
1059
- var USE_REACT_QUERY_FOR_MANAGING_REMOTE_DATA = "API calls should be managed using React Query";
1060
- var FILES_INSIDE_REACT_QUERY_FOLDER_SHOULD_END_WITH_API = "Files inside reactQuery folder should end with Api";
1061
- var USE_ZUSTAND_FOR_GLOBAL_STATE_MANAGEMENT = "Use zustand for global state management";
1062
- var AVOID_T_FUNCTIONS_IN_STRING_INTERPOLATION = "Translation function should not be used in string interpolation. Instead use a single translation key for the entire string. Refer: https://bit.ly/localization-best-practices";
1063
- var AVOID_MULTIPLE_T_FUNCTIONS_UNDER_SAME_PARENT = "Avoid using multiple translation functions under the same JSX parent. Instead use a single translation function with a single key. Refer: https://bit.ly/localization-best-practices";
1064
- var USE_TRANS_COMPONENTS_AND_VALUES_PROPS = "Instead of using numbered tags in translation string use `components` and `values` props of `Trans` to use named tag in translation string. Refer: https://bit.ly/localization-best-practices";
1065
- var USE_TRANSLATION_HOOK_IN_COMPONENTS = "Use translation function from `useTranslation()` hook in components.";
1066
- var USE_COMPONENTS_CHILDREN_PROP_IN_TRANS = "Use components children prop instead of label prop in `Trans` component to avoid multiple translation keys.";
1067
- var USE_I18NEXT_PLURALS = "Use plurals that comes with the `i18next` package for hard-coded strings. Refer: https://bit.ly/i18next-plurals";
1068
- var USE_PLURALIZE_PACKAGE = "Use `pluralize` package for dynamic values. Refer: https://bit.ly/i18next-plurals";
1069
- var USE_COPY_TO_CLIPBOARD_FROM_NEETO_COMMONS = "Use `copyToClipboard` from `@bigbinary/neeto-commons-frontend` package. Refer: https://bit.ly/copy-to-clipboard-utility-function";
1070
- var USE_ZUSTAND_PICK_TRANSFORMER = "Replace the boilerplate with zustand-pick syntax offered by babel-preset-neeto. Refer: https://bit.ly/zustand-pick-transform-doc";
1071
- var HARD_CODED_STRING_SHOULD_BE_LOCALIZED = "Hard-coded string should be localized";
1072
- var PROPS_NOT_SORTED = "Props inside spread attributes should be alphabetically sorted";
1073
- var MERGE_ADJACENT_SPREAD_ATTRIBUTES = "Merge spread attributes";
1074
- var DIFFERENT_PROPS_MUST_BE_OUTSIDE = "Props with different key and value should be outside the spread attribute";
1075
- var PROP_KEY_VALUE_DUPLICATE = "Prop key and value names should not be repeated";
1076
- var USE_WITH_IMMUTABLE_ACTIONS_WRAPPER = 'Use "withImmutableActions" wrapper from "neeto-commons-frontend" inside zustand create. Refer: https://bit.ly/withimmutableactions';
1077
-
1078
1215
  var toCamelCase = function toCamelCase(text) {
1079
1216
  var capitalized = text.split(/[^0-9a-z]/i).map(function (part) {
1080
1217
  return "".concat(part[0].toUpperCase()).concat(part.slice(1));
@@ -1140,37 +1277,6 @@
1140
1277
  }
1141
1278
  };
1142
1279
 
1143
- function _toPrimitive(input, hint) {
1144
- if (_typeof(input) !== "object" || input === null) return input;
1145
- var prim = input[Symbol.toPrimitive];
1146
- if (prim !== undefined) {
1147
- var res = prim.call(input, hint || "default");
1148
- if (_typeof(res) !== "object") return res;
1149
- throw new TypeError("@@toPrimitive must return a primitive value.");
1150
- }
1151
- return (hint === "string" ? String : Number)(input);
1152
- }
1153
-
1154
- function _toPropertyKey(arg) {
1155
- var key = _toPrimitive(arg, "string");
1156
- return _typeof(key) === "symbol" ? key : String(key);
1157
- }
1158
-
1159
- function _defineProperty(obj, key, value) {
1160
- key = _toPropertyKey(key);
1161
- if (key in obj) {
1162
- Object.defineProperty(obj, key, {
1163
- value: value,
1164
- enumerable: true,
1165
- configurable: true,
1166
- writable: true
1167
- });
1168
- } else {
1169
- obj[key] = value;
1170
- }
1171
- return obj;
1172
- }
1173
-
1174
1280
  var AWAIT_DECLARATION_PATTERN = {
1175
1281
  type: TYPES.VARIABLE_DECLARATOR,
1176
1282
  init: {
@@ -5855,7 +5961,7 @@
5855
5961
 
5856
5962
  var findAllRamdaUsage = function findAllRamdaUsage(node, identifierName) {
5857
5963
  var acc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
5858
- if (!node || _typeof(node) !== "object") return acc;
5964
+ if (!node || _typeof$1(node) !== "object") return acc;
5859
5965
  return Object.entries(node).reduce(function (acc, _ref) {
5860
5966
  var _ref2 = _slicedToArray(_ref, 2),
5861
5967
  key = _ref2[0],
@@ -6226,12 +6332,6 @@
6226
6332
  return ((_property$key = property.key) === null || _property$key === void 0 ? void 0 : _property$key.name) !== ((_property$value = property.value) === null || _property$value === void 0 ? void 0 : _property$value.name);
6227
6333
  });
6228
6334
  };
6229
- var isOtherPropsInBetweenJSXAttribute = function isOtherPropsInBetweenJSXAttribute(attributes) {
6230
- return attributes.slice(1, -1).some(pure.matches(OTHER_PROPS));
6231
- };
6232
- var isOtherPropsAtBottomOrBetweenSpreadAttributes = function isOtherPropsAtBottomOrBetweenSpreadAttributes(properties) {
6233
- return properties.slice(1).some(pure.matches(OTHER_PROPS_INSIDE_SPREAD_ATTRIBUTE));
6234
- };
6235
6335
  var getRepeatedKeyValueProps = function getRepeatedKeyValueProps(attributes) {
6236
6336
  return attributes.filter(function (attribute) {
6237
6337
  var _attribute$value, _attribute$value$expr;
@@ -6558,44 +6658,45 @@
6558
6658
  },
6559
6659
  create: function create(context) {
6560
6660
  return {
6561
- JSXOpeningElement: function JSXOpeningElement(node) {
6562
- var existingSpreadAttributesProperties = node.attributes.flatMap(function (item) {
6563
- return pure.matches(SPREAD_ATTRIBUTE_WITH_OBJECT_EXPRESSION, item) ? item.argument.properties : [];
6564
- });
6565
- var nonRepeatedKeyValueProperties = getNonRepeatedKeyValueProperties(existingSpreadAttributesProperties);
6566
- if (ramda.isEmpty(nonRepeatedKeyValueProperties)) return;
6567
- var isNotFixable = isOtherPropsInBetweenJSXAttribute(node.attributes) || isOtherPropsAtBottomOrBetweenSpreadAttributes(existingSpreadAttributesProperties);
6568
- if (isNotFixable) {
6569
- nonRepeatedKeyValueProperties.map(function (errorNode) {
6570
- return context.report({
6571
- node: errorNode,
6572
- message: DIFFERENT_PROPS_MUST_BE_OUTSIDE
6573
- });
6574
- });
6661
+ JSXSpreadAttribute: function JSXSpreadAttribute(node) {
6662
+ if (!pure.matches(SPREAD_ATTRIBUTE_WITH_OBJECT_EXPRESSION, node)) {
6575
6663
  return;
6576
6664
  }
6577
- nonRepeatedKeyValueProperties.map(function (errorNode) {
6578
- return context.report({
6579
- node: errorNode,
6580
- message: DIFFERENT_PROPS_MUST_BE_OUTSIDE,
6581
- fix: function fix(fixer) {
6582
- var fixToRemoveComma = null;
6583
- var fixToRemoveErrorNode = fixer.remove(errorNode);
6584
- var commaTokenBefore = context.getTokenBefore(errorNode);
6585
- var commaTokenAfter = context.getTokenAfter(errorNode);
6586
- if (commaTokenAfter.value === ",") {
6587
- fixToRemoveComma = fixer.remove(commaTokenAfter);
6588
- } else if (commaTokenBefore.value === ",") {
6589
- fixToRemoveComma = fixer.remove(commaTokenBefore);
6590
- } else {
6591
- fixToRemoveErrorNode = fixer.remove(errorNode.parent.parent);
6665
+ var properties = node.argument.properties;
6666
+ var nonRepeatedKeyValueProperties = getNonRepeatedKeyValueProperties(properties);
6667
+ if (ramda.isEmpty(nonRepeatedKeyValueProperties)) return;
6668
+ nonRepeatedKeyValueProperties.forEach(function (property) {
6669
+ var positionToInsert = null;
6670
+ var index = properties.indexOf(property);
6671
+ var nodesBeforeTarget = properties.slice(0, index);
6672
+ var nodesAfterTarget = properties.slice(index + 1);
6673
+ if (!nodesAfterTarget.find(pure.matches(OTHER_PROPS_INSIDE_SPREAD_ATTRIBUTE))) {
6674
+ positionToInsert = "below";
6675
+ } else if (!nodesBeforeTarget.find(pure.matches(OTHER_PROPS_INSIDE_SPREAD_ATTRIBUTE))) {
6676
+ positionToInsert = "above";
6677
+ }
6678
+ if (positionToInsert) {
6679
+ context.report({
6680
+ node: property,
6681
+ message: DIFFERENT_PROPS_MUST_BE_OUTSIDE,
6682
+ fix: function fix(fixer) {
6683
+ var fixToRemoveComma = null;
6684
+ var fixToRemoveErrorNode = fixer.remove(property);
6685
+ var tokenBefore = context.getTokenBefore(property);
6686
+ var tokenAfter = context.getTokenAfter(property);
6687
+ if (tokenAfter.value === ",") {
6688
+ fixToRemoveComma = fixer.remove(tokenAfter);
6689
+ } else if (tokenBefore.value === ",") {
6690
+ fixToRemoveComma = fixer.remove(tokenBefore);
6691
+ } else {
6692
+ fixToRemoveErrorNode = fixer.remove(node);
6693
+ }
6694
+ var indentLevel = context.getSourceCode().getFirstToken(node.parent.attributes[0]).loc.start.column;
6695
+ var fixToAddProperty = positionToInsert === "below" ? fixer.insertTextAfter(node, "\n".concat(" ".repeat(indentLevel)).concat(property.key.name, "={").concat(property.value.name, "}")) : fixer.insertTextBefore(node, "".concat(property.key.name, "={").concat(property.value.name, "}\n").concat(" ".repeat(indentLevel)));
6696
+ return [fixToRemoveComma, fixToRemoveErrorNode, fixToAddProperty].filter(Boolean);
6592
6697
  }
6593
- var indentLevel = context.getSourceCode().getFirstToken(node.attributes[0]).loc.start.column;
6594
- var newAttribute = "\n".concat(" ".repeat(indentLevel)).concat(errorNode.key.name, "={").concat(errorNode.value.name, "}");
6595
- var fixToAddNewAttribute = fixer.insertTextAfter(errorNode.parent.parent, newAttribute);
6596
- return [fixToRemoveComma, fixToRemoveErrorNode, fixToAddNewAttribute].filter(Boolean);
6597
- }
6598
- });
6698
+ });
6699
+ }
6599
6700
  });
6600
6701
  }
6601
6702
  };
@@ -26149,12 +26250,16 @@
26149
26250
  "no-repetition-in-prop-key-value-names": noRepetitionInPropKeyAndValueName,
26150
26251
  "use-functions-and-hooks-from-neeto-commons-frontend": useFunctionsAndHooksFromNeetoCommonsFrontend,
26151
26252
  "no-unnecessary-if-condition": noUnnecessaryIfCondition,
26152
- "zustand-use-with-immutable-actions-wrapper-inside-create": useWithImmutableActionsWrapperInsideCreate
26253
+ "zustand-use-with-immutable-actions-wrapper-inside-create": useWithImmutableActionsWrapperInsideCreate,
26254
+ "add-required-peer-dependencies": addRequiredPeerDependencies
26153
26255
  },
26154
26256
  configs: {
26155
26257
  recommended: recommended,
26156
26258
  "nextjs-recommended": nextjsRecommended,
26157
26259
  "nanos-recommended": nanosRecommended
26260
+ },
26261
+ processors: {
26262
+ ".json": jsonProcessor
26158
26263
  }
26159
26264
  };
26160
26265
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/eslint-plugin-neeto",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "main": "dist/index.js",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {