Skip to content

Commit a259014

Browse files
ResDiaryLewismarionebl
authored andcommitted
fix: pass defaultIgnores from configuration in @commitlint/cli (#771)
* fix: pass defaultIgnores from configuration in @commitlint/cli pass defaultIgnores from configuration to the linter * fixup! fix: pass defaultIgnores from configuration in @commitlint/cli
1 parent 6332d97 commit a259014

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
defaultIgnores: false,
3+
rules: {
4+
'subject-empty': [2, 'never']
5+
}
6+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
defaultIgnores: true,
3+
rules: {
4+
'subject-empty': [2, 'never']
5+
}
6+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
rules: {
3+
'subject-empty': [2, 'never']
4+
}
5+
};

@commitlint/cli/src/cli.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ async function main(options) {
147147
const opts = {
148148
parserOpts: {},
149149
plugins: {},
150-
ignores: []
150+
ignores: [],
151+
defaultIgnores: true
151152
};
152153
if (parserOpts) {
153154
opts.parserOpts = parserOpts;
@@ -158,6 +159,9 @@ async function main(options) {
158159
if (loaded.ignores) {
159160
opts.ignores = loaded.ignores;
160161
}
162+
if (loaded.defaultIgnores === false) {
163+
opts.defaultIgnores = false;
164+
}
161165
const format = loadFormatter(loaded, flags);
162166

163167
// Strip comments if reading from `.git/COMMIT_EDIT_MSG`

@commitlint/cli/src/cli.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,24 @@ test('should not skip linting if message does not match ignores config', async t
318318
t.is(actual.code, 1);
319319
});
320320

321+
test('should not skip linting if defaultIgnores is false', async t => {
322+
const cwd = await git.bootstrap('fixtures/default-ignores-false');
323+
const actual = await cli([], {cwd})('fixup! foo: bar');
324+
t.is(actual.code, 1);
325+
});
326+
327+
test('should skip linting if defaultIgnores is true', async t => {
328+
const cwd = await git.bootstrap('fixtures/default-ignores-true');
329+
const actual = await cli([], {cwd})('fixup! foo: bar');
330+
t.is(actual.code, 0);
331+
});
332+
333+
test('should skip linting if defaultIgnores is unset', async t => {
334+
const cwd = await git.bootstrap('fixtures/default-ignores-unset');
335+
const actual = await cli([], {cwd})('fixup! foo: bar');
336+
t.is(actual.code, 0);
337+
});
338+
321339
test('should fail for invalid formatters from flags', async t => {
322340
const cwd = await git.bootstrap('fixtures/custom-formatter');
323341
const actual = await cli(['--format', 'through-flag'], {cwd})('foo: bar');

0 commit comments

Comments
 (0)