Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unicorn/prefer-json-parse-buffer is incompatible with TypeScript #52

Closed
andersk opened this issue Mar 9, 2022 · 0 comments
Closed

unicorn/prefer-json-parse-buffer is incompatible with TypeScript #52

andersk opened this issue Mar 9, 2022 · 0 comments

Comments

@andersk
Copy link
Contributor

andersk commented Mar 9, 2022

import * as fs from 'node:fs';

JSON.parse(fs.readFileSync('./package.json', 'utf8'));
$ npx xo

  test.ts:3:46
  ✖  3:46  Prefer reading the JSON file as a buffer.  unicorn/prefer-json-parse-buffer

  1 error
$ npx xo --fix
$ npx tsc test.ts
test.ts:3:12 - error TS2345: Argument of type 'Buffer' is not assignable to parameter of type 'string'.

3 JSON.parse(fs.readFileSync('./package.json'));
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in test.ts:3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant