Skip to content

Commit

Permalink
Fix handling of parserOptions for TypeScript (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersk committed Jun 2, 2021
1 parent 7629ce0 commit 7ace6e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/options-manager.js
Expand Up @@ -511,6 +511,7 @@ const buildTSConfig = options => config => {
config.baseConfig.extends = config.baseConfig.extends.concat('xo-typescript');
config.baseConfig.parser = require.resolve('@typescript-eslint/parser');
config.baseConfig.parserOptions = {
...config.baseConfig.parserOptions,
warnOnUnsupportedTypeScriptVersion: false,
ecmaFeatures: {jsx: true},
project: options.tsConfigPath,
Expand Down
9 changes: 7 additions & 2 deletions test/options-manager.js
Expand Up @@ -436,14 +436,19 @@ test('buildConfig: typescript', t => {
});

test('buildConfig: typescript with parserOption', t => {
const config = manager.buildConfig({ts: true, parserOptions: {projectFolderIgnoreList: []}, tsConfigPath: 'path/to/tmp-tsconfig.json'}, {});
const config = manager.buildConfig({
ts: true,
parserOptions: {projectFolderIgnoreList: [], sourceType: 'script'},
tsConfigPath: 'path/to/tmp-tsconfig.json'
}, {});

t.is(config.baseConfig.parser, require.resolve('@typescript-eslint/parser'));
t.deepEqual(config.baseConfig.parserOptions, {
warnOnUnsupportedTypeScriptVersion: false,
ecmaFeatures: {jsx: true},
projectFolderIgnoreList: [],
project: 'path/to/tmp-tsconfig.json'
project: 'path/to/tmp-tsconfig.json',
sourceType: 'script'
});
});

Expand Down

0 comments on commit 7ace6e5

Please sign in to comment.