gajus / gajus/eslint-plugin-flowtype

Bug: incorrect `no-undef` error for Flow Enums

Open
#502 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.1k
Forks
151
PR merge metrics
No merged PRs in 30d

Description

I know this sounds like it's not a problem with this plugin but bear with me.

Problematic code:

```js
// @flow strict

enum Status {
Active,
Paused,
Off,
}
```

This code uses the new [Flow Enums](https://flow.org/en/docs/enums/). Eslint throws the following errors:

```text
3:6 error 'Status' is not defined no-undef
4:3 error 'Active' is not defined no-undef
5:3 error 'Paused' is not defined no-undef
6:3 error 'Off' is not defined no-undef
```

It should not throw anything (at least not `no-undef`).

We already have [`define-flow-type`](https://github.com/gajus/eslint-plugin-flowtype/tree/4265b274c7ba4e489a1e8f2dae56a25e2cb03c9e#eslint-plugin-flowtype-rules-define-flow-type) that seems to be solving the issue for other Flow specifics ([code](https://github.com/gajus/eslint-plugin-flowtype/blob/4265b274c7ba4e489a1e8f2dae56a25e2cb03c9e/src/rules/defineFlowType.js)). I _think_ we have to extend this rule to support Flow Enums correctly.

Contributor guide

Open the contributing guide

Research direction

Start with src/rules/defineFlowType.js and compare its handling of existing Flow-specific syntax with the enum example in the issue. The change is done when the shown Flow Enum code no longer produces no-undef errors for Status, Active, Paused, or Off.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.