Selaa lähdekoodia

Add rule banning literal text in JSX (#1367)

Jed Fox 5 vuotta sitten
vanhempi
commit
8ce595e5d6
2 muutettua tiedostoa jossa 9 lisäystä ja 2 poistoa
  1. 8 1
      package.json
  2. 1 1
      src/components/LoadingMessage.tsx

+ 8 - 1
package.json

@@ -83,7 +83,14 @@
         }
       ],
       "prefer-template": "warn",
-      "prettier/prettier": "warn"
+      "prettier/prettier": "warn",
+      "no-restricted-syntax": [
+        "warn",
+        {
+          "selector": "JSXText[value=/\\w/]",
+          "message": "Use 't(...)' instead of literal text in JSX"
+        }
+      ]
     }
   },
   "homepage": ".",

+ 1 - 1
src/components/LoadingMessage.tsx

@@ -4,7 +4,7 @@ export const LoadingMessage = () => {
   // !! KEEP THIS IN SYNC WITH index.html !!
   return (
     <div className="LoadingMessage">
-      <span>Loading scene...</span>
+      <span>{"Loading scene..."}</span>
     </div>
   );
 };