diff --git a/.vscode/settings.json b/.vscode/settings.json index 0f0399082a6..cb928ceff40 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,5 +17,9 @@ "temp": true, "**/test/**/temp": false, "coverage": true + }, + "files.associations": { + "rush.json": "jsonc", + "**/common/config/rush/*.json": "jsonc" } } diff --git a/apps/rush-lib/assets/rush-init/rush.json b/apps/rush-lib/assets/rush-init/rush.json index 62fa181790e..ccef81732ee 100644 --- a/apps/rush-lib/assets/rush-init/rush.json +++ b/apps/rush-lib/assets/rush-init/rush.json @@ -270,6 +270,14 @@ */ /*[LINE "HYPOTHETICAL"]*/ "hotfixChangeEnabled": false, + /** + * If a warning message matches any of the regular expressions listed here, it should be treated + * as a standard log message rather than a warning. This prevents inconsequential warning messages + * caused by external packages from breaking incremental builds (packages marked as "success with + * warnings" will be rebuilt on each rush build). + */ + /*[LINE "HYPOTHETICAL"]*/ "suppressedWarnings": [], + /** * (Required) This is the inventory of projects to be managed by Rush. * diff --git a/apps/rush-lib/src/api/RushConfiguration.ts b/apps/rush-lib/src/api/RushConfiguration.ts index fb337793f31..5b954585dc1 100644 --- a/apps/rush-lib/src/api/RushConfiguration.ts +++ b/apps/rush-lib/src/api/RushConfiguration.ts @@ -122,6 +122,7 @@ export interface IRushConfigurationJson { yarnOptions?: IYarnOptionsJson; ensureConsistentVersions?: boolean; variants?: IRushVariantOptionsJson[]; + suppressedWarnings?: string[]; } /** @@ -246,6 +247,7 @@ export class RushConfiguration { private _variants: { [variantName: string]: boolean; }; + private _suppressedWarnings: RegExp[]; // "approvedPackagesPolicy" feature private _approvedPackagesPolicy: ApprovedPackagesPolicy; @@ -734,6 +736,14 @@ export class RushConfiguration { return this._ensureConsistentVersions; } + /** + * Gets a list of regular expressions for suppressing warnings. If a warning message + * matches any of these, it should be treated as a standard message rather than an error. + */ + public get suppressedWarnings(): RegExp[] { + return this._suppressedWarnings; + } + /** * Indicates whether telemetry collection is enabled for Rush runs. * @beta @@ -974,6 +984,9 @@ export class RushConfiguration { this._ensureConsistentVersions = !!rushConfigurationJson.ensureConsistentVersions; + const suppressedWarnings: string[] = rushConfigurationJson.suppressedWarnings || []; + this._suppressedWarnings = suppressedWarnings.map((value: string) => new RegExp(value)); + this._pnpmOptions = new PnpmOptionsConfiguration(rushConfigurationJson.pnpmOptions || {}); this._yarnOptions = new YarnOptionsConfiguration(rushConfigurationJson.yarnOptions || { }); diff --git a/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts b/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts index 95a7ba38a6e..43033f28d96 100644 --- a/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts +++ b/apps/rush-lib/src/logic/taskRunner/ProjectTask.ts @@ -160,8 +160,14 @@ export class ProjectTask implements ITaskDefinition { }); task.stderr.on('data', (data: string) => { - writer.writeError(data); - this._hasWarningOrError = true; + // If this error matches any of the suppressed warnings from the config, write it to + // stdout instead of stderr and don't treat the task as having a warning/error. + if (this._rushConfiguration.suppressedWarnings.some((warning: RegExp) => warning.test(data))) { + writer.write(data); + } else { + writer.writeError(data); + this._hasWarningOrError = true; + } }); return new Promise((resolve: (status: TaskStatus) => void, reject: (error: TaskError) => void) => { diff --git a/apps/rush-lib/src/schemas/rush.schema.json b/apps/rush-lib/src/schemas/rush.schema.json index 714969a6345..2251e161cb2 100644 --- a/apps/rush-lib/src/schemas/rush.schema.json +++ b/apps/rush-lib/src/schemas/rush.schema.json @@ -234,7 +234,14 @@ } }, "additionalProperties": false - } + }, + "suppressedWarnings": { + "description": "A list of warning messages which should be treated as standard log messages instead of warnings.", + "type": "array", + "items": { + "type": "string" + } +} }, "additionalProperties": false, "required": [ diff --git a/common/changes/@microsoft/rush/ignore-warnings_2019-04-10-19-30.json b/common/changes/@microsoft/rush/ignore-warnings_2019-04-10-19-30.json new file mode 100644 index 00000000000..6b63444b726 --- /dev/null +++ b/common/changes/@microsoft/rush/ignore-warnings_2019-04-10-19-30.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "Add suppressedWarnings option", + "packageName": "@microsoft/rush", + "type": "none" + } + ], + "packageName": "@microsoft/rush", + "email": "ecraig12345@users.noreply.github.com" +} \ No newline at end of file diff --git a/common/reviews/api/rush-lib.api.md b/common/reviews/api/rush-lib.api.md index 8220d670d8c..9dc98910839 100644 --- a/common/reviews/api/rush-lib.api.md +++ b/common/reviews/api/rush-lib.api.md @@ -259,6 +259,7 @@ export class RushConfiguration { readonly rushJsonFolder: string; readonly rushLinkJsonFilename: string; readonly shrinkwrapFilePhrase: string; + readonly suppressedWarnings: string[]; // @beta readonly telemetryEnabled: boolean; readonly tempShrinkwrapFilename: string; diff --git a/rush.json b/rush.json index 0ad0659eab9..1f1a345d668 100644 --- a/rush.json +++ b/rush.json @@ -223,6 +223,14 @@ */ // "hotfixChangeEnabled": false, + /** + * If a warning message matches any of the regular expressions listed here, it should be treated + * as a standard log message rather than a warning. This prevents inconsequential warning messages + * caused by external packages from breaking incremental builds (packages marked as "success with + * warnings" will be rebuilt on each rush build). + */ + // "suppressedWarnings": [], + /** * (Required) This is the inventory of projects to be managed by Rush. *