@bigbinary/eslint-plugin-neeto 1.2.0 → 1.3.0

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 +90 -16
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -124,6 +124,7 @@ module.exports = {
124
124
  - [move-spread-attributes-to-top-position](./docs/src/rules/move-spread-attributes-to-top-position.md)
125
125
  - [prefer-function-reference.md](./docs/src/rules/prefer-function-reference.md)
126
126
  - [jsx-prefer-guard-clause.md](./docs/src/rules/jsx-prefer-guard-clause.md)
127
+ - [use-show-thumbs-up-toastr.md](./docs/src/rules/use-show-thumbs-up-toastr)
127
128
 
128
129
  ## Other references
129
130
 
package/dist/index.js CHANGED
@@ -164,7 +164,8 @@
164
164
  "@bigbinary/neeto/use-common-constants": "warn",
165
165
  "@bigbinary/neeto/move-spread-attributes-to-top-position": "error",
166
166
  "@bigbinary/neeto/prefer-function-reference": "warn",
167
- "@bigbinary/neeto/jsx-prefer-guard-clause": "warn"
167
+ "@bigbinary/neeto/jsx-prefer-guard-clause": "warn",
168
+ "@bigbinary/neeto/use-show-thumbs-up-toastr": "error"
168
169
  };
169
170
 
170
171
  var recommended = {
@@ -439,6 +440,18 @@
439
440
  var NO_OF_LINES_ALLOWED_FOR_MULTIPLE_COMPONENTS_IN_A_FILE = 20;
440
441
  var MAX_LINES_FOR_FUNCTIONS_INSIDE_JSX = 4;
441
442
 
443
+ // import { functionName } from neetocommons/utils;
444
+ var NEETO_COMMONS_UTILS_IMPORT_PATTERN = {
445
+ type: TYPES.IMPORT_DECLARATION,
446
+ source: {
447
+ type: TYPES.LITERAL,
448
+ value: "neetocommons/utils"
449
+ },
450
+ specifiers: [{
451
+ type: TYPES.IMPORT_SPECIFIER
452
+ }]
453
+ };
454
+
442
455
  var ARGUMENT_LIMIT = 3;
443
456
  var API_ACTIONS_ARGUMENT_LIMIT = 2;
444
457
  var FIXABLE_PARAMETER_TYPES = [TYPES.IDENTIFIER, TYPES.ASSIGNMENT_PATTERN];
@@ -571,6 +584,7 @@
571
584
  var AVOID_SNAKE_CASE_DESTRUCTURING_USEQUERYPARAMS_OR_GETQUERYPARAMS = "Avoid destructuring snake-cased values from getQueryParams or useQueryParams";
572
585
  var PREFER_FUNCTION_REFERENCE = "Prefer passing function reference instead of creating a new function as the parameters and arguments are the same.";
573
586
  var JSX_PREFER_GUARD_CLAUSE = "Prefer adding a guard clause for conditional statements left of JSX statments in the last return statement of the function.";
587
+ var USE_SHOW_THUMBS_UP_TOASTR_FUNCTION = "Use 'showThumbsUpToastr' function from '@bigbinary/neeto-commons-frontend/utils' for displaying thumbs up toast message.";
574
588
  var NO_UNNECESSARY_CLASSNAMES = "classnames usage is unnecessary";
575
589
 
576
590
  var PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
@@ -2070,7 +2084,7 @@
2070
2084
  }
2071
2085
  };
2072
2086
 
2073
- var OBJECT_EXPRESSION_PATTERN = {
2087
+ var OBJECT_EXPRESSION_PATTERN$1 = {
2074
2088
  type: TYPES.OBJECT_EXPRESSION,
2075
2089
  properties: neetoCist.isNotEmpty
2076
2090
  };
@@ -2092,7 +2106,7 @@
2092
2106
  ObjectExpression: function ObjectExpression(node) {
2093
2107
  var _resolveConfig$sync;
2094
2108
  if (isExcludedFile(EXCLUDED_FILES, context.getFilename())) return;
2095
- if (!neetoCist.matches(OBJECT_EXPRESSION_PATTERN, node)) return;
2109
+ if (!neetoCist.matches(OBJECT_EXPRESSION_PATTERN$1, node)) return;
2096
2110
  var sourceCode = context.getSourceCode();
2097
2111
  var hasComments = neetoCist.isNotEmpty(sourceCode.getCommentsInside(node));
2098
2112
  if (hasComments) return;
@@ -9032,18 +9046,6 @@
9032
9046
  })
9033
9047
  };
9034
9048
 
9035
- // import { functionName } from neetocommons/utils;
9036
- var NEETO_COMMONS_UTILS_IMPORT_PATTERN = {
9037
- type: TYPES.IMPORT_DECLARATION,
9038
- source: {
9039
- type: TYPES.LITERAL,
9040
- value: "neetocommons/utils"
9041
- },
9042
- specifiers: [{
9043
- type: TYPES.IMPORT_SPECIFIER
9044
- }]
9045
- };
9046
-
9047
9049
  var createSubscriptionImportPattern = function createSubscriptionImportPattern(functionName) {
9048
9050
  return {
9049
9051
  type: TYPES.IMPORT_DECLARATION,
@@ -9495,6 +9497,77 @@
9495
9497
  }
9496
9498
  };
9497
9499
 
9500
+ var OBJECT_EXPRESSION_PATTERN = {
9501
+ type: TYPES.OBJECT_EXPRESSION,
9502
+ properties: neetoCist.existsBy({
9503
+ key: {
9504
+ name: "icon"
9505
+ },
9506
+ value: {
9507
+ value: "👍"
9508
+ }
9509
+ })
9510
+ };
9511
+
9512
+ // Toastr.success("", { icon: "👍", className: "w-20" });
9513
+ var TOASTR_SUCCESS_THUMBS_UP_PATTERN = {
9514
+ callee: {
9515
+ object: {
9516
+ name: "Toastr"
9517
+ },
9518
+ property: {
9519
+ name: "success"
9520
+ }
9521
+ },
9522
+ arguments: neetoCist.existsBy(OBJECT_EXPRESSION_PATTERN)
9523
+ };
9524
+
9525
+ // const THUMBS_UP = { icon: "👍", className: "w-20" }
9526
+ var THUMBS_UP_OBJECT_DECLARATION = {
9527
+ id: {
9528
+ type: TYPES.IDENTIFIER,
9529
+ name: "THUMBS_UP"
9530
+ },
9531
+ init: OBJECT_EXPRESSION_PATTERN
9532
+ };
9533
+
9534
+ var useShowThumbsUpToastr = {
9535
+ meta: {
9536
+ type: "problem",
9537
+ docs: {
9538
+ url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/use-show-thumbs-up-toastr.md",
9539
+ description: "Enforces the use of 'showThumbsUpToastr' function for displaying thumbs up toast messages."
9540
+ },
9541
+ fixable: "code"
9542
+ },
9543
+ create: function create(context) {
9544
+ return {
9545
+ CallExpression: function CallExpression(node) {
9546
+ if (!neetoCist.matches(TOASTR_SUCCESS_THUMBS_UP_PATTERN, node)) return;
9547
+ context.report({
9548
+ node: node,
9549
+ message: USE_SHOW_THUMBS_UP_TOASTR_FUNCTION,
9550
+ fix: function fix(fixer) {
9551
+ var fixerArr = [fixer.replaceText(node, "showThumbsUpToastr()")];
9552
+ var addImport = addFunctionImport({
9553
+ context: context,
9554
+ fixer: fixer,
9555
+ functions: ["showThumbsUpToastr"],
9556
+ importPattern: NEETO_COMMONS_UTILS_IMPORT_PATTERN
9557
+ });
9558
+ if (addImport) fixerArr.push(addImport);
9559
+ return fixerArr;
9560
+ }
9561
+ });
9562
+ },
9563
+ VariableDeclarator: function VariableDeclarator(node) {
9564
+ if (!neetoCist.matches(THUMBS_UP_OBJECT_DECLARATION, node)) return;
9565
+ context.report(node, USE_SHOW_THUMBS_UP_TOASTR_FUNCTION);
9566
+ }
9567
+ };
9568
+ }
9569
+ };
9570
+
9498
9571
  var isSnakeCase = function isSnakeCase(text) {
9499
9572
  return SNAKE_CASE_REGEX.test(text);
9500
9573
  };
@@ -10588,7 +10661,8 @@
10588
10661
  "use-common-constants": useCommonConstants,
10589
10662
  "move-spread-attributes-to-top-position": moveSpreadAttributesToTopPosition,
10590
10663
  "prefer-function-reference": preferFunctionReference,
10591
- "jsx-prefer-guard-clause": jsxPreferGuardClause
10664
+ "jsx-prefer-guard-clause": jsxPreferGuardClause,
10665
+ "use-show-thumbs-up-toastr": useShowThumbsUpToastr
10592
10666
  },
10593
10667
  configs: {
10594
10668
  recommended: recommended,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/eslint-plugin-neeto",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {