Rule Change: support i18n attributes for rule's meta.message template #19210
Open
Description
opened on Dec 4, 2024
What rule do you want to change?
every rule's meta.message attribute
What change do you want to make?
Implement suggestions
How do you think the change should be implemented?
A new default behavior
Example code
// eslint.config.js
module.exports = [
/* ... */
]
// convert to new structure
module.exports = {
language: 'en-US', // en-US as default, and also if not exist rule's language configuration as provided
rules: [ /* ... */ ] // the original rules array
}
What does the rule currently do for this code?
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Require braces around arrow function bodies",
recommended: false,
url: "https://eslint.org/docs/latest/rules/arrow-body-style"
},
messages: {
unexpectedOtherBlock: "Unexpected block statement surrounding arrow body",
unexpectedEmptyBlock: "Unexpected block statement surrounding arrow body; put a value of `undefined` immediately after the `=>`.",
unexpectedObjectBlock: "Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`.",
unexpectedSingleBlock: "Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`.",
expectedBlock: "Expected block statement surrounding arrow body."
}
}
}
What will the rule do after it's changed?
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Require braces around arrow function bodies",
recommended: false,
url: "https://eslint.org/docs/latest/rules/arrow-body-style"
},
messages: {
// support reading i18n object
unexpectedOtherBlock: {
"en-US": "Unexpected block statement surrounding arrow body",
"zh-CN": "不期望箭头函数包裹块语句"
},
unexpectedEmptyBlock: "Unexpected block statement surrounding arrow body; put a value of `undefined` immediately after the `=>`.",
unexpectedObjectBlock: "Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`.",
unexpectedSingleBlock: "Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`.",
expectedBlock: "Expected block statement surrounding arrow body."
}
}
}
Participation
- I am willing to submit a pull request to implement this change.
Additional comments
No response
Metadata
Assignees
Labels
Type
Projects
Status
RFC Opened
Activity