@bigbinary/eslint-plugin-neeto 1.1.41 → 1.2.0
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 +59 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ module.exports = {
|
|
|
46
46
|
|
|
47
47
|
## Exported rules
|
|
48
48
|
|
|
49
|
+
- [no-unnecessary-classnames](./docs/src/rules/no-unnecessary-classnames.md)
|
|
49
50
|
- [no-snake-case-destructuring-for-use-query-params-and-get-query-params](./docs/src/rules/no-snake-case-destructuring-for-use-query-params-and-get-query-params.md)
|
|
50
51
|
- [no-local-storage](./docs/src/rules/no-local-storage.md)
|
|
51
52
|
- [no-lowercase-on-translation](./docs/src/rules/no-lowercase-on-translation.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/no-unnecessary-classnames": "error",
|
|
45
46
|
"@bigbinary/neeto/no-snake-case-destructuring-for-use-query-params-and-get-query-params": "warn",
|
|
46
47
|
"@bigbinary/neeto/no-local-storage": "error",
|
|
47
48
|
"@bigbinary/neeto/no-lowercase-on-translation": "warn",
|
|
@@ -453,10 +454,10 @@
|
|
|
453
454
|
return "Do not use the package ".concat(packageName);
|
|
454
455
|
};
|
|
455
456
|
var exportedObjectShouldBe = function exportedObjectShouldBe(caseStyle) {
|
|
456
|
-
return "Exported object should be in ".concat(caseStyle, ". Refer https://
|
|
457
|
+
return "Exported object should be in ".concat(caseStyle, ". Refer https://youtu.be/uZtRIvo8-ww");
|
|
457
458
|
};
|
|
458
459
|
var filenameShouldBe = function filenameShouldBe(caseStyle) {
|
|
459
|
-
return "Filename should be in ".concat(caseStyle, ". Refer https://
|
|
460
|
+
return "Filename should be in ".concat(caseStyle, ". Refer https://youtu.be/uZtRIvo8-ww");
|
|
460
461
|
};
|
|
461
462
|
var moveToConstantsJs = function moveToConstantsJs(constantName) {
|
|
462
463
|
return "Move the constant ".concat(constantName, " to a constants.js file.");
|
|
@@ -570,6 +571,7 @@
|
|
|
570
571
|
var AVOID_SNAKE_CASE_DESTRUCTURING_USEQUERYPARAMS_OR_GETQUERYPARAMS = "Avoid destructuring snake-cased values from getQueryParams or useQueryParams";
|
|
571
572
|
var PREFER_FUNCTION_REFERENCE = "Prefer passing function reference instead of creating a new function as the parameters and arguments are the same.";
|
|
572
573
|
var JSX_PREFER_GUARD_CLAUSE = "Prefer adding a guard clause for conditional statements left of JSX statments in the last return statement of the function.";
|
|
574
|
+
var NO_UNNECESSARY_CLASSNAMES = "classnames usage is unnecessary";
|
|
573
575
|
|
|
574
576
|
var PACKAGES_TO_CHECK = ["@bigbinary/neeto-molecules", "@bigbinary/neetoui", "@bigbinary/neeto-commons-frontend"];
|
|
575
577
|
|
|
@@ -4350,7 +4352,7 @@
|
|
|
4350
4352
|
}, {}) : {};
|
|
4351
4353
|
var translationsFilePath = path$2.join(context.options[0].translationsDir, "".concat(lng, ".json"));
|
|
4352
4354
|
var translationsContent = parseJsonData(translationsFilePath);
|
|
4353
|
-
var combinedContent =
|
|
4355
|
+
var combinedContent = ramda.mergeDeepLeft(translationsContent, nanosContent[lng]);
|
|
4354
4356
|
return {
|
|
4355
4357
|
lng: lng,
|
|
4356
4358
|
content: combinedContent
|
|
@@ -6607,7 +6609,7 @@
|
|
|
6607
6609
|
};
|
|
6608
6610
|
|
|
6609
6611
|
var SNAKE_CASE_WITHOUT_SINGLE_WORDS = /^[a-z]+_[a-z0-9_]+$/;
|
|
6610
|
-
var PATTERN = {
|
|
6612
|
+
var PATTERN$1 = {
|
|
6611
6613
|
id: {
|
|
6612
6614
|
type: "ObjectPattern",
|
|
6613
6615
|
properties: ramda.any(neetoCist.matches({
|
|
@@ -6647,7 +6649,7 @@
|
|
|
6647
6649
|
create: function create(context) {
|
|
6648
6650
|
return {
|
|
6649
6651
|
VariableDeclarator: function VariableDeclarator(node) {
|
|
6650
|
-
if (neetoCist.matches(PATTERN, node)) {
|
|
6652
|
+
if (neetoCist.matches(PATTERN$1, node)) {
|
|
6651
6653
|
context.report({
|
|
6652
6654
|
node: node,
|
|
6653
6655
|
message: AVOID_SNAKE_CASE_DESTRUCTURING_USEQUERYPARAMS_OR_GETQUERYPARAMS
|
|
@@ -6658,6 +6660,57 @@
|
|
|
6658
6660
|
}
|
|
6659
6661
|
};
|
|
6660
6662
|
|
|
6663
|
+
var CLASS_NAME = "className";
|
|
6664
|
+
var CLASS_NAMES = ["classnames", "classNames"];
|
|
6665
|
+
var PATTERN = neetoCist.matches({
|
|
6666
|
+
name: {
|
|
6667
|
+
name: CLASS_NAME
|
|
6668
|
+
},
|
|
6669
|
+
value: {
|
|
6670
|
+
expression: {
|
|
6671
|
+
type: TYPES.CALL_EXPRESSION,
|
|
6672
|
+
callee: {
|
|
6673
|
+
name: matchesAny(CLASS_NAMES)
|
|
6674
|
+
},
|
|
6675
|
+
arguments: _defineProperty({
|
|
6676
|
+
length: 1
|
|
6677
|
+
}, 0, {
|
|
6678
|
+
type: matchesAny([TYPES.LITERAL, TYPES.TEMPLATE_LITERAL])
|
|
6679
|
+
})
|
|
6680
|
+
}
|
|
6681
|
+
}
|
|
6682
|
+
});
|
|
6683
|
+
|
|
6684
|
+
var noUnnecessaryClassnames = {
|
|
6685
|
+
meta: {
|
|
6686
|
+
type: "suggestion",
|
|
6687
|
+
docs: {
|
|
6688
|
+
url: "https://github.com/bigbinary/eslint-plugin-neeto/blob/main/docs/src/rules/no-unnecessary-classnames.md",
|
|
6689
|
+
description: "classnames usage is unnecessary"
|
|
6690
|
+
},
|
|
6691
|
+
fixable: "code"
|
|
6692
|
+
},
|
|
6693
|
+
create: function create(context) {
|
|
6694
|
+
return {
|
|
6695
|
+
JSXAttribute: function JSXAttribute(node) {
|
|
6696
|
+
if (!neetoCist.matches(PATTERN, node)) return;
|
|
6697
|
+
context.report({
|
|
6698
|
+
node: node,
|
|
6699
|
+
message: NO_UNNECESSARY_CLASSNAMES,
|
|
6700
|
+
fix: function fix(fixer) {
|
|
6701
|
+
var singleClass = node.value.expression.arguments[0];
|
|
6702
|
+
var classText = context.getSourceCode().getText(singleClass);
|
|
6703
|
+
if (singleClass.type === TYPES.TEMPLATE_LITERAL) {
|
|
6704
|
+
classText = "{".concat(classText, "}");
|
|
6705
|
+
}
|
|
6706
|
+
return fixer.replaceTextRange([node.range[0], node.range[1]], "className=".concat(classText));
|
|
6707
|
+
}
|
|
6708
|
+
});
|
|
6709
|
+
}
|
|
6710
|
+
};
|
|
6711
|
+
}
|
|
6712
|
+
};
|
|
6713
|
+
|
|
6661
6714
|
// if (condition) statement;
|
|
6662
6715
|
var SINGLE_LINE_IF_CONDITION_PATTERN = {
|
|
6663
6716
|
parent: {
|
|
@@ -10456,6 +10509,7 @@
|
|
|
10456
10509
|
|
|
10457
10510
|
var index = {
|
|
10458
10511
|
rules: {
|
|
10512
|
+
"no-unnecessary-classnames": noUnnecessaryClassnames,
|
|
10459
10513
|
"no-snake-case-destructuring-for-use-query-params-and-get-query-params": noSnakeCaseDestructuringForUseQueryParamsAndGetQueryParams,
|
|
10460
10514
|
"no-local-storage": noLocalStorage,
|
|
10461
10515
|
"no-lowercase-on-translation": noLowercaseOnTranslation,
|