Skip to content

[space-infix-ops] no error when right type is function #4802

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
andrewda opened this issue Apr 11, 2022 · 0 comments · Fixed by #4848
Closed
3 tasks done

[space-infix-ops] no error when right type is function #4802

andrewda opened this issue Apr 11, 2022 · 0 comments · Fixed by #4848
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working formatting Related to whitespace/bracket formatting. We strongly recommend you use a formatter instead. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@andrewda
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

module.exports = {
	"parser": "@typescript-eslint/parser",
	"plugins": ["@typescript-eslint"],
	"extends": [
		"eslint:recommended",
		"plugin:@typescript-eslint/eslint-recommended",
		"plugin:@typescript-eslint/recommended"
	],
	"rules": {
		"@typescript-eslint/space-infix-ops": "error"
	}
}
// Does not throw error 👎
export interface Test {
  default?: boolean|(() => boolean);
}
// Does not throw error 👎
export interface Test {
  default?: (() => boolean)|(() => string);
}
// Correctly throws error 👍
export interface Test {
  default?: (() => boolean)|boolean;
}
// Correctly throws error 👍
export interface Test {
  default?: boolean | (() => boolean|Promise<boolean>);
}
// Correctly throws error 👍
export interface Test {
  default?: boolean|string;
}

Expected Result

I expect an error when running npx eslint repro.ts on the first two cases above:

/home/andrewda/Development/repro.ts
  2:20  error  Operator '|' must be spaced  @typescript-eslint/space-infix-ops

Actual Result

No error messages are printed by eslint when the right type is a function, e.g. (() => string). If the left type is a function, errors are thrown correctly.

Versions

package version
@typescript-eslint/eslint-plugin 5.18.0
@typescript-eslint/parser 5.18.0
TypeScript 4.6.3
ESLint 8.13.0
node 16.13.0
@andrewda andrewda added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Apr 11, 2022
@JoshuaKGoldberg JoshuaKGoldberg added bug Something isn't working accepting prs Go ahead, send a pull request that resolves this issue formatting Related to whitespace/bracket formatting. We strongly recommend you use a formatter instead. and removed triage Waiting for team members to take a look labels Apr 17, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working formatting Related to whitespace/bracket formatting. We strongly recommend you use a formatter instead. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants