@intlayer/docs 9.3.1 → 9.3.2
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/cjs/generated/docs.entry.cjs +20 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +20 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/eslint.md +336 -0
- package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +1 -1
- package/docs/bn/eslint.md +336 -0
- package/docs/cs/eslint.md +336 -0
- package/docs/de/eslint.md +336 -0
- package/docs/en/eslint.md +336 -0
- package/docs/en-GB/eslint.md +336 -0
- package/docs/en-GB/intlayer_with_create_react_app.md +32 -35
- package/docs/en-GB/intlayer_with_react_router_v7_fs_routes.md +1 -1
- package/docs/es/eslint.md +336 -0
- package/docs/fr/eslint.md +336 -0
- package/docs/hi/eslint.md +336 -0
- package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +1 -1
- package/docs/hi/intlayer_with_vite+svelte.md +2 -2
- package/docs/id/eslint.md +336 -0
- package/docs/it/eslint.md +336 -0
- package/docs/ja/eslint.md +336 -0
- package/docs/ja/intlayer_with_react_router_v7.md +1 -146
- package/docs/ja/intlayer_with_vite+react.md +5 -1
- package/docs/ko/eslint.md +336 -0
- package/docs/ko/intlayer_with_lynx+react.md +4 -0
- package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +1 -1
- package/docs/ko/intlayer_with_storybook.md +5 -5
- package/docs/nl/eslint.md +336 -0
- package/docs/pl/eslint.md +336 -0
- package/docs/pl/intlayer_with_astro.md +1 -114
- package/docs/pl/migration_from_i18next_to_intlayer.md +4 -0
- package/docs/pl/migration_from_next-i18next_to_intlayer.md +8 -4
- package/docs/pl/migration_from_next-intl_to_intlayer.md +11 -5
- package/docs/pl/migration_from_nuxtjs_i18n_to_intlayer.md +8 -4
- package/docs/pl/migration_from_react-i18next_to_intlayer.md +8 -4
- package/docs/pl/migration_from_vue-i18n_to_intlayer.md +4 -0
- package/docs/pt/eslint.md +336 -0
- package/docs/pt/intlayer_with_astro.md +1 -114
- package/docs/ru/eslint.md +336 -0
- package/docs/tr/eslint.md +336 -0
- package/docs/uk/eslint.md +336 -0
- package/docs/uk/packages/angular-intlayer/exports.md +2 -2
- package/docs/ur/eslint.md +336 -0
- package/docs/vi/eslint.md +336 -0
- package/docs/zh/eslint.md +336 -0
- package/docs/zh/intlayer_with_create_react_app.md +4 -0
- package/docs/zh/intlayer_with_lynx+react.md +4 -0
- package/docs/zh/intlayer_with_nextjs_14.md +0 -2
- package/docs/zh/intlayer_with_nextjs_15.md +0 -2
- package/docs/zh/intlayer_with_nextjs_page_router.md +0 -2
- package/docs/zh/intlayer_with_nuxt.md +1 -1
- package/docs/zh/intlayer_with_react_router_v7.md +4 -0
- package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +4 -0
- package/docs/zh/intlayer_with_solid_start.md +1 -1
- package/docs/zh/intlayer_with_vite+vue.md +0 -2
- package/docs/zh-TW/eslint.md +336 -0
- package/package.json +6 -6
- package/src/generated/docs.entry.ts +20 -0
|
@@ -300,120 +300,7 @@ Integracja z Astro dodaje oprogramowanie pośredniczące Vite, które pomaga w r
|
|
|
300
300
|
|
|
301
301
|
</Step>
|
|
302
302
|
|
|
303
|
-
<Step number={
|
|
304
|
-
|
|
305
|
-
Kontynuuj budowanie swojej aplikacji, korzystając z wybranego frameworka.
|
|
306
|
-
|
|
307
|
-
- Intlayer + React: [Intlayer z React](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_with_vite+react.md)
|
|
308
|
-
- Intlayer + Vue: [Intlayer z Vue](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_with_vite+vue.md)
|
|
309
|
-
- Intlayer + Svelte: [Intlayer z Svelte](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_with_vite+svelte.md)
|
|
310
|
-
- Intlayer + Solid: [Intlayer z Solid](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_with_vite+solid.md)
|
|
311
|
-
- Intlayer + Preact: [Intlayer z Preact](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_with_vite+preact.md)
|
|
312
|
-
</Step>
|
|
313
|
-
|
|
314
|
-
<Step number={17} title="Wyodrębnij zawartość swoich komponentów" isOptional={true}>
|
|
315
|
-
|
|
316
|
-
Jeśli masz istniejącą bazę kodu, transformacja tysięcy plików może być czasochłonna.
|
|
317
|
-
|
|
318
|
-
Aby ułatwić ten proces, Intlayer proponuje [kompilator](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/compiler.md) / [ekstraktor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/cli/extract.md), aby przetransformować komponenty i wyodrębnić zawartość.
|
|
319
|
-
|
|
320
|
-
Aby go skonfigurować, możesz dodać sekcję `compiler` w pliku `intlayer.config.ts`:
|
|
321
|
-
|
|
322
|
-
```typescript fileName="intlayer.config.ts" codeFormat={["typescript", "esm", "commonjs"]}
|
|
323
|
-
import { type IntlayerConfig } from "intlayer";
|
|
324
|
-
|
|
325
|
-
const config: IntlayerConfig = {
|
|
326
|
-
// ... Reszta Twojej konfiguracji
|
|
327
|
-
compiler: {
|
|
328
|
-
/**
|
|
329
|
-
* Wskazuje, czy kompilator powinien być włączony.
|
|
330
|
-
*/
|
|
331
|
-
enabled: true,
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Definiuje ścieżkę plików wyjściowych
|
|
335
|
-
*/
|
|
336
|
-
output: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Wskazuje, czy komponenty powinny zostać zapisane po transformacji. W ten sposób kompilator można uruchomić tylko raz, aby przetransformować aplikację, a następnie go usunąć.
|
|
340
|
-
*/
|
|
341
|
-
saveComponents: false,
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Prefiks klucza słownika
|
|
345
|
-
*/
|
|
346
|
-
dictionaryKeyPrefix: "",
|
|
347
|
-
},
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
export default config;
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
<Tabs>
|
|
354
|
-
<Tab value='Polecenie wyodrębniania'>
|
|
355
|
-
|
|
356
|
-
Uruchom ekstraktor, aby przetransformować komponenty i wyodrębnić zawartość
|
|
357
|
-
|
|
358
|
-
```bash packageManager="npm"
|
|
359
|
-
npx intlayer extract
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
```bash packageManager="pnpm"
|
|
363
|
-
pnpm intlayer extract
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
```bash packageManager="yarn"
|
|
367
|
-
yarn intlayer extract
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
```bash packageManager="bun"
|
|
371
|
-
bun x intlayer extract
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
</Tab>
|
|
375
|
-
<Tab value='Kompilator Babel'>
|
|
376
|
-
|
|
377
|
-
> Since v9, the `intlayerCompiler` is included in the `intlayer` plugin. So you don't need to add it manually.
|
|
378
|
-
|
|
379
|
-
Zaktualizuj `vite.config.ts`, aby dołączyć wtyczkę `intlayerCompiler`:
|
|
380
|
-
|
|
381
|
-
```ts fileName="vite.config.ts"
|
|
382
|
-
import { defineConfig } from "vite";
|
|
383
|
-
import { intlayer, intlayerCompiler } from "vite-intlayer";
|
|
384
|
-
|
|
385
|
-
export default defineConfig({
|
|
386
|
-
plugins: [
|
|
387
|
-
intlayer(),
|
|
388
|
-
intlayerCompiler(), // Adds the compiler plugin
|
|
389
|
-
],
|
|
390
|
-
});
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
```bash packageManager="npm"
|
|
394
|
-
npm run build # Lub npm run dev
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
```bash packageManager="pnpm"
|
|
398
|
-
pnpm run build # Or pnpm run dev
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
```bash packageManager="yarn"
|
|
402
|
-
yarn build # Or yarn dev
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
```bash packageManager="bun"
|
|
406
|
-
bun run build # Or bun run dev
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
</Tab>
|
|
410
|
-
</Tabs>
|
|
411
|
-
|
|
412
|
-
---
|
|
413
|
-
|
|
414
|
-
</Step>
|
|
415
|
-
|
|
416
|
-
</Steps>
|
|
303
|
+
<Step number={8} title="Sitemap i Robots.txt">
|
|
417
304
|
|
|
418
305
|
#### Mapa witryny
|
|
419
306
|
|
|
@@ -98,6 +98,10 @@ Następujące kroki są minimalne wymagane aby uruchomić istniejącą aplikacj
|
|
|
98
98
|
|
|
99
99
|
Zainstaluj pakiety rdzenia Intlayer i adapter compat:
|
|
100
100
|
|
|
101
|
+
</Step>
|
|
102
|
+
|
|
103
|
+
</Steps>
|
|
104
|
+
|
|
101
105
|
## Pełna migracja
|
|
102
106
|
|
|
103
107
|
Poniższe kroki są opcjonalne i można je wykonywać stopniowo. Odblokowują one pełny zestaw funkcji Intlayer: edytor wizualny, CMS, pliki zawartości z typami, automatyczne tłumaczenie oparte na AI i wiele więcej.
|
|
@@ -335,13 +335,17 @@ Intlayer uses module augmentation to provide full TypeScript intellisense for yo
|
|
|
335
335
|
|
|
336
336
|
---
|
|
337
337
|
|
|
338
|
-
##
|
|
338
|
+
## Konfiguracja Git
|
|
339
339
|
|
|
340
|
-
|
|
340
|
+
Dodaj wygenerowany przez Intlayer katalog do pliku `.gitignore`:
|
|
341
341
|
|
|
342
|
-
|
|
342
|
+
```plaintext fileName=".gitignore"
|
|
343
|
+
# Ignoruj pliki wygenerowane przez Intlayer
|
|
344
|
+
.intlayer
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
343
348
|
|
|
344
|
-
<Step number={1} title="Zainstaluj zależności">
|
|
345
349
|
## Idź dalej
|
|
346
350
|
|
|
347
351
|
- **Visual Editor** — Zarządzaj tłumaczeniami wizualnie w przeglądarce: [Intlayer Visual Editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_visual_editor.md)
|
|
@@ -312,15 +312,21 @@ export default config;
|
|
|
312
312
|
|
|
313
313
|
---
|
|
314
314
|
|
|
315
|
-
|
|
315
|
+
Zainstaluj pakiety rdzenia Intlayer i adapter compat `@intlayer/next-intl`:
|
|
316
316
|
|
|
317
|
-
|
|
317
|
+
## Co można usunąć po migracji
|
|
318
318
|
|
|
319
|
-
|
|
319
|
+
Po wdrożeniu `@intlayer/next-intl` można usunąć następujący boilerplate `next-intl`:
|
|
320
320
|
|
|
321
|
-
|
|
321
|
+
| Plik / wzorzec | Dlaczego już nie jest potrzebny |
|
|
322
|
+
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
323
|
+
| `src/i18n.ts` → eksport `getRequestConfig` | Intlayer kompiluje słowniki w czasie budowania; nie ma ładowania wiadomości dla każdego żądania. Zachowaj plik tylko jeśli eksportuje również pomocniki routingu `createNavigation`. |
|
|
324
|
+
| Wywołanie `loadMessages()` / `getMessages()` w layout | `NextIntlClientProvider` z `@intlayer/next-intl` czyta ze skompilowanych danych wyjściowych; prop `messages` nie jest wymagany. |
|
|
325
|
+
| Importy `locales/{locale}/*.json` w layout | Pakiety JSON są potrzebne tylko jeśli nadal używasz pluginu `syncJSON`. Po migracji do plików `.content.ts` możesz usunąć folder JSON. |
|
|
322
326
|
|
|
323
|
-
|
|
327
|
+
Gdy będziesz gotowy, aby pójść dalej, Intlayer **automatycznie odkrywa wszystkie pliki `.content.ts` i `.content.json` gdziekolwiek w twoim codebase** (domyślnie gdziekolwiek wewnątrz `./src`). Możesz umieścić plik `about.content.ts` tuż obok `about/page.tsx` i Intlayer podciągnie go w czasie budowania bez żadnej dodatkowej konfiguracji — bez importów, bez rejestracji, bez scentralizowanego pliku indeksu. Sprawia to, że współlokalizowanie tłumaczeń ze stronami i komponentami jest całkowicie pozbawione tarcia.
|
|
328
|
+
|
|
329
|
+
---
|
|
324
330
|
|
|
325
331
|
## Konfiguracja TypeScript
|
|
326
332
|
|
|
@@ -307,13 +307,17 @@ Intlayer używa module augmentation, aby zapewnić pełny TypeScript intellisens
|
|
|
307
307
|
|
|
308
308
|
---
|
|
309
309
|
|
|
310
|
-
##
|
|
310
|
+
## Konfiguracja Git
|
|
311
311
|
|
|
312
|
-
|
|
312
|
+
Dodaj wygenerowany przez Intlayer katalog do `.gitignore`:
|
|
313
313
|
|
|
314
|
-
|
|
314
|
+
```plaintext fileName=".gitignore"
|
|
315
|
+
# Ignoruj pliki wygenerowane przez Intlayer
|
|
316
|
+
.intlayer
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
---
|
|
315
320
|
|
|
316
|
-
<Step number={1} title="Zainstaluj zależności">
|
|
317
321
|
## Idź dalej
|
|
318
322
|
|
|
319
323
|
- **Visual Editor** — Zarządzaj tłumaczeniami wizualnie w przeglądarce: [Intlayer Visual Editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_visual_editor.md)
|
|
@@ -361,13 +361,17 @@ Intlayer używa module augmentation, aby zapewnić pełny intellisense TypeScrip
|
|
|
361
361
|
|
|
362
362
|
---
|
|
363
363
|
|
|
364
|
-
##
|
|
364
|
+
## Konfiguracja Git
|
|
365
365
|
|
|
366
|
-
|
|
366
|
+
Dodaj wygenerowany przez Intlayer katalog do `.gitignore`:
|
|
367
367
|
|
|
368
|
-
|
|
368
|
+
```plaintext fileName=".gitignore"
|
|
369
|
+
# Ignoruj pliki wygenerowane przez Intlayer
|
|
370
|
+
.intlayer
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
---
|
|
369
374
|
|
|
370
|
-
<Step number={1} title="Zainstaluj zależności">
|
|
371
375
|
## Idź dalej
|
|
372
376
|
|
|
373
377
|
- **Visual Editor** — Zarządzaj tłumaczeniami wizualnie w przeglądarce: [Intlayer Visual Editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_visual_editor.md)
|
|
@@ -99,6 +99,10 @@ Następujące kroki są minimalne wymagane aby uruchomić istniejącą aplikacj
|
|
|
99
99
|
|
|
100
100
|
Zainstaluj pakiety rdzenia Intlayer i adapter compat:
|
|
101
101
|
|
|
102
|
+
</Step>
|
|
103
|
+
|
|
104
|
+
</Steps>
|
|
105
|
+
|
|
102
106
|
## Pełna migracja
|
|
103
107
|
|
|
104
108
|
Poniższe kroki są opcjonalne i mogą być wykonywane stopniowo. Odblokowują pełny zestaw funkcji Intlayer: edytor wizualny, CMS, pliki zawartości z typami, tłumaczenie wspierane przez AI i wiele więcej.
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2026-08-12
|
|
3
|
+
updatedAt: 2026-08-12
|
|
4
|
+
title: Plugin ESLint | Regras de lint para o Intlayer
|
|
5
|
+
description: Detecte strings codificadas diretamente, chamadas dinâmicas que o compilador do Intlayer não consegue otimizar e conteúdo de dicionário não utilizado com eslint-plugin-intlayer. Compatível com ESLint e oxlint, no React, Vue, Svelte, Angular e Astro.
|
|
6
|
+
keywords:
|
|
7
|
+
- Intlayer
|
|
8
|
+
- ESLint
|
|
9
|
+
- oxlint
|
|
10
|
+
- Linting
|
|
11
|
+
- i18n
|
|
12
|
+
- Internacionalização
|
|
13
|
+
- no-raw-text
|
|
14
|
+
- Strings codificadas diretamente
|
|
15
|
+
- Traduções não utilizadas
|
|
16
|
+
- Conteúdo morto
|
|
17
|
+
- React
|
|
18
|
+
- Vue
|
|
19
|
+
- Svelte
|
|
20
|
+
- Angular
|
|
21
|
+
slugs:
|
|
22
|
+
- doc
|
|
23
|
+
- eslint
|
|
24
|
+
history:
|
|
25
|
+
- version: 9.3.1
|
|
26
|
+
date: 2026-08-12
|
|
27
|
+
changes: "Histórico inicial"
|
|
28
|
+
author: aymericzip
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
# Plugin ESLint x OXLint
|
|
32
|
+
|
|
33
|
+
O `eslint-plugin-intlayer` detecta os tipos de erros de i18n que o TypeScript não consegue identificar:
|
|
34
|
+
|
|
35
|
+
1. **Texto codificado diretamente (hardcoded)** que nunca chegou a um dicionário.
|
|
36
|
+
2. **Chamadas dinâmicas** que passam na verificação de tipos e são executadas, mas que o compilador do Intlayer não consegue otimizar.
|
|
37
|
+
3. **Conteúdo morto** — dicionários e campos que nada no projeto lê (ativação opcional).
|
|
38
|
+
|
|
39
|
+
Chaves de dicionário desconhecidas, caminhos de campos desconhecidos e idiomas ausentes já são erros de compilação, portanto o plugin não os repete.
|
|
40
|
+
|
|
41
|
+
## Instalação
|
|
42
|
+
|
|
43
|
+
```bash packageManager="npm"
|
|
44
|
+
npm install --save-dev eslint-plugin-intlayer
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```bash packageManager="pnpm"
|
|
48
|
+
pnpm add --save-dev eslint-plugin-intlayer
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```bash packageManager="yarn"
|
|
52
|
+
yarn add --dev eslint-plugin-intlayer
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Requer o ESLint 9 ou superior (flat config).
|
|
56
|
+
|
|
57
|
+
## Utilização
|
|
58
|
+
|
|
59
|
+
O plugin funciona tanto no ESLint quanto no [oxlint](https://oxc.rs) — com as mesmas regras e as mesmas opções.
|
|
60
|
+
|
|
61
|
+
<Tabs defaultTab="eslint">
|
|
62
|
+
<Tab label="ESLint" value="eslint">
|
|
63
|
+
|
|
64
|
+
```javascript fileName="eslint.config.mjs" codeFormat="esm"
|
|
65
|
+
import intlayer from "eslint-plugin-intlayer";
|
|
66
|
+
|
|
67
|
+
export default [...intlayer.configs.recommended];
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Ou ative as regras uma a uma:
|
|
71
|
+
|
|
72
|
+
```javascript fileName="eslint.config.mjs" codeFormat="esm"
|
|
73
|
+
import intlayer from "eslint-plugin-intlayer";
|
|
74
|
+
|
|
75
|
+
export default [
|
|
76
|
+
{
|
|
77
|
+
plugins: { intlayer },
|
|
78
|
+
rules: {
|
|
79
|
+
"intlayer/no-raw-text": "warn",
|
|
80
|
+
"intlayer/static-dictionary-key": "error",
|
|
81
|
+
"intlayer/no-dynamic-field-access": "error",
|
|
82
|
+
"intlayer/enforce-adapter-import": "warn",
|
|
83
|
+
"intlayer/no-unused-content": "warn",
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
</Tab>
|
|
90
|
+
<Tab label="oxlint" value="oxlint">
|
|
91
|
+
|
|
92
|
+
```json fileName=".oxlintrc.json"
|
|
93
|
+
{
|
|
94
|
+
"jsPlugins": ["eslint-plugin-intlayer"],
|
|
95
|
+
"rules": {
|
|
96
|
+
"intlayer/no-raw-text": "warn",
|
|
97
|
+
"intlayer/static-dictionary-key": "error",
|
|
98
|
+
"intlayer/no-dynamic-field-access": "error",
|
|
99
|
+
"intlayer/enforce-adapter-import": "warn"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Duas ressalvas: o suporte a plugins JS no oxlint ainda está em versão alfa e o oxlint não suporta parsers customizados — portanto, arquivos `.vue`, `.svelte`, `.astro` e templates do Angular não são verificados lá. Execute o oxlint nos seus arquivos JS/TS/JSX e mantenha o ESLint para o restante.
|
|
105
|
+
|
|
106
|
+
O `no-unused-content` foi omitido acima de propósito: ele precisa do diretório de trabalho e do caminho do arquivo analisado a partir do contexto da regra, o que a ponte alfa de plugins JS não garante. Execute-o no ESLint.
|
|
107
|
+
|
|
108
|
+
</Tab>
|
|
109
|
+
</Tabs>
|
|
110
|
+
|
|
111
|
+
### Configurações
|
|
112
|
+
|
|
113
|
+
| Configuração | `no-raw-text` | `static-dictionary-key` | `no-dynamic-field-access` | `enforce-adapter-import` | `no-unused-content` |
|
|
114
|
+
| --------------- | ------------------------------ | ----------------------- | ------------------------- | ------------------------ | ------------------- |
|
|
115
|
+
| `recommended` | warn | error | error | off | off |
|
|
116
|
+
| `strict` | error (+ literais fora de JSX) | error | error | error | off |
|
|
117
|
+
| `contract-only` | off | error | error | off | off |
|
|
118
|
+
|
|
119
|
+
A configuração `recommended` mantém deliberadamente `no-raw-text` como `warn`: apontá-la para uma base de código existente traz à tona todas as strings não traduzidas de uma só vez, o que não deve quebrar a sua compilação logo no primeiro dia.
|
|
120
|
+
|
|
121
|
+
O `enforce-adapter-import` fica desativado por padrão — ative-o explicitamente se desejar.
|
|
122
|
+
|
|
123
|
+
O `no-unused-content` fica desativado em todas as configurações, inclusive na `strict`. É a única regra que lê sua configuração do Intlayer e percorre seus arquivos de código no disco; portanto, ativá-la deve ser uma escolha consciente e não algo imposto por uma predefinição.
|
|
124
|
+
|
|
125
|
+
## Regras
|
|
126
|
+
|
|
127
|
+
### `no-raw-text`
|
|
128
|
+
|
|
129
|
+
Reporta texto voltado ao usuário que não esteja declarado em um dicionário. Ele usa a mesma detecção do `intlayer extract`, portanto nomes de marcas, classes CSS e identificadores técnicos são ignorados.
|
|
130
|
+
|
|
131
|
+
```jsx
|
|
132
|
+
// ✗ Reportado
|
|
133
|
+
<h1>Welcome to our documentation</h1>
|
|
134
|
+
<input placeholder="Enter your email address" />
|
|
135
|
+
|
|
136
|
+
// ✓ Correto
|
|
137
|
+
const { title } = useIntlayer("home");
|
|
138
|
+
<h1>{title}</h1>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Arquivos de declaração de conteúdo (`*.content.ts`, …) são ignorados.
|
|
142
|
+
|
|
143
|
+
Para corrigir um arquivo inteiro de uma só vez, execute `npx intlayer extract` e deixe o compilador mover as strings para um dicionário para você.
|
|
144
|
+
|
|
145
|
+
**Opções**
|
|
146
|
+
|
|
147
|
+
```javascript fileName="eslint.config.mjs" codeFormat="esm"
|
|
148
|
+
{
|
|
149
|
+
"intlayer/no-raw-text": [
|
|
150
|
+
"warn",
|
|
151
|
+
{
|
|
152
|
+
// Atributos cujo valor é texto voltado ao usuário.
|
|
153
|
+
// Padrão: title, placeholder, alt, aria-label, label
|
|
154
|
+
attributes: ["title", "placeholder", "alt", "aria-label", "label"],
|
|
155
|
+
|
|
156
|
+
// Elementos cujo conteúdo nunca é texto voltado ao usuário.
|
|
157
|
+
// Padrão: code, pre, script, style
|
|
158
|
+
ignoreElements: ["code", "pre", "script", "style"],
|
|
159
|
+
|
|
160
|
+
// Expressões regulares para textos que nunca devem ser reportados.
|
|
161
|
+
ignorePatterns: ["^Powered by"],
|
|
162
|
+
|
|
163
|
+
// Também reportar literais de string fora do markup. Padrão: false
|
|
164
|
+
includeStringLiterals: false,
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### `static-dictionary-key`
|
|
171
|
+
|
|
172
|
+
Exige que a chave do dicionário seja uma string literal.
|
|
173
|
+
|
|
174
|
+
O compilador só consegue pré-carregar um dicionário quando pode ler a chave diretamente no local da chamada. Com uma chave calculada, ele pula silenciosamente a otimização e inclui todos os dicionários no bundle.
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
// ✗ Reportado
|
|
178
|
+
useIntlayer(dictionaryKey);
|
|
179
|
+
useIntlayer(`home-${suffix}`);
|
|
180
|
+
getTranslations({ namespace: page });
|
|
181
|
+
|
|
182
|
+
// ✗ Uma variável ainda não é um literal
|
|
183
|
+
const key = "home";
|
|
184
|
+
useIntlayer(key);
|
|
185
|
+
|
|
186
|
+
// ✓ Correto
|
|
187
|
+
useIntlayer("home");
|
|
188
|
+
getTranslations({ namespace: "home" });
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Isso se aplica ao `useIntlayer`, `getIntlayer` e a todos os adaptadores de compatibilidade (`useTranslation`, `useTranslations`, `formatMessage`, `<FormattedMessage id>`, `<Trans i18nKey>`, …).
|
|
192
|
+
|
|
193
|
+
### `no-dynamic-field-access`
|
|
194
|
+
|
|
195
|
+
Exige que o campo lido de um dicionário seja conhecido estaticamente.
|
|
196
|
+
|
|
197
|
+
O compilador remove campos que não são identificados como utilizados. Um acesso computado é invisível para ele, portanto a leitura pode retornar `undefined` em tempo de execução.
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// ✗ Reportado
|
|
201
|
+
const content = useIntlayer("home");
|
|
202
|
+
content[fieldName];
|
|
203
|
+
|
|
204
|
+
const t = useTranslations("home");
|
|
205
|
+
t(messageKey);
|
|
206
|
+
|
|
207
|
+
// ✓ Correto
|
|
208
|
+
content.title;
|
|
209
|
+
content["title"];
|
|
210
|
+
content.items[0];
|
|
211
|
+
t("hero.title");
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### `enforce-adapter-import`
|
|
215
|
+
|
|
216
|
+
Prefere o adaptador de compatibilidade `@intlayer/*` ao pacote original. O original só é resolvido para o Intlayer quando o alias do empacotador está configurado; o adaptador sempre funciona. Corrigível automaticamente com `--fix`.
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// ✗ Reportado
|
|
220
|
+
import { useTranslation } from "react-i18next";
|
|
221
|
+
import { getTranslations } from "next-intl/server";
|
|
222
|
+
|
|
223
|
+
// ✓ Correto
|
|
224
|
+
import { useTranslation } from "@intlayer/react-i18next";
|
|
225
|
+
import { getTranslations } from "@intlayer/next-intl/server";
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### `no-unused-content`
|
|
229
|
+
|
|
230
|
+
**Desativada por padrão.** Reporta conteúdo que nada em seu projeto lê, além de chaves de dicionário declaradas em mais de um local.
|
|
231
|
+
|
|
232
|
+
```typescript fileName="src/home.content.ts"
|
|
233
|
+
export default {
|
|
234
|
+
key: "home", // ✗ Reportado se nenhum chamador no projeto solicitar "home"
|
|
235
|
+
content: {
|
|
236
|
+
title: t({ pt: "Título", en: "Title" }),
|
|
237
|
+
|
|
238
|
+
// ✗ Reportado se nada ler `hero`
|
|
239
|
+
hero: {
|
|
240
|
+
subtitle: t({ pt: "Subtítulo", en: "Subtitle" }),
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Ao contrário das outras regras, esta não pode responder apenas com base no arquivo analisado — um campo só é considerado não utilizado em relação ao projeto inteiro. Na primeira declaração de conteúdo de uma execução do linter, ela carrega a sua configuração do Intlayer, busca os arquivos de código declarados por essa configuração (`build.traversePattern`, `compiler.transformPattern`) e executa o mesmo analisador de uso que alimenta o `@intlayer/lsp` e o tachado de "não utilizado" na extensão do VS Code. O resultado é armazenado em cache por `cacheTtl` milissegundos, para que a varredura ocorra uma vez por execução e não a cada arquivo.
|
|
247
|
+
|
|
248
|
+
**Opções**
|
|
249
|
+
|
|
250
|
+
```javascript fileName="eslint.config.mjs" codeFormat="esm"
|
|
251
|
+
{
|
|
252
|
+
"intlayer/no-unused-content": [
|
|
253
|
+
"warn",
|
|
254
|
+
{
|
|
255
|
+
// Reportar chaves de dicionário que nada referencia. Padrão: true
|
|
256
|
+
reportUnusedDictionaries: true,
|
|
257
|
+
|
|
258
|
+
// Reportar campos de conteúdo que nada lê. Padrão: true
|
|
259
|
+
reportUnusedFields: true,
|
|
260
|
+
|
|
261
|
+
// Reportar chaves declaradas em mais de um lugar. Padrão: true
|
|
262
|
+
reportDuplicateKeys: true,
|
|
263
|
+
|
|
264
|
+
// Expressões regulares para caminhos de campos que nunca devem ser reportados.
|
|
265
|
+
ignoreFields: ["^meta"],
|
|
266
|
+
|
|
267
|
+
// Raiz do projeto a partir de onde a verificação começa. Padrão: diretório de trabalho do ESLint
|
|
268
|
+
baseDir: process.cwd(),
|
|
269
|
+
|
|
270
|
+
// Tempo de reutilização de uma varredura de projeto, em ms. Padrão: 30000
|
|
271
|
+
cacheTtl: 30000,
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Diminua `cacheTtl` ao executar o lint a partir de um servidor de editor de longa duração e quiser que as alterações apareçam mais rápido; defina `baseDir` quando uma única execução de lint cobrir vários projetos Intlayer em um monorepo.
|
|
278
|
+
|
|
279
|
+
> **Tende ao silêncio.** Um falso positivo aqui apagaria uma tradução; portanto, nada é reportado quando o dicionário é consumido de uma forma que a análise não consiga rastrear: o objeto de conteúdo passado por completo, uma função de tradução vinculada a partir dele (`const t = useTranslations("home")`), uma declaração acessada por importação direta (`useDictionary(myDictionary)`), um `nest()` de outro dicionário ou uma lista de campos tornada não exaustiva por um spread. Componentes de arquivo único (`.vue`, `.svelte`, `.astro`) são considerados como usuários de todos os campos dos dicionários mencionados, pois seus blocos de script não são analisados aqui.
|
|
280
|
+
|
|
281
|
+
O `reportDuplicateKeys` lê os dicionários não mesclados que o build grava em `.intlayer/`, portanto permanece em silêncio até que o projeto tenha sido construído pelo menos uma vez. Duas declarações compartilhando uma chave são mescladas, o que é um padrão válido — o aviso existe porque um campo definido em ambos os lados mantém silenciosamente apenas um dos dois valores.
|
|
282
|
+
|
|
283
|
+
O analisador é carregado a partir do `@intlayer/lsp`, distribuído como ESM. A regra requer, portanto, uma versão do Node compatível com `require()` em módulos ES — Node 20.19+ ou 22.12+. Em versões anteriores, ela não reporta nada em vez de falhar a execução do lint.
|
|
284
|
+
|
|
285
|
+
## Frameworks
|
|
286
|
+
|
|
287
|
+
Todas as regras funcionam em todas as integrações do Intlayer, inclusive dentro de templates Vue, Svelte e Angular. Você só precisa informar ao ESLint qual parser lê cada tipo de arquivo.
|
|
288
|
+
|
|
289
|
+
| Framework | Arquivos | Parser |
|
|
290
|
+
| ------------------------- | ----------------- | --------------------------------- |
|
|
291
|
+
| React, Preact, Solid, Lit | `.jsx` `.tsx` | `typescript-eslint` |
|
|
292
|
+
| Next.js | `.jsx` `.tsx` | `typescript-eslint` |
|
|
293
|
+
| Vue, Nuxt | `.vue` | `vue-eslint-parser` |
|
|
294
|
+
| Svelte, SvelteKit | `.svelte` | `svelte-eslint-parser` |
|
|
295
|
+
| Angular | `.ts` | `typescript-eslint` |
|
|
296
|
+
| Templates do Angular | `.component.html` | `@angular-eslint/template-parser` |
|
|
297
|
+
| Astro | `.astro` | `astro-eslint-parser` |
|
|
298
|
+
|
|
299
|
+
```javascript fileName="eslint.config.mjs" codeFormat="esm"
|
|
300
|
+
import intlayer from "eslint-plugin-intlayer";
|
|
301
|
+
import tseslint from "typescript-eslint";
|
|
302
|
+
import vueParser from "vue-eslint-parser";
|
|
303
|
+
import svelteParser from "svelte-eslint-parser";
|
|
304
|
+
import angularTemplateParser from "@angular-eslint/template-parser";
|
|
305
|
+
|
|
306
|
+
export default [
|
|
307
|
+
...intlayer.configs.recommended,
|
|
308
|
+
|
|
309
|
+
{
|
|
310
|
+
files: ["**/*.{ts,tsx,jsx}"],
|
|
311
|
+
languageOptions: { parser: tseslint.parser },
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
files: ["**/*.vue"],
|
|
315
|
+
languageOptions: {
|
|
316
|
+
parser: vueParser,
|
|
317
|
+
parserOptions: { parser: tseslint.parser },
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
files: ["**/*.svelte"],
|
|
322
|
+
languageOptions: {
|
|
323
|
+
parser: svelteParser,
|
|
324
|
+
parserOptions: { parser: tseslint.parser },
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
files: ["**/*.component.html"],
|
|
329
|
+
languageOptions: { parser: angularTemplateParser },
|
|
330
|
+
},
|
|
331
|
+
];
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Instale apenas os parsers de que seu projeto precisa.
|
|
335
|
+
|
|
336
|
+
> **Limitação conhecida.** Em templates do Vue e Angular, uma expressão como `{{ content[key] }}` não é verificada pelo `no-dynamic-field-access`. Leituras dinâmicas escritas no bloco script são identificadas normalmente.
|