-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
442 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
import printResults from '../helpers/print-results.js'; | ||
|
||
export default class PrettyFormatter { | ||
export default class MultiFormatter { | ||
constructor(options = {}) { | ||
this.options = options; | ||
} | ||
|
||
format(results, todoInfo) { | ||
async format(results, todoInfo) { | ||
let formatConfig = this.options.config.format; | ||
|
||
if (!formatConfig && !formatConfig.formatters) { | ||
return ''; | ||
} | ||
if (formatConfig && formatConfig.formatters) { | ||
// The following disable should be safe. This particular rule does not need to identify | ||
// cycles that are broken when using dynamic imports. See https://github.com/import-js/eslint-plugin-import/issues/2265 | ||
// eslint-disable-next-line import/no-cycle | ||
const { default: printResults } = await import('../helpers/print-results.js'); | ||
for (let formatter of formatConfig.formatters) { | ||
let formatterOptions = { | ||
options: Object.assign({}, this.options, { | ||
format: formatter.name, | ||
}), | ||
todoInfo, | ||
config: this.options.config, | ||
}; | ||
|
||
for (let formatter of formatConfig.formatters) { | ||
let formatterOptions = { | ||
options: Object.assign({}, this.options, { | ||
format: formatter.name, | ||
}), | ||
todoInfo, | ||
config: this.options.config, | ||
}; | ||
if (formatter.outputFile) { | ||
formatterOptions.options.outputFile = formatter.outputFile; | ||
} | ||
|
||
if (formatter.outputFile) { | ||
formatterOptions.options.outputFile = formatter.outputFile; | ||
await printResults(results, formatterOptions); | ||
} | ||
|
||
printResults(results, formatterOptions); | ||
} | ||
|
||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.