@bigbinary/eslint-plugin-neeto 1.1.29 → 1.1.31

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 +2 -0
  2. package/dist/index.js +107 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -46,6 +46,8 @@ module.exports = {
46
46
 
47
47
  ## Exported rules
48
48
 
49
+ - [no-local-storage](./docs/src/rules/no-local-storage.md)
50
+ - [no-lowercase-on-translation](./docs/src/rules/no-lowercase-on-translation.md)
49
51
  - [use-use-query-client-hook](./docs/src/rules/use-use-query-client-hook.md)
50
52
  - [use-early-return](./docs/src/rules/use-early-return.md)
51
53
  - [use-classnames-for-dynamic-classes](./docs/src/rules/use-classnames-for-dynamic-classes.md)
package/dist/index.js CHANGED
@@ -42,6 +42,8 @@
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-local-storage": "error",
46
+ "@bigbinary/neeto/no-lowercase-on-translation": "warn",
45
47
  "@bigbinary/neeto/use-use-query-client-hook": "error",
46
48
  "@bigbinary/neeto/use-early-return": "warn",
47
49
  "@bigbinary/neeto/use-classnames-for-dynamic-classes": "error",
@@ -556,6 +558,8 @@
556
558
  var USE_CLASSNAMES_PACKAGE = "Use classnames package for dynamic classes";
557
559
  var USE_USE_QUERY_CLIENT_HOOK = "Use 'useQueryClient' hook from 'react-query'";
558
560
  var USE_EARLY_RETURN = "Use early return to avoid nested statement";
561
+ var NO_LOCAL_STORAGE = "Do not use localStorage directly. Use 'getFromLocalStorage()', 'setToLocalStorage()', or 'useLocalStorage()' from neeto-commons-frontend instead.";
562
+ var NO_TRANSLATION_LOWERCASE = "No need to lowercase i18next translations";
559
563
 
560
564
  var PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
561
565
 
@@ -6192,6 +6196,107 @@
6192
6196
  }
6193
6197
  };
6194
6198
 
6199
+ var noLocalStorage = {
6200
+ meta: {
6201
+ type: "error",
6202
+ docs: {
6203
+ url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/no-local-storage.md",
6204
+ description: "Disallows the usage of localStorage directly"
6205
+ }
6206
+ },
6207
+ create: function create(context) {
6208
+ return {
6209
+ MemberExpression: function MemberExpression(node) {
6210
+ if (node.object.name === "localStorage") {
6211
+ context.report({
6212
+ node: node,
6213
+ message: NO_LOCAL_STORAGE
6214
+ });
6215
+ }
6216
+ }
6217
+ };
6218
+ }
6219
+ };
6220
+
6221
+ var createPattern = function createPattern(functionName) {
6222
+ return {
6223
+ property: {
6224
+ type: TYPES.IDENTIFIER,
6225
+ name: functionName
6226
+ },
6227
+ object: {
6228
+ type: TYPES.CALL_EXPRESSION,
6229
+ callee: {
6230
+ type: TYPES.IDENTIFIER,
6231
+ name: "t"
6232
+ }
6233
+ }
6234
+ };
6235
+ };
6236
+ var createPatternForArguments = function createPatternForArguments(functionName) {
6237
+ return {
6238
+ parent: {
6239
+ type: TYPES.OBJECT_EXPRESSION,
6240
+ parent: {
6241
+ type: TYPES.CALL_EXPRESSION,
6242
+ callee: {
6243
+ type: TYPES.IDENTIFIER,
6244
+ name: "t"
6245
+ }
6246
+ }
6247
+ },
6248
+ value: {
6249
+ type: TYPES.CALL_EXPRESSION,
6250
+ callee: {
6251
+ type: TYPES.MEMBER_EXPRESSION,
6252
+ property: {
6253
+ type: TYPES.IDENTIFIER,
6254
+ name: functionName
6255
+ }
6256
+ }
6257
+ }
6258
+ };
6259
+ };
6260
+ var NO_LOWERCASE_PATTERN = [createPattern("toLowerCase"), createPattern("toLocaleLowerCase")];
6261
+ var NO_LOWERCASE_PATTERN_ON_ARGUMENTS = [createPatternForArguments("toLowerCase"), createPatternForArguments("toLocaleLowerCase")];
6262
+
6263
+ var noLowercaseOnTranslation = {
6264
+ meta: {
6265
+ type: "suggestion",
6266
+ docs: {
6267
+ url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/no-lowercase-on-translation.md",
6268
+ description: "lowercasing dynamic text is handled by i18next initializer"
6269
+ },
6270
+ fixable: "code"
6271
+ },
6272
+ create: function create(context) {
6273
+ return {
6274
+ MemberExpression: function MemberExpression(node) {
6275
+ if (matchesAny(NO_LOWERCASE_PATTERN, node)) {
6276
+ context.report({
6277
+ node: node,
6278
+ message: NO_TRANSLATION_LOWERCASE,
6279
+ fix: function fix(fixer) {
6280
+ return fixer.removeRange([node.object.range[1], node.parent.range[1]]);
6281
+ }
6282
+ });
6283
+ }
6284
+ },
6285
+ Property: function Property(node) {
6286
+ if (matchesAny(NO_LOWERCASE_PATTERN_ON_ARGUMENTS, node)) {
6287
+ context.report({
6288
+ node: node,
6289
+ message: NO_TRANSLATION_LOWERCASE,
6290
+ fix: function fix(fixer) {
6291
+ return fixer.removeRange([node.value.callee.object.range[1], node.range[1]]);
6292
+ }
6293
+ });
6294
+ }
6295
+ }
6296
+ };
6297
+ }
6298
+ };
6299
+
6195
6300
  var noMultipleComponentsInAFile = {
6196
6301
  meta: {
6197
6302
  type: "problem",
@@ -10193,6 +10298,8 @@
10193
10298
 
10194
10299
  var index = {
10195
10300
  rules: {
10301
+ "no-local-storage": noLocalStorage,
10302
+ "no-lowercase-on-translation": noLowercaseOnTranslation,
10196
10303
  "use-use-query-client-hook": useUseQueryClientHook,
10197
10304
  "use-early-return": useEarlyReturn,
10198
10305
  "use-classnames-for-dynamic-classes": useClassnamesForDynamicClasses,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/eslint-plugin-neeto",
3
- "version": "1.1.29",
3
+ "version": "1.1.31",
4
4
  "main": "dist/index.js",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {