8000 fix(eslint-plugin): [naming-convention] support unicode in regex (#2241) · jasnross/typescript-eslint@5fdd21a · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fdd21a

Browse files
authored
fix(eslint-plugin): [naming-convention] support unicode in regex (typescript-eslint#2241)
1 parent a2202c7 commit 5fdd21a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

packages/eslint-plugin/src/rules/naming-convention.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ function normalizeOption(option: Selector): NormalizedSelector {
12131213
format: option.format ? option.format.map(f => PredefinedFormats[f]) : null,
12141214
custom: option.custom
12151215
? {
1216-
regex: new RegExp(option.custom.regex),
1216+
regex: new RegExp(option.custom.regex, 'u'),
12171217
match: option.custom.match,
12181218
}
12191219
: null,
@@ -1236,9 +1236,9 @@ function normalizeOption(option: Selector): NormalizedSelector {
12361236
filter:
12371237
option.filter !== undefined
12381238
? typeof option.filter === 'string'
1239-
? { regex: new RegExp(option.filter), match: true }
1239+
? { regex: new RegExp(option.filter, 'u'), match: true }
12401240
: {
1241-
regex: new RegExp(option.filter.regex),
1241+
regex: new RegExp(option.filter.regex, 'u'),
12421242
match: option.filter.match,
12431243
}
12441244
: null,

packages/eslint-plugin/tests/rules/naming-convention.test.ts

Lines changed: 5 additions & 5 deletions
< 8000 /tr>
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ ruleTester.run('naming-convention', rule, {
963963
data: {
964964
type: 'Variable',
965965
name: 'unused_foo',
966-
regex: '/^unused_\\w/',
966+
regex: '/^unused_\\w/u',
967967
regexMatch: 'not match',
968968
},
969969
},
@@ -973,7 +973,7 @@ ruleTester.run('naming-convention', rule, {
973973
data: {
974974
type: 'Variable',
975975
name: '_unused_foo',
976-
regex: '/^unused_\\w/',
976+
regex: '/^unused_\\w/u',
977977
regexMatch: 'not match',
978978
},
979979
},
@@ -983,7 +983,7 @@ ruleTester.run('naming-convention', rule, {
983983
data: {
984984
type: 'Interface',
985985
name: 'IFoo',
986-
regex: '/^I[A-Z]/',
986+
regex: '/^I[A-Z]/u',
987987
regexMatch: 'not match',
988988
},
989989
},
@@ -993,7 +993,7 @@ ruleTester.run('naming-convention', rule, {
993993
data: {
994994
type: 'Class',
995995
name: 'IBar',
996-
regex: '/^I[A-Z]/',
996+
regex: '/^I[A-Z]/u',
997997
regexMatch: 'not match',
998998
},
999999
},
@@ -1003,7 +1003,7 @@ ruleTester.run('naming-convention', rule, {
10031003
data: {
10041004
type: 'Function',
10051005
name: 'fooBar',
1006-
regex: '/function/',
1006+
regex: '/function/u',
10071007
regexMatch: 'match',
10081008
},
10091009
},

0 commit comments

Comments
 (0)
0