Skip to content

Commit

Permalink
Fix space/useTabs conflict message (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg authored and sindresorhus committed May 19, 2018
1 parent 0765998 commit 36f7f38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/options-manager.js
Expand Up @@ -129,8 +129,8 @@ const mergeWithPrettierConf = (opts, prettierOpts) => {
throw new Error(`The Prettier config \`semi\` is ${prettierOpts.semi} while XO \`semicolon\` is ${opts.semicolon}`);
}

if (((opts.space === true || typeof opts.space === 'number') && prettierOpts.useTabs === false) ||
((opts.space === false || typeof opts.space === 'number') && prettierOpts.useTabs === true)) {
if (((opts.space === true || typeof opts.space === 'number') && prettierOpts.useTabs === true) ||
((opts.space === false) && prettierOpts.useTabs === false)) {
throw new Error(`The Prettier config \`useTabs\` is ${prettierOpts.useTabs} while XO \`space\` is ${opts.space}`);
}

Expand Down
11 changes: 5 additions & 6 deletions test/options-manager.js
Expand Up @@ -279,13 +279,12 @@ test('mergeWithPrettierConf: throw error is `semi`/`semicolon` conflicts', t =>
});

test('mergeWithPrettierConf: throw error is `space`/`useTabs` conflicts', t => {
t.throws(() => manager.mergeWithPrettierConf({space: true}, {useTabs: false}));
t.throws(() => manager.mergeWithPrettierConf({space: 4}, {useTabs: false}));
t.throws(() => manager.mergeWithPrettierConf({space: 0}, {useTabs: false}));
t.throws(() => manager.mergeWithPrettierConf({space: false}, {useTabs: true}));
t.throws(() => manager.mergeWithPrettierConf({space: false}, {useTabs: false}));
t.throws(() => manager.mergeWithPrettierConf({space: true}, {useTabs: true}));

t.notThrows(() => manager.mergeWithPrettierConf({space: false}, {useTabs: false}));
t.notThrows(() => manager.mergeWithPrettierConf({space: true}, {useTabs: true}));
t.notThrows(() => manager.mergeWithPrettierConf({space: 4}, {useTabs: false}));
t.notThrows(() => manager.mergeWithPrettierConf({space: true}, {useTabs: false}));
t.notThrows(() => manager.mergeWithPrettierConf({space: false}, {useTabs: true}));
});

test('mergeWithPrettierConf: throw error is `space`/`tabWidth` conflicts', t => {
Expand Down

0 comments on commit 36f7f38

Please sign in to comment.