/
report-error-message-formtat.js
44 lines (42 loc) 路 1.81 KB
/
report-error-message-formtat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";
import rule from "../../lib/rules/report-error-message-format.js";
const ruleTester = new RuleTester();
ruleTester.run("report-error-message-format", rule, {
valid: [
"makeErrorTemplates({});",
'makeErrorTemplates({ ThisIsAnError: "This is an error." });',
`makeErrorTemplates({ ThisIsAnError: "'this' is an error." });`,
`makeErrorTemplates({ ThisIsAnError: "\`this\` is an error." });`,
`makeErrorTemplates({ ThisIsAnError: "This is an error?" });`,
`makeErrorTemplates({ ThisIsAnError: "'this' is an error?" });`,
`makeErrorTemplates({ ThisIsAnError: "\`this\` is an error?" });`,
'makeErrorTemplates({ ThisIsAnError: "This is\\nan error." });',
`makeErrorTemplates({ ThisIsAnError: "'this' is\\nan error." });`,
`makeErrorTemplates({ ThisIsAnError: "\`this\` is\\nan error." });`,
`makeErrorTemplates({ ThisIsAnError: "This is\\nan error?" });`,
`makeErrorTemplates({ ThisIsAnError: "'this' is\\nan error?" });`,
`makeErrorTemplates({ ThisIsAnError: "\`this\` is\\nan error?" });`,
],
invalid: [
{
code: "makeErrorTemplates({ ThisIsAnError: 'this is an error.' });",
errors: [{ messageId: "mustMatchPattern" }],
},
{
code: "makeErrorTemplates({ ThisIsAnError: 'This is an error' });",
errors: [{ messageId: "mustMatchPattern" }],
},
{
code: "makeErrorTemplates({ ThisIsAnError: 'this is an error?' });",
errors: [{ messageId: "mustMatchPattern" }],
},
{
code: "makeErrorTemplates({ ThisIsAnError: '`this` is an error' });",
errors: [{ messageId: "mustMatchPattern" }],
},
{
code: `makeErrorTemplates({ ThisIsAnError: "'this' is an error" });`,
errors: [{ messageId: "mustMatchPattern" }],
},
],
});