Skip to content

Commit ab7833e

Browse files
authored
Merge pull request #138 from microsoft/users/aubreyquinn/reactStrictModeBug
Fixes #136
2 parents 5fb9d2b + a52242f commit ab7833e

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

lib/rules/accordion-item-needs-header-and-panel.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ const rule = ESLintUtils.RuleCreator.withoutDocs({
2525
create(context) {
2626
return {
2727
JSXOpeningElement(node: TSESTree.JSXOpeningElement) {
28-
if (node.name.type === AST_NODE_TYPES.JSXIdentifier && node.name.name !== "AccordionItem") {
29-
return;
30-
}
28+
const isAccordionItem =
29+
node.name.type === AST_NODE_TYPES.JSXIdentifier &&
30+
node.name.name === "AccordionItem";
31+
32+
if (!isAccordionItem) return;
3133

3234
if (!(node.parent && node.parent.type === AST_NODE_TYPES.JSXElement)) {
3335
return;

lib/rules/dialogbody-needs-title-content-and-actions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ const rule = ESLintUtils.RuleCreator.withoutDocs({
2525
create(context) {
2626
return {
2727
JSXOpeningElement(node: TSESTree.JSXOpeningElement) {
28-
if (node.name.type === AST_NODE_TYPES.JSXIdentifier && node.name.name !== "DialogBody") {
28+
const isDialogBody =
29+
node.name.type === AST_NODE_TYPES.JSXIdentifier &&
30+
node.name.name === "DialogBody";
31+
32+
if (!isDialogBody) {
2933
return;
3034
}
3135

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/lib/rules/accordion-item-needs-header-and-panel.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import rule from "../../../lib/rules/accordion-item-needs-header-and-panel";
1515

1616
ruleTester.run("accordion-item-needs-header-and-panel", rule as unknown as Rule.RuleModule, {
1717
valid: [
18-
`<AccordionItem><AccordionHeader>Accordion Header 1</AccordionHeader><AccordionPanel><div>Accordion Panel 1</div></AccordionPanel></AccordionItem>`
18+
`<AccordionItem><AccordionHeader>Accordion Header 1</AccordionHeader><AccordionPanel><div>Accordion Panel 1</div></AccordionPanel></AccordionItem>`,
19+
`<React.StrictMode><Component /></React.StrictMode>`
1920
],
2021

2122
invalid: [

tests/lib/rules/dialogbody-needs-title-content-and-actions.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ ruleTester.run("dialogbody-needs-title-content-and-actions", rule as any as Rule
2222
<Button>Close</Button>
2323
<Button>Do Something</Button>
2424
</DialogActions>
25-
</DialogBody>`
25+
</DialogBody>`,
26+
`<React.StrictMode><Component /></React.StrictMode>`
2627
],
2728

2829
invalid: [

0 commit comments

Comments
 (0)