Skip to content

Commit

Permalink
Set indent rule for TS files too (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Apr 2, 2020
1 parent 28902f0 commit 41b1bd7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/options-manager.js
Expand Up @@ -282,10 +282,10 @@ const buildXOConfig = options => config => {
}

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

if (options.ts) {
config.rules['@typescript-eslint/indent'] = ['error', spaces, {SwitchCase: 1}];
} else {
config.rules.indent = ['error', spaces, {SwitchCase: 1}];
}

// Only apply if the user has the React plugin
Expand Down
6 changes: 6 additions & 0 deletions test/options-manager.js
Expand Up @@ -67,6 +67,12 @@ test('buildConfig: space: 4', t => {
t.deepEqual(config.rules.indent, ['error', 4, {SwitchCase: 1}]);
});

test('buildConfig: space: 4 (ts file)', t => {
const config = manager.buildConfig({space: 4, ts: true});
t.deepEqual(config.rules.indent, ['error', 4, {SwitchCase: 1}]);
t.deepEqual(config.rules['@typescript-eslint/indent'], ['error', 4, {SwitchCase: 1}]);
});

test('buildConfig: semicolon', t => {
const config = manager.buildConfig({semicolon: false, nodeVersion: '12'});
t.deepEqual(config.rules.semi, ['error', 'never']);
Expand Down

0 comments on commit 41b1bd7

Please sign in to comment.