Skip to content

Commit 116552c

Browse files
committed
turn ignorelastcallback to true
1 parent 1e13293 commit 116552c

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

__tests__/always-return.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ ruleTester.run('always-return', rule, {
111111
{
112112
code: 'hey.then(x => {})',
113113
errors: [{ message }],
114+
options: [{ ignoreLastCallback: false }],
114115
},
115116
{
116117
code: 'hey.then(function() { })',
117118
errors: [{ message }],
119+
options: [{ ignoreLastCallback: false }],
118120
},
119121
{
120122
code: 'hey.then(function() { }).then(x)',
@@ -123,42 +125,52 @@ ruleTester.run('always-return', rule, {
123125
{
124126
code: 'hey.then(function() { }).then(function() { })',
125127
errors: [{ message }, { message }],
128+
options: [{ ignoreLastCallback: false }],
126129
},
127130
{
128131
code: 'hey.then(function() { return; }).then(function() { })',
129132
errors: [{ message }],
133+
options: [{ ignoreLastCallback: false }],
130134
},
131135
{
132136
code: 'hey.then(function() { doSomethingWicked(); })',
133137
errors: [{ message }],
138+
options: [{ ignoreLastCallback: false }],
134139
},
135140
{
136141
code: 'hey.then(function() { if (x) { return x; } })',
137142
errors: [{ message }],
143+
options: [{ ignoreLastCallback: false }],
138144
},
139145
{
140146
code: 'hey.then(function() { if (x) { return x; } else { }})',
141147
errors: [{ message }],
148+
options: [{ ignoreLastCallback: false }],
142149
},
143150
{
144151
code: 'hey.then(function() { if (x) { } else { return x; }})',
145152
errors: [{ message }],
153+
options: [{ ignoreLastCallback: false }],
146154
},
147155
{
148156
code: 'hey.then(function() { if (x) { process.chdir(); } else { return x; }})',
149157
errors: [{ message }],
158+
options: [{ ignoreLastCallback: false }],
150159
},
151160
{
152161
code: 'hey.then(function() { if (x) { return you.then(function() { return x; }); } })',
153162
errors: [{ message }],
163+
options: [{ ignoreLastCallback: false }],
154164
},
155165
{
156166
code: 'hey.then( x => { x ? x.id : null })',
157167
errors: [{ message }],
168+
options: [{ ignoreLastCallback: false }],
158169
},
159170
{
160171
code: 'hey.then(function(x) { x ? x.id : null })',
161172
errors: [{ message }],
173+
options: [{ ignoreLastCallback: false }],
162174
},
163175
{
164176
code: `(function() {
@@ -181,6 +193,7 @@ ruleTester.run('always-return', rule, {
181193
}
182194
})`,
183195
errors: [{ message }],
196+
options: [{ ignoreLastCallback: false }],
184197
},
185198
{
186199
code: `
@@ -190,6 +203,7 @@ ruleTester.run('always-return', rule, {
190203
}
191204
})`,
192205
errors: [{ message }],
206+
options: [{ ignoreLastCallback: false }],
193207
},
194208
{
195209
code: `

docs/rules/always-return.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ myPromise.then((b) => {
4949

5050
##### `ignoreLastCallback`
5151

52-
You can pass an `{ ignoreLastCallback: true }` as an option to this rule to the
53-
last `then()` callback in a promise chain does not warn if it does not have a
54-
`return`. Default is `false`.
52+
You can pass an `{ ignoreLastCallback: false }` as an option to this rule to
53+
have the last `then()` callback in a promise chain not warn if it does not have
54+
a `return`. Default is `true`.
5555

5656
```js
5757
// OK

rules/always-return.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ module.exports = {
149149
},
150150
create(context) {
151151
const options = context.options[0] || {}
152-
const ignoreLastCallback = !!options.ignoreLastCallback
152+
const ignoreLastCallback = options.ignoreLastCallback ?? true
153153
/**
154154
* @typedef {object} FuncInfo
155155
* @property {string[]} branchIDStack This is a stack representing the currently

0 commit comments

Comments
 (0)