Skip to content

Commit 9040254

Browse files
authored
Merge pull request #10 from eduzz/hotfix-object-ids
fix(id-rule): remove id with object as value from validation
2 parents 944d236 + a8c4030 commit 9040254

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@eduzz/eslint-config",
33
"private": false,
4-
"version": "2.5.3",
4+
"version": "2.5.4",
55
"keywords": [
66
"eduzz",
77
"eslint"

rules/requiredId.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const isDefaultImportSourceSupported = source =>
2121
'antd/lib/checkbox/Checkbox'
2222
].includes(source);
2323

24+
const excludeNestedComponentsNameList = [['Checkbox', 'Group']];
25+
2426
module.exports = {
2527
meta: {
2628
type: 'suggestion',
@@ -85,6 +87,13 @@ module.exports = {
8587
return;
8688
}
8789

90+
if (
91+
node.name.type === 'JSXMemberExpression' &&
92+
excludeNestedComponentsNameList.includes([node.name.object.name, node.name.property.name])
93+
) {
94+
return;
95+
}
96+
8897
const [id] = node.attributes.filter(({ name }) => {
8998
if (!name) {
9099
return false;

rules/validId.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ module.exports = {
4646

4747
const isJsxExpressionValueVariable =
4848
node.value.type === 'JSXExpressionContainer' &&
49-
(node.value.expression.type === 'Identifier' || node.value.expression.type === 'MemberExpression');
49+
(node.value.expression.type === 'Identifier' ||
50+
node.value.expression.type === 'MemberExpression' ||
51+
node.value.expression.type === 'ObjectExpression' ||
52+
node.value.expression.type === 'ArrayExpression');
5053

5154
if (isJsxExpressionValueVariable) {
5255
return;

0 commit comments

Comments
 (0)