Skip to content

Commit

Permalink
Add --treatValidationWarningsAsErrors
Browse files Browse the repository at this point in the history
Closes #2199
  • Loading branch information
Gerrit0 committed Mar 16, 2023
1 parent c1b5ebd commit 4855eb6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Unreleased

### Features

- Added `--treatValidationWarningsAsErrors` to turn treat only validation warnings as errors without treating all warnings as errors, #2199.

### Bug Fixes

- Fixed a bug where optional properties were not appropriately marked as optional, #2200.
Expand Down
8 changes: 6 additions & 2 deletions bin/typedoc
Expand Up @@ -94,13 +94,17 @@ async function run(app) {
return ExitCodes.CompileError;
}

const preValidationWarnCount = app.logger.warningCount;
app.validate(project);
const hadValidationWarnings =
app.logger.warningCount !== preValidationWarnCount;
if (app.logger.hasErrors()) {
return ExitCodes.ValidationError;
}
if (
app.options.getValue("treatWarningsAsErrors") &&
app.logger.hasWarnings()
hadValidationWarnings &&
(app.options.getValue("treatWarningsAsErrors") ||
app.options.getValue("treatValidationWarningsAsErrors"))
) {
return ExitCodes.ValidationError;
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/utils/options/declaration.ts
Expand Up @@ -157,6 +157,7 @@ export interface TypeDocOptionMap {

// Validation
treatWarningsAsErrors: boolean;
treatValidationWarningsAsErrors: boolean;
intentionallyNotExported: string[];
validation: ValidationOptions;
requiredToBeDocumented: (keyof typeof ReflectionKind)[];
Expand Down
7 changes: 6 additions & 1 deletion src/lib/utils/options/sources/typedoc.ts
Expand Up @@ -656,7 +656,12 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {

options.addDeclaration({
name: "treatWarningsAsErrors",
help: "If set, warnings will be treated as errors.",
help: "If set, all warnings will be treated as errors.",
type: ParameterType.Boolean,
});
options.addDeclaration({
name: "treatValidationWarningsAsErrors",
help: "If set, warnings emitted during validation will be treated as errors. This option cannot be used to disable treatWarningsAsErrors for validation warnings.",
type: ParameterType.Boolean,
});
options.addDeclaration({
Expand Down

0 comments on commit 4855eb6

Please sign in to comment.