ProjectEvergreen/greenwood

refactor project to use JSON Modules

Offen

#1.015 geöffnet am 02.12.2022

 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (15 Forks)auto 404
CLIPluginsenhancementgood first issue

Repository-Metriken

Stars
 (132 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 25T 20h) (29 gemergte PRs in 30 T)

Beschreibung

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?

Contributor Guide