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.
Suggestion
There should be an method that disables
no-multiple-lines-of-errorsfor some tests, just likenoFormatdoes forplugin-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 triggerno-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.typescript-eslint/packages/eslint-plugin-internal/tests/rules/plugin-test-formatting.test.ts
Lines 890 to 1072 in b7b2670
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.