ProjectEvergreen/greenwood

refactor project to use JSON Modules

开放

#1,015 创建于 2022年12月2日

 (2 条评论) (0 个反应) (0 位负责人)JavaScript (15 个派生)auto 404
CLIPluginsenhancementgood first issue

仓库指标

星标
 (132 个星标)
PR 合并指标
 (平均合并 25天 20小时) (30 天内合并 29 个 PR)

描述

After the upgrade to #1014 for Node v18 support, we can now refactor all instances of reading a JSON file to use native JSON modules, using import assertions

// before
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
const greenwoodPackageJson = JSON.parse(await fs.promises.readFile(new URL('../package.json', import.meta.url), 'utf-8'))

// after
import packageConfig from './package.json' assert { type: 'json' };

So goal would be to go and replace all those instances to the new version.


This will also require us updating our ESLint version to include support for import assertions, which we might still need to wait for? https://github.com/eslint/eslint/discussions/15305

Or maybe we can get around it with a plugin?

贡献者指南