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

Support warnings-as-errors #613

Merged
merged 2 commits into from Nov 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/cmd/lint.js
Expand Up @@ -16,6 +16,7 @@ export type LinterCreatorParams = {
logLevel: 'debug' | 'fatal',
stack: boolean,
pretty?: boolean,
warningsAsErrors?: boolean,
metadata?: boolean,
output?: LinterOutputType,
boring?: boolean,
Expand All @@ -42,6 +43,7 @@ export type LintCmdParams = {
output?: LinterOutputType,
metadata?: boolean,
pretty?: boolean,
warningsAsErrors?: boolean,
};

export type LintCmdOptions = {
Expand All @@ -52,7 +54,7 @@ export type LintCmdOptions = {
export default function lint(
{
verbose, sourceDir, selfHosted, boring, output,
metadata, pretty,
metadata, pretty, warningsAsErrors,
}: LintCmdParams,
{
createLinter = defaultLinterCreator,
Expand All @@ -65,6 +67,7 @@ export default function lint(
logLevel: verbose ? 'debug' : 'fatal',
stack: Boolean(verbose),
pretty,
warningsAsErrors,
metadata,
output,
boring,
Expand Down
6 changes: 6 additions & 0 deletions src/program.js
Expand Up @@ -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',
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test-cmd/test.lint.js
Expand Up @@ -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);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks great! I think it would make sense to add one more test that does lint() without specifying the warnings flag and asserts the linter is called with warningsAsErrors = undefined (or should it be false?)


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(() => {
Expand Down