eslint-plugin-formatjs 5.3.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib_esnext/package.json +1 -1
- package/lib_esnext/util.js +19 -0
- package/package.json +3 -3
- package/util.js +19 -0
package/lib_esnext/package.json
CHANGED
package/lib_esnext/util.js
CHANGED
|
@@ -67,9 +67,19 @@ export function extractMessageDescriptor(node) {
|
|
|
67
67
|
if (isStringLiteral(valueNode)) {
|
|
68
68
|
value = valueNode.value;
|
|
69
69
|
}
|
|
70
|
+
// like "`asd`"
|
|
70
71
|
else if (isTemplateLiteralWithoutVar(valueNode)) {
|
|
71
72
|
value = valueNode.quasis[0].value.cooked;
|
|
72
73
|
}
|
|
74
|
+
// like "dedent`asd`"
|
|
75
|
+
else if (valueNode.type === 'TaggedTemplateExpression') {
|
|
76
|
+
const { quasi } = valueNode;
|
|
77
|
+
if (!isTemplateLiteralWithoutVar(quasi)) {
|
|
78
|
+
throw new Error('Tagged template expression must be no substitution');
|
|
79
|
+
}
|
|
80
|
+
value = quasi.quasis[0].value.cooked;
|
|
81
|
+
}
|
|
82
|
+
// like "`asd` + `asd`"
|
|
73
83
|
else if (valueNode.type === 'BinaryExpression') {
|
|
74
84
|
const [result, isStatic] = staticallyEvaluateStringConcat(valueNode);
|
|
75
85
|
if (isStatic) {
|
|
@@ -132,9 +142,18 @@ function extractMessageDescriptorFromJSXElement(node) {
|
|
|
132
142
|
value = result;
|
|
133
143
|
}
|
|
134
144
|
}
|
|
145
|
+
// like "`asd`"
|
|
135
146
|
else if (isTemplateLiteralWithoutVar(expression)) {
|
|
136
147
|
value = expression.quasis[0].value.cooked;
|
|
137
148
|
}
|
|
149
|
+
// like "dedent`asd`"
|
|
150
|
+
else if (expression.type === 'TaggedTemplateExpression') {
|
|
151
|
+
const { quasi } = expression;
|
|
152
|
+
if (!isTemplateLiteralWithoutVar(quasi)) {
|
|
153
|
+
throw new Error('Tagged template expression must be no substitution');
|
|
154
|
+
}
|
|
155
|
+
value = quasi.quasis[0].value.cooked;
|
|
156
|
+
}
|
|
138
157
|
}
|
|
139
158
|
}
|
|
140
159
|
switch (key.name) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-formatjs",
|
|
3
3
|
"description": "ESLint plugin for formatjs",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.4.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Long Ho <holevietlong@gmail.com>",
|
|
7
7
|
"dependencies": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"picomatch": "2 || 3 || 4",
|
|
13
13
|
"tslib": "^2.8.0",
|
|
14
14
|
"unicode-emoji-utils": "^1.2.0",
|
|
15
|
-
"@formatjs/
|
|
16
|
-
"@formatjs/
|
|
15
|
+
"@formatjs/ts-transformer": "3.14.0",
|
|
16
|
+
"@formatjs/icu-messageformat-parser": "2.11.2"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"eslint": "^9.23.0"
|
package/util.js
CHANGED
|
@@ -74,9 +74,19 @@ function extractMessageDescriptor(node) {
|
|
|
74
74
|
if (isStringLiteral(valueNode)) {
|
|
75
75
|
value = valueNode.value;
|
|
76
76
|
}
|
|
77
|
+
// like "`asd`"
|
|
77
78
|
else if (isTemplateLiteralWithoutVar(valueNode)) {
|
|
78
79
|
value = valueNode.quasis[0].value.cooked;
|
|
79
80
|
}
|
|
81
|
+
// like "dedent`asd`"
|
|
82
|
+
else if (valueNode.type === 'TaggedTemplateExpression') {
|
|
83
|
+
const { quasi } = valueNode;
|
|
84
|
+
if (!isTemplateLiteralWithoutVar(quasi)) {
|
|
85
|
+
throw new Error('Tagged template expression must be no substitution');
|
|
86
|
+
}
|
|
87
|
+
value = quasi.quasis[0].value.cooked;
|
|
88
|
+
}
|
|
89
|
+
// like "`asd` + `asd`"
|
|
80
90
|
else if (valueNode.type === 'BinaryExpression') {
|
|
81
91
|
const [result, isStatic] = staticallyEvaluateStringConcat(valueNode);
|
|
82
92
|
if (isStatic) {
|
|
@@ -139,9 +149,18 @@ function extractMessageDescriptorFromJSXElement(node) {
|
|
|
139
149
|
value = result;
|
|
140
150
|
}
|
|
141
151
|
}
|
|
152
|
+
// like "`asd`"
|
|
142
153
|
else if (isTemplateLiteralWithoutVar(expression)) {
|
|
143
154
|
value = expression.quasis[0].value.cooked;
|
|
144
155
|
}
|
|
156
|
+
// like "dedent`asd`"
|
|
157
|
+
else if (expression.type === 'TaggedTemplateExpression') {
|
|
158
|
+
const { quasi } = expression;
|
|
159
|
+
if (!isTemplateLiteralWithoutVar(quasi)) {
|
|
160
|
+
throw new Error('Tagged template expression must be no substitution');
|
|
161
|
+
}
|
|
162
|
+
value = quasi.quasis[0].value.cooked;
|
|
163
|
+
}
|
|
145
164
|
}
|
|
146
165
|
}
|
|
147
166
|
switch (key.name) {
|