Skip to content

test(multiline-ternary): make tests more strict #2853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 43 additions & 36 deletions tests/lib/rules/multiline-ternary.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
*/
'use strict'

const { RuleTester, ESLint } = require('../../eslint-compat')
const { RuleTester } = require('../../eslint-compat')
const rule = require('../../../lib/rules/multiline-ternary')
const semver = require('semver')

const tester = new RuleTester({
languageOptions: {
Expand Down Expand Up @@ -80,8 +79,7 @@ tester.run('multiline-ternary', rule, {
</div>
</template>
`,
output: semver.gte(ESLint.version, '7.1.0')
? `
output: `
<template>
<div :class="{
'test': someReallyLongCondition ?
Expand All @@ -90,15 +88,16 @@ tester.run('multiline-ternary', rule, {
}">
</div>
</template>
`
: null,
`,
options: ['always-multiline'],
errors: [
{
message:
'Expected newline between consequent and alternate of ternary expression.',
line: 5,
column: 15
column: 15,
endLine: 5,
endColumn: 30
}
]
},
Expand All @@ -113,23 +112,23 @@ tester.run('multiline-ternary', rule, {
</div>
</template>
`,
output: semver.gte(ESLint.version, '7.1.0')
? `
output: `
<template>
<div :class="{
'test': someReallyLongCondition ?aVeryLongOutput : thisCantFitOnASingleLine
}">
</div>
</template>
`
: null,
`,
options: ['never'],
errors: [
{
message:
'Unexpected newline between test and consequent of ternary expression.',
line: 4,
column: 21
column: 21,
endLine: 4,
endColumn: 44
}
]
},
Expand All @@ -143,8 +142,7 @@ tester.run('multiline-ternary', rule, {
</div>
</template>
`,
output: semver.gte(ESLint.version, '7.1.0')
? `
output: `
<template>
<div :class="{
'test': someReallyLongCondition
Expand All @@ -153,20 +151,23 @@ tester.run('multiline-ternary', rule, {
}">
</div>
</template>
`
: null,
`,
errors: [
{
message:
'Expected newline between test and consequent of ternary expression.',
line: 4,
column: 21
column: 21,
endLine: 4,
endColumn: 44
},
{
message:
'Expected newline between consequent and alternate of ternary expression.',
line: 4,
column: 47
column: 47,
endLine: 4,
endColumn: 62
}
]
},
Expand All @@ -180,8 +181,7 @@ tester.run('multiline-ternary', rule, {
</div>
</template>
`,
output: semver.gte(ESLint.version, '7.1.0')
? `
output: `
<template>
<div :style="{
'test': someReallyLongCondition
Expand All @@ -190,20 +190,23 @@ tester.run('multiline-ternary', rule, {
}">
</div>
</template>
`
: null,
`,
errors: [
{
message:
'Expected newline between test and consequent of ternary expression.',
line: 4,
column: 21
column: 21,
endLine: 4,
endColumn: 44
},
{
message:
'Expected newline between consequent and alternate of ternary expression.',
line: 4,
column: 47
column: 47,
endLine: 4,
endColumn: 62
}
]
},
Expand All @@ -220,8 +223,7 @@ tester.run('multiline-ternary', rule, {
}
</style>
`,
output: semver.gte(ESLint.version, '7.1.0')
? `
output: `
<template>
<div class="test">
</div>
Expand All @@ -233,20 +235,23 @@ tester.run('multiline-ternary', rule, {
: thisCantFitOnASingleLine')
}
</style>
`
: null,
`,
errors: [
{
message:
'Expected newline between test and consequent of ternary expression.',
line: 8,
column: 30
column: 30,
endLine: 8,
endColumn: 53
},
{
message:
'Expected newline between consequent and alternate of ternary expression.',
line: 8,
column: 56
column: 56,
endLine: 8,
endColumn: 71
}
]
},
Expand All @@ -263,8 +268,7 @@ tester.run('multiline-ternary', rule, {
let test = someReallyLongCondition ? aVeryLongOutput : thisCantFitOnASingleLine
</script>
`,
output: semver.gte(ESLint.version, '7.1.0')
? `
output: `
<template>
<div :class="{
'test': someReallyLongCondition
Expand All @@ -276,20 +280,23 @@ tester.run('multiline-ternary', rule, {
<script>
let test = someReallyLongCondition ? aVeryLongOutput : thisCantFitOnASingleLine
</script>
`
: null,
`,
errors: [
{
message:
'Expected newline between test and consequent of ternary expression.',
line: 4,
column: 19
column: 19,
endLine: 4,
endColumn: 42
},
{
message:
'Expected newline between consequent and alternate of ternary expression.',
line: 4,
column: 45
column: 45,
endLine: 4,
endColumn: 60
}
]
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy