From 0b49b9114a3ba6ef9a39131707c86f56090a391b Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Wed, 18 Sep 2024 10:53:56 +1000 Subject: [PATCH] refactor: rework `no-deprecated-deno-api` rule (#1326) --- src/rules/no_deprecated_deno_api.rs | 580 ++++++++++++++++++---------- 1 file changed, 384 insertions(+), 196 deletions(-) diff --git a/src/rules/no_deprecated_deno_api.rs b/src/rules/no_deprecated_deno_api.rs index 6460a530..98fdea96 100644 --- a/src/rules/no_deprecated_deno_api.rs +++ b/src/rules/no_deprecated_deno_api.rs @@ -63,34 +63,42 @@ fn extract_symbol<'a>( enum DeprecatedApi { Buffer, + Close, Copy, CustomInspect, + Fdatasync, + FdatasyncSync, File, + Flock, + FlockSync, + Fstat, + FstatSync, + Fsync, + FsyncSync, + Ftruncate, + FtruncateSync, + Funlock, + FunlockSync, + Futime, + FutimeSync, + Isatty, Iter, IterSync, + Metrics, + Read, + ReadSync, ReadAll, ReadAllSync, - Run, - WriteAll, - WriteAllSync, - Isatty, - Metrics, Resources, - ServeHttp, + Run, Seek, SeekSync, - Read, - ReadSync, + ServeHttp, Shutdown, - Ftruncate, - FtruncateSync, - Close, Write, WriteSync, - Futime, - FutimeSync, - Fstat, - FstatSync, + WriteAll, + WriteAllSync, } impl TryFrom<(&str, &str)> for DeprecatedApi { @@ -109,34 +117,42 @@ impl TryFrom<(&str, &str)> for DeprecatedApi { match prop_symbol { "Buffer" => Ok(DeprecatedApi::Buffer), + "close" => Ok(DeprecatedApi::Close), "copy" => Ok(DeprecatedApi::Copy), "customInspect" => Ok(DeprecatedApi::CustomInspect), + "fdatasync" => Ok(DeprecatedApi::Fdatasync), + "fdatasyncSync" => Ok(DeprecatedApi::FdatasyncSync), + "File" => Ok(DeprecatedApi::File), + "flock" => Ok(DeprecatedApi::Flock), + "flockSync" => Ok(DeprecatedApi::FlockSync), + "fstat" => Ok(DeprecatedApi::Fstat), + "fstatSync" => Ok(DeprecatedApi::FstatSync), + "fsync" => Ok(DeprecatedApi::Fsync), + "fsyncSync" => Ok(DeprecatedApi::FsyncSync), + "ftruncate" => Ok(DeprecatedApi::Ftruncate), + "ftruncateSync" => Ok(DeprecatedApi::FtruncateSync), + "funlock" => Ok(DeprecatedApi::Funlock), + "funlockSync" => Ok(DeprecatedApi::FunlockSync), + "futime" => Ok(DeprecatedApi::Futime), + "futimeSync" => Ok(DeprecatedApi::FutimeSync), + "isatty" => Ok(DeprecatedApi::Isatty), "iter" => Ok(DeprecatedApi::Iter), "iterSync" => Ok(DeprecatedApi::IterSync), - "File" => Ok(DeprecatedApi::File), + "metrics" => Ok(DeprecatedApi::Metrics), + "read" => Ok(DeprecatedApi::Read), + "readSync" => Ok(DeprecatedApi::ReadSync), "readAll" => Ok(DeprecatedApi::ReadAll), "readAllSync" => Ok(DeprecatedApi::ReadAllSync), - "run" => Ok(DeprecatedApi::Run), - "writeAll" => Ok(DeprecatedApi::WriteAll), - "writeAllSync" => Ok(DeprecatedApi::WriteAllSync), - "isatty" => Ok(DeprecatedApi::Isatty), - "metrics" => Ok(DeprecatedApi::Metrics), "resources" => Ok(DeprecatedApi::Resources), - "serveHttp" => Ok(DeprecatedApi::ServeHttp), + "run" => Ok(DeprecatedApi::Run), "seek" => Ok(DeprecatedApi::Seek), "seekSync" => Ok(DeprecatedApi::SeekSync), - "read" => Ok(DeprecatedApi::Read), - "readSync" => Ok(DeprecatedApi::ReadSync), + "serveHttp" => Ok(DeprecatedApi::ServeHttp), "shutdown" => Ok(DeprecatedApi::Shutdown), - "ftruncate" => Ok(DeprecatedApi::Ftruncate), - "ftruncateSync" => Ok(DeprecatedApi::FtruncateSync), - "close" => Ok(DeprecatedApi::Close), "write" => Ok(DeprecatedApi::Write), "writeSync" => Ok(DeprecatedApi::WriteSync), - "futime" => Ok(DeprecatedApi::Futime), - "futimeSync" => Ok(DeprecatedApi::FutimeSync), - "fstat" => Ok(DeprecatedApi::Fstat), - "fstatSync" => Ok(DeprecatedApi::FstatSync), + "writeAll" => Ok(DeprecatedApi::WriteAll), + "writeAllSync" => Ok(DeprecatedApi::WriteAllSync), _ => Err(()), } } @@ -144,8 +160,7 @@ impl TryFrom<(&str, &str)> for DeprecatedApi { enum Replacement { NameAndUrl(&'static str, &'static str), Name(&'static str), - #[allow(dead_code)] - NameAndUrls(Vec<(&'static str, &'static str)>), + Method(&'static str), None, } @@ -153,7 +168,7 @@ impl DeprecatedApi { fn message(&self) -> String { let name = self.get_deprecated_api_name(); format!( - "`{}` is deprecated and scheduled for removal in Deno 2.0", + "`{}` was removed in Deno 2. See the Deno 1.x to 2.x Migration Guide for further details: https://docs.deno.com/runtime/reference/migrate_deprecations/", name, ) } @@ -164,17 +179,10 @@ impl DeprecatedApi { Replacement::NameAndUrl(name, url) => { Some(format!("Use `{}` from {} instead", name, url)) } - Replacement::NameAndUrls(name_and_urls) => { - let mut hint = String::from("Use "); - for (i, (name, url)) in name_and_urls.into_iter().enumerate() { - if i != 0 { - hint.push_str(" and "); - } - hint.push_str(&format!("`{}` from {}", name, url)); - } - hint.push_str(" instead"); - Some(hint) - } + Replacement::Method(method) => Some(format!( + "Use `{}` from the given class instance instead", + method + )), Replacement::None => None, } } @@ -184,129 +192,104 @@ impl DeprecatedApi { match *self { Buffer => "Deno.Buffer", Copy => "Deno.copy", + Close => "Deno.close", CustomInspect => "Deno.customInspect", + Fdatasync => "Deno.fdatasync", + FdatasyncSync => "Deno.fdatasyncSync", + File => "Deno.File", + Flock => "Deno.flock", + FlockSync => "Deno.flockSync", + Fstat => "Deno.fstat", + FstatSync => "Deno.fstatSync", + Fsync => "Deno.fsync", + FsyncSync => "Deno.fsyncSync", + Ftruncate => "Deno.ftruncate", + FtruncateSync => "Deno.ftruncateSync", + Funlock => "Deno.funlock", + FunlockSync => "Deno.funlockSync", + Futime => "Deno.futime", + FutimeSync => "Deno.futimeSync", + Isatty => "Deno.isatty", Iter => "Deno.iter", IterSync => "Deno.iterSync", - File => "Deno.File", + Metrics => "Deno.metrics", + Read => "Deno.read", + ReadSync => "Deno.readSync", ReadAll => "Deno.readAll", ReadAllSync => "Deno.readAllSync", - Run => "Deno.run", - WriteAll => "Deno.writeAll", - WriteAllSync => "Deno.writeAllSync", - Isatty => "Deno.isatty", - Metrics => "Deno.metrics", Resources => "Deno.resources", - ServeHttp => "Deno.serveHttp", + Run => "Deno.run", Seek => "Deno.seek", SeekSync => "Deno.seekSync", - Read => "Deno.read", - ReadSync => "Deno.readSync", + ServeHttp => "Deno.serveHttp", Shutdown => "Deno.shutdown", - Ftruncate => "Deno.ftruncate", - FtruncateSync => "Deno.ftruncateSync", - Close => "Deno.close", Write => "Deno.write", WriteSync => "Deno.writeSync", - Futime => "Deno.futime", - FutimeSync => "Deno.futimeSync", - Fstat => "Deno.fstat", - FstatSync => "Deno.fstatSync", + WriteAll => "Deno.writeAll", + WriteAllSync => "Deno.writeAllSync", } } fn get_replacement(&self) -> Replacement { - const DENO_COMMAND_API: &str = "https://deno.land/api?s=Deno.Command"; - const STD_BUFFER: &str = "https://deno.land/std/io/buffer.ts?s=Buffer"; - const STD_COPY: &str = "https://deno.land/std/io/copy.ts?s=copy"; - const STD_READ_ALL: &str = "https://deno.land/std/io/read_all.ts?s=readAll"; - const STD_READ_ALL_SYNC: &str = - "https://deno.land/std/io/read_all.ts?s=readAllSync"; - const STD_WRITE_ALL: &str = - "https://deno.land/std/io/write_all.ts?s=writeAll"; - const STD_WRITE_ALL_SYNC: &str = - "https://deno.land/std/io/write_all.ts?s=writeAllSync"; - const STREAMS_READABLE_TS: &str = "https://deno.land/api?s=ReadableStream"; - use DeprecatedApi::*; use Replacement::*; match *self { - Buffer => Name(STD_BUFFER), - Copy => Name(STD_COPY), + Buffer => { + NameAndUrl("Buffer", "https://jsr.io/@std/io/doc/buffer/~/Buffer") + } + Close => Method(".close()"), + Copy => NameAndUrl("copy()", "https://jsr.io/@std/io/doc/copy/~/copy"), CustomInspect => Name("Symbol.for(\"Deno.customInspect\")"), - Iter => Name(STREAMS_READABLE_TS), - IterSync => Name(STREAMS_READABLE_TS), + Fdatasync => Method(".syncData()"), + FdatasyncSync => Method(".syncDataSync()"), File => Name("Deno.FsFile"), - ReadAll => NameAndUrl("readAll", STD_READ_ALL), - ReadAllSync => NameAndUrl("readAllSync", STD_READ_ALL_SYNC), - Run => NameAndUrl("Deno.Command", DENO_COMMAND_API), - WriteAll => NameAndUrl("writeAll", STD_WRITE_ALL), - WriteAllSync => NameAndUrl("writeAllSync", STD_WRITE_ALL_SYNC), - Isatty => Name("Deno.stdin.isTerminal"), + Flock => Method(".lock()"), + FlockSync => Method(".lockSync()"), + Fstat => Method(".stat()"), + FstatSync => Method(".statSync()"), + Fsync => Method(".sync()"), + FsyncSync => Method(".syncSync()"), + Ftruncate => Method(".truncate()"), + FtruncateSync => Method(".truncateSync()"), + Funlock => Method(".unlock()"), + FunlockSync => Method(".unlockSync()"), + Futime => Method(".utime()"), + FutimeSync => Method(".utimeSync()"), + Isatty => Method(".isTerminal()"), + Iter => NameAndUrl( + "iterateReader()", + "https://jsr.io/@std/io/doc/iterate-reader/~/iterateReader", + ), + IterSync => NameAndUrl( + "iterateReaderSync()", + "https://jsr.io/@std/io/doc/iterate-reader/~/iterateReaderSync", + ), Metrics => None, + Read => Method(".read()"), + ReadSync => Method(".readSync()"), + ReadAll => { + NameAndUrl("readAll()", "https://jsr.io/@std/io/doc/read-all/~/readAll") + } + ReadAllSync => NameAndUrl( + "readAllSync()", + "https://jsr.io/@std/io/doc/read-all/~/readAllSync", + ), Resources => None, - ServeHttp => Name("Deno.serve"), - Seek | SeekSync => NameAndUrls(vec![ - ( - "Deno.FsFile.seek", - "https://deno.land/apis?s=Deno.FsFile#method_seek_0", - ), - ( - "Deno.FsFile.seekSync", - "https://deno.land/apis?s=Deno.FsFile#method_seekSync_0", - ), - ]), - Read | ReadSync => NameAndUrls(vec![ - ( - "Deno.FsFile.read", - "https://deno.land/apis?s=Deno.FsFile#method_read_0", - ), - ( - "Deno.FsFile.readSync", - "https://deno.land/apis?s=Deno.FsFile#method_readSync_0", - ), - ]), - Ftruncate | FtruncateSync => NameAndUrls(vec![ - ( - "Deno.FsFile.ftruncate", - "https://deno.land/apis?s=Deno.FsFile#method_ftruncate_0", - ), - ( - "Deno.FsFile.ftruncateSync", - "https://deno.land/apis?s=Deno.FsFile#method_ftruncateSync_0", - ), - ]), - Write | WriteSync => NameAndUrls(vec![ - ( - "Deno.FsFile.write", - "https://deno.land/apis?s=Deno.FsFile#method_write_0", - ), - ( - "Deno.FsFile.writeSync", - "https://deno.land/apis?s=Deno.FsFile#method_writeSync_0", - ), - ]), - Futime | FutimeSync => NameAndUrls(vec![ - ( - "Deno.FsFile.futime", - "https://deno.land/apis?s=Deno.FsFile#method_futime_0", - ), - ( - "Deno.FsFile.futimeSync", - "https://deno.land/apis?s=Deno.FsFile#method_futimeSync_0", - ), - ]), - Fstat | FstatSync => NameAndUrls(vec![ - ( - "Deno.FsFile.fstat", - "https://deno.land/apis?s=Deno.FsFile#method_fstat_0", - ), - ( - "Deno.FsFile.fstatSync", - "https://deno.land/apis?s=Deno.FsFile#method_fstatSync_0", - ), - ]), - Shutdown => Name("Deno.Conn.closeWrite"), - Close => Name(".close()"), + Run => NameAndUrl("Deno.Command", "https://deno.land/api?s=Deno.Command"), + Seek => Method(".seek()"), + SeekSync => Method(".seekSync()"), + ServeHttp => Name("Deno.serve()"), + Shutdown => Method(".closeWrite()"), + Write => Method(".write()"), + WriteSync => Method(".writeSync()"), + WriteAll => NameAndUrl( + "writeAll", + "https://jsr.io/@std/io/doc/write-all/~/writeAllSync", + ), + WriteAllSync => NameAndUrl( + "writeAllSync", + "https://jsr.io/@std/io/doc/write-all/~/writeAllSync", + ), } } } @@ -382,77 +365,198 @@ mod tests { NoDeprecatedDenoApi, "Deno.foo();", "Deno.foo.Buffer();", - "Deno.foo.readAll();", - "Deno.foo.readAllSync();", - "Deno.foo.writeAll();", - "Deno.foo.writeAllSync();", - "Deno.foo.iter();", - "Deno.foo.iterSync();", + "Deno.foo.close();", "Deno.foo.copy();", "Deno.foo.customInspect;", + "Deno.foo.fdatasync();", + "Deno.foo.fdatasyncSync();", + "new Deno.foo.File();", + "Deno.foo.flock();", + "Deno.foo.flockSync();", + "Deno.foo.fstat();", + "Deno.foo.fstatSync();", + "Deno.foo.fsync();", + "Deno.foo.fsyncSync();", + "Deno.foo.ftruncate();", + "Deno.foo.ftruncateSync();", + "Deno.foo.funlock();", + "Deno.foo.funlockSync();", + "Deno.foo.futime();", + "Deno.foo.futimeSync();", "Deno.foo.isatty();", + "Deno.foo.iter();", + "Deno.foo.iterSync();", "Deno.foo.metrics();", + "Deno.foo.read();", + "Deno.foo.readSync();", + "Deno.foo.readAll();", + "Deno.foo.readAllSync();", "Deno.foo.resources();", + "Deno.foo.run();", + "Deno.foo.seek();", + "Deno.foo.seekSync();", "Deno.foo.serveHttp();", + "Deno.foo.shutdown();", + "Deno.foo.write();", + "Deno.foo.writeSync();", + "Deno.foo.writeAll();", + "Deno.foo.writeAllSync();", "foo.Deno.Buffer();", - "foo.Deno.readAll();", - "foo.Deno.readAllSync();", - "foo.Deno.writeAll();", - "foo.Deno.writeAllSync();", - "foo.Deno.iter();", - "foo.Deno.iterSync();", + "foo.Deno.close();", "foo.Deno.copy();", "foo.Deno.customInspect;", + "foo.Deno.fdatasync();", + "foo.Deno.fdatasyncSync();", + "new foo.Deno.File();", + "foo.Deno.flock();", + "foo.Deno.flockSync();", + "foo.Deno.fstat();", + "foo.Deno.fstatSync();", + "foo.Deno.fsync();", + "foo.Deno.fsyncSync();", + "foo.Deno.ftruncate();", + "foo.Deno.ftruncateSync();", + "foo.Deno.funlock();", + "foo.Deno.funlockSync();", + "foo.Deno.futime();", + "foo.Deno.futimeSync();", "foo.Deno.isatty();", + "foo.Deno.iter();", + "foo.Deno.iterSync();", "foo.Deno.metrics();", + "foo.Deno.read();", + "foo.Deno.readSync();", + "foo.Deno.readAll();", + "foo.Deno.readAllSync();", "foo.Deno.resources();", + "foo.Deno.run();", + "foo.Deno.seek();", + "foo.Deno.seekSync();", "foo.Deno.serveHttp();", + "foo.Deno.shutdown();", + "foo.Deno.write();", + "foo.Deno.writeSync();", + "foo.Deno.writeAll();", + "foo.Deno.writeAllSync();", // `Deno` is shadowed "const Deno = 42; const a = new Deno.Buffer();", + "const Deno = 42; Deno.close(closer);", + "const Deno = 42; const a = Deno.copy(src, dst);", + "const Deno = 42; const a = Deno.customInspect;", + "const Deno = 42; await Deno.fdatasync(rid);", + "const Deno = 42; Deno.fdatasyncSync(rid);", + "const Deno = 42; const a = new Deno.File();", + "const Deno = 42; await Deno.flock(rid, exclusive);", + "const Deno = 42; Deno.flockSync(rid, exclusive);", + "const Deno = 42; const a = await Deno.fstat(rid);", + "const Deno = 42; const a = Deno.fstatSync(rid);", + "const Deno = 42; await Deno.fsync(rid);", + "const Deno = 42; Deno.fsyncSync(rid);", + "const Deno = 42; await Deno.ftruncate(rid, len);", + "const Deno = 42; Deno.ftruncateSync(rid, len);", + "const Deno = 42; await Deno.funlock(rid);", + "const Deno = 42; Deno.funlockSync(rid);", + "const Deno = 42; await Deno.futime(rid, atime, mtime);", + "const Deno = 42; Deno.futimeSync(rid, atime, mtime);", + "const Deno = 42; const a = Deno.isatty(rid);", + "const Deno = 42; for await (const x of Deno.iter(reader)) {}", + "const Deno = 42; for (const x of Deno.iterSync(reader)) {}", + "const Deno = 42; Deno.metrics();", + "const Deno = 42; const a = await Deno.read(reader, buffer);", + "const Deno = 42; const a = Deno.readSync(rid, buffer);", "const Deno = 42; const a = await Deno.readAll(reader);", "const Deno = 42; const a = Deno.readAllSync(reader);", + "const Deno = 42; Deno.resources();", + "const Deno = 42; const a = Deno.run(options);", + "const Deno = 42; const a = await Deno.seek(rid, offset, whence);", + "const Deno = 42; const a = Deno.seekSync(rid, offset, whence);", + "const Deno = 42; const a = Deno.serveHttp();", + "const Deno = 42; await Deno.shutdown(rid);", + "const Deno = 42; const a = await Deno.write(rid, data);", + "const Deno = 42; const a = Deno.writeSync(rid, data);", "const Deno = 42; await Deno.writeAll(writer, data);", "const Deno = 42; Deno.writeAllSync(writer, data);", - "const Deno = 42; for await (const x of Deno.iter(xs)) {}", - "const Deno = 42; for (const x of Deno.iterSync(xs)) {}", - "const Deno = 42; await Deno.copy(reader, writer);", - "const Deno = 42; Deno.isatty(rid);", - "const Deno = 42; Deno.metrics();", - "const Deno = 42; Deno.resources();", - "const Deno = 42; Deno.serveHttp();", r#"const Deno = 42; Deno.customInspect"#, r#"import { Deno } from "./foo.ts"; Deno.writeAllSync(writer, data);"#, // access property with string literal (shadowed) - r#"const Deno = 42; new Deno["Buffer"]();"#, - r#"const Deno = 42; Deno["readAll"](reader);"#, - r#"const Deno = 42; Deno["readAllSync"](reader);"#, - r#"const Deno = 42; Deno["writeAll"](writer, data);"#, - r#"const Deno = 42; Deno["writeAllSync"](writer, data);"#, - r#"const Deno = 42; for await (const x of Deno["iter"](xs)) {}"#, - r#"const Deno = 42; for (const x of Deno["iterSync"](xs)) {}"#, - r#"const Deno = 42; Deno["copy"](reader, writer);"#, - r#"const Deno = 42; Deno["customInspect"]"#, - r#"const Deno = 42; Deno["isatty"](rid);"#, + r#"const Deno = 42; const a = new Deno["Buffer"]();"#, + r#"const Deno = 42; Deno["close"](closer);"#, + r#"const Deno = 42; const a = Deno["copy"](src, dst);"#, + r#"const Deno = 42; const a = Deno["customInspect"];"#, + r#"const Deno = 42; await Deno["fdatasync"](rid);"#, + r#"const Deno = 42; Deno["fdatasyncSync"](rid);"#, + r#"const Deno = 42; const a = new Deno["File"]();"#, + r#"const Deno = 42; await Deno["flock"](rid, exclusive);"#, + r#"const Deno = 42; Deno["flockSync"](rid, exclusive);"#, + r#"const Deno = 42; const a = await Deno["fstat"](rid);"#, + r#"const Deno = 42; const a = Deno["fstatSync"](rid);"#, + r#"const Deno = 42; await Deno["fsync"](rid);"#, + r#"const Deno = 42; Deno["fsyncSync"](rid);"#, + r#"const Deno = 42; await Deno["ftruncate"](rid, len);"#, + r#"const Deno = 42; Deno["ftruncateSync"](rid, len);"#, + r#"const Deno = 42; await Deno["funlock"](rid);"#, + r#"const Deno = 42; Deno["funlockSync"](rid);"#, + r#"const Deno = 42; await Deno["futime"](rid, atime, mtime);"#, + r#"const Deno = 42; Deno["futimeSync"](rid, atime, mtime);"#, + r#"const Deno = 42; const a = Deno["isatty"](rid);"#, + r#"const Deno = 42; for await (const x of Deno["iter"](reader)) {}"#, + r#"const Deno = 42; for (const x of Deno["iterSync"](reader)) {}"#, r#"const Deno = 42; Deno["metrics"]();"#, + r#"const Deno = 42; const a = await Deno["read"](reader, buffer);"#, + r#"const Deno = 42; const a = Deno["readSync"](rid, buffer);"#, + r#"const Deno = 42; const a = await Deno["readAll"](reader);"#, + r#"const Deno = 42; const a = Deno["readAllSync"](reader);"#, r#"const Deno = 42; Deno["resources"]();"#, - r#"const Deno = 42; Deno["serveHttp"]();"#, + r#"const Deno = 42; const a = Deno["run"](options);"#, + r#"const Deno = 42; const a = await Deno["seek"](rid, offset, whence);"#, + r#"const Deno = 42; const a = Deno["seekSync"](rid, offset, whence);"#, + r#"const Deno = 42; const a = Deno["serveHttp"]();"#, + r#"const Deno = 42; await Deno["shutdown"](rid);"#, + r#"const Deno = 42; const a = await Deno["write"](rid, data);"#, + r#"const Deno = 42; const a = Deno["writeSync"](rid, data);"#, + r#"const Deno = 42; await Deno["writeAll"](writer, data);"#, + r#"const Deno = 42; Deno["writeAllSync"](writer, data);"#, // access property with template literal (shadowed) r#"const Deno = 42; new Deno[`Buffer`]();"#, - r#"const Deno = 42; Deno[`readAll`](reader);"#, - r#"const Deno = 42; Deno[`readAllSync`](reader);"#, - r#"const Deno = 42; Deno[`writeAll`](writer, data);"#, - r#"const Deno = 42; Deno[`writeAllSync`](writer, data);"#, - r#"const Deno = 42; for await (const x of Deno[`iter`](xs)) {}"#, - r#"const Deno = 42; for (const x of Deno[`iterSync`](xs)) {}"#, - r#"const Deno = 42; Deno[`copy`](reader, writer);"#, - r#"const Deno = 42; Deno[`customInspect`]"#, - r#"const Deno = 42; Deno[`isatty`](rid);"#, + r#"const Deno = 42; Deno[`close`](closer);"#, + r#"const Deno = 42; const a = Deno[`copy`](src, dst);"#, + r#"const Deno = 42; const a = Deno[`customInspect`];"#, + r#"const Deno = 42; await Deno[`fdatasync`](rid);"#, + r#"const Deno = 42; Deno[`fdatasyncSync`](rid);"#, + r#"const Deno = 42; const a = new Deno[`File`]();"#, + r#"const Deno = 42; await Deno[`flock`](rid, exclusive);"#, + r#"const Deno = 42; Deno[`flockSync`](rid, exclusive);"#, + r#"const Deno = 42; const a = await Deno[`fstat`](rid);"#, + r#"const Deno = 42; const a = Deno[`fstatSync`](rid);"#, + r#"const Deno = 42; await Deno[`fsync`](rid);"#, + r#"const Deno = 42; Deno[`fsyncSync`](rid);"#, + r#"const Deno = 42; await Deno[`ftruncate`](rid, len);"#, + r#"const Deno = 42; Deno[`ftruncateSync`](rid, len);"#, + r#"const Deno = 42; await Deno[`funlock`](rid);"#, + r#"const Deno = 42; Deno[`funlockSync`](rid);"#, + r#"const Deno = 42; await Deno[`futime`](rid, atime, mtime);"#, + r#"const Deno = 42; Deno[`futimeSync`](rid, atime, mtime);"#, + r#"const Deno = 42; const a = Deno[`isatty`](rid);"#, + r#"const Deno = 42; for await (const x of Deno[`iter`](reader)) {}"#, + r#"const Deno = 42; for (const x of Deno[`iterSync`](reader)) {}"#, r#"const Deno = 42; Deno[`metrics`]();"#, + r#"const Deno = 42; const a = await Deno[`read`](reader, buffer);"#, + r#"const Deno = 42; const a = Deno[`readSync`](rid, buffer);"#, + r#"const Deno = 42; const a = await Deno[`readAll`](reader);"#, + r#"const Deno = 42; const a = Deno[`readAllSync`](reader);"#, r#"const Deno = 42; Deno[`resources`]();"#, - r#"const Deno = 42; Deno[`serveHttp`]();"#, + r#"const Deno = 42; const a = Deno[`run`](options);"#, + r#"const Deno = 42; const a = await Deno[`seek`](rid, offset, whence);"#, + r#"const Deno = 42; const a = Deno[`seekSync`](rid, offset, whence);"#, + r#"const Deno = 42; const a = Deno[`serveHttp`]();"#, + r#"const Deno = 42; await Deno[`shutdown`](rid);"#, + r#"const Deno = 42; const a = await Deno[`write`](rid, data);"#, + r#"const Deno = 42; const a = Deno[`writeSync`](rid, data);"#, + r#"const Deno = 42; await Deno[`writeAll`](writer, data);"#, + r#"const Deno = 42; Deno[`writeAllSync`](writer, data);"#, // Ignore template literals that include expressions r#"const read = "read"; Deno[`${read}All`](reader);"#, @@ -724,18 +828,102 @@ Deno.readAll(reader); let tests = vec![ ( "Buffer", - "Use `https://deno.land/std/io/buffer.ts?s=Buffer` instead", + "Use `Buffer` from https://jsr.io/@std/io/doc/buffer/~/Buffer instead", + ), + ( + "close", + "Use `.close()` from the given class instance instead", + ), + ( + "copy", + "Use `copy()` from https://jsr.io/@std/io/doc/copy/~/copy instead", + ), + ( + "customInspect", + "Use `Symbol.for(\"Deno.customInspect\")` instead", + ), + ("fdatasync", "Use `.syncData()` from the given class instance instead"), + ( + "fdatasyncSync", + "Use `.syncDataSync()` from the given class instance instead", ), - ("copy", "Use `https://deno.land/std/io/copy.ts?s=copy` instead"), - ("customInspect", "Use `Symbol.for(\"Deno.customInspect\")` instead"), ("File", "Use `Deno.FsFile` instead"), - ("iter", "Use `https://deno.land/api?s=ReadableStream` instead"), - ("iterSync", "Use `https://deno.land/api?s=ReadableStream` instead"), - ("readAll", "Use `readAll` from https://deno.land/std/io/read_all.ts?s=readAll instead"), - ("readAllSync", "Use `readAllSync` from https://deno.land/std/io/read_all.ts?s=readAllSync instead"), - ("run", "Use `Deno.Command` from https://deno.land/api?s=Deno.Command instead"), - ("writeAll", "Use `writeAll` from https://deno.land/std/io/write_all.ts?s=writeAll instead"), - ("writeAllSync", "Use `writeAllSync` from https://deno.land/std/io/write_all.ts?s=writeAllSync instead"), + ("flock", "Use `.lock()` from the given class instance instead"), + ( + "flockSync", + "Use `.lockSync()` from the given class instance instead", + ), + ("fstat", "Use `.stat()` from the given class instance instead"), + ( + "fstatSync", + "Use `.statSync()` from the given class instance instead", + ), + ("fsync", "Use `.sync()` from the given class instance instead"), + ( + "fsyncSync", + "Use `.syncSync()` from the given class instance instead", + ), + ( + "ftruncate", + "Use `.truncate()` from the given class instance instead", + ), + ( + "ftruncateSync", + "Use `.truncateSync()` from the given class instance instead", + ), + ("funlock", "Use `.unlock()` from the given class instance instead"), + ( + "funlockSync", + "Use `.unlockSync()` from the given class instance instead", + ), + ("futime", "Use `.utime()` from the given class instance instead"), + ( + "futimeSync", + "Use `.utimeSync()` from the given class instance instead", + ), + ("isatty", "Use `.isTerminal()` from the given class instance instead"), + ( + "iter", + "Use `iterateReader()` from https://jsr.io/@std/io/doc/iterate-reader/~/iterateReader instead", + ), + ( + "iterSync", + "Use `iterateReaderSync()` from https://jsr.io/@std/io/doc/iterate-reader/~/iterateReaderSync instead", + ), + ("read", "Use `.read()` from the given class instance instead"), + ("readSync", "Use `.readSync()` from the given class instance instead"), + ( + "readAll", + "Use `readAll()` from https://jsr.io/@std/io/doc/read-all/~/readAll instead", + ), + ( + "readAllSync", + "Use `readAllSync()` from https://jsr.io/@std/io/doc/read-all/~/readAllSync instead", + ), + ( + "run", + "Use `Deno.Command` from https://deno.land/api?s=Deno.Command instead", + ), + ("seek", "Use `.seek()` from the given class instance instead"), + ("seekSync", "Use `.seekSync()` from the given class instance instead"), + ( + "serveHttp", + "Use `Deno.serve()` instead", + ), + ("shutdown", "Use `.closeWrite()` from the given class instance instead"), + ("write", "Use `.write()` from the given class instance instead"), + ( + "writeSync", + "Use `.writeSync()` from the given class instance instead", + ), + ( + "writeAll", + "Use `writeAll` from https://jsr.io/@std/io/doc/write-all/~/writeAllSync instead", + ), + ( + "writeAllSync", + "Use `writeAllSync` from https://jsr.io/@std/io/doc/write-all/~/writeAllSync instead", + ), ]; for test in tests {