Skip to content

Commit

Permalink
Update esm-utils to v3 (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored Mar 23, 2022
1 parent 7da6311 commit 072c6d8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/options-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
CACHE_DIR_NAME,
} from './constants.js';

const {__dirname, json, require} = createEsmUtils(import.meta);
const {__dirname, readJson, require} = createEsmUtils(import.meta);
const {normalizePackageName} = Legacy.naming;
const resolveModule = Legacy.ModuleResolver.resolve;

Expand Down Expand Up @@ -161,7 +161,7 @@ const handleTSConfig = async options => {

if (tsConfigProjectPath) {
options.tsConfigPath = path.resolve(options.cwd, tsConfigProjectPath);
options.tsConfig = await json.load(options.tsConfigPath);
options.tsConfig = await readJson(options.tsConfigPath);
} else {
const tsConfigExplorer = cosmiconfig([], {
searchPlaces: ['tsconfig.json'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-unicorn": "^40.1.0",
"esm-utils": "^2.0.1",
"esm-utils": "^3.0.0",
"find-cache-dir": "^3.3.2",
"find-up": "^6.3.0",
"get-stdin": "^9.0.0",
Expand Down
14 changes: 7 additions & 7 deletions test/options-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import MurmurHash3 from 'imurmurhash';
import {DEFAULT_EXTENSION, DEFAULT_IGNORES, TSCONFIG_DEFAULTS} from '../lib/constants.js';
import * as manager from '../lib/options-manager.js';

const {__dirname, require, json} = createEsmUtils(import.meta);
const parentConfig = json.loadSync('./fixtures/nested/package.json');
const childConfig = json.loadSync('./fixtures/nested/child/package.json');
const prettierConfig = json.loadSync('./fixtures/prettier/package.json');
const enginesConfig = json.loadSync('./fixtures/engines/package.json');
const {__dirname, require, readJson, readJsonSync} = createEsmUtils(import.meta);
const parentConfig = readJsonSync('./fixtures/nested/package.json');
const childConfig = readJsonSync('./fixtures/nested/child/package.json');
const prettierConfig = readJsonSync('./fixtures/prettier/package.json');
const enginesConfig = readJsonSync('./fixtures/engines/package.json');

process.chdir(__dirname);

Expand Down Expand Up @@ -552,7 +552,7 @@ test('mergeWithFileConfig: resolves expected typescript file options', async t =
const cwd = path.resolve('fixtures', 'typescript', 'child');
const filePath = path.resolve(cwd, 'file.ts');
const tsConfigPath = path.resolve(cwd, 'tsconfig.json');
const tsConfig = await json.load(tsConfigPath);
const tsConfig = await readJson(tsConfigPath);
const {options} = await manager.mergeWithFileConfig({cwd, filePath});
const eslintConfigId = new MurmurHash3(path.resolve(cwd, 'package.json')).hash(tsConfigPath).result();
const expected = {
Expand All @@ -574,7 +574,7 @@ test('mergeWithFileConfig: resolves expected tsx file options', async t => {
const filePath = path.resolve(cwd, 'file.tsx');
const {options} = await manager.mergeWithFileConfig({cwd, filePath});
const tsConfigPath = path.resolve(cwd, 'tsconfig.json');
const tsConfig = await json.load(tsConfigPath);
const tsConfig = await readJson(tsConfigPath);
const eslintConfigId = new MurmurHash3(path.join(cwd, 'package.json')).hash(tsConfigPath).result();
const expected = {
filePath,
Expand Down

0 comments on commit 072c6d8

Please sign in to comment.