Skip to content

Commit f7032d9

Browse files
committed
two more tests
1 parent c52d0a2 commit f7032d9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-unused-props.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,40 @@ ruleTesterWithTypes.run(RULE_NAME, rule, {
333333
endLine: 1,
334334
line: 1,
335335
}],
336+
}, {
337+
// correct error span on complex prop type
338+
code: tsx`
339+
function Component({ abc }: { abc: string; hello: { abc: string; subHello: number | null }; }) {
340+
return null;
341+
}
342+
`,
343+
errors: [{
344+
messageId: "noUnusedProps",
345+
column: 44,
346+
data: {
347+
name: "hello",
348+
},
349+
endColumn: 49,
350+
endLine: 1,
351+
line: 1,
352+
}],
353+
}, {
354+
// access of sub property should mark property as used
355+
code: tsx`
356+
function Component({ hello: { subHello } }: { abc: string; hello: { abc: string; subHello: number | null }; }) {
357+
return null;
358+
}
359+
`,
360+
errors: [{
361+
messageId: "noUnusedProps",
362+
column: 47,
363+
data: {
364+
name: "abc",
365+
},
366+
endColumn: 50,
367+
endLine: 1,
368+
line: 1,
369+
}],
336370
}],
337371
valid: [
338372
{

0 commit comments

Comments
 (0)