Skip to content

[Bug] await on non-async function does not throw an error #2997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
AbdelrahmanHafez opened this issue Feb 4, 2021 · 1 comment
Closed
3 tasks done

[Bug] await on non-async function does not throw an error #2997

AbdelrahmanHafez opened this issue Feb 4, 2021 · 1 comment
Labels
package: parser Issues related to @typescript-eslint/parser working as intended Issues that are closed as they are working as intended

Comments

@AbdelrahmanHafez
Copy link

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "parser": "@typescript-eslint/parser",
  "plugins": ["@typescript-eslint"]
}
run();

function run () {
  await 'anything'; // SyntaxError: await is only valid in async function
}

Expected Result

Expected ESLint to throw an error, I am using await without declaring the function as async.

  4:9  error  Parsing error: Unexpected token 'anything'   
✖ 1 problem (1 error, 0 warnings)

Actual Result
ESLint falsely passes, when removing the parser property in .eslintrc, it correctly gives me the error in the expected result.

Additional Info

Debug output:

  eslint:cli CLI args: [ '--debug', './test.js' ] +0ms
  eslint:cli Running on files +5ms
  eslintrc:config-array-factory Loading .eslintignore file: my-directory\.eslintignore +0ms
  eslintrc:ignore-pattern Create with: [ IgnorePattern { patterns: [ '/**/node_modules/*' ], basePath: 'my-directory', loose: false } ] +0ms
  eslintrc:ignore-pattern   processed: { basePath: 'my-directory', patterns: [ '/**/node_modules/*' ] } +5ms
  eslintrc:ignore-pattern Create with: [ IgnorePattern { patterns: [ '/**/node_modules/*' ], basePath: 'my-directory', loose: false } ] +2ms
  eslintrc:ignore-pattern   processed: { basePath: 'my-directory', patterns: [ '/**/node_modules/*' ] } +2ms
  eslint:file-enumerator Start to iterate files: [ './test.js' ] +0ms
  eslint:file-enumerator File: my-directory\test.js +1ms
  eslintrc:cascading-config-array-factory Load config files for my-directory. +0ms
  eslintrc:cascading-config-array-factory No cache found: my-directory. +2ms
  eslintrc:config-array-factory Loading legacy config file: my-directory\.eslintrc +18ms
  eslintrc:config-array-factory Config file found: my-directory\.eslintrc +24ms
  eslintrc:config-array-factory Loading parser "@typescript-eslint/parser" from my-directory\.eslintrc +1ms
  eslintrc:config-array-factory Loaded: @typescript-eslint/parser@4.14.1 (my-directory\node_modules\@typescript-eslint\parser\dist\index.js) +3ms
  eslintrc:config-array-factory Loading plugin "@typescript-eslint" from my-directory\.eslintrc +286ms
  eslintrc:config-array-factory Loaded: @typescript-eslint/eslint-plugin@4.14.1 (my-directory\node_modules\@typescript-eslint\eslint-plugin\dist\index.js) +2ms
  eslintrc:config-array-factory Plugin my-directory\node_modules\@typescript-eslint\eslint-plugin\dist\index.js loaded in: 291ms +292ms
  eslintrc:cascading-config-array-factory No cache found: E:\Info\localhost\Web Development\NodeJS. +610ms
  eslintrc:config-array-factory Config file not found on E:\Info\localhost\Web Development\NodeJS +3ms
  eslintrc:cascading-config-array-factory No cache found: E:\Info\localhost\Web Development. +2ms
  eslintrc:config-array-factory Config file not found on E:\Info\localhost\Web Development +4ms
  eslintrc:cascading-config-array-factory No cache found: E:\Info\localhost. +4ms
  eslintrc:config-array-factory Config file not found on E:\Info\localhost +2ms
  eslintrc:cascading-config-array-factory No cache found: E:\Info. +2ms
  eslintrc:config-array-factory Config file not found on E:\Info +1ms
  eslintrc:cascading-config-array-factory No cache found: E:\. +2ms
  eslintrc:config-array-factory Config file not found on E:\ +3ms
  eslintrc:cascading-config-array-factory Configuration was determined: ConfigArray(3) [ { type: 'config', name: 'DefaultIgnorePattern', filePath: '', criteria: null, env: undefined, globals: undefined, ignorePattern: IgnorePattern { patterns: [Array], basePath: 'my-directory', loose: false }, noInlineConfig: undefined, parser: undefined, parserOptions: undefined, plugins: undefined, processor: undefined, reportUnusedDisableDirectives: undefined, root: undefined, rules: undefined, settings: undefined }, { type: 'config', name: '.eslintrc', filePath: 'my-directory\\.eslintrc', criteria: null, env: undefined, globals: undefined, ignorePattern: undefined, noInlineConfig: undefined, parser: { error: null, filePath: 'my-directory\\node_modules\\@typescript-eslint\\parser\\dist\\index.js', id: '@typescript-eslint/parser', importerName: '.eslintrc', importerPath: 'my-directory\\.eslintrc' }, parserOptions: undefined, plugins: { '@typescript-eslint': [Object] }, processor: undefined, reportUnusedDisableDirectives: undefined, root: undefined, rules: undefined, settings: undefined }, { type: 'ignore', name: '.eslintignore', filePath: 'my-directory\\.eslintignore', criteria: null, env: undefined, globals: undefined, ignorePattern: IgnorePattern { patterns: [Array], basePath: 'my-directory', loose: true }, noInlineConfig: undefined, parser: undefined, parserOptions: undefined, plugins: undefined, processor: undefined, reportUnusedDisableDirectives: undefined, root: undefined, rules: undefined, settings: undefined } ] on my-directory +4ms
  eslintrc:ignore-pattern Create with: [ IgnorePattern { patterns: [ '/**/node_modules/*' ], basePath: 'my-directory', loose: false }, IgnorePattern { patterns: [ '/node_modules/*' ], basePath: 'my-directory', loose: true } ] +652ms
  eslintrc:ignore-pattern   processed: { basePath: 'my-directory', patterns: [ '/**/node_modules/*', '/node_modules/*' ] } +4ms
  eslintrc:ignore-pattern Check {
  filePath: 'my-directory\\test.js',
  dot: false,
  relativePath: 'test.js',
  result: false
} +2ms
  eslint:cli-engine Lint my-directory\test.js +0ms
  eslint:linter Linting code for my-directory\test.js (pass 1) +0ms
  eslint:linter Verify +1ms
  eslint:linter With ConfigArray: my-directory\test.js +0ms
  eslint:linter Generating fixed text for my-directory\test.js (pass 1) +24ms
  eslint:source-code-fixer Applying fixes +0ms
  eslint:source-code-fixer shouldFix parameter was false, not attempting fixes +1ms
  eslint:file-enumerator Complete iterating files: ["./test.js"] +688ms
  eslint:cli-engine Linting complete in: 691ms +31ms

Versions

package version
@typescript-eslint/parser 4.14.1
TypeScript 4.1.3
ESLint 7.19.0
node 14.15.4
@AbdelrahmanHafez AbdelrahmanHafez added package: parser Issues related to @typescript-eslint/parser triage Waiting for team members to take a look labels Feb 4, 2021
@bradzacher bradzacher added working as intended Issues that are closed as they are working as intended and removed triage Waiting for team members to take a look labels Feb 4, 2021
@bradzacher
Copy link
Member

Our parser does not throw errors #1852

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: parser Issues related to @typescript-eslint/parser working as intended Issues that are closed as they are working as intended
Projects
None yet
Development

No branches or pull requests

2 participants