question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no-undef rule applies to Flow type annotations

See original GitHub issue

In my codebase I have the lines:

  warnInProgressUpload(e: UnloadEvent) {
    if (!this.state.uploadingUploads.size) return undefined;
    var confirmationMessage = 'You have an upload in progress, if you leave the page your upload will be cancelled.';
    (e || window.event).returnValue = confirmationMessage;
    return confirmationMessage;
  }

UnloadEvent is a type declaration defined in a separate file

declare class UnloadEvent extends Event {
    returnValue: string;
}

This produces the error:

  107:27  error  "UnloadEvent" is not defined  no-undef

Can eslint skip running no-undef on type annotations?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
gibbokcommented, Sep 18, 2017

Check out eslint-plugin-flowtype: An eslint plugin that makes flow type annotations global variables and marks declarations as used. Solves the problem of false positives with no-undef and no-unused-vars.

0reactions
tmcwcommented, Dec 18, 2015

Ah thanks everyone!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type Annotations | Flow
Adding type annotations is an important part of your interaction with Flow. Flow has a powerful ability to infer the types of your...
Read more >
eslint-plugin-flowtype - npm
This rule requires an empty line after the Flow annotation. Options. The rule has a string option: "always" (default): Enforces that @flow ......
Read more >
D81678 Introduce noundef attribute at call sites for ... - LLVM
This change adds a new IR noundef attribute, which denotes when a function call argument or return val may never contain uninitialized bits....
Read more >
Flow – JavaScript Type Checker | Object Computing, Inc.
Flow is a static type checker, designed to find type errors in JavaScript programs. ... Node.js cannot directly run code that is annotated...
Read more >
Lighthouse: flow-report/.eslintrc.cjs | Fossies
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 4 * Unless required by applicable law or agreed to in writing, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found