@astroscope/eslint-plugin-i18n 0.1.2 → 0.1.3
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/dist/index.js +42 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -75,9 +75,14 @@ var DEFAULT_IGNORE_ATTRIBUTES = [
|
|
|
75
75
|
"sizes",
|
|
76
76
|
"color",
|
|
77
77
|
"crossorigin",
|
|
78
|
+
"fetchPriority",
|
|
79
|
+
"fetchpriority",
|
|
78
80
|
"referrerpolicy",
|
|
79
81
|
"charset",
|
|
80
82
|
"lang",
|
|
83
|
+
"property",
|
|
84
|
+
"itemprop",
|
|
85
|
+
"itemtype",
|
|
81
86
|
"form",
|
|
82
87
|
"key",
|
|
83
88
|
"slot",
|
|
@@ -124,11 +129,29 @@ var DEFAULT_IGNORE_ATTRIBUTES = [
|
|
|
124
129
|
"clip-rule",
|
|
125
130
|
"fill-rule",
|
|
126
131
|
"path",
|
|
127
|
-
"values"
|
|
132
|
+
"values",
|
|
133
|
+
"operator",
|
|
134
|
+
"mode",
|
|
135
|
+
"stdDeviation",
|
|
136
|
+
"dy",
|
|
137
|
+
"dx",
|
|
138
|
+
"x",
|
|
139
|
+
"y",
|
|
140
|
+
"x1",
|
|
141
|
+
"x2",
|
|
142
|
+
"y1",
|
|
143
|
+
"y2",
|
|
144
|
+
"cx",
|
|
145
|
+
"cy",
|
|
146
|
+
"r",
|
|
147
|
+
"rx",
|
|
148
|
+
"ry",
|
|
149
|
+
"width",
|
|
150
|
+
"height"
|
|
128
151
|
];
|
|
129
152
|
var DEFAULT_IGNORE_ATTRIBUTE_PATTERNS = [
|
|
130
|
-
/
|
|
131
|
-
// *ClassName, *classname (e.g. labelClassName,
|
|
153
|
+
/classNames?$/i,
|
|
154
|
+
// *ClassName, *classNames, *classname (e.g. labelClassName, classNames)
|
|
132
155
|
/^data-/
|
|
133
156
|
// data-* attributes
|
|
134
157
|
];
|
|
@@ -169,15 +192,21 @@ var noRawStringsInJsx = {
|
|
|
169
192
|
if (ignoreAttributes.has(name)) return true;
|
|
170
193
|
return DEFAULT_IGNORE_ATTRIBUTE_PATTERNS.some((p) => p.test(name));
|
|
171
194
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
if (attrName && shouldIgnoreAttribute(attrName)) return true;
|
|
195
|
+
function getAttributeName(node) {
|
|
196
|
+
if (node.name?.type === "JSXIdentifier") return node.name.name;
|
|
197
|
+
if (node.name?.type === "JSXNamespacedName") {
|
|
198
|
+
return `${node.name.namespace.name}:${node.name.name.name}`;
|
|
177
199
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
function isInsideIgnoredAttribute(node) {
|
|
203
|
+
let current = node.parent;
|
|
204
|
+
while (current) {
|
|
205
|
+
if (current.type === "JSXAttribute") {
|
|
206
|
+
const attrName = getAttributeName(current);
|
|
207
|
+
return attrName ? shouldIgnoreAttribute(attrName) : false;
|
|
208
|
+
}
|
|
209
|
+
current = current.parent;
|
|
181
210
|
}
|
|
182
211
|
return false;
|
|
183
212
|
}
|
|
@@ -215,6 +244,8 @@ var noRawStringsInJsx = {
|
|
|
215
244
|
const inJsxExpression = ancestors.some((a) => a.type === "JSXExpressionContainer");
|
|
216
245
|
if (!inJsxExpression) return;
|
|
217
246
|
if (ancestors.some((a) => a.type === "CallExpression")) return;
|
|
247
|
+
if (node.parent?.type === "BinaryExpression") return;
|
|
248
|
+
if (node.parent?.type === "TSAsExpression") return;
|
|
218
249
|
const text = node.value;
|
|
219
250
|
if (shouldIgnore(text)) return;
|
|
220
251
|
if (isInsideIgnoredAttribute(node)) return;
|