Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: pass defaultIgnores from configuration in @commitlint/cli
pass defaultIgnores from configuration to the linter
  • Loading branch information
ResDiaryLewis committed Jul 31, 2019
commit ea280c923031005a1dceee2cdf91949500110175
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']
}
};
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: false
};
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) {
opts.defaultIgnores = loaded.defaultIgnores;
}
const format = loadFormatter(loaded, flags);

// Strip comments if reading from `.git/COMMIT_EDIT_MSG`
Expand Down
12 changes: 12 additions & 0 deletions @commitlint/cli/src/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,18 @@ 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, 0);
Copy link
Member

Choose a reason for hiding this comment

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

Ok, so when the defaultIgnores is false, it should not ignore the fixup! ... empty subject right? So that means it would fail, instead of pass 😄 (this should be t.is(actual.code, 1);, a failure code)

});

test('should skip linting if defaultIgnores is true', async t => {
const cwd = await git.bootstrap('fixtures/default-ignores-false');
Copy link
Member

Choose a reason for hiding this comment

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

I think you intended to use fixtures/default-ignores-true, instead of -false right? 😄

const actual = await cli([], {cwd})('fixup! foo: bar');
t.is(actual.code, 1);
Copy link
Member

Choose a reason for hiding this comment

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

And I think this should be 0 right? Since it enables the defaultIgnores, and thus let it pass 😄

});

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