denoland / deno_lint

Blazing fast linter for JavaScript and TypeScript written in Rust
https://lint.deno.land/
MIT License
1.53k stars 172 forks source link

fix: wrong hint for deprecated Deno APIs #1222

Closed skanehira closed 8 months ago

skanehira commented 9 months ago

fix https://github.com/denoland/deno_lint/issues/1221

The results

$ ./target/debug/examples/dlint run /Users/skanehira/dev/github.com/skanehira/sandbox/deno/stream/main.ts
no-deprecated-deno-api

  × `Deno.readAll` is deprecated and scheduled for removal in Deno 2.0
   ╭─[/Users/skanehira/dev/github.com/skanehira/sandbox/deno/stream/main.ts:2:7]
 2 │ const file = await Deno.open("./main.ts");
 3 │ await Deno.readAll(file);
   ·       ──────┬─────
   ·             ╰── Use `ReadableStream` from https://deno.land/api?s=ReadableStream and `toArrayBuffer()` from https://deno.land/std/streams/to_array_buffer.ts?s=toArrayBuffer instead
 4 │ Deno.iter(file);
   ╰────
  help: https://lint.deno.land/#no-deprecated-deno-api

no-deprecated-deno-api

  × `Deno.iter` is deprecated and scheduled for removal in Deno 2.0
   ╭─[/Users/skanehira/dev/github.com/skanehira/sandbox/deno/stream/main.ts:3:1]
 3 │ await Deno.readAll(file);
 4 │ Deno.iter(file);
   · ────┬────
   ·     ╰── Use `https://deno.land/api?s=ReadableStream` instead
 5 │ Deno.iterSync(file);
   ╰────
  help: https://lint.deno.land/#no-deprecated-deno-api

no-deprecated-deno-api

  × `Deno.iterSync` is deprecated and scheduled for removal in Deno 2.0
   ╭─[/Users/skanehira/dev/github.com/skanehira/sandbox/deno/stream/main.ts:4:1]
 4 │ Deno.iter(file);
 5 │ Deno.iterSync(file);
   · ──────┬──────
   ·       ╰── Use `https://deno.land/api?s=ReadableStream` instead
 6 │ Deno.readAllSync(file);
   ╰────
  help: https://lint.deno.land/#no-deprecated-deno-api

no-deprecated-deno-api

  × `Deno.readAllSync` is deprecated and scheduled for removal in Deno 2.0
   ╭─[/Users/skanehira/dev/github.com/skanehira/sandbox/deno/stream/main.ts:5:1]
 5 │ Deno.iterSync(file);
 6 │ Deno.readAllSync(file);
   · ────────┬───────
   ·         ╰── Use `ReadableStream` from https://deno.land/api?s=ReadableStream and `toArrayBuffer()` from https://deno.land/std/streams/to_array_buffer.ts?s=toArrayBuffer instead
 7 │ Deno.readAll(file);
   ╰────
  help: https://lint.deno.land/#no-deprecated-deno-api

no-deprecated-deno-api

  × `Deno.readAll` is deprecated and scheduled for removal in Deno 2.0
   ╭─[/Users/skanehira/dev/github.com/skanehira/sandbox/deno/stream/main.ts:6:1]
 6 │ Deno.readAllSync(file);
 7 │ Deno.readAll(file);
   · ──────┬─────
   ·       ╰── Use `ReadableStream` from https://deno.land/api?s=ReadableStream and `toArrayBuffer()` from https://deno.land/std/streams/to_array_buffer.ts?s=toArrayBuffer instead
 8 │ Deno.copy(file, file);
   ╰────
  help: https://lint.deno.land/#no-deprecated-deno-api

no-deprecated-deno-api

  × `Deno.copy` is deprecated and scheduled for removal in Deno 2.0
   ╭─[/Users/skanehira/dev/github.com/skanehira/sandbox/deno/stream/main.ts:7:1]
 7 │ Deno.readAll(file);
 8 │ Deno.copy(file, file);
   · ────┬────
   ·     ╰── Use `https://deno.land/api?s=ReadableStream#method_pipeTo_4` instead
 9 │ Deno.write(0, new Uint8Array(1));
   ╰────
  help: https://lint.deno.land/#no-deprecated-deno-api

no-deprecated-deno-api

  × `Deno.writeAll` is deprecated and scheduled for removal in Deno 2.0
    ╭─[/Users/skanehira/dev/github.com/skanehira/sandbox/deno/stream/main.ts:9:1]
  9 │ Deno.write(0, new Uint8Array(1));
 10 │ Deno.writeAll(file, new Uint8Array(1));
    · ──────┬──────
    ·       ╰── Use `WritableStream` from https://deno.land/api?s=WritableStream and `ReadableStream.from` from https://deno.land/api@v1.39.2?s=ReadableStream#variable_ReadableStream and `ReadableStream.pipeTo` from https://
deno.land/api?s=ReadableStream#method_pipeTo_4 instead
    ╰────
  help: https://lint.deno.land/#no-deprecated-deno-api

Found 7 problems
CLAassistant commented 9 months ago

CLA assistant check
All committers have signed the CLA.

skanehira commented 9 months ago

Thanks for catching the wrong URLs suggested by the linter. It also seems like the doc is outdated too - would you be interested in working on it? (if not, no worries. I will open an issue in that case)

I'll update docs in other PR