@bigbinary/eslint-plugin-neeto 1.1.14 → 1.1.16
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 +2 -0
- package/dist/index.js +77 -0
- 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-large-functions-inside-jsx](./docs/src/rules/no-large-functions-inside-jsx.md)
|
|
50
|
+
- [use-standard-date-time-formats](./docs/src/rules/use-standard-date-time-formats.md)
|
|
49
51
|
- [no-dumb-components-with-use-translation](./docs/src/rules/no-dumb-components-with-use-translation.md)
|
|
50
52
|
- [no-unnecessary-if-condition](./docs/src/rules/no-unnecessary-if-condition.md)
|
|
51
53
|
- [api-connector-name-should-match-filename](./docs/src/rules/api-connector-name-should-match-filename.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-large-functions-inside-jsx": "error",
|
|
46
|
+
"@bigbinary/neeto/use-standard-date-time-formats": "error",
|
|
45
47
|
"@bigbinary/neeto/no-dumb-components-with-use-translation": "error",
|
|
46
48
|
"@bigbinary/neeto/api-connector-name-should-match-filename": "error",
|
|
47
49
|
"@bigbinary/neeto/api-connector-should-use-default-export": "error",
|
|
@@ -405,7 +407,19 @@
|
|
|
405
407
|
}
|
|
406
408
|
}]
|
|
407
409
|
};
|
|
410
|
+
var PROP_FUNCTION_PATTERN = {
|
|
411
|
+
value: {
|
|
412
|
+
type: TYPES.JSX_EXPRESSION_CONTAINER,
|
|
413
|
+
expression: {
|
|
414
|
+
type: TYPES.ARROW_FUNCTION_EXPRESSION,
|
|
415
|
+
body: {
|
|
416
|
+
type: TYPES.BLOCK_STATEMENT
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
};
|
|
408
421
|
var NO_OF_LINES_ALLOWED_FOR_MULTIPLE_COMPONENTS_IN_A_FILE = 20;
|
|
422
|
+
var MAX_LINES_FOR_FUNCTIONS_INSIDE_JSX = 4;
|
|
409
423
|
|
|
410
424
|
var ARGUMENT_LIMIT = 3;
|
|
411
425
|
var API_ACTIONS_ARGUMENT_LIMIT = 2;
|
|
@@ -457,6 +471,10 @@
|
|
|
457
471
|
var maxAllowedNoOfLines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 20;
|
|
458
472
|
return "Do not have multiple component definitions that exceed ".concat(maxAllowedNoOfLines, " lines in a single file.");
|
|
459
473
|
};
|
|
474
|
+
var avoidLargeFunctionsInsideJsx = function avoidLargeFunctionsInsideJsx() {
|
|
475
|
+
var maxAllowedNoOfLines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;
|
|
476
|
+
return "Avoid inline functions that exceed ".concat(maxAllowedNoOfLines, " lines directly inside JSX. Extract the function outside of JSX.");
|
|
477
|
+
};
|
|
460
478
|
var suggestNeetoCommonsFunctionsAndHooks = function suggestNeetoCommonsFunctionsAndHooks(functionName, utilType, url) {
|
|
461
479
|
return "Use \"".concat(functionName, "\" from \"@bigbinary/neeto-commons-frontend/").concat(utilType, "\" instead. Refer: ").concat(url);
|
|
462
480
|
};
|
|
@@ -526,6 +544,7 @@
|
|
|
526
544
|
var PROP_KEY_VALUE_DUPLICATE = "Prop key and value names should not be repeated";
|
|
527
545
|
var USE_WITH_IMMUTABLE_ACTIONS_WRAPPER = 'Use "withImmutableActions" wrapper from "neeto-commons-frontend" inside zustand create. Refer: https://bit.ly/withimmutableactions';
|
|
528
546
|
var USE_WITH_T_HOC_IN_DUMB_COMPONENTS = 'Use "withT" HOC from "neeto-commons-frontend" instead of useTranslation hook in Dumb components';
|
|
547
|
+
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
548
|
|
|
530
549
|
var PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
|
|
531
550
|
|
|
@@ -6086,6 +6105,35 @@
|
|
|
6086
6105
|
}
|
|
6087
6106
|
};
|
|
6088
6107
|
|
|
6108
|
+
var noLargeFunctionsInsideJsx = {
|
|
6109
|
+
meta: {
|
|
6110
|
+
type: "problem",
|
|
6111
|
+
docs: {
|
|
6112
|
+
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/no-large-functions-inside-jsx.md",
|
|
6113
|
+
description: "Disallows the use of functions with large bodies, that exceed maxAllowedNoOfLines, directly inside JSX elements." + "The default value for maxAllowedNoOfLines is 4."
|
|
6114
|
+
}
|
|
6115
|
+
},
|
|
6116
|
+
create: function create(context) {
|
|
6117
|
+
return {
|
|
6118
|
+
JSXAttribute: function JSXAttribute(node) {
|
|
6119
|
+
var _context$options$;
|
|
6120
|
+
if (!pure.matches(PROP_FUNCTION_PATTERN, node)) return;
|
|
6121
|
+
var functionBody = node.value.expression.body;
|
|
6122
|
+
var _functionBody$loc = functionBody.loc,
|
|
6123
|
+
start = _functionBody$loc.start,
|
|
6124
|
+
end = _functionBody$loc.end;
|
|
6125
|
+
var linesInsideBlock = end.line - (start.line + 1);
|
|
6126
|
+
var maxAllowedNoOfLines = ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.maxAllowedNoOfLines) || MAX_LINES_FOR_FUNCTIONS_INSIDE_JSX;
|
|
6127
|
+
if (linesInsideBlock <= maxAllowedNoOfLines) return;
|
|
6128
|
+
context.report({
|
|
6129
|
+
node: node,
|
|
6130
|
+
message: avoidLargeFunctionsInsideJsx(maxAllowedNoOfLines)
|
|
6131
|
+
});
|
|
6132
|
+
}
|
|
6133
|
+
};
|
|
6134
|
+
}
|
|
6135
|
+
};
|
|
6136
|
+
|
|
6089
6137
|
var noMultipleComponentsInAFile = {
|
|
6090
6138
|
meta: {
|
|
6091
6139
|
type: "problem",
|
|
@@ -25956,6 +26004,33 @@
|
|
|
25956
26004
|
}
|
|
25957
26005
|
};
|
|
25958
26006
|
|
|
26007
|
+
var useStandardDateTimeFormats = {
|
|
26008
|
+
meta: {
|
|
26009
|
+
type: "problem",
|
|
26010
|
+
docs: {
|
|
26011
|
+
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/use-standard-date-time-formats.md",
|
|
26012
|
+
description: "Enforces the usage of standard date and time formats instead of dayjs().format()"
|
|
26013
|
+
}
|
|
26014
|
+
},
|
|
26015
|
+
create: function create(context) {
|
|
26016
|
+
var sourceCode = context.getSourceCode();
|
|
26017
|
+
return {
|
|
26018
|
+
CallExpression: function CallExpression(node) {
|
|
26019
|
+
var callee = node.callee;
|
|
26020
|
+
if (callee.type !== TYPES.MEMBER_EXPRESSION) return;
|
|
26021
|
+
var expression = sourceCode.getText(callee);
|
|
26022
|
+
if (!(expression.includes("dayjs") && expression.includes(".format"))) {
|
|
26023
|
+
return;
|
|
26024
|
+
}
|
|
26025
|
+
context.report({
|
|
26026
|
+
node: node,
|
|
26027
|
+
message: USE_STANDARD_DATE_TIME_FORMATS
|
|
26028
|
+
});
|
|
26029
|
+
}
|
|
26030
|
+
};
|
|
26031
|
+
}
|
|
26032
|
+
};
|
|
26033
|
+
|
|
25959
26034
|
var useWebpackAlias = {
|
|
25960
26035
|
meta: {
|
|
25961
26036
|
type: "suggestion",
|
|
@@ -26539,6 +26614,8 @@
|
|
|
26539
26614
|
|
|
26540
26615
|
var index = {
|
|
26541
26616
|
rules: {
|
|
26617
|
+
"no-large-functions-inside-jsx": noLargeFunctionsInsideJsx,
|
|
26618
|
+
"use-standard-date-time-formats": useStandardDateTimeFormats,
|
|
26542
26619
|
"no-dumb-components-with-use-translation": noDumbComponentsWithUseTranslation,
|
|
26543
26620
|
"api-connector-name-should-match-filename": apiConnectorNameShouldMatchFilename,
|
|
26544
26621
|
"api-connector-should-use-default-export": apiConnectorShouldUseDefaultExport,
|