From 458913fd9daf1c6e554fabe8dedc16a1e00f9d53 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Sun, 15 Nov 2026 20:51:07 +0100 Subject: [PATCH] Translation files: read the language files in node too and enforce the lint rules Co-Authored-By: Claude Sonnet 5.5 --- web/eslint.config.js | 9 ++++----- web/src/i18n/index.ts | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/web/eslint.config.js b/web/eslint.config.js index c36ef19..fb19cb5 100644 --- a/web/eslint.config.js +++ b/web/eslint.config.js @@ -34,8 +34,7 @@ export default tseslint.config( }, { // Texts of the site live in the language files (src/i18n), not in the - // JSX. Warning for now while the pages are moved over, an error when - // that is done. Left out: the hero (becomes a CMS module), tests and + // JSX (an error, so a new hardcoded text is stopped). Left out: the hero (becomes a CMS module), tests and // the build-only helpers. files: ['src/components/**/*.tsx', 'src/routes/**/*.tsx'], ignores: [ @@ -49,16 +48,16 @@ export default tseslint.config( rules: { // Text in attributes that people read or hear (labels, alt text) 'no-restricted-syntax': [ - 'warn', + 'error', { selector: - "JSXAttribute[name.name=/^(aria-label|aria-description|alt|title|placeholder|label)$/][value.type='Literal']", + "JSXAttribute[name.name=/^(aria-label|aria-description|alt|title|placeholder|label)$/][value.type='Literal'][value.value!='']", message: 'Put the text in a language file (src/i18n) and use t().', }, ], 'react/jsx-no-literals': [ - 'warn', + 'error', { noStrings: false, ignoreProps: true, diff --git a/web/src/i18n/index.ts b/web/src/i18n/index.ts index d280e9f..a1d11a5 100644 --- a/web/src/i18n/index.ts +++ b/web/src/i18n/index.ts @@ -1,13 +1,13 @@ -import about from './nl/about.json'; -import common from './nl/common.json'; -import contact from './nl/contact.json'; -import home from './nl/home.json'; -import instagram from './nl/instagram.json'; -import portfolio from './nl/portfolio.json'; -import seo from './nl/seo.json'; -import shoots from './nl/shoots.json'; -import site from './nl/site.json'; -import testimonials from './nl/testimonials.json'; +import about from './nl/about.json' with { type: 'json' }; +import common from './nl/common.json' with { type: 'json' }; +import contact from './nl/contact.json' with { type: 'json' }; +import home from './nl/home.json' with { type: 'json' }; +import instagram from './nl/instagram.json' with { type: 'json' }; +import portfolio from './nl/portfolio.json' with { type: 'json' }; +import seo from './nl/seo.json' with { type: 'json' }; +import shoots from './nl/shoots.json' with { type: 'json' }; +import site from './nl/site.json' with { type: 'json' }; +import testimonials from './nl/testimonials.json' with { type: 'json' }; // The texts of the site, per language, as JSON per area (src/i18n//*.json). // Only Dutch exists now. The types come from the Dutch files: a second language