Skip to content
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

[rush] Add suppressedWarnings option #1224

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@
"temp": true,
"**/test/**/temp": false,
"coverage": true
},
"files.associations": {
"rush.json": "jsonc",
"**/common/config/rush/*.json": "jsonc"
}
}
8 changes: 8 additions & 0 deletions apps/rush-lib/assets/rush-init/rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
13 changes: 13 additions & 0 deletions apps/rush-lib/src/api/RushConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export interface IRushConfigurationJson {
yarnOptions?: IYarnOptionsJson;
ensureConsistentVersions?: boolean;
variants?: IRushVariantOptionsJson[];
suppressedWarnings?: string[];
}

/**
Expand Down Expand Up @@ -246,6 +247,7 @@ export class RushConfiguration {
private _variants: {
[variantName: string]: boolean;
};
private _suppressedWarnings: RegExp[];

// "approvedPackagesPolicy" feature
private _approvedPackagesPolicy: ApprovedPackagesPolicy;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 || { });

Expand Down
10 changes: 8 additions & 2 deletions apps/rush-lib/src/logic/taskRunner/ProjectTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
9 changes: 8 additions & 1 deletion apps/rush-lib/src/schemas/rush.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add suppressedWarnings option",
"packageName": "@microsoft/rush",
"type": "none"
}
],
"packageName": "@microsoft/rush",
"email": "[email protected]"
}
1 change: 1 addition & 0 deletions common/reviews/api/rush-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down