Skip to content

Commit

Permalink
fix(eslint-plugin): [naming-convention] support unicode in regex (#2241)
Browse files Browse the repository at this point in the history
  • Loading branch information
octogonz committed Jun 24, 2020
1 parent a2202c7 commit 5fdd21a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/eslint-plugin/src/rules/naming-convention.ts
Expand Up @@ -1213,7 +1213,7 @@ function normalizeOption(option: Selector): NormalizedSelector {
format: option.format ? option.format.map(f => PredefinedFormats[f]) : null,
custom: option.custom
? {
regex: new RegExp(option.custom.regex),
regex: new RegExp(option.custom.regex, 'u'),
match: option.custom.match,
}
: null,
Expand All @@ -1236,9 +1236,9 @@ function normalizeOption(option: Selector): NormalizedSelector {
filter:
option.filter !== undefined
? typeof option.filter === 'string'
? { regex: new RegExp(option.filter), match: true }
? { regex: new RegExp(option.filter, 'u'), match: true }
: {
regex: new RegExp(option.filter.regex),
regex: new RegExp(option.filter.regex, 'u'),
match: option.filter.match,
}
: null,
Expand Down
10 changes: 5 additions & 5 deletions packages/eslint-plugin/tests/rules/naming-convention.test.ts
Expand Up @@ -963,7 +963,7 @@ ruleTester.run('naming-convention', rule, {
data: {
type: 'Variable',
name: 'unused_foo',
regex: '/^unused_\\w/',
regex: '/^unused_\\w/u',
regexMatch: 'not match',
},
},
Expand All @@ -973,7 +973,7 @@ ruleTester.run('naming-convention', rule, {
data: {
type: 'Variable',
name: '_unused_foo',
regex: '/^unused_\\w/',
regex: '/^unused_\\w/u',
regexMatch: 'not match',
},
},
Expand All @@ -983,7 +983,7 @@ ruleTester.run('naming-convention', rule, {
data: {
type: 'Interface',
name: 'IFoo',
regex: '/^I[A-Z]/',
regex: '/^I[A-Z]/u',
regexMatch: 'not match',
},
},
Expand All @@ -993,7 +993,7 @@ ruleTester.run('naming-convention', rule, {
data: {
type: 'Class',
name: 'IBar',
regex: '/^I[A-Z]/',
regex: '/^I[A-Z]/u',
regexMatch: 'not match',
},
},
Expand All @@ -1003,7 +1003,7 @@ ruleTester.run('naming-convention', rule, {
data: {
type: 'Function',
name: 'fooBar',
regex: '/function/',
regex: '/function/u',
regexMatch: 'match',
},
},
Expand Down

0 comments on commit 5fdd21a

Please sign in to comment.