@bigbinary/eslint-plugin-neeto 1.1.33 → 1.1.35

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.
package/README.md CHANGED
@@ -46,6 +46,7 @@ module.exports = {
46
46
 
47
47
  ## Exported rules
48
48
 
49
+ - [no-snake-case-destructuring-for-use-query-params-and-get-query-params](./docs/src/rules/no-snake-case-destructuring-for-use-query-params-and-get-query-params.md)
49
50
  - [no-local-storage](./docs/src/rules/no-local-storage.md)
50
51
  - [no-lowercase-on-translation](./docs/src/rules/no-lowercase-on-translation.md)
51
52
  - [use-use-query-client-hook](./docs/src/rules/use-use-query-client-hook.md)
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@
42
42
  var commonResolve$2 = loadJS$2("node_modules/@bigbinary/neeto-commons-frontend/configs/webpack/resolve.js");
43
43
  var resolve$2 = ramda.mergeDeepLeft(projectResolve$2, commonResolve$2);
44
44
  var rules = {
45
+ "@bigbinary/neeto/no-snake-case-destructuring-for-use-query-params-and-get-query-params": "warn",
45
46
  "@bigbinary/neeto/no-local-storage": "error",
46
47
  "@bigbinary/neeto/no-lowercase-on-translation": "warn",
47
48
  "@bigbinary/neeto/use-use-query-client-hook": "error",
@@ -560,6 +561,7 @@
560
561
  var USE_EARLY_RETURN = "Use early return to avoid nested statement";
561
562
  var NO_LOCAL_STORAGE = "Do not use localStorage directly. Use 'getFromLocalStorage()', 'setToLocalStorage()', 'removeFromLocalStorage()' or 'useLocalStorage()' from neeto-commons-frontend instead.";
562
563
  var NO_TRANSLATION_LOWERCASE = "No need to lowercase i18next translations";
564
+ var AVOID_SNAKE_CASE_DESTRUCTURING_USEQUERYPARAMS_OR_GETQUERYPARAMS = "Avoid destructuring snake-cased values from getQueryParams or useQueryParams";
563
565
 
564
566
  var PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
565
567
 
@@ -6288,7 +6290,7 @@
6288
6290
  node: node,
6289
6291
  message: NO_TRANSLATION_LOWERCASE,
6290
6292
  fix: function fix(fixer) {
6291
- return fixer.removeRange([node.value.callee.object.range[1], node.range[1]]);
6293
+ return fixer.removeRange([node.value.callee.property.range[0] - 1, node.range[1]]);
6292
6294
  }
6293
6295
  });
6294
6296
  }
@@ -6551,6 +6553,58 @@
6551
6553
  }
6552
6554
  };
6553
6555
 
6556
+ var SNAKE_CASE_WITHOUT_SINGLE_WORDS = /^[a-z]+_[a-z0-9_]+$/;
6557
+ var PATTERN = {
6558
+ id: {
6559
+ type: "ObjectPattern",
6560
+ properties: ramda.any(neetoCist.matches({
6561
+ type: "Property",
6562
+ key: {
6563
+ name: ramda.test(SNAKE_CASE_WITHOUT_SINGLE_WORDS)
6564
+ }
6565
+ }))
6566
+ },
6567
+ init: {
6568
+ type: "CallExpression",
6569
+ callee: {
6570
+ name: matchesAny(["getQueryParams", "useQueryParams"])
6571
+ },
6572
+ arguments: ramda.none(neetoCist.matches({
6573
+ type: "ObjectExpression",
6574
+ properties: ramda.any(neetoCist.matches({
6575
+ key: {
6576
+ name: "toCamelCase"
6577
+ },
6578
+ value: {
6579
+ value: false
6580
+ }
6581
+ }))
6582
+ }))
6583
+ }
6584
+ };
6585
+
6586
+ var noSnakeCaseDestructuringForUseQueryParamsAndGetQueryParams = {
6587
+ meta: {
6588
+ type: "warn",
6589
+ docs: {
6590
+ url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/no-snake-case-destructuring-for-use-query-params-and-get-query-params.md",
6591
+ description: "Prevent destructuring snake-cased values within the useQueryParams and getQueryParams function"
6592
+ }
6593
+ },
6594
+ create: function create(context) {
6595
+ return {
6596
+ VariableDeclarator: function VariableDeclarator(node) {
6597
+ if (neetoCist.matches(PATTERN, node)) {
6598
+ context.report({
6599
+ node: node,
6600
+ message: AVOID_SNAKE_CASE_DESTRUCTURING_USEQUERYPARAMS_OR_GETQUERYPARAMS
6601
+ });
6602
+ }
6603
+ }
6604
+ };
6605
+ }
6606
+ };
6607
+
6554
6608
  // if (condition) statement;
6555
6609
  var SINGLE_LINE_IF_CONDITION_PATTERN = {
6556
6610
  parent: {
@@ -10298,6 +10352,7 @@
10298
10352
 
10299
10353
  var index = {
10300
10354
  rules: {
10355
+ "no-snake-case-destructuring-for-use-query-params-and-get-query-params": noSnakeCaseDestructuringForUseQueryParamsAndGetQueryParams,
10301
10356
  "no-local-storage": noLocalStorage,
10302
10357
  "no-lowercase-on-translation": noLowercaseOnTranslation,
10303
10358
  "use-use-query-client-hook": useUseQueryClientHook,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/eslint-plugin-neeto",
3
- "version": "1.1.33",
3
+ "version": "1.1.35",
4
4
  "main": "dist/index.js",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {