-
Notifications
You must be signed in to change notification settings - Fork 248
Closed
Labels
Description
It looks like eslint crashes on a specific file in my project:
const request = require('supertest');
describe('eslintplugin-jest PoC', () => {
test('should not crash', () => new Promise((done) => {
request() // Some parts of the code not reproduced here but issue will happen with this simplified file
.then(() => {
expect(1).toBe(1);
return done();
});
}));
});Stacktrace:
$ /some/frontend_project/node_modules/.bin/eslint server/poc.js
TypeError: Cannot read property 'type' of undefined
at isPromiseReturnedLater (/some/frontend_project/node_modules/eslint-plugin-jest/rules/valid-expect-in-promise.js:61:24)
at isParentThenOrPromiseReturned (/some/frontend_project/node_modules/eslint-plugin-jest/rules/valid-expect-in-promise.js:92:5)
at promiseCallbacks.some.promiseCallback (/some/frontend_project/node_modules/eslint-plugin-jest/rules/valid-expect-in-promise.js:107:10)
at Array.some (<anonymous>)
at verifyExpectWithReturn (/some/frontend_project/node_modules/eslint-plugin-jest/rules/valid-expect-in-promise.js:103:20)
at MemberExpression (/some/frontend_project/node_modules/eslint-plugin-jest/rules/valid-expect-in-promise.js:154:13)
at listeners.(anonymous function).forEach.listener (/some/frontend_project/node_modules/eslint/lib/util/safe-emitter.js:45:58)
at Array.forEach (<anonymous>)
at Object.emit (/some/frontend_project/node_modules/eslint/lib/util/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/some/frontend_project/node_modules/eslint/lib/util/node-event-generator.js:251:26)
error Command failed with exit code 2.
Versions
- eslint@5.8.0
- eslint-plugin-jest@21.26.2
Eslint config
yarn eslint --print-config server/poc.js produces:
[...]
"jest/expect-expect": [
"warn",
{
"assertFunctionNames": [
"expect",
"assert"
]
}
],
"jest/no-test-callback": "warn",
"jest/no-test-return-statement": "warn",
"jest/prefer-to-be-undefined": "warn",
"jest/prefer-to-contain": "warn",
"jest/valid-expect-in-promise": "warn",
[...]
I also extend plugin:jest/recommended and airbnb.
Everything works perfectly well for the other files.
Let me know if you need more information.
lukeapage