Bug: prefer-optional-chain throws error unexpected Identifier #5556
Labels
duplicate
This issue or pull request already exists
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=4.7.4&sourceType=module&code=MYewdgzgLgBAZiEMC8MBEBDARsNBuAKFElgEsUYAmQgQgRAG1yBaGARgF0A6AGwFMwAcygALGAB9xMUniA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Y6RAM0WloHsalfkwCG8WmQAWo5uii9o-aJHBgAviHVA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA
Repro Code
ESLint Config
tsconfig
Expected Result
I expect the rule not to cause ESLint to throw; it is a valid code and lint rule "prefer-optional-chain" does not apply there.
Actual Result
Rule causes an ESLint throw error.
Additional Info
The minimal pattern
!foo[i - 1].length || i;
is a bit obscure, so here's the actual source code I distilled it from:it's an npm package
generate-atomic-css
, line 742 in the source: https://github.com/codsen/codsen/blob/main/packages/generate-atomic-css/src/util.ts#L742Also, I can confirm the linting rule was not breaking on
@typescript-eslint/eslint-plugin
previous version5.33.1
, I was trying to bump it to5.35.1
and only now it throws.Versions
@typescript-eslint/eslint-plugin
5.35.1
@typescript-eslint/parser
5.35.1
TypeScript
4.7.4
ESLint
8.22.0
node
16.17.0
The text was updated successfully, but these errors were encountered: