Skip to content

Commit

Permalink
fix(no-global-regexp-flag-in-query): check if empty name property node (
Browse files Browse the repository at this point in the history
#566)

* fix(no-global-regexp-flag-in-query): check if empty name property node

* style: write the valid snippet without an object

Closes #565
  • Loading branch information
Belco90 committed Apr 4, 2022
1 parent b62ba43 commit 7f751e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/rules/no-global-regexp-flag-in-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ export default createTestingLibraryRule<Options, MessageIds>({
ASTUtils.isIdentifier(p.key) &&
p.key.name === 'name' &&
isLiteral(p.value)
) as TSESTree.ObjectLiteralElement & { value: TSESTree.Literal };
report(namePropertyNode.value);
) as TSESTree.Property | undefined;

if (namePropertyNode) {
report(namePropertyNode.value);
}
}
},
};
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/rules/no-global-regexp-flag-in-query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ ruleTester.run(RULE_NAME, rule, {
const utils = render(<Component/>)
utils.notAQuery(/hello/i)
`,

// issue #565
`
import { screen } from "@testing-library/react"
describe("App", () => {
test("is rendered", async () => {
await screen.findByText("Hello World", { exact: false });
})
})
`,
],
invalid: [
{
Expand Down

0 comments on commit 7f751e1

Please sign in to comment.