Skip to content

Commit 6ed0dba

Browse files
committed
fix: fix validator string Regx (#3)
1 parent 4c90746 commit 6ed0dba

File tree

9 files changed

+17
-7
lines changed

9 files changed

+17
-7
lines changed

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "client",
33
"displayName": "React-Intl-Linter - Client",
4-
"version": "0.0.2",
4+
"version": "0.0.3",
55
"description": "vscode linter extension for react-intl",
66
"repository": "git@github.com:Styx11/react-intl-linter.git",
77
"author": "styx11 <1654630248@qq.com>",

client/src/lib/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const getIntlIdCount = (number: number): string =>
3737
*/
3838
export const getCleanIntlId = (translationResult: string): string =>
3939
{
40-
return translationResult.replace(INVALID_INTL_ID_CHARACTER, '')
40+
return translationResult.replace(INVALID_INTL_ID_CHARACTER, '').trim()
4141
}
4242

4343
/**

client/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"src"
1515
],
1616
"exclude": [
17-
"node_modules"
17+
"node_modules",
18+
"package-lock.json",
19+
"package.json"
1820
]
1921
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-intl-linter",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"publisher": "styx11",
55
"description": "vscode linter extension for react-intl",
66
"repository": "git@github.com:Styx11/react-intl-linter.git",

react-intl-linter-0.0.2.vsix

-1.02 MB
Binary file not shown.

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "server",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "vscode linter extension for react-intl",
55
"repository": "git@github.com:Styx11/react-intl-linter.git",
66
"author": "styx11 <1654630248@qq.com>",

server/src/lib/util.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
// 匹配单引号/双引号内的字符串文本
3-
export const StringReg = /'(.+)'|"(.+)"/gu
3+
// 单个字符 . 的匹配默认是贪婪的,所以当有多个带引号的句子在一行时,匹配结果就会是从第一个引号开始到最后一个引号结束,所以要用 [^'\n]+ 和 [^"\n]+ 去匹配
4+
// 例如 const message = `${'添加'}hellllllo${'添加'}` 会匹配为 添加'}hellllllo${'添加
5+
export const StringReg = /'([^'\n]+)'|"([^"\n]+)"/gu
46

57
// 错误信息
68
export const DiagnosticMessage = ' is a Chinese sentence'

test_files/TypescriptReact.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@
88

99
'添加'
1010

11+
const message = `${"添加"}hellllllo${"添加"}`
12+
13+
const testMsg = `${'添加'}hellllllo${'一个文本'}hellllllo{"这是另一个文本"}`
14+
1115
"English!!!"

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"src"
1414
],
1515
"exclude": [
16-
"node_modules"
16+
"node_modules",
17+
"package-lock.json",
18+
"package.json"
1719
],
1820
"references": [
1921
{ "path": "./client" },

0 commit comments

Comments
 (0)