Skip to content

Commit ec7a1ee

Browse files
josteinkkumar303
authored andcommitted
feat: Added new option web-ext lint --warnings-as-errors (#613)
This patch adds support for using --warnings-as-errors as a parameter for the lint command. This complements the PR mozilla/addons-linter#1016 and completes the issue mozilla/addons-linter#1014.
1 parent 665a3f2 commit ec7a1ee

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/cmd/lint.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type LinterCreatorParams = {
1616
logLevel: 'debug' | 'fatal',
1717
stack: boolean,
1818
pretty?: boolean,
19+
warningsAsErrors?: boolean,
1920
metadata?: boolean,
2021
output?: LinterOutputType,
2122
boring?: boolean,
@@ -42,6 +43,7 @@ export type LintCmdParams = {
4243
output?: LinterOutputType,
4344
metadata?: boolean,
4445
pretty?: boolean,
46+
warningsAsErrors?: boolean,
4547
};
4648

4749
export type LintCmdOptions = {
@@ -52,7 +54,7 @@ export type LintCmdOptions = {
5254
export default function lint(
5355
{
5456
verbose, sourceDir, selfHosted, boring, output,
55-
metadata, pretty,
57+
metadata, pretty, warningsAsErrors,
5658
}: LintCmdParams,
5759
{
5860
createLinter = defaultLinterCreator,
@@ -65,6 +67,7 @@ export default function lint(
6567
logLevel: verbose ? 'debug' : 'fatal',
6668
stack: Boolean(verbose),
6769
pretty,
70+
warningsAsErrors,
6871
metadata,
6972
output,
7073
boring,

src/program.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ Example: $0 --help run.
300300
type: 'boolean',
301301
default: false,
302302
},
303+
'warnings-as-errors': {
304+
describe: 'Treat warnings as errors',
305+
alias: 'w',
306+
type: 'boolean',
307+
default: false,
308+
},
303309
'pretty': {
304310
describe: 'Prettify JSON output',
305311
type: 'boolean',

tests/unit/test-cmd/test.lint.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ describe('lint', () => {
6565
});
6666
});
6767

68+
it('passes warningsAsErrors to the linter', () => {
69+
const {lint, createLinter} = setUp();
70+
return lint({warningsAsErrors: true}).then(() => {
71+
const config = createLinter.firstCall.args[0].config;
72+
assert.equal(config.warningsAsErrors, true);
73+
});
74+
});
75+
76+
it('passes warningsAsErrors undefined to the linter', () => {
77+
const {lint, createLinter} = setUp();
78+
return lint({}).then(() => {
79+
const config = createLinter.firstCall.args[0].config;
80+
assert.equal(config.warningsAsErrors, undefined);
81+
});
82+
});
83+
6884
it('configures the linter when verbose', () => {
6985
const {lint, createLinter} = setUp();
7086
return lint({verbose: true}).then(() => {

0 commit comments

Comments
 (0)