Skip to content
Permalink
Browse files
Fix space/useTabs conflict message (#327)
  • Loading branch information
pvdlg authored and sindresorhus committed May 19, 2018
1 parent 0765998 commit 36f7f38f3c2f495283cda764c68cfee9b4494973
Showing 2 changed files with 7 additions and 8 deletions.
@@ -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}`);
}

@@ -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 => {

0 comments on commit 36f7f38

Please sign in to comment.