Files
test-repo/scripts/tools/eslint-plugin-prettier-internal-rules/jsx-identifier-case.js
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
941 B
JavaScript
Raw Normal View History

2020-12-15 12:23:40 +08:00
const MESSAGE_ID = "jsx-identifier-case";
2026-06-16 02:09:45 +08:00
// To ignore variables, config ESLint like this
2020-12-15 12:23:40 +08:00
// {'prettier-internal-rules/jsx-identifier-case': ['error', 'name1', ... 'nameN']}
export default {
2020-12-15 12:23:40 +08:00
meta: {
type: "suggestion",
messages: {
[MESSAGE_ID]: "Please rename '{{name}}' to '{{fixed}}'.",
},
fixable: "code",
schema: {
type: "array",
uniqueItems: true,
},
2020-12-15 12:23:40 +08:00
},
create(context) {
const ignored = new Set(context.options);
return {
"Identifier[name=/JSX/]:not(ObjectExpression > Property.properties > .key)"(
node,
) {
const { name } = node;
if (ignored.has(name)) {
return;
}
const fixed = name.replaceAll("JSX", "Jsx");
2020-12-15 12:23:40 +08:00
context.report({
node,
messageId: MESSAGE_ID,
data: { name, fixed },
fix: (fixer) => fixer.replaceText(node, fixed),
});
},
};
},
};