Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eslint-plugin): [naming-convention] support unicode in regex #2241

Merged
merged 1 commit into from Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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