@bigbinary/eslint-plugin-neeto 1.1.30 → 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.
package/README.md CHANGED
@@ -47,6 +47,7 @@ module.exports = {
47
47
  ## Exported rules
48
48
 
49
49
  - [no-local-storage](./docs/src/rules/no-local-storage.md)
50
+ - [no-lowercase-on-translation](./docs/src/rules/no-lowercase-on-translation.md)
50
51
  - [use-use-query-client-hook](./docs/src/rules/use-use-query-client-hook.md)
51
52
  - [use-early-return](./docs/src/rules/use-early-return.md)
52
53
  - [use-classnames-for-dynamic-classes](./docs/src/rules/use-classnames-for-dynamic-classes.md)
package/dist/index.js CHANGED
@@ -43,6 +43,7 @@
43
43
  var resolve$2 = ramda.mergeDeepLeft(projectResolve$2, commonResolve$2);
44
44
  var rules = {
45
45
  "@bigbinary/neeto/no-local-storage": "error",
46
+ "@bigbinary/neeto/no-lowercase-on-translation": "warn",
46
47
  "@bigbinary/neeto/use-use-query-client-hook": "error",
47
48
  "@bigbinary/neeto/use-early-return": "warn",
48
49
  "@bigbinary/neeto/use-classnames-for-dynamic-classes": "error",
@@ -558,6 +559,7 @@
558
559
  var USE_USE_QUERY_CLIENT_HOOK = "Use 'useQueryClient' hook from 'react-query'";
559
560
  var USE_EARLY_RETURN = "Use early return to avoid nested statement";
560
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";
561
563
 
562
564
  var PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
563
565
 
@@ -6216,6 +6218,85 @@
6216
6218
  }
6217
6219
  };
6218
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
+
6219
6300
  var noMultipleComponentsInAFile = {
6220
6301
  meta: {
6221
6302
  type: "problem",
@@ -10218,6 +10299,7 @@
10218
10299
  var index = {
10219
10300
  rules: {
10220
10301
  "no-local-storage": noLocalStorage,
10302
+ "no-lowercase-on-translation": noLowercaseOnTranslation,
10221
10303
  "use-use-query-client-hook": useUseQueryClientHook,
10222
10304
  "use-early-return": useEarlyReturn,
10223
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.30",
3
+ "version": "1.1.31",
4
4
  "main": "dist/index.js",
5
5
  "license": "UNLICENSED",
6
6
  "scripts": {