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

ignoreLintWarnings option #213

Merged
merged 8 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface Options {
async: boolean;
ignoreDiagnostics: number[];
ignoreLints: string[];
ignoreLintWarnings: boolean;
reportFiles: string[];
colors: boolean;
logger: Logger;
Expand Down Expand Up @@ -84,6 +85,7 @@ class ForkTsCheckerWebpackPlugin {
private watch: string[];
private ignoreDiagnostics: number[];
private ignoreLints: string[];
private ignoreLintWarnings: boolean;
private reportFiles: string[];
private logger: Logger;
private silent: boolean;
Expand Down Expand Up @@ -144,6 +146,7 @@ class ForkTsCheckerWebpackPlugin {
typeof options.watch === 'string' ? [options.watch] : options.watch || [];
this.ignoreDiagnostics = options.ignoreDiagnostics || [];
this.ignoreLints = options.ignoreLints || [];
this.ignoreLintWarnings = options.ignoreLintWarnings === true;
this.reportFiles = options.reportFiles || [];
this.logger = options.logger || console;
this.silent = options.silent === true; // default false
Expand Down Expand Up @@ -792,7 +795,7 @@ class ForkTsCheckerWebpackPlugin {
file: message.file
};

if (message.isWarningSeverity()) {
if (message.isWarningSeverity() && !this.ignoreLintWarnings) {
compilation.warnings.push(formatted);
} else {
compilation.errors.push(formatted);
Expand Down Expand Up @@ -838,7 +841,7 @@ class ForkTsCheckerWebpackPlugin {
(this.lints || []).concat(this.diagnostics).forEach(message => {
const formattedMessage = this.formatter(message, this.useColors);

message.isWarningSeverity()
message.isWarningSeverity() && !this.ignoreLintWarnings
? this.logger.warn(formattedMessage)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be an issue in the case where you have a warning and you are ignoring warnings - it looks like an error would be logged in that case ..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. So int that case I would want to do nothing here, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think so

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, updated. Let me know if that looks correct to you.

: this.logger.error(formattedMessage);
});
Expand Down Expand Up @@ -868,4 +871,6 @@ class ForkTsCheckerWebpackPlugin {

export = ForkTsCheckerWebpackPlugin;

namespace ForkTsCheckerWebpackPlugin {}
namespace ForkTsCheckerWebpackPlugin {

}
15 changes: 15 additions & 0 deletions test/integration/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ function makeCommonTests(useTypescriptIncrementalApi) {
expect(plugin.watch).to.deep.equal(['/test']);
});

it('should not print warnings when ignoreLintWarnings passed as option', function(callback) {
const fileName = 'lintingError2';
helpers.testLintAutoFixTest(
callback,
fileName,
{
tslint: true,
ignoreLintWarnings: true
},
(err, stats) => {
expect(stats.compilation.warnings.length).to.be.eq(0);
}
);
});

it('should find semantic errors', function(callback) {
var compiler = createCompiler({
tsconfig: 'tsconfig-semantic-error-only.json'
Expand Down