Skip to content

Commit 48d18e0

Browse files
committed
docs(linter): Improve diagnostic message for promise/catch-or-return rule (#15980)
Including the rule name in the diagnostic was a bit odd.
1 parent cce1c89 commit 48d18e0

File tree

2 files changed

+51
-53
lines changed

2 files changed

+51
-53
lines changed

crates/oxc_linter/src/rules/promise/catch_or_return.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ use crate::{
1212
};
1313

1414
fn catch_or_return_diagnostic(method_name: &str, span: Span) -> OxcDiagnostic {
15-
OxcDiagnostic::warn(format!(
16-
"eslint-plugin-promise(catch-or-return): Expected {method_name} or return"
17-
))
18-
.with_help(format!("Return the promise or chain a {method_name}()"))
19-
.with_label(span)
15+
OxcDiagnostic::warn(format!("Expected `{method_name}` or `return`."))
16+
.with_help(format!("Return the promise or chain a `{method_name}()`."))
17+
.with_label(span)
2018
}
2119

2220
#[derive(Debug, Default, Clone)]
Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,170 @@
11
---
22
source: crates/oxc_linter/src/tester.rs
33
---
4-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
4+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
55
╭─[catch_or_return.tsx:1:37]
66
1function callPromise(promise, cb) { promise.then(cb) }
77
· ────────────────
88
╰────
9-
help: Return the promise or chain a catch()
9+
help: Return the promise or chain a `catch()`.
1010

11-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
11+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
1212
╭─[catch_or_return.tsx:1:1]
1313
1fetch("http://www.yahoo.com").then(console.log.bind(console))
1414
· ─────────────────────────────────────────────────────────────
1515
╰────
16-
help: Return the promise or chain a catch()
16+
help: Return the promise or chain a `catch()`.
1717

18-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
18+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
1919
╭─[catch_or_return.tsx:1:1]
2020
1a.then(function() { return "x"; }).then(function(y) { throw y; })
2121
· ─────────────────────────────────────────────────────────────────
2222
╰────
23-
help: Return the promise or chain a catch()
23+
help: Return the promise or chain a `catch()`.
2424

25-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
25+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
2626
╭─[catch_or_return.tsx:1:1]
2727
1Promise.resolve(frank)
2828
· ──────────────────────
2929
╰────
30-
help: Return the promise or chain a catch()
30+
help: Return the promise or chain a `catch()`.
3131

32-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
32+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
3333
╭─[catch_or_return.tsx:1:1]
3434
1Promise.all([])
3535
· ───────────────
3636
╰────
37-
help: Return the promise or chain a catch()
37+
help: Return the promise or chain a `catch()`.
3838

39-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
39+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
4040
╭─[catch_or_return.tsx:1:1]
4141
1Promise.allSettled([])
4242
· ──────────────────────
4343
╰────
44-
help: Return the promise or chain a catch()
44+
help: Return the promise or chain a `catch()`.
4545

46-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
46+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
4747
╭─[catch_or_return.tsx:1:1]
4848
1Promise.any([])
4949
· ───────────────
5050
╰────
51-
help: Return the promise or chain a catch()
51+
help: Return the promise or chain a `catch()`.
5252

53-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
53+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
5454
╭─[catch_or_return.tsx:1:1]
5555
1Promise.race([])
5656
· ────────────────
5757
╰────
58-
help: Return the promise or chain a catch()
58+
help: Return the promise or chain a `catch()`.
5959

60-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
60+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
6161
╭─[catch_or_return.tsx:1:1]
6262
1frank().then(to).catch(fn).then(foo)
6363
· ────────────────────────────────────
6464
╰────
65-
help: Return the promise or chain a catch()
65+
help: Return the promise or chain a `catch()`.
6666

67-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
67+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
6868
╭─[catch_or_return.tsx:1:1]
6969
1frank().finally(fn)
7070
· ───────────────────
7171
╰────
72-
help: Return the promise or chain a catch()
72+
help: Return the promise or chain a `catch()`.
7373

74-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
74+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
7575
╭─[catch_or_return.tsx:1:1]
7676
1frank().then(to).finally(fn)
7777
· ────────────────────────────
7878
╰────
79-
help: Return the promise or chain a catch()
79+
help: Return the promise or chain a `catch()`.
8080

81-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
81+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
8282
╭─[catch_or_return.tsx:1:1]
8383
1frank().then(go).catch(doIt).finally(fn)
8484
· ────────────────────────────────────────
8585
╰────
86-
help: Return the promise or chain a catch()
86+
help: Return the promise or chain a `catch()`.
8787

88-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
88+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
8989
╭─[catch_or_return.tsx:1:1]
9090
1frank().then(go).then().then().then().catch(doIt).finally(fn)
9191
· ─────────────────────────────────────────────────────────────
9292
╰────
93-
help: Return the promise or chain a catch()
93+
help: Return the promise or chain a `catch()`.
9494

95-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
95+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
9696
╭─[catch_or_return.tsx:1:1]
9797
1frank().then(go).then().catch(function() { /* why bother */ }).finally(fn)
9898
· ──────────────────────────────────────────────────────────────────────────
9999
╰────
100-
help: Return the promise or chain a catch()
100+
help: Return the promise or chain a `catch()`.
101101

102-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
102+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
103103
╭─[catch_or_return.tsx:1:16]
104104
1function a() { frank().then(go) }
105105
· ────────────────
106106
╰────
107-
help: Return the promise or chain a catch()
107+
help: Return the promise or chain a `catch()`.
108108

109-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
109+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
110110
╭─[catch_or_return.tsx:1:16]
111111
1function a() { frank().then(go).then().then().then() }
112112
· ─────────────────────────────────────
113113
╰────
114-
help: Return the promise or chain a catch()
114+
help: Return the promise or chain a `catch()`.
115115

116-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
116+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
117117
╭─[catch_or_return.tsx:1:16]
118118
1function a() { frank().then(go).then()}
119119
· ───────────────────────
120120
╰────
121-
help: Return the promise or chain a catch()
121+
help: Return the promise or chain a `catch()`.
122122

123-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
123+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
124124
╭─[catch_or_return.tsx:1:16]
125125
1function a() { frank.then(go).then(to) }
126126
· ───────────────────────
127127
╰────
128-
help: Return the promise or chain a catch()
128+
help: Return the promise or chain a `catch()`.
129129

130-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
130+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
131131
╭─[catch_or_return.tsx:1:1]
132132
1frank().then(go).catch(doIt).finally(fn).then(foo)
133133
· ──────────────────────────────────────────────────
134134
╰────
135-
help: Return the promise or chain a catch()
135+
help: Return the promise or chain a `catch()`.
136136

137-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
137+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
138138
╭─[catch_or_return.tsx:1:1]
139139
1frank().then(go).catch(doIt).finally(fn).foobar(foo)
140140
· ────────────────────────────────────────────────────
141141
╰────
142-
help: Return the promise or chain a catch()
142+
help: Return the promise or chain a `catch()`.
143143

144-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected done or return
144+
eslint-plugin-promise(catch-or-return): Expected `done` or `return`.
145145
╭─[catch_or_return.tsx:1:1]
146146
1frank().then(go)
147147
· ────────────────
148148
╰────
149-
help: Return the promise or chain a done()
149+
help: Return the promise or chain a `done()`.
150150

151-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected done or return
151+
eslint-plugin-promise(catch-or-return): Expected `done` or `return`.
152152
╭─[catch_or_return.tsx:1:1]
153153
1frank().catch(go)
154154
· ─────────────────
155155
╰────
156-
help: Return the promise or chain a done()
156+
help: Return the promise or chain a `done()`.
157157

158-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
158+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
159159
╭─[catch_or_return.tsx:1:1]
160160
1frank().catch(go).someOtherMethod()
161161
· ───────────────────────────────────
162162
╰────
163-
help: Return the promise or chain a catch()
163+
help: Return the promise or chain a `catch()`.
164164

165-
eslint-plugin-promise(catch-or-return): eslint-plugin-promise(catch-or-return): Expected catch or return
165+
eslint-plugin-promise(catch-or-return): Expected `catch` or `return`.
166166
╭─[catch_or_return.tsx:1:1]
167167
1frank()['catch'](go).someOtherMethod()
168168
· ──────────────────────────────────────
169169
╰────
170-
help: Return the promise or chain a catch()
170+
help: Return the promise or chain a `catch()`.

0 commit comments

Comments
 (0)