Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions crates/oxc_linter/src/rules/promise/catch_or_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ use crate::{
};

fn catch_or_return_diagnostic(method_name: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!(
"eslint-plugin-promise(catch-or-return): Expected {method_name} or return"
))
.with_help(format!("Return the promise or chain a {method_name}()"))
.with_label(span)
OxcDiagnostic::warn(format!("Expected `{method_name}` or `return`."))
.with_help(format!("Return the promise or chain a `{method_name}()`."))
.with_label(span)
}

#[derive(Debug, Default, Clone)]
Expand Down
96 changes: 48 additions & 48 deletions crates/oxc_linter/src/snapshots/promise_catch_or_return.snap
Original file line number Diff line number Diff line change
@@ -1,170 +1,170 @@
---
source: crates/oxc_linter/src/tester.rs
---
⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:37]
1 │ function callPromise(promise, cb) { promise.then(cb) }
· ────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ fetch("http://www.yahoo.com").then(console.log.bind(console))
· ─────────────────────────────────────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ a.then(function() { return "x"; }).then(function(y) { throw y; })
· ─────────────────────────────────────────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ Promise.resolve(frank)
· ──────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ Promise.all([])
· ───────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ Promise.allSettled([])
· ──────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ Promise.any([])
· ───────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ Promise.race([])
· ────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank().then(to).catch(fn).then(foo)
· ────────────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank().finally(fn)
· ───────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank().then(to).finally(fn)
· ────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank().then(go).catch(doIt).finally(fn)
· ────────────────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank().then(go).then().then().then().catch(doIt).finally(fn)
· ─────────────────────────────────────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank().then(go).then().catch(function() { /* why bother */ }).finally(fn)
· ──────────────────────────────────────────────────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:16]
1 │ function a() { frank().then(go) }
· ────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:16]
1 │ function a() { frank().then(go).then().then().then() }
· ─────────────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:16]
1 │ function a() { frank().then(go).then()}
· ───────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:16]
1 │ function a() { frank.then(go).then(to) }
· ───────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank().then(go).catch(doIt).finally(fn).then(foo)
· ──────────────────────────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank().then(go).catch(doIt).finally(fn).foobar(foo)
· ────────────────────────────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected done or return
⚠ eslint-plugin-promise(catch-or-return): Expected `done` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank().then(go)
· ────────────────
╰────
help: Return the promise or chain a done()
help: Return the promise or chain a `done()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected done or return
⚠ eslint-plugin-promise(catch-or-return): Expected `done` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank().catch(go)
· ─────────────────
╰────
help: Return the promise or chain a done()
help: Return the promise or chain a `done()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank().catch(go).someOtherMethod()
· ───────────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.

⚠ eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
⚠ eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
╭─[catch_or_return.tsx:1:1]
1 │ frank()['catch'](go).someOtherMethod()
· ──────────────────────────────────────
╰────
help: Return the promise or chain a catch()
help: Return the promise or chain a `catch()`.
Loading