From 47f9e21a96142396a6d83944eb7a0205a4315892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= Date: Wed, 26 Oct 2016 21:20:26 +0200 Subject: [PATCH 1/2] feat: Support warnings-as-errors This patch adds support for using --warnings-as-errors as a parameter for the lint command. This complements the PR https://github.com/mozilla/addons-linter/pull/1016 and completes the issue https://github.com/mozilla/addons-linter/issues/1014. --- src/cmd/lint.js | 5 ++++- src/program.js | 6 ++++++ tests/unit/test-cmd/test.lint.js | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/cmd/lint.js b/src/cmd/lint.js index ec0ef2412b..5f6a40edda 100644 --- a/src/cmd/lint.js +++ b/src/cmd/lint.js @@ -16,6 +16,7 @@ export type LinterCreatorParams = { logLevel: 'debug' | 'fatal', stack: boolean, pretty?: boolean, + warningsAsErrors?: boolean, metadata?: boolean, output?: LinterOutputType, boring?: boolean, @@ -42,6 +43,7 @@ export type LintCmdParams = { output?: LinterOutputType, metadata?: boolean, pretty?: boolean, + warningsAsErrors?: boolean, }; export type LintCmdOptions = { @@ -52,7 +54,7 @@ export type LintCmdOptions = { export default function lint( { verbose, sourceDir, selfHosted, boring, output, - metadata, pretty, + metadata, pretty, warningsAsErrors, }: LintCmdParams, { createLinter = defaultLinterCreator, @@ -65,6 +67,7 @@ export default function lint( logLevel: verbose ? 'debug' : 'fatal', stack: Boolean(verbose), pretty, + warningsAsErrors, metadata, output, boring, diff --git a/src/program.js b/src/program.js index 9da30a57ad..38c25c1923 100644 --- a/src/program.js +++ b/src/program.js @@ -300,6 +300,12 @@ Example: $0 --help run. type: 'boolean', default: false, }, + 'warnings-as-errors': { + describe: 'Treat warnings as errors', + alias: 'w', + type: 'boolean', + default: false, + }, 'pretty': { describe: 'Prettify JSON output', type: 'boolean', diff --git a/tests/unit/test-cmd/test.lint.js b/tests/unit/test-cmd/test.lint.js index c86850459a..48da78df79 100644 --- a/tests/unit/test-cmd/test.lint.js +++ b/tests/unit/test-cmd/test.lint.js @@ -65,6 +65,22 @@ describe('lint', () => { }); }); + it('passes warningsAsErrors to the linter', () => { + const {lint, createLinter} = setUp(); + return lint({warningsAsErrors: true}).then(() => { + const config = createLinter.firstCall.args[0].config; + assert.equal(config.warningsAsErrors, true); + }); + }); + + it('passes warningsAsErrors undefined to the linter', () => { + const {lint, createLinter} = setUp(); + return lint({}).then(() => { + const config = createLinter.firstCall.args[0].config; + assert.equal(config.warningsAsErrors, undefined); + }); + }); + it('configures the linter when verbose', () => { const {lint, createLinter} = setUp(); return lint({verbose: true}).then(() => { From 5019374876e7f8894b8506390fa2bd803bb3887a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= Date: Tue, 8 Nov 2016 10:49:45 +0100 Subject: [PATCH 2/2] chore: Update addons-linter to requirered minimum-version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 44d141d009..844d54a959 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "opera" ], "dependencies": { - "addons-linter": "0.15.6", + "addons-linter": "0.15.10", "babel-polyfill": "6.16.0", "babel-runtime": "6.11.6", "bunyan": "1.8.4",