pasika 0.10.28 → 0.10.29
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/eslint/pasika/index.js +12 -1
- package/package.json +1 -1
|
@@ -3981,6 +3981,9 @@ function looksLikeLocaleKey(name) {
|
|
|
3981
3981
|
function looksLikeUserFacingString(value) {
|
|
3982
3982
|
return typeof value === "string" && /^\p{Lu}/u.test(value);
|
|
3983
3983
|
}
|
|
3984
|
+
function looksLikeUserFacingJsxText(value) {
|
|
3985
|
+
return typeof value === "string" && /\p{L}/u.test(value);
|
|
3986
|
+
}
|
|
3984
3987
|
var localesLocationRule = {
|
|
3985
3988
|
meta: {
|
|
3986
3989
|
schema: [],
|
|
@@ -3996,9 +3999,17 @@ var localesLocationRule = {
|
|
|
3996
3999
|
const srcIdx = segments.lastIndexOf("src");
|
|
3997
4000
|
if (srcIdx === -1) return {};
|
|
3998
4001
|
const folder = segments[srcIdx + 1];
|
|
3999
|
-
|
|
4002
|
+
const skipObjectLiteralCheck = folder === "app" || folder === "config";
|
|
4000
4003
|
return {
|
|
4004
|
+
JSXText(node) {
|
|
4005
|
+
if (!looksLikeUserFacingJsxText(node.value)) return;
|
|
4006
|
+
context.report({
|
|
4007
|
+
node,
|
|
4008
|
+
message: "User-facing JSX text must come from src/locales/index.ts, not be written inline."
|
|
4009
|
+
});
|
|
4010
|
+
},
|
|
4001
4011
|
VariableDeclarator(node) {
|
|
4012
|
+
if (skipObjectLiteralCheck) return;
|
|
4002
4013
|
if (node.id.type === "Identifier" && node.init?.type === "ObjectExpression" && node.init.properties.length > 0 && looksLikeLocaleKey(node.id.name)) {
|
|
4003
4014
|
const hasUserFacingStringValues = node.init.properties.some(
|
|
4004
4015
|
(p) => p.type === "Property" && p.value.type === "Literal" && looksLikeUserFacingString(p.value.value)
|