npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@astroscope/eslint-plugin-i18n

v0.1.4

Published

ESLint rules for @astroscope/i18n

Readme

@astroscope/eslint-plugin-i18n

Note: This package is in active development. APIs may change between versions.

ESLint rules for projects using @astroscope/i18n. Enforces correct t() usage, catches build-time extraction issues, and promotes i18n best practices.

Installation

npm install -D @astroscope/eslint-plugin-i18n

Setup

// eslint.config.js
import i18n from '@astroscope/eslint-plugin-i18n';

export default [
  i18n.configs.recommended,
];

Rules

| Rule | Severity | Fixable | Description | |------|----------|---------|-------------| | @astroscope/i18n/t-import-source | error | | t must be imported from @astroscope/i18n/translate | | @astroscope/i18n/no-module-level-t | error | | t() must not be called at module level (needs request context on server, hydrated translations on client) | | @astroscope/i18n/t-static-key | error | | first argument must be a static string literal (dynamic keys break build-time extraction) | | @astroscope/i18n/t-requires-meta | warn | | second argument (fallback/meta) should be provided for development DX | | @astroscope/i18n/no-t-reassign | error | | forbids aliasing or reassigning t (the extractor only recognizes t() calls) | | @astroscope/i18n/prefer-x-directives | error | yes | prefer client:load-x over client:load (and visible, idle, media, only) for i18n-aware hydration | | @astroscope/i18n/no-raw-strings-in-jsx | warn | | warns when raw strings appear in JSX that may need translation |

Rule Details

t-import-source

Ensures t is only imported from the correct @astroscope/i18n entrypoints.

// good
import { t } from '@astroscope/i18n/translate';

// bad
import { t } from 'i18next';
import { t } from './my-translate';

no-module-level-t

Forbids calling t() at module scope. On the server, t() reads from AsyncLocalStorage (request context). On the client, it reads from window.__i18n__. Neither is available during module evaluation.

// good
function render() {
  return t('key', 'fallback');
}

// bad
const title = t('key', 'fallback');

t-static-key

The first argument must be a string literal. Dynamic keys cannot be extracted at build time by the Babel plugin.

// good
t('checkout.title', 'Checkout');

// bad
t(key, 'fallback');
t('prefix.' + suffix, 'fallback');
t(`prefix.${suffix}`, 'fallback');

t-requires-meta

The second argument (fallback string or meta object) provides the fallback text shown during development when translations are missing.

// good
t('key', 'Hello World');
t('key', { fallback: 'Hello World', description: 'Greeting' });

// bad (no fallback — shows raw key in dev)
t('key');

no-t-reassign

The build-time extractor only recognizes t() calls by name. Aliasing or reassigning breaks extraction.

// good
import { t } from '@astroscope/i18n/translate';

// bad
import { t as translate } from '@astroscope/i18n/translate';
const translate = t;

prefer-x-directives

The -x client directives preload translations before hydration. They are a strict superset of the standard directives — components without translations work identically.

<!-- good -->
<Cart client:load-x />
<Cart client:visible-x />

<!-- bad -->
<Cart client:load />
<Cart client:visible />

no-raw-strings-in-jsx

Warns when JSX contains raw string literals that may need translation. Ignores whitespace, numbers, and common non-translatable attributes (className, href, type, etc.).

// warns
<div>Hello World</div>
<button>Submit</button>

// no warning
<div className="container" />
<div>{t('greeting', 'Hello World')}</div>

Options

'@astroscope/i18n/no-raw-strings-in-jsx': ['warn', {
  // additional regex patterns to ignore (applied to text content)
  ignorePatterns: ['^TODO'],
  // additional attribute names to ignore
  ignoreAttributes: ['data-tooltip'],
}]

The default ignore list is exported as DEFAULT_IGNORE_ATTRIBUTES for consumers who want to extend it:

import i18n, { DEFAULT_IGNORE_ATTRIBUTES } from '@astroscope/eslint-plugin-i18n';

// ...
'@astroscope/i18n/no-raw-strings-in-jsx': ['warn', {
  ignoreAttributes: [...DEFAULT_IGNORE_ATTRIBUTES, 'alt', 'data-tooltip'],
}]

Compatibility

  • ESLint 9 and 10
  • Works with eslint-plugin-astro for .astro file support

License

MIT