Skip to content

Commit

Permalink
Merge 446aa8f into fd662af
Browse files Browse the repository at this point in the history
  • Loading branch information
josteink committed Oct 29, 2016
2 parents fd662af + 446aa8f commit c3a18c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cmd/lint.js
Original file line number Diff line number Diff line change
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
5 changes: 5 additions & 0 deletions src/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ Example: $0 --help run.
type: 'boolean',
default: false,
},
'warnings-as-errors': {
describe: 'Treat warnings as errors',
type: 'boolean',
default: false,
},
'pretty': {
describe: 'Prettify JSON output',
type: 'boolean',
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test-cmd/test.lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ 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('configures the linter when verbose', () => {
const {lint, createLinter} = setUp();
return lint({verbose: true}).then(() => {
Expand Down Expand Up @@ -96,13 +104,16 @@ describe('lint', () => {
boring: 'boring flag',
// $FLOW_IGNORE: wrong type used for testing purpose
selfHosted: 'self-hosted flag',
// $FLOW_IGNORE: wrong type used for testing purpose
warningsAsErrors: 'warnings-as-errors flag',
}).then(() => {
const config = createLinter.firstCall.args[0].config;
assert.equal(config.pretty, 'pretty flag');
assert.equal(config.metadata, 'metadata flag');
assert.equal(config.output, 'output value');
assert.equal(config.boring, 'boring flag');
assert.equal(config.selfHosted, 'self-hosted flag');
assert.equal(config.warningsAsErrors, 'warnings-as-errors flag');
});
});

Expand Down

0 comments on commit c3a18c7

Please sign in to comment.