Skip to content

Repo: Create a method that allows multiple lines of error #12290

@Vinccool96

Description

@Vinccool96

Suggestion

There should be an method that disables no-multiple-lines-of-errors for some tests, just like noFormat does for plugin-test-formatting.

One such useful case would be in plugin-test-formatting.test.ts, in which some tests are sanity checks that verifies that the rule runs on all tests (as shown below), but none of the errors have their positions specified, as to not trigger no-multiple-lines-of-errors. This would help the test to verify that the errors are indeed at the correct position, while not triggering a linting error.

// sanity check that it runs on all tests
{
code: `
ruleTester.run({
valid: [
{
code: \`foo\`,
},
{
code: \`foo
\`,
},
{
code: \`
foo\`,
},
],
invalid: [
{
code: \`foo\`,
},
{
code: \`foo
\`,
},
{
code: \`
foo\`,
},
],
});
`,
errors: [
{
messageId: 'singleLineQuotes',
},
{
messageId: 'templateLiteralEmptyEnds',
},
{
messageId: 'templateLiteralEmptyEnds',
},
{
messageId: 'singleLineQuotes',
},
{
messageId: 'templateLiteralEmptyEnds',
},
{
messageId: 'templateLiteralEmptyEnds',
},
],
output: [
`
ruleTester.run({
valid: [
{
code: 'foo',
},
{
code: \`
foo
\`,
},
{
code: \`
foo
\`,
},
],
invalid: [
{
code: 'foo',
},
{
code: \`
foo
\`,
},
{
code: \`
foo
\`,
},
],
});
`,
`
ruleTester.run({
valid: [
{
code: 'foo;',
},
{
code: \`
foo
\`,
},
{
code: \`
foo
\`,
},
],
invalid: [
{
code: 'foo;',
},
{
code: \`
foo
\`,
},
{
code: \`
foo
\`,
},
],
});
`,
`
ruleTester.run({
valid: [
{
code: 'foo;',
},
{
code: \`
foo;
\`,
},
{
code: \`
foo
\`,
},
],
invalid: [
{
code: 'foo;',
},
{
code: \`
foo;
\`,
},
{
code: \`
foo
\`,
},
],
});
`,
],
},
// handles prettier errors
{
code: `
ruleTester.run({
valid: [
{
code: 'const x = ";',
},
],
});
`,
errors: [
{
column: 13,
data: {
message: 'Unterminated string literal.',
},
endColumn: 27,
endLine: 5,
line: 5,
messageId: 'prettierException',
},
],
output: null,
},

Additional Info

This may be ported to eslint-plugin-eslint-plugin, since they don't have a rule to prevent multiple lines of errors in the first place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    repo maintenancethings to do with maintenance of the repo, and not with code/docstriageWaiting for team members to take a look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions