🚫 This rule is disabled in the ✅ recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
When reading and parsing a JSON file, it's unnecessary to read it as a string, because JSON.parse()
can also parse Buffer
.
Passing in a buffer may not be performant and is not compatible with TypeScript.
const packageJson = JSON.parse(await fs.readFile('./package.json', 'utf8'));
const promise = fs.readFile('./package.json', {encoding: 'utf8'});
const packageJson = JSON.parse(await promise);
const packageJson = JSON.parse(await fs.readFile('./package.json'));
const promise = fs.readFile('./package.json', {encoding: 'utf8', signal});
const packageJson = JSON.parse(await promise);
const data = JSON.parse(await fs.readFile('./file.json', 'buffer'));
const data = JSON.parse(await fs.readFile('./file.json', 'gbk'));