Skip to content

Commit 7d56efd

Browse files
RoyLee1224sanederchik
authored andcommitted
feat(ui): add i18n linting warning rules (apache#51131)
* feat(ui): add i18n linting warning rules * fix: check files under src directory
1 parent ff119bf commit 7d56efd

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed

airflow-core/src/airflow/ui/eslint.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* @import { FlatConfig } from "@typescript-eslint/utils/ts-eslint";
2222
*/
2323
import { coreRules } from "./rules/core.js";
24+
import { i18nextRules } from "./rules/i18next.js";
2425
import { perfectionistRules } from "./rules/perfectionist.js";
2526
import { prettierRules } from "./rules/prettier.js";
2627
import { reactRules } from "./rules/react.js";
@@ -44,4 +45,5 @@ export default /** @type {const} @satisfies {ReadonlyArray<FlatConfig.Config>} *
4445
reactRules,
4546
stylisticRules,
4647
unicornRules,
48+
i18nextRules,
4749
]);

airflow-core/src/airflow/ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"@vitest/coverage-v8": "^2.1.9",
7676
"eslint": "^9.25.1",
7777
"eslint-config-prettier": "^10.1.2",
78+
"eslint-plugin-i18next": "^6.1.1",
7879
"eslint-plugin-jsx-a11y": "^6.10.2",
7980
"eslint-plugin-perfectionist": "^4.12.3",
8081
"eslint-plugin-prettier": "^5.2.6",

airflow-core/src/airflow/ui/pnpm-lock.yaml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*!
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/**
21+
* @import { FlatConfig } from "@typescript-eslint/utils/ts-eslint";
22+
*/
23+
import i18nextPlugin from "eslint-plugin-i18next";
24+
25+
import { WARN } from "./levels.js";
26+
27+
const allExtensions = "*.{j,t}s{x,}";
28+
29+
/**
30+
* ESLint rules for i18next to enforce internationalization best practices.
31+
* This is a customized configuration.
32+
*
33+
* @see [eslint-plugin-i18next](https://github.com/edvardchen/eslint-plugin-i18next)
34+
*/
35+
export const i18nextRules = /** @type {const} @satisfies {FlatConfig.Config} */ ({
36+
files: [
37+
// Check files in the ui/src directory
38+
`src/**/${allExtensions}`,
39+
],
40+
plugins: {
41+
i18next: i18nextPlugin,
42+
},
43+
rules: {
44+
/**
45+
* Enforce no literal strings in JSX/TSX markup.
46+
* This rule helps ensure all user-facing strings are properly internationalized.
47+
*
48+
* @example
49+
* ```typescript
50+
* // ❌ Incorrect
51+
* <div>Hello, world!</div>
52+
*
53+
* // ✅ Correct
54+
* <div>{translate('greeting')}</div>
55+
* ```
56+
* @see [i18next/no-literal-string](https://github.com/edvardchen/eslint-plugin-i18next#no-literal-string)
57+
*/
58+
"i18next/no-literal-string": [
59+
WARN,
60+
{
61+
markupOnly: true,
62+
},
63+
],
64+
},
65+
});

0 commit comments

Comments
 (0)