Skip to content

Commit

Permalink
Improve validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 6, 2022
1 parent ecec039 commit 9b896dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/report/formats/detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export const computeFormat = function ({ config: { output } }) {
return format
}

// Validate that a reporter supports the format specified by a given `output`
export const validateFormat = function (
format,
// Validate that a reporter supports the `format` specified by a given `output`
export const validateOutputFormat = function (
output,
{
config: { output },
config: { format },
context: {
plugin,
plugin: { id },
Expand All @@ -43,7 +43,7 @@ export const validateFormat = function (

if (!hasMethod) {
throw new Error(
`must not use unsupported "output: ${output}" with reporter "${id}".`,
`uses a file extension or format not supported by the reporter "${id}".`,
)
}
}
7 changes: 5 additions & 2 deletions src/report/reporters/top_definitions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computeFormat, validateFormat } from '../formats/detect.js'
import { computeFormat, validateOutputFormat } from '../formats/detect.js'
import { isTtyOutput } from '../tty.js'

// Reporter-specific definitions of top-level properties
Expand All @@ -25,7 +25,10 @@ export const reportersTopDefinitions = [
{
name: 'format',
compute: computeFormat,
validate: validateFormat,
},
{
name: 'output',
validate: validateOutputFormat,
},
// `reporter.config.tty` is `true` when output is interactive terminal.
// Several reporter's configuration properties default to `true` only when
Expand Down

0 comments on commit 9b896dd

Please sign in to comment.