Skip to content

Commit

Permalink
fix: pass defaultIgnores from configuration in @commitlint/cli (#771)
Browse files Browse the repository at this point in the history
* fix: pass defaultIgnores from configuration in @commitlint/cli

pass defaultIgnores from configuration to the linter

* fixup! fix: pass defaultIgnores from configuration in @commitlint/cli
  • Loading branch information
ResDiaryLewis authored and marionebl committed Aug 6, 2019
1 parent 6332d97 commit a259014
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
defaultIgnores: false,
rules: {
'subject-empty': [2, 'never']
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
defaultIgnores: true,
rules: {
'subject-empty': [2, 'never']
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
rules: {
'subject-empty': [2, 'never']
}
};
6 changes: 5 additions & 1 deletion @commitlint/cli/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ async function main(options) {
const opts = {
parserOpts: {},
plugins: {},
ignores: []
ignores: [],
defaultIgnores: true
};
if (parserOpts) {
opts.parserOpts = parserOpts;
Expand All @@ -158,6 +159,9 @@ async function main(options) {
if (loaded.ignores) {
opts.ignores = loaded.ignores;
}
if (loaded.defaultIgnores === false) {
opts.defaultIgnores = false;
}
const format = loadFormatter(loaded, flags);

// Strip comments if reading from `.git/COMMIT_EDIT_MSG`
Expand Down
18 changes: 18 additions & 0 deletions @commitlint/cli/src/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,24 @@ test('should not skip linting if message does not match ignores config', async t
t.is(actual.code, 1);
});

test('should not skip linting if defaultIgnores is false', async t => {
const cwd = await git.bootstrap('fixtures/default-ignores-false');
const actual = await cli([], {cwd})('fixup! foo: bar');
t.is(actual.code, 1);
});

test('should skip linting if defaultIgnores is true', async t => {
const cwd = await git.bootstrap('fixtures/default-ignores-true');
const actual = await cli([], {cwd})('fixup! foo: bar');
t.is(actual.code, 0);
});

test('should skip linting if defaultIgnores is unset', async t => {
const cwd = await git.bootstrap('fixtures/default-ignores-unset');
const actual = await cli([], {cwd})('fixup! foo: bar');
t.is(actual.code, 0);
});

test('should fail for invalid formatters from flags', async t => {
const cwd = await git.bootstrap('fixtures/custom-formatter');
const actual = await cli(['--format', 'through-flag'], {cwd})('foo: bar');
Expand Down

0 comments on commit a259014

Please sign in to comment.