GithubHelp home page GithubHelp logo

eslint-plugin-flow-vars's Introduction

THIS PROJECT IS DEPRECATED

The functionality provided by eslint-plugin-flow-vars has been merge into eslint-plugin-flowtype.

To migrate, install [email protected] or higher, and update your eslint config like this:

{
  "parser": "babel-eslint",
  "plugins": [
-    "flow-vars"
+    "flowtype"
  ],
  "rules": {
-    "flow-vars/define-flow-type": 1,
-    "flow-vars/use-flow-type": 1
+    "flowtype/define-flow-type": 1,
+    "flowtype/use-flow-type": 1
  }
}

eslint-plugin-flow-vars

Build Status

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 when using babel-eslint.

Usage

npm install eslint babel-eslint eslint-plugin-flow-vars

In your .eslintrc:

{
  "parser": "babel-eslint",
  "plugins": [
    "flow-vars"
  ],
  "rules": {
    "flow-vars/define-flow-type": 1,
    "flow-vars/use-flow-type": 1
  }
}

eslint-plugin-flow-vars's People

Contributors

amilajack avatar marudor avatar zertosh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

eslint-plugin-flow-vars's Issues

Suppress duplicate import when one is normal import and second is type import

Hi, great package. Works as advertised.

I have no idea if this can be implemented but it would be cool to suppress this:

import { Foo } from './foo.js';
import type { Bar } from './foo.js';  // <- ESLint warns for duplicate import

At the moment, we explicitly suppress the warning with // eslint-disable-next-line no-duplicate-imports

Definition was not found

I'm getting following warnings for the exact setup as in README

  1:1  warning  Definition for rule 'flow-vars/define-flow-type' was not found  flow-vars/define-flow-type
  1:1  warning  Definition for rule 'flow-vars/use-flow-type' was not found     flow-vars/use-flow-type

Did I miss something?

Add a Changelog?

When updating, it would be really useful to have a list of the changes included in each release somewhere. This will make it easier to know how to best handle the update (e.g. enable new rules).

Lint rules to mark missing type annotations

Hey,

For fixing the false positive problem with eslint shouting about no-undef and no-unused-vars this plugin is working great. Much appreciated!

I wonder what it would take to get eslint to check for untyped arguments and return values? Does that fall within the scope of this plugin?

For example, code like this…

function multiplyByTwo(number) {
  return number * 2;
}

… would run against these additional rules …

{
 "flow-vars/no-argument-type": 2,
 "flow-vars/no-return-type": 2
}

… with this result:

1:15  error  Function arguments must have type annotations  flow-vars/no-argument-type
1:19  error  Function return value must have a type annotation  flow-vars/no-return-type

Stopped working

This plugin stopped working with newest eslint and babel-eslint.

This is what I got:

Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
    at isFunction (/usr/local/lib/node_modules/eslint/lib/rules/no-use-before-define.js:49:28)
    at isFunctionOrOuterClass (/usr/local/lib/node_modules/eslint/lib/rules/no-use-before-define.js:74:12)
    at /usr/local/lib/node_modules/eslint/lib/rules/no-use-before-define.js:162:17
    at Array.forEach (native)
    at findVariablesInScope (/usr/local/lib/node_modules/eslint/lib/rules/no-use-before-define.js:149:26)
    at EventEmitter.findVariables (/usr/local/lib/node_modules/eslint/lib/rules/no-use-before-define.js:184:9)
    at emitOne (events.js:83:20)
    at EventEmitter.emit (events.js:170:7)
    at NodeEventGenerator.leaveNode (/usr/local/lib/node_modules/eslint/lib/util/node-event-generator.js:51:22)
    at CodePathAnalyzer.leaveNode (/usr/local/lib/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:611:23)

If I either stop using no-use-before-define or the flow-vars rule, this error stop appearing; however, if I remove the flow-vars rules, I get all the annoying "errors" from eslint that this module is for.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.