@bigbinary/eslint-plugin-neeto 1.1.12 → 1.1.14
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/dist/index.js +39 -37
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -525,6 +525,7 @@
|
|
|
525
525
|
var DIFFERENT_PROPS_MUST_BE_OUTSIDE = "Props with different key and value should be outside the spread attribute";
|
|
526
526
|
var PROP_KEY_VALUE_DUPLICATE = "Prop key and value names should not be repeated";
|
|
527
527
|
var USE_WITH_IMMUTABLE_ACTIONS_WRAPPER = 'Use "withImmutableActions" wrapper from "neeto-commons-frontend" inside zustand create. Refer: https://bit.ly/withimmutableactions';
|
|
528
|
+
var USE_WITH_T_HOC_IN_DUMB_COMPONENTS = 'Use "withT" HOC from "neeto-commons-frontend" instead of useTranslation hook in Dumb components';
|
|
528
529
|
|
|
529
530
|
var PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
|
|
530
531
|
|
|
@@ -5896,7 +5897,7 @@
|
|
|
5896
5897
|
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$2(arr) || _nonIterableRest();
|
|
5897
5898
|
}
|
|
5898
5899
|
|
|
5899
|
-
|
|
5900
|
+
({
|
|
5900
5901
|
type: TYPES.VARIABLE_DECLARATION,
|
|
5901
5902
|
declarations: [{
|
|
5902
5903
|
type: TYPES.VARIABLE_DECLARATOR,
|
|
@@ -5908,8 +5909,8 @@
|
|
|
5908
5909
|
}
|
|
5909
5910
|
}
|
|
5910
5911
|
}]
|
|
5911
|
-
};
|
|
5912
|
-
|
|
5912
|
+
});
|
|
5913
|
+
({
|
|
5913
5914
|
type: TYPES.EXPRESSION_STATEMENT,
|
|
5914
5915
|
expression: {
|
|
5915
5916
|
type: TYPES.CALL_EXPRESSION,
|
|
@@ -5918,7 +5919,7 @@
|
|
|
5918
5919
|
name: ramda.test(/use[a-zA-z0-9].+/)
|
|
5919
5920
|
}
|
|
5920
5921
|
}
|
|
5921
|
-
};
|
|
5922
|
+
});
|
|
5922
5923
|
|
|
5923
5924
|
// import { functionName } from "neetocommons/react-utils";
|
|
5924
5925
|
var NEETO_COMMONS_REACT_UTILS_IMPORT_PATTERN = {
|
|
@@ -5932,6 +5933,31 @@
|
|
|
5932
5933
|
}]
|
|
5933
5934
|
};
|
|
5934
5935
|
|
|
5936
|
+
var BREAK_STATEMENT_PATTERN = {
|
|
5937
|
+
type: TYPES.BREAK_STATEMENT
|
|
5938
|
+
};
|
|
5939
|
+
var RETURN_STATEMENT_PATTERN = {
|
|
5940
|
+
type: TYPES.RETURN_STATEMENT
|
|
5941
|
+
};
|
|
5942
|
+
var ARRAY_LENGTH_TEST_PATTERN = {
|
|
5943
|
+
test: {
|
|
5944
|
+
right: {
|
|
5945
|
+
type: TYPES.MEMBER_EXPRESSION,
|
|
5946
|
+
property: {
|
|
5947
|
+
name: "length"
|
|
5948
|
+
}
|
|
5949
|
+
}
|
|
5950
|
+
}
|
|
5951
|
+
};
|
|
5952
|
+
var CHAR_AT_PATTERN = {
|
|
5953
|
+
type: TYPES.CALL_EXPRESSION,
|
|
5954
|
+
callee: {
|
|
5955
|
+
property: {
|
|
5956
|
+
name: ramda.includes(ramda.__, ["charAt", "charCodeAt"])
|
|
5957
|
+
}
|
|
5958
|
+
}
|
|
5959
|
+
};
|
|
5960
|
+
|
|
5935
5961
|
var noDumbComponentsWithUseTranslation = {
|
|
5936
5962
|
meta: {
|
|
5937
5963
|
type: "suggestion",
|
|
@@ -5949,15 +5975,16 @@
|
|
|
5949
5975
|
arrowFunctionExpression = _node$declarations[0].init;
|
|
5950
5976
|
var blockStatement = arrowFunctionExpression.body;
|
|
5951
5977
|
if (!blockStatement.body) return;
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5978
|
+
if (blockStatement.body.length !== 2) return;
|
|
5979
|
+
var _blockStatement$body = _slicedToArray(blockStatement.body, 2),
|
|
5980
|
+
firstStatement = _blockStatement$body[0],
|
|
5981
|
+
secondStatement = _blockStatement$body[1];
|
|
5982
|
+
if (!(pure.matches(USE_TRANSLATION_HOOK_PATTERN, firstStatement) && pure.matches(RETURN_STATEMENT_PATTERN, secondStatement))) {
|
|
5983
|
+
return;
|
|
5984
|
+
}
|
|
5958
5985
|
context.report({
|
|
5959
5986
|
node: node,
|
|
5960
|
-
message:
|
|
5987
|
+
message: USE_WITH_T_HOC_IN_DUMB_COMPONENTS,
|
|
5961
5988
|
fix: function fix(fixer) {
|
|
5962
5989
|
var fixers = [];
|
|
5963
5990
|
var _arrowFunctionExpress = _toArray(arrowFunctionExpression.params),
|
|
@@ -5978,7 +6005,7 @@
|
|
|
5978
6005
|
return "";
|
|
5979
6006
|
};
|
|
5980
6007
|
var blockStatementCode = getCode$1(context, blockStatement);
|
|
5981
|
-
var useTranslationHookCode = getCode$1(context,
|
|
6008
|
+
var useTranslationHookCode = getCode$1(context, firstStatement);
|
|
5982
6009
|
var body = blockStatementCode.replace(useTranslationHookCode, "");
|
|
5983
6010
|
var withTWrap = "withT((".concat(getPropsCode()).concat(pure.isNotEmpty(restParams) ? ", ".concat(restParams.map(function (param) {
|
|
5984
6011
|
return getCode$1(context, param);
|
|
@@ -7786,31 +7813,6 @@
|
|
|
7786
7813
|
}
|
|
7787
7814
|
};
|
|
7788
7815
|
|
|
7789
|
-
var BREAK_STATEMENT_PATTERN = {
|
|
7790
|
-
type: TYPES.BREAK_STATEMENT
|
|
7791
|
-
};
|
|
7792
|
-
var RETURN_STATEMENT_PATTERN = {
|
|
7793
|
-
type: TYPES.RETURN_STATEMENT
|
|
7794
|
-
};
|
|
7795
|
-
var ARRAY_LENGTH_TEST_PATTERN = {
|
|
7796
|
-
test: {
|
|
7797
|
-
right: {
|
|
7798
|
-
type: TYPES.MEMBER_EXPRESSION,
|
|
7799
|
-
property: {
|
|
7800
|
-
name: "length"
|
|
7801
|
-
}
|
|
7802
|
-
}
|
|
7803
|
-
}
|
|
7804
|
-
};
|
|
7805
|
-
var CHAR_AT_PATTERN = {
|
|
7806
|
-
type: TYPES.CALL_EXPRESSION,
|
|
7807
|
-
callee: {
|
|
7808
|
-
property: {
|
|
7809
|
-
name: ramda.includes(ramda.__, ["charAt", "charCodeAt"])
|
|
7810
|
-
}
|
|
7811
|
-
}
|
|
7812
|
-
};
|
|
7813
|
-
|
|
7814
7816
|
var isForLoopReplacable = function isForLoopReplacable(node) {
|
|
7815
7817
|
return ramda.not(patternExistsDeep(BREAK_STATEMENT_PATTERN, node.body) || patternExistsDeep(RETURN_STATEMENT_PATTERN, node.body) || patternExistsDeep(CHAR_AT_PATTERN, node.body));
|
|
7816
7818
|
};
|