@bigbinary/eslint-plugin-neeto 1.1.13 → 1.1.15
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 +1 -0
- package/dist/index.js +67 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ module.exports = {
|
|
|
46
46
|
|
|
47
47
|
## Exported rules
|
|
48
48
|
|
|
49
|
+
- [use-standard-date-time-formats](./docs/src/rules/use-standard-date-time-formats.md)
|
|
49
50
|
- [no-dumb-components-with-use-translation](./docs/src/rules/no-dumb-components-with-use-translation.md)
|
|
50
51
|
- [no-unnecessary-if-condition](./docs/src/rules/no-unnecessary-if-condition.md)
|
|
51
52
|
- [api-connector-name-should-match-filename](./docs/src/rules/api-connector-name-should-match-filename.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/use-standard-date-time-formats": "error",
|
|
45
46
|
"@bigbinary/neeto/no-dumb-components-with-use-translation": "error",
|
|
46
47
|
"@bigbinary/neeto/api-connector-name-should-match-filename": "error",
|
|
47
48
|
"@bigbinary/neeto/api-connector-should-use-default-export": "error",
|
|
@@ -526,6 +527,7 @@
|
|
|
526
527
|
var PROP_KEY_VALUE_DUPLICATE = "Prop key and value names should not be repeated";
|
|
527
528
|
var USE_WITH_IMMUTABLE_ACTIONS_WRAPPER = 'Use "withImmutableActions" wrapper from "neeto-commons-frontend" inside zustand create. Refer: https://bit.ly/withimmutableactions';
|
|
528
529
|
var USE_WITH_T_HOC_IN_DUMB_COMPONENTS = 'Use "withT" HOC from "neeto-commons-frontend" instead of useTranslation hook in Dumb components';
|
|
530
|
+
var USE_STANDARD_DATE_TIME_FORMATS = 'Use "dateFormat/timeFormat" from "@bigbinary/neeto-commons-frontend/utils" instead. Refer: https://github.com/bigbinary/neeto-commons-frontend/blob/main/docs/utils/README.md#dateformattimeformat';
|
|
529
531
|
|
|
530
532
|
var PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
|
|
531
533
|
|
|
@@ -5897,7 +5899,7 @@
|
|
|
5897
5899
|
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$2(arr) || _nonIterableRest();
|
|
5898
5900
|
}
|
|
5899
5901
|
|
|
5900
|
-
|
|
5902
|
+
({
|
|
5901
5903
|
type: TYPES.VARIABLE_DECLARATION,
|
|
5902
5904
|
declarations: [{
|
|
5903
5905
|
type: TYPES.VARIABLE_DECLARATOR,
|
|
@@ -5909,8 +5911,8 @@
|
|
|
5909
5911
|
}
|
|
5910
5912
|
}
|
|
5911
5913
|
}]
|
|
5912
|
-
};
|
|
5913
|
-
|
|
5914
|
+
});
|
|
5915
|
+
({
|
|
5914
5916
|
type: TYPES.EXPRESSION_STATEMENT,
|
|
5915
5917
|
expression: {
|
|
5916
5918
|
type: TYPES.CALL_EXPRESSION,
|
|
@@ -5919,7 +5921,7 @@
|
|
|
5919
5921
|
name: ramda.test(/use[a-zA-z0-9].+/)
|
|
5920
5922
|
}
|
|
5921
5923
|
}
|
|
5922
|
-
};
|
|
5924
|
+
});
|
|
5923
5925
|
|
|
5924
5926
|
// import { functionName } from "neetocommons/react-utils";
|
|
5925
5927
|
var NEETO_COMMONS_REACT_UTILS_IMPORT_PATTERN = {
|
|
@@ -5933,6 +5935,31 @@
|
|
|
5933
5935
|
}]
|
|
5934
5936
|
};
|
|
5935
5937
|
|
|
5938
|
+
var BREAK_STATEMENT_PATTERN = {
|
|
5939
|
+
type: TYPES.BREAK_STATEMENT
|
|
5940
|
+
};
|
|
5941
|
+
var RETURN_STATEMENT_PATTERN = {
|
|
5942
|
+
type: TYPES.RETURN_STATEMENT
|
|
5943
|
+
};
|
|
5944
|
+
var ARRAY_LENGTH_TEST_PATTERN = {
|
|
5945
|
+
test: {
|
|
5946
|
+
right: {
|
|
5947
|
+
type: TYPES.MEMBER_EXPRESSION,
|
|
5948
|
+
property: {
|
|
5949
|
+
name: "length"
|
|
5950
|
+
}
|
|
5951
|
+
}
|
|
5952
|
+
}
|
|
5953
|
+
};
|
|
5954
|
+
var CHAR_AT_PATTERN = {
|
|
5955
|
+
type: TYPES.CALL_EXPRESSION,
|
|
5956
|
+
callee: {
|
|
5957
|
+
property: {
|
|
5958
|
+
name: ramda.includes(ramda.__, ["charAt", "charCodeAt"])
|
|
5959
|
+
}
|
|
5960
|
+
}
|
|
5961
|
+
};
|
|
5962
|
+
|
|
5936
5963
|
var noDumbComponentsWithUseTranslation = {
|
|
5937
5964
|
meta: {
|
|
5938
5965
|
type: "suggestion",
|
|
@@ -5950,12 +5977,13 @@
|
|
|
5950
5977
|
arrowFunctionExpression = _node$declarations[0].init;
|
|
5951
5978
|
var blockStatement = arrowFunctionExpression.body;
|
|
5952
5979
|
if (!blockStatement.body) return;
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5980
|
+
if (blockStatement.body.length !== 2) return;
|
|
5981
|
+
var _blockStatement$body = _slicedToArray(blockStatement.body, 2),
|
|
5982
|
+
firstStatement = _blockStatement$body[0],
|
|
5983
|
+
secondStatement = _blockStatement$body[1];
|
|
5984
|
+
if (!(pure.matches(USE_TRANSLATION_HOOK_PATTERN, firstStatement) && pure.matches(RETURN_STATEMENT_PATTERN, secondStatement))) {
|
|
5985
|
+
return;
|
|
5986
|
+
}
|
|
5959
5987
|
context.report({
|
|
5960
5988
|
node: node,
|
|
5961
5989
|
message: USE_WITH_T_HOC_IN_DUMB_COMPONENTS,
|
|
@@ -5979,7 +6007,7 @@
|
|
|
5979
6007
|
return "";
|
|
5980
6008
|
};
|
|
5981
6009
|
var blockStatementCode = getCode$1(context, blockStatement);
|
|
5982
|
-
var useTranslationHookCode = getCode$1(context,
|
|
6010
|
+
var useTranslationHookCode = getCode$1(context, firstStatement);
|
|
5983
6011
|
var body = blockStatementCode.replace(useTranslationHookCode, "");
|
|
5984
6012
|
var withTWrap = "withT((".concat(getPropsCode()).concat(pure.isNotEmpty(restParams) ? ", ".concat(restParams.map(function (param) {
|
|
5985
6013
|
return getCode$1(context, param);
|
|
@@ -7787,31 +7815,6 @@
|
|
|
7787
7815
|
}
|
|
7788
7816
|
};
|
|
7789
7817
|
|
|
7790
|
-
var BREAK_STATEMENT_PATTERN = {
|
|
7791
|
-
type: TYPES.BREAK_STATEMENT
|
|
7792
|
-
};
|
|
7793
|
-
var RETURN_STATEMENT_PATTERN = {
|
|
7794
|
-
type: TYPES.RETURN_STATEMENT
|
|
7795
|
-
};
|
|
7796
|
-
var ARRAY_LENGTH_TEST_PATTERN = {
|
|
7797
|
-
test: {
|
|
7798
|
-
right: {
|
|
7799
|
-
type: TYPES.MEMBER_EXPRESSION,
|
|
7800
|
-
property: {
|
|
7801
|
-
name: "length"
|
|
7802
|
-
}
|
|
7803
|
-
}
|
|
7804
|
-
}
|
|
7805
|
-
};
|
|
7806
|
-
var CHAR_AT_PATTERN = {
|
|
7807
|
-
type: TYPES.CALL_EXPRESSION,
|
|
7808
|
-
callee: {
|
|
7809
|
-
property: {
|
|
7810
|
-
name: ramda.includes(ramda.__, ["charAt", "charCodeAt"])
|
|
7811
|
-
}
|
|
7812
|
-
}
|
|
7813
|
-
};
|
|
7814
|
-
|
|
7815
7818
|
var isForLoopReplacable = function isForLoopReplacable(node) {
|
|
7816
7819
|
return ramda.not(patternExistsDeep(BREAK_STATEMENT_PATTERN, node.body) || patternExistsDeep(RETURN_STATEMENT_PATTERN, node.body) || patternExistsDeep(CHAR_AT_PATTERN, node.body));
|
|
7817
7820
|
};
|
|
@@ -25955,6 +25958,33 @@
|
|
|
25955
25958
|
}
|
|
25956
25959
|
};
|
|
25957
25960
|
|
|
25961
|
+
var useStandardDateTimeFormats = {
|
|
25962
|
+
meta: {
|
|
25963
|
+
type: "problem",
|
|
25964
|
+
docs: {
|
|
25965
|
+
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/use-standard-date-time-formats.md",
|
|
25966
|
+
description: "Enforces the usage of standard date and time formats instead of dayjs().format()"
|
|
25967
|
+
}
|
|
25968
|
+
},
|
|
25969
|
+
create: function create(context) {
|
|
25970
|
+
var sourceCode = context.getSourceCode();
|
|
25971
|
+
return {
|
|
25972
|
+
CallExpression: function CallExpression(node) {
|
|
25973
|
+
var callee = node.callee;
|
|
25974
|
+
if (callee.type !== TYPES.MEMBER_EXPRESSION) return;
|
|
25975
|
+
var expression = sourceCode.getText(callee);
|
|
25976
|
+
if (!(expression.includes("dayjs") && expression.includes(".format"))) {
|
|
25977
|
+
return;
|
|
25978
|
+
}
|
|
25979
|
+
context.report({
|
|
25980
|
+
node: node,
|
|
25981
|
+
message: USE_STANDARD_DATE_TIME_FORMATS
|
|
25982
|
+
});
|
|
25983
|
+
}
|
|
25984
|
+
};
|
|
25985
|
+
}
|
|
25986
|
+
};
|
|
25987
|
+
|
|
25958
25988
|
var useWebpackAlias = {
|
|
25959
25989
|
meta: {
|
|
25960
25990
|
type: "suggestion",
|
|
@@ -26538,6 +26568,7 @@
|
|
|
26538
26568
|
|
|
26539
26569
|
var index = {
|
|
26540
26570
|
rules: {
|
|
26571
|
+
"use-standard-date-time-formats": useStandardDateTimeFormats,
|
|
26541
26572
|
"no-dumb-components-with-use-translation": noDumbComponentsWithUseTranslation,
|
|
26542
26573
|
"api-connector-name-should-match-filename": apiConnectorNameShouldMatchFilename,
|
|
26543
26574
|
"api-connector-should-use-default-export": apiConnectorShouldUseDefaultExport,
|