diff --git a/lib/options-manager.js b/lib/options-manager.js index be3611cc..52e5e4ff 100644 --- a/lib/options-manager.js +++ b/lib/options-manager.js @@ -10,7 +10,6 @@ import prettier from 'prettier'; import semver from 'semver'; import {cosmiconfig, defaultLoaders} from 'cosmiconfig'; import micromatch from 'micromatch'; -import JSON5 from 'json5'; import stringify from 'json-stable-stringify-without-jsonify'; import {Legacy} from '@eslint/eslintrc'; import createEsmUtils from 'esm-utils'; @@ -159,21 +158,17 @@ const handleTSConfig = async options => { options.tsConfig = {}; options.tsConfigPath = ''; - const {project: tsConfigProjectPath, tsconfigRootDir} = options.parserOptions || {}; + const {project: tsConfigProjectPath} = options.parserOptions || {}; if (tsConfigProjectPath) { options.tsConfigPath = path.resolve(options.cwd, tsConfigProjectPath); options.tsConfig = tsConfigResolvePaths(getTsconfig(options.tsConfigPath).config, options.tsConfigPath); } else { - const tsConfigExplorer = cosmiconfig([], { - searchPlaces: ['tsconfig.json'], - loaders: {'.json': (_, content) => JSON5.parse(content)}, - stopDir: tsconfigRootDir, - }); - const searchResults = (await tsConfigExplorer.search(options.filePath)) || {}; - options.tsConfigPath = searchResults.filepath; + const {config: tsConfig, path: filepath} = getTsconfig(options.filePath) || {}; + options.tsConfigPath = filepath; + options.tsConfig = tsConfig; if (options.tsConfigPath) { - options.tsConfig = tsConfigResolvePaths(getTsconfig(options.tsConfigPath).config, options.tsConfigPath); + options.tsConfig = tsConfigResolvePaths(tsConfig, options.tsConfigPath); } else { delete options.tsConfig; } diff --git a/package.json b/package.json index be4674ee..de96cf1a 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,6 @@ "globby": "^13.1.2", "imurmurhash": "^0.1.4", "json-stable-stringify-without-jsonify": "^1.0.1", - "json5": "^2.2.1", "lodash-es": "^4.17.21", "meow": "^11.0.0", "micromatch": "^4.0.5", @@ -94,7 +93,8 @@ "semver": "^7.3.8", "slash": "^5.0.0", "to-absolute-glob": "^2.0.2", - "typescript": "^5.0.3" + "typescript": "^5.0.3", + "xo": "file:./index.js" }, "devDependencies": { "ava": "^5.1.0",