Skip to content

Commit 6c57ff7

Browse files
authoredMar 26, 2020
Add xo-typescript and prettier/@typescript-eslint before user extends (#442)
1 parent fc30597 commit 6c57ff7

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed
 

Diff for: ‎lib/options-manager.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ const mergeWithPrettierConfig = (options, prettierOptions) => {
415415

416416
const buildTSConfig = options => config => {
417417
if (options.ts) {
418-
config.baseConfig.extends = config.baseConfig.extends.concat('xo-typescript');
419418
config.baseConfig.parser = require.resolve('@typescript-eslint/parser');
420419
config.baseConfig.parserOptions = {
421420
warnOnUnsupportedTypeScriptVersion: false,
@@ -424,9 +423,12 @@ const buildTSConfig = options => config => {
424423
};
425424

426425
if (options.prettier) {
427-
config.baseConfig.extends = config.baseConfig.extends.concat('prettier/@typescript-eslint');
426+
config.baseConfig.extends = ['prettier/@typescript-eslint', ...config.baseConfig.extends];
428427
}
429428

429+
config.baseConfig.extends = ['xo-typescript', ...config.baseConfig.extends];
430+
431+
delete config.parser;
430432
delete config.tsConfigPath;
431433
delete config.ts;
432434
}

Diff for: ‎test/options-manager.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,10 @@ test('buildConfig: prettier: true, typescript file', t => {
115115
trailingComma: 'none'
116116
}]);
117117

118-
// eslint-prettier-config must always be last
119-
t.deepEqual(config.baseConfig.extends[config.baseConfig.extends.length - 1], 'prettier/@typescript-eslint');
120-
t.deepEqual(config.baseConfig.extends[config.baseConfig.extends.length - 2], 'xo-typescript');
121-
t.deepEqual(config.baseConfig.extends[config.baseConfig.extends.length - 3], 'prettier/unicorn');
122-
t.deepEqual(config.baseConfig.extends[config.baseConfig.extends.length - 4], 'prettier');
118+
// Config prettier/@typescript-eslint must always be after xo-typescript
119+
t.deepEqual(config.baseConfig.extends[0], 'xo-typescript');
120+
t.deepEqual(config.baseConfig.extends[1], 'prettier/@typescript-eslint');
121+
123122
// Indent rule is not enabled
124123
t.is(config.rules.indent, undefined);
125124
// Semi rule is not enabled
@@ -435,7 +434,7 @@ test('buildConfig: extends', t => {
435434
test('buildConfig: typescript', t => {
436435
const config = manager.buildConfig({ts: true, tsConfigPath: './tsconfig.json'});
437436

438-
t.deepEqual(config.baseConfig.extends[config.baseConfig.extends.length - 1], 'xo-typescript');
437+
t.deepEqual(config.baseConfig.extends[0], 'xo-typescript');
439438
t.is(config.baseConfig.parser, require.resolve('@typescript-eslint/parser'));
440439
t.deepEqual(config.baseConfig.parserOptions, {
441440
warnOnUnsupportedTypeScriptVersion: false,

0 commit comments

Comments
 (0)
Please sign in to comment.