alleyinteractive / alleyinteractive/alley-scripts

Custom Oxlint JS plugin for WordPress i18n

Offen
#859 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
10
Forks
3
Ø Merge
4 T. 22 Std.
Gemergte PRs (30 T.)
2

Beschreibung

### Description

Currently, for proper i18n support, if you need to check text domains in js files, one needs to use [this package](https://www.npmjs.com/package/@wordpress/eslint-plugin). WPCS removed support for checking js files, so this package is the new way to do it. We should take that into account.

---

Create `@alleyinteractive/oxlint-wp-i18n` with a native support for the Oxlint JS plugin.

**Rules to implement** (from `@wordpress/eslint-plugin`):
1. `i18n-ellipsis` - enforce proper ellipsis in translatable strings
2. `i18n-hyphenated-range` - validate hyphenation in range expressions
3. `i18n-no-collapsible-whitespace` - prevent unnecessary whitespace in i18n strings
4. `i18n-no-flanking-whitespace` - no leading/trailing whitespace in translations
5. `i18n-no-placeholders-only` - disallow strings with only placeholders
6. `i18n-no-variables` - prevent variable interpolation in translation calls
7. `i18n-text-domain` - enforce correct text domain
8. `i18n-translator-comments` - require translator comments

**Approach:**
- Use Oxlint's JS plugin API (`jsPlugins` in oxlintrc.json)
- Port the rule logic from `@wordpress/eslint-plugin` source (GPL-2.0 compatible)
- Target WordPress translation functions: `__()`, `_x()`, `_n()`, `_nx()`, `sprintf()`
- Ship as separate npm package: `@alleyinteractive/oxlint-plugin-wordpress-i18n`
- Add documentation to use it this new package
- Add documentation to use https://www.npmjs.com/package/@wordpress/eslint-plugin as a bridge

### Use Case

As titled.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.