Skip to content

Commit

Permalink
Do not add indent rule when prettier option is true (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg authored and sindresorhus committed Feb 15, 2018
1 parent bf29ed8 commit 5a55cee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/options-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const buildConfig = opts => {
}
}

if (opts.space) {
if (opts.space && !opts.prettier) {
config.rules.indent = ['error', spaces, {SwitchCase: 1}];

// Only apply if the user has the React plugin
Expand Down
19 changes: 19 additions & 0 deletions test/options-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ test('buildConfig: prettier: true, space: 4', t => {
tabWidth: 4,
trailingComma: 'es5'
}]);
// Indent rule is not enabled
t.is(config.rules.indent, undefined);
});

test('buildConfig: prettier: true, esnext: false', t => {
Expand All @@ -139,6 +141,23 @@ test('buildConfig: prettier: true, esnext: false', t => {
}]);
});

test('buildConfig: prettier: true, space: true', t => {
const config = manager.buildConfig({prettier: true, space: true});

// Sets `useTabs` and `tabWidth` options in `prettier/prettier` rule based on the XO `space` options
t.deepEqual(config.rules['prettier/prettier'], ['error', {
useTabs: false,
bracketSpacing: false,
jsxBracketSameLine: false,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5'
}]);
// Indent rule is not enabled
t.is(config.rules.indent, undefined);
});

test('buildConfig: engines: undefined', t => {
const config = manager.buildConfig({});

Expand Down

0 comments on commit 5a55cee

Please sign in to comment.