I set
'require-await': 'off',
'@typescript-eslint/require-await': 'error',
and alsoturning off the typescript-eslint rule gets rid of the error.
I'm getting this error only since today after "yarn upgrade" upgrade typescript-eslint (it worked with the previous published version, I run that package upgrade command daily).
So this seems to be a regression.
EDIT: The error occurs in a file belonging to eslint. However the rule is turned off for eslint, and when I turn off the typescript-eslint rule the error disappears. So while it is reported in an eslint file it seems to originate from typescript-eslint? eslint was not updated in a month and it all worked -- with daily package updates and package.json set to "*" for all these packages to always get whatever is latest -- until I ran today's update.
TypeError: Cannot set property 'hasAwait' of null
Occurred while linting /home/mha/Projects/core/src/websocket-promisifier.ts:493
TypeError: Cannot set property 'hasAwait' of null
Occurred while linting /home/mha/Projects/core/src/websocket-promisifier.ts:493
at Object.AwaitExpression (/home/mha/Projects/core/node_modules/eslint/lib/rules/require-await.js:92:36)
at ReturnStatement (/home/mha/Projects/core/node_modules/@typescript-eslint/eslint-plugin/dist/rules/require-await.js:68:27)
at /home/mha/Projects/core/node_modules/eslint/lib/linter/safe-emitter.js:45:58
at Array.forEach (<anonymous>)
at Object.emit (/home/mha/Projects/core/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
at NodeEventGenerator.applySelector (/home/mha/Projects/core/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
at NodeEventGenerator.applySelectors (/home/mha/Projects/core/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
at NodeEventGenerator.enterNode (/home/mha/Projects/core/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
at CodePathAnalyzer.enterNode (/home/mha/Projects/core/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:634:23)
at /home/mha/Projects/core/node_modules/eslint/lib/linter/linter.js:936:32
The code at websocket-promisifier.ts:493 is ("function" header is line 492)
function sendFn(type: number, ...args: ReadonlyArray<unknown>): Promise<unknown> {
return new Promise((resolve, reject) => {
...
Another file that has that error has it in a function that has this return statement:
return (): Promise<void> => {
if (lastAccessibleObjectsSize < RESUME_THRESHOLD) {
return Promise.resolve(); // ESLINT ERROR HERE
}
....
};
eslintrc (top):
module.exports = {
root: true,
// eslint recommended defaults can be found in [INSTALL_DIR]/eslint/conf/eslint.json
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/eslint-recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
ecmaFeatures: {impliedStrict: true},
project: './tsconfig.json'
},
env: {
es6: true,
mocha: true,
node: true,
browser: true
},
plugins: ['@typescript-eslint', 'jsdoc'],
rules: {
...
Versions
| package | version |
| ---------------------------------- | ------- |
| @typescript-eslint/eslint-plugin | 2.8.0 |
| @typescript-eslint/parser | 2.8.0 |
| TypeScript | 3.7.2 |
| ESLint | 6.6.0 |
| node | 12.13.1 |
| npm | `6.12.1 |
This is all inside functions though — I'm not using global await.
Furthermore, there is no await at all in those locations, those are no "async" functions but regular functions returning a "traditional" manually created Promise.
Duplicate of #1226
The fix has been merged to master, and will be released monday.
If you need it sooner, please try the canary tag.
Most helpful comment
Duplicate of #1226
The fix has been merged to master, and will be released monday.
If you need it sooner, please try the canary tag.