// Tests for the i18n/no-hardcoded-user-text rule // (web/eslint-plugins/i18n/no-hardcoded-user-text.js). // // The rule is a pure AST check over the Svelte template, so it runs through the // standard RuleTester with svelte-eslint-parser + the TS sub-parser. The // exclusion list (brand, formats, units, registry source strings) is the whole // point of the pilot, so every exclusion has a case here. import { RuleTester } from "eslint"; import svelteParser from "svelte-eslint-parser"; import tseslint from "typescript-eslint"; import { describe, expect, it } from "vitest"; import rule, { hasUserWords } from "../i18n/no-hardcoded-user-text.js"; import { asRuleModule } from "./helpers.js"; RuleTester.describe = describe; RuleTester.it = it; const ruleTester = new RuleTester({ languageOptions: { parser: svelteParser, parserOptions: { parser: tseslint.parser }, }, }); const OPTIONS = [{ allowWords: ["easy-image-tools"] }]; ruleTester.run("no-hardcoded-user-text", asRuleModule(rule), { valid: [ // Translated text comes from t(), never from a literal. { code: '

{t("ui.reset")}

', filename: "Component.svelte" }, { code: '