eslint-plugin-lingui-typescript 1.13.0 → 1.15.0
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/README.md +46 -10
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/rules/consistent-plural-format.d.ts +2 -1
- package/dist/rules/consistent-plural-format.d.ts.map +1 -1
- package/dist/rules/consistent-plural-format.js +76 -4
- package/dist/rules/consistent-plural-format.js.map +1 -1
- package/dist/rules/consistent-plural-format.test.js +6 -0
- package/dist/rules/consistent-plural-format.test.js.map +1 -1
- package/dist/types.d.ts +8 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/eslint-plugin-lingui-typescript)
|
|
4
4
|
[](https://www.npmjs.com/package/eslint-plugin-lingui-typescript)
|
|
5
5
|
[](https://github.com/sebastian-software/eslint-plugin-lingui-typescript/actions/workflows/ci.yml)
|
|
6
|
+
[](https://oxc.rs/)
|
|
6
7
|
[](LICENSE)
|
|
7
8
|
|
|
8
9
|
ESLint rules for [Lingui](https://lingui.dev/) that read TypeScript types instead of guessing. Your whitelist goes away.
|
|
@@ -114,18 +115,51 @@ Or pick individual rules:
|
|
|
114
115
|
|
|
115
116
|
That's it. DOM APIs, Intl methods, string literal unions, styling props, comparisons, numeric strings — all handled from the first run.
|
|
116
117
|
|
|
118
|
+
## OXLint support
|
|
119
|
+
|
|
120
|
+
This plugin works with [OXLint](https://oxc.rs/) via its [JavaScript plugin system](https://oxc.rs/docs/guide/usage/linter/js-plugins.html). Eight of nine rules run natively in OXLint — no code changes, no wrapper, no adapter.
|
|
121
|
+
|
|
122
|
+
Add to your `.oxlintrc.json`:
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"jsPlugins": ["eslint-plugin-lingui-typescript"],
|
|
127
|
+
"rules": {
|
|
128
|
+
"lingui-typescript/no-nested-macros": "error",
|
|
129
|
+
"lingui-typescript/no-single-variables-to-translate": "error",
|
|
130
|
+
"lingui-typescript/no-single-tag-to-translate": "error",
|
|
131
|
+
"lingui-typescript/t-call-in-function": "warn",
|
|
132
|
+
"lingui-typescript/no-expression-in-message": "warn",
|
|
133
|
+
"lingui-typescript/consistent-plural-format": "warn",
|
|
134
|
+
"lingui-typescript/prefer-trans-in-jsx": "warn",
|
|
135
|
+
"lingui-typescript/text-restrictions": ["error", { "rules": [] }]
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The only rule not supported in OXLint is `no-unlocalized-strings` — it uses TypeScript's type checker at runtime to distinguish UI text from technical strings. As OXLint's [type-aware linting](https://oxc.rs/blog/2025-12-08-type-aware-alpha) matures, this rule will follow.
|
|
141
|
+
|
|
142
|
+
**Dual setup** — run OXLint for speed, ESLint for full coverage:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
oxlint . && eslint .
|
|
146
|
+
```
|
|
147
|
+
|
|
117
148
|
## Rules
|
|
118
149
|
|
|
119
|
-
| Rule | Description | Recommended |
|
|
120
|
-
|
|
121
|
-
| [no-unlocalized-strings](docs/rules/no-unlocalized-strings.md) | Catches user-visible strings not wrapped in Lingui macros. Uses TypeScript types to skip technical strings automatically. | ✅ |
|
|
122
|
-
| [no-single-variables-to-translate](docs/rules/no-single-variables-to-translate.md) | Prevents messages with only variables and no text — translators need context. | ✅ |
|
|
123
|
-
| [no-single-tag-to-translate](docs/rules/no-single-tag-to-translate.md) | Prevents `<Trans>` wrapping a single JSX element without surrounding text. | ✅ |
|
|
124
|
-
| [no-nested-macros](docs/rules/no-nested-macros.md) | Prevents nesting Lingui macros inside each other — nested macros produce broken catalogs. | ✅ |
|
|
125
|
-
| [no-expression-in-message](docs/rules/no-expression-in-message.md) | Keeps expressions simple inside messages. Complex logic goes into named variables. | ✅ |
|
|
126
|
-
| [t-call-in-function](docs/rules/t-call-in-function.md) | Keeps `t` macro calls inside functions where i18n is initialized. | ✅ |
|
|
127
|
-
| [consistent-plural-format](docs/rules/consistent-plural-format.md) | Enforces consistent plural format — either `#` hash or `${var}` template literals. | ✅ |
|
|
128
|
-
| [
|
|
150
|
+
| Rule | Description | Recommended | Fixable | OXLint |
|
|
151
|
+
|------|-------------|:-----------:|:-------:|:------:|
|
|
152
|
+
| [no-unlocalized-strings](docs/rules/no-unlocalized-strings.md) | Catches user-visible strings not wrapped in Lingui macros. Uses TypeScript types to skip technical strings automatically. | error | ✅ | *1 |
|
|
153
|
+
| [no-single-variables-to-translate](docs/rules/no-single-variables-to-translate.md) | Prevents messages with only variables and no text — translators need context. | error | — | ✅ |
|
|
154
|
+
| [no-single-tag-to-translate](docs/rules/no-single-tag-to-translate.md) | Prevents `<Trans>` wrapping a single JSX element without surrounding text. | error | — | ✅ |
|
|
155
|
+
| [no-nested-macros](docs/rules/no-nested-macros.md) | Prevents nesting Lingui macros inside each other — nested macros produce broken catalogs. | error | — | ✅ |
|
|
156
|
+
| [no-expression-in-message](docs/rules/no-expression-in-message.md) | Keeps expressions simple inside messages. Complex logic goes into named variables. | warn | — | ✅ |
|
|
157
|
+
| [t-call-in-function](docs/rules/t-call-in-function.md) | Keeps `t` macro calls inside functions where i18n is initialized. | warn | — | ✅ |
|
|
158
|
+
| [consistent-plural-format](docs/rules/consistent-plural-format.md) | Enforces consistent plural format — either `#` hash or `${var}` template literals. | warn | ✅ | ✅ |
|
|
159
|
+
| [prefer-trans-in-jsx](docs/rules/prefer-trans-in-jsx.md) | Prefers `<Trans>` over `` {t`...`} `` in JSX for consistency. | warn | ✅ | ✅ |
|
|
160
|
+
| [text-restrictions](docs/rules/text-restrictions.md) | Enforces project-specific text patterns and restrictions. Requires configuration. | — | — | ✅ |
|
|
161
|
+
|
|
162
|
+
*1 Requires TypeScript's type checker to distinguish UI text from technical strings. OXLint's [type-aware linting](https://oxc.rs/blog/2025-12-08-type-aware-alpha) is in alpha — once stable, this rule will be supported too.
|
|
129
163
|
|
|
130
164
|
## Branded types for edge cases
|
|
131
165
|
|
|
@@ -154,6 +188,7 @@ logger.error("Connection failed:", error) // Not flagged
|
|
|
154
188
|
| `UnlocalizedClassName` | CSS class names |
|
|
155
189
|
| `UnlocalizedEvent` | Analytics/tracking event names |
|
|
156
190
|
| `UnlocalizedKey` | Storage keys, query keys |
|
|
191
|
+
| `UnlocalizedRecord<K>` | Key-value maps (`Record<K, UnlocalizedText>`) |
|
|
157
192
|
|
|
158
193
|
As the plugin gets smarter, some brands become unnecessary. Enable `reportUnnecessaryBrands` to find the ones you can remove:
|
|
159
194
|
|
|
@@ -217,6 +252,7 @@ Contributions welcome. See the [Contributing Guide](CONTRIBUTING.md) and [Code o
|
|
|
217
252
|
- [Lingui](https://lingui.dev/) — The i18n library this plugin is built for
|
|
218
253
|
- [eslint-plugin-lingui](https://github.com/lingui/eslint-plugin-lingui) — The official Lingui ESLint plugin
|
|
219
254
|
- [typescript-eslint](https://typescript-eslint.io/) — Makes type-aware linting possible
|
|
255
|
+
- [OXLint](https://oxc.rs/) — High-performance linter with JS plugin support
|
|
220
256
|
|
|
221
257
|
## License
|
|
222
258
|
|
package/dist/index.js
CHANGED
|
@@ -43,13 +43,13 @@ plugin.configs = {
|
|
|
43
43
|
"lingui-ts": plugin
|
|
44
44
|
},
|
|
45
45
|
rules: {
|
|
46
|
-
"lingui-ts/consistent-plural-format": "
|
|
47
|
-
"lingui-ts/no-expression-in-message": "
|
|
46
|
+
"lingui-ts/consistent-plural-format": "warn",
|
|
47
|
+
"lingui-ts/no-expression-in-message": "warn",
|
|
48
48
|
"lingui-ts/no-nested-macros": "error",
|
|
49
49
|
"lingui-ts/no-single-tag-to-translate": "error",
|
|
50
50
|
"lingui-ts/no-single-variables-to-translate": "error",
|
|
51
51
|
"lingui-ts/no-unlocalized-strings": "error",
|
|
52
|
-
"lingui-ts/t-call-in-function": "
|
|
52
|
+
"lingui-ts/t-call-in-function": "warn",
|
|
53
53
|
"lingui-ts/prefer-trans-in-jsx": "warn"
|
|
54
54
|
// text-restrictions not in recommended (requires configuration)
|
|
55
55
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAC3F,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAyB,CAAA;AAC7F,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,IAAI,OAAO,CAAA;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAC9E,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D,MAAM,MAAM,GAAG;IACb,IAAI,EAAE;QACJ,IAAI,EAAE,iCAAiC;QACvC,OAAO,EAAE,cAAc;KACxB;IAC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AE,MAAM,6CAA6C,CAAA;AAC1F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D,MAAM,MAAM,GAAG;IACb,IAAI,EAAE;QACJ,IAAI,EAAE,iCAAiC;QACvC,OAAO,EAAE,cAAc;KACxB;IACD,KAAK,EAAE;QACL,0BAA0B,EAAE,sBAAsB;QAClD,0BAA0B,EAAE,qBAAqB;QACjD,kBAAkB,EAAE,cAAc;QAClC,4BAA4B,EAAE,sBAAsB;QACpD,kCAAkC,EAAE,4BAA4B;QAChE,wBAAwB,EAAE,oBAAoB;QAC9C,qBAAqB,EAAE,gBAAgB;QACvC,mBAAmB,EAAE,gBAAgB;QACrC,oBAAoB,EAAE,eAAe;KACtC;IACD,OAAO,EAAE,EAA6B;CACvC,CAAA;AAED,sCAAsC;AACtC,MAAM,CAAC,OAAO,GAAG;IACf,kBAAkB,EAAE;QAClB,OAAO,EAAE;YACP,WAAW,EAAE,MAAM;SACpB;QACD,KAAK,EAAE;YACL,oCAAoC,EAAE,MAAM;YAC5C,oCAAoC,EAAE,MAAM;YAC5C,4BAA4B,EAAE,OAAO;YACrC,sCAAsC,EAAE,OAAO;YAC/C,4CAA4C,EAAE,OAAO;YACrD,kCAAkC,EAAE,OAAO;YAC3C,8BAA8B,EAAE,MAAM;YACtC,+BAA+B,EAAE,MAAM;YACvC,gEAAgE;SACjE;KACF;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { type TSESLint } from "@typescript-eslint/utils";
|
|
1
2
|
type MessageId = "hashRequired" | "templateRequired";
|
|
2
3
|
type Style = "hash" | "template";
|
|
3
4
|
export interface Options {
|
|
4
5
|
style: Style;
|
|
5
6
|
}
|
|
6
|
-
export declare const consistentPluralFormat:
|
|
7
|
+
export declare const consistentPluralFormat: TSESLint.RuleModule<MessageId, [Options], unknown, TSESLint.RuleListener>;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=consistent-plural-format.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consistent-plural-format.d.ts","sourceRoot":"","sources":["../../src/rules/consistent-plural-format.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"consistent-plural-format.d.ts","sourceRoot":"","sources":["../../src/rules/consistent-plural-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAiB,MAAM,0BAA0B,CAAA;AAIvF,KAAK,SAAS,GAAG,cAAc,GAAG,kBAAkB,CAAA;AAEpD,KAAK,KAAK,GAAG,MAAM,GAAG,UAAU,CAAA;AAEhC,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,KAAK,CAAA;CACb;AAiID,eAAO,MAAM,sBAAsB,2EA0KjC,CAAA"}
|
|
@@ -104,6 +104,7 @@ export const consistentPluralFormat = createRule({
|
|
|
104
104
|
name: "consistent-plural-format",
|
|
105
105
|
meta: {
|
|
106
106
|
type: "problem",
|
|
107
|
+
fixable: "code",
|
|
107
108
|
docs: {
|
|
108
109
|
description: "Enforce consistent plural format style (# hash or ${var} template)"
|
|
109
110
|
},
|
|
@@ -131,6 +132,73 @@ export const consistentPluralFormat = createRule({
|
|
|
131
132
|
}
|
|
132
133
|
],
|
|
133
134
|
create(context, [options]) {
|
|
135
|
+
const sourceCode = context.sourceCode;
|
|
136
|
+
/**
|
|
137
|
+
* Fix: convert template format (${var}) to hash format (#).
|
|
138
|
+
*/
|
|
139
|
+
function fixToHash(fixer, node, valueVar) {
|
|
140
|
+
if (valueVar === null || node.type !== AST_NODE_TYPES.TemplateLiteral) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const allExpressionsAreVar = node.expressions.every((expr) => expr.type === AST_NODE_TYPES.Identifier && expr.name === valueVar);
|
|
144
|
+
if (allExpressionsAreVar) {
|
|
145
|
+
// All expressions are the count variable — produce a plain string with #
|
|
146
|
+
let content = "";
|
|
147
|
+
for (const [i, quasi] of node.quasis.entries()) {
|
|
148
|
+
content += quasi.value.cooked;
|
|
149
|
+
if (i < node.expressions.length) {
|
|
150
|
+
content += "#";
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const escaped = content.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
154
|
+
const replacement = `"${escaped}"`;
|
|
155
|
+
// In JSX, replace the entire {`...`} container with "..."
|
|
156
|
+
const { parent } = node;
|
|
157
|
+
if (parent.type === AST_NODE_TYPES.JSXExpressionContainer) {
|
|
158
|
+
return fixer.replaceText(parent, replacement);
|
|
159
|
+
}
|
|
160
|
+
return fixer.replaceText(node, replacement);
|
|
161
|
+
}
|
|
162
|
+
// Some expressions are not the count variable — only replace ${varName} with #
|
|
163
|
+
const fixes = [];
|
|
164
|
+
for (const expr of node.expressions) {
|
|
165
|
+
if (expr.type === AST_NODE_TYPES.Identifier && expr.name === valueVar) {
|
|
166
|
+
fixes.push(fixer.replaceTextRange([expr.range[0] - 2, expr.range[1] + 1], "#"));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return fixes.length > 0 ? fixes : null;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Fix: convert hash format (#) to template format (${var}).
|
|
173
|
+
*/
|
|
174
|
+
function fixToTemplate(fixer, node, valueVar) {
|
|
175
|
+
if (valueVar === null) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
if (node.type === AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
179
|
+
const content = node.value.replace(/#/g, `\${${valueVar}}`);
|
|
180
|
+
const replacement = `\`${content}\``;
|
|
181
|
+
// In JSX: one="# item" → one={`${count} item`}
|
|
182
|
+
const { parent } = node;
|
|
183
|
+
if (parent.type === AST_NODE_TYPES.JSXAttribute) {
|
|
184
|
+
return fixer.replaceText(node, `{${replacement}}`);
|
|
185
|
+
}
|
|
186
|
+
return fixer.replaceText(node, replacement);
|
|
187
|
+
}
|
|
188
|
+
if (node.type === AST_NODE_TYPES.TemplateLiteral) {
|
|
189
|
+
// Rebuild template literal, replacing # in static text with ${varName}
|
|
190
|
+
let newText = "`";
|
|
191
|
+
for (const [i, quasi] of node.quasis.entries()) {
|
|
192
|
+
newText += quasi.value.raw.replace(/#/g, `\${${valueVar}}`);
|
|
193
|
+
if (i < node.expressions.length) {
|
|
194
|
+
newText += `\${${sourceCode.getText(node.expressions[i])}}`;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
newText += "`";
|
|
198
|
+
return fixer.replaceText(node, newText);
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
134
202
|
function checkPluralNode(node) {
|
|
135
203
|
const info = getPluralInfo(node);
|
|
136
204
|
if (info === undefined) {
|
|
@@ -141,22 +209,26 @@ export const consistentPluralFormat = createRule({
|
|
|
141
209
|
const hasHash = opt.stringValue !== null && usesHashFormat(opt.stringValue);
|
|
142
210
|
const hasTemplate = usesTemplateFormat(opt.value, valueVar);
|
|
143
211
|
if (options.style === "hash") {
|
|
144
|
-
// Hash required: error if using template format
|
|
145
212
|
if (hasTemplate && !hasHash) {
|
|
146
213
|
context.report({
|
|
147
214
|
node: opt.value,
|
|
148
215
|
messageId: "hashRequired",
|
|
149
|
-
data: { key: opt.key }
|
|
216
|
+
data: { key: opt.key },
|
|
217
|
+
fix(fixer) {
|
|
218
|
+
return fixToHash(fixer, opt.value, valueVar);
|
|
219
|
+
}
|
|
150
220
|
});
|
|
151
221
|
}
|
|
152
222
|
}
|
|
153
223
|
else {
|
|
154
|
-
// Template required: error if using hash format
|
|
155
224
|
if (hasHash && !hasTemplate) {
|
|
156
225
|
context.report({
|
|
157
226
|
node: opt.value,
|
|
158
227
|
messageId: "templateRequired",
|
|
159
|
-
data: { key: opt.key }
|
|
228
|
+
data: { key: opt.key },
|
|
229
|
+
fix(fixer) {
|
|
230
|
+
return fixToTemplate(fixer, opt.value, valueVar);
|
|
231
|
+
}
|
|
160
232
|
});
|
|
161
233
|
}
|
|
162
234
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consistent-plural-format.js","sourceRoot":"","sources":["../../src/rules/consistent-plural-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"consistent-plural-format.js","sourceRoot":"","sources":["../../src/rules/consistent-plural-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgC,MAAM,0BAA0B,CAAA;AAEvF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAUpD,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AAEtE;;GAEG;AACH,SAAS,aAAa,CAAC,IAAmD;IAMxE,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,cAAc,EAAE,CAAC;QAChD,qDAAqD;QACrD,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACpF,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC,SAAS,CAAA;QAC7C,IAAI,UAAU,EAAE,IAAI,KAAK,cAAc,CAAC,gBAAgB,EAAE,CAAC;YACzD,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,MAAM,QAAQ,GAAG,QAAQ,EAAE,IAAI,KAAK,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;QAEpF,MAAM,OAAO,GAAwE,EAAE,CA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AAC;oBACN,IAAI,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;wBAC5B,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,GAAG,CAAC,KAAK;4BACf,SAAS,EAAE,kBAAkB;4BAC7B,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE;4BACtB,GAAG,CAAC,KAAK;gCACP,OAAO,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;4BAClD,CAAC;yBACF,CAAC,CAAA;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO;YACL,cAAc,CAAC,IAAI;gBACjB,eAAe,CAAC,IAAI,CAAC,CAAA;YACvB,CAAC;YACD,UAAU,CAAC,IAAI;gBACb,eAAe,CAAC,IAAI,CAAC,CAAA;YACvB,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -57,6 +57,7 @@ ruleTester.run("consistent-plural-format", consistentPluralFormat, {
|
|
|
57
57
|
// plural() with template when hash expected
|
|
58
58
|
{
|
|
59
59
|
code: "plural(numBooks, { one: `${numBooks} book`, other: `${numBooks} books` })",
|
|
60
|
+
output: 'plural(numBooks, { one: "# book", other: "# books" })',
|
|
60
61
|
errors: [
|
|
61
62
|
{ messageId: "hashRequired", data: { key: "one" } },
|
|
62
63
|
{ messageId: "hashRequired", data: { key: "other" } }
|
|
@@ -65,6 +66,7 @@ ruleTester.run("consistent-plural-format", consistentPluralFormat, {
|
|
|
65
66
|
// Mixed: some hash, some template
|
|
66
67
|
{
|
|
67
68
|
code: 'plural(count, { zero: `${count} items`, one: "# item", other: `${count} items` })',
|
|
69
|
+
output: 'plural(count, { zero: "# items", one: "# item", other: "# items" })',
|
|
68
70
|
errors: [
|
|
69
71
|
{ messageId: "hashRequired", data: { key: "zero" } },
|
|
70
72
|
{ messageId: "hashRequired", data: { key: "other" } }
|
|
@@ -73,6 +75,7 @@ ruleTester.run("consistent-plural-format", consistentPluralFormat, {
|
|
|
73
75
|
// <Plural> with template when hash expected
|
|
74
76
|
{
|
|
75
77
|
code: "<Plural value={count} one={`${count} item`} other={`${count} items`} />",
|
|
78
|
+
output: '<Plural value={count} one="# item" other="# items" />',
|
|
76
79
|
errors: [
|
|
77
80
|
{ messageId: "hashRequired", data: { key: "one" } },
|
|
78
81
|
{ messageId: "hashRequired", data: { key: "other" } }
|
|
@@ -82,6 +85,7 @@ ruleTester.run("consistent-plural-format", consistentPluralFormat, {
|
|
|
82
85
|
// plural() with hash when template expected
|
|
83
86
|
{
|
|
84
87
|
code: 'plural(numBooks, { one: "# book", other: "# books" })',
|
|
88
|
+
output: "plural(numBooks, { one: `${numBooks} book`, other: `${numBooks} books` })",
|
|
85
89
|
options: [{ style: "template" }],
|
|
86
90
|
errors: [
|
|
87
91
|
{ messageId: "templateRequired", data: { key: "one" } },
|
|
@@ -91,6 +95,7 @@ ruleTester.run("consistent-plural-format", consistentPluralFormat, {
|
|
|
91
95
|
// Mixed: some template, some hash
|
|
92
96
|
{
|
|
93
97
|
code: 'plural(count, { zero: "# items", one: `${count} item`, other: "# items" })',
|
|
98
|
+
output: "plural(count, { zero: `${count} items`, one: `${count} item`, other: `${count} items` })",
|
|
94
99
|
options: [{ style: "template" }],
|
|
95
100
|
errors: [
|
|
96
101
|
{ messageId: "templateRequired", data: { key: "zero" } },
|
|
@@ -100,6 +105,7 @@ ruleTester.run("consistent-plural-format", consistentPluralFormat, {
|
|
|
100
105
|
// <Plural> with hash when template expected
|
|
101
106
|
{
|
|
102
107
|
code: '<Plural value={count} one="# item" other="# items" />',
|
|
108
|
+
output: "<Plural value={count} one={`${count} item`} other={`${count} items`} />",
|
|
103
109
|
options: [{ style: "template" }],
|
|
104
110
|
errors: [
|
|
105
111
|
{ messageId: "templateRequired", data: { key: "one" } },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consistent-plural-format.test.js","sourceRoot":"","sources":["../../src/r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UAAU,EAAE,CAAC;YAChC,MAAM,EAAE;gBACN,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;gBACxD,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;aAC1D;SACF;QAED,4CAA4C;QAC5C;YACE,IAAI,EAAE,uDAAuD;YAC7D,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;YAChC,MAAM,EAAE;gBACN,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;gBACvD,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;aAC1D;SACF;KACF;CACF,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"consistent-plural-format.test.js","sourceRoot":"","sources":["../../src/rules/consistent-plural-format.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAEtE,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAA;AAC9B,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAA;AAC9B,UAAU,CAAC,EAAE,GAAG,EAAE,CAAA;AAElB,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC;IAChC,eAAe,EAAE;QACf,aAAa,EAAE;YACb,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,QAAQ;YACpB,YAAY,EAAE;gBACZ,GAAG,EAAE,IAAI;aACV;SACF;KACF;CACF,CAAC,CAAA;AAEF,UAAU,CAAC,GAAG,CAAC,0BAA0B,EAAE,sBAAsB,EAAE;IACj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AS,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;aAC1D;SACF;KACF;CACF,CAAC,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -249,13 +249,15 @@ export type UnlocalizedKey = string & {
|
|
|
249
249
|
* ```ts
|
|
250
250
|
* import type { UnlocalizedRecord } from "eslint-plugin-lingui-typescript/types"
|
|
251
251
|
*
|
|
252
|
-
* //
|
|
252
|
+
* // Simple key-value map
|
|
253
253
|
* const svgProps: UnlocalizedRecord = { fill: "red", stroke: "blue" }
|
|
254
254
|
*
|
|
255
|
-
* //
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
255
|
+
* // With typed keys
|
|
256
|
+
* type SvgProp = "fill" | "stroke" | "opacity"
|
|
257
|
+
* const defaults: UnlocalizedRecord<SvgProp> = {
|
|
258
|
+
* fill: "currentColor",
|
|
259
|
+
* stroke: "none",
|
|
260
|
+
* opacity: "1",
|
|
259
261
|
* }
|
|
260
262
|
*
|
|
261
263
|
* // Component props
|
|
@@ -264,5 +266,5 @@ export type UnlocalizedKey = string & {
|
|
|
264
266
|
* }
|
|
265
267
|
* ```
|
|
266
268
|
*/
|
|
267
|
-
export type UnlocalizedRecord = Record<
|
|
269
|
+
export type UnlocalizedRecord<K extends string = string> = Record<K, UnlocalizedText>;
|
|
268
270
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAG,gBAAyB,CAAA;AAE5D;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAG,oBAA6B,CAAA;AAMrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,MAAM,mBAA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AAE,gBAAgB,CAAA;CAAE,CAAA;AAMpF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,eAAe,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-lingui-typescript",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "ESLint plugin for Lingui with TypeScript type-aware rules",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"format:check": "prettier --check .",
|
|
36
36
|
"test": "vitest run",
|
|
37
37
|
"test:watch": "vitest",
|
|
38
|
+
"test:oxlint": "tests/oxlint/smoke-test.sh",
|
|
38
39
|
"typecheck": "tsc --noEmit",
|
|
39
40
|
"prepublishOnly": "npm run build",
|
|
40
41
|
"prepare": "husky",
|