Debian Codegraph @

eslint/babel-eslint-plugin-development-internal/src/rules/report-error-message-format.cjs

raw symbols SCIP
1 const messageId = "mustMatchPattern";
2
3 const pattern = /(('.*')|(`.*`)|[A-Z]).*(\.|\?)$/s;
4
5 module.exports = {
6 meta: {
7 type: "suggestion",
8 docs: {
9 description: "enforce @babel/parser's error message formatting.",
10 },
11 messages: {
12 [messageId]: `Report message does not match the pattern ${pattern.toString()}.`,
13 },
14 },
15 create({ report }) {
16 return {
17 "CallExpression[callee.type='Identifier'][callee.name='makeErrorTemplates'] > ObjectExpression > Property[value.type='Literal']"(
18 node,
19 ) {
20 const { value } = node;
21 if (typeof value.value === "string" && pattern.test(value.value)) {
22 return;
23 }
24 report({
25 node: value,
26 messageId,
27 });
28 },
29 };
30 },
31 };