Skip to content
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

Raise foreach exception during linting of typescript files #205

Closed
bskydive opened this issue Sep 14, 2020 · 4 comments
Closed

Raise foreach exception during linting of typescript files #205

bskydive opened this issue Sep 14, 2020 · 4 comments

Comments

@bskydive
Copy link

bskydive commented Sep 14, 2020

Description

Raise forEach exception during linting of typescript files

Steps to Reproduce

  1. Install and configure eslint-plugin-promise like described in https://github.com/xjamundx/eslint-plugin-promise/blob/development/README.md
  2. install and configure @typescript-eslint/parser like described in https://github.com/typescript-eslint/typescript-eslint#readme
  3. remove all rules except 'promise/no-native': 'warn', in .eslintrc.js
  4. add to package.json scripts section "lint": "eslint ./src --ext .ts,.tsx",
  5. add some *.ts or *.tsx files in the src folder
  6. run npm run lint

Workaround:

  1. comment // 'promise/no-native': 'warn', rule in .eslintrc.js
  2. run npm run lint

Expected behavior:

Eslint perform linting without throwing TypeError: Cannot read property 'forEach' of undefined

Actual behavior:

TypeError: Cannot read property 'forEach' of undefined
Occurred while linting ./src/somefile.ts:1
    at Program:exit (./node_modules/eslint-plugin-promise/rules/no-native.js:43:29)
    at ./node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (./node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (./node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (./node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.leaveNode (./node_modules/eslint/lib/linter/node-event-generator.js:306:14)
    at CodePathAnalyzer.leaveNode (./node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:655:23)
    at ./node_modules/eslint/lib/linter/linter.js:938:32
    at Array.forEach (<anonymous>)

Versions

  • Node version: 14.5.0
  • ESLint version: 6.6.0, 7.9.0
  • eslint-plugin-promise version: 4.2.1
  • "@typescript-eslint/eslint-plugin": "^4.1.0",
  • "@typescript-eslint/parser": "^4.1.0",

Additional Information

.eslintrc.js

module.exports = {
	extends: [
		'plugin:promise/recommended'
	],
	env: {
		browser: true,
		node: true
	},
	parser: '@typescript-eslint/parser', 
	parserOptions: {
		project: ['./tsconfig.eslint.json'],
		ecmaFeatures: {
			tsx: true,
			jsx: true
		}
	},
	plugins: [
		'eslint-plugin-promise',
	],
	rules: {
		'promise/no-native': 'warn',
	}
};
@ghost
Copy link

ghost commented Mar 3, 2021

Had the same issue.

Any news about this one?

@aaditmshah
Copy link
Contributor

I'm also facing the same issue. It's been almost 2 years since this issue was first reported. Any updates?

@xjamundx
Copy link
Contributor

xjamundx commented Aug 24, 2022 via email

@aaditmshah
Copy link
Contributor

@xjamundx Fixed the issue in #331.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants