Skip to content

Commit d973a65

Browse files
committed
Merge remote-tracking branch '311/feat-allow-regexp-in-skip'
2 parents 50c94b8 + 5c9f92c commit d973a65

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/rules/no-raw-text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function create(context) {
5050
const hasOnlyLineBreak = (value) => /^[\r\n\t\f\v]+$/.test(value.replace(/ /g, ''));
5151

5252
const scope = context.getScope();
53-
const getValidation = (node) => !allowedElements.includes(elementName(node.parent, scope));
53+
const getValidation = (node) => !allowedElements.some((el) => new RegExp(`^${el}$`).test(elementName(node.parent, scope)));
5454

5555
return {
5656
Literal(node) {

tests/lib/rules/no-raw-text.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ const tests = {
105105
`,
106106
options: [{ skip: ['Title.Text'] }],
107107
},
108+
{
109+
code: `
110+
const Title = ({ children }) => (<Title.Text>{children}</Title.Text>);
111+
Title.Text = ({ children }) => (<Text>{children}</Text>);
112+
<Title.Text>This is the title</Title.Text>
113+
`,
114+
options: [{ skip: ['Title.*'] }],
115+
},
108116
{
109117
code: `
110118
export default class MyComponent extends Component {

0 commit comments

Comments
 (0)