You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

eslint-plugin-flowtype

Package Overview
Dependencies
Maintainers
1
Versions
185
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

bin/readmeAssertions.js

60

package.json
{
"name": "eslint-plugin-flowtype",
"version": "1.0.0",
"description": "ESLint checking of files containing FlowType annotations",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"description": "Flowtype linting rules for ESLint.",
"version": "2.0.0",
"main": "./dist/index.js",
"repository": {
"type": "git",
"url": "https://github.com/gajus/eslint-plugin-flowtype"
},

@@ -12,27 +13,40 @@ "keywords": [

"plugin",
"eslintplugin",
"flowtype"
],
"author": {
"name": "Gajus Kuizinas",
"email": "gajus@gajus.com",
"url": "http://gajus.com"
},
"license": "BSD-3-Clause",
"peerDependencies": {
"eslint": ">=0.20.0"
"eslint": ">=2.0.0"
},
"files": [
"README.md",
"index.js"
],
"homepage": "https://github.com/gcazaciuc/eslint-plugin-flowtype",
"repository": {
"type": "git",
"url": "https://github.com/gcazaciuc/eslint-plugin-flowtype.git"
},
"author": "Cazaciuc Gabriel",
"license": "MIT",
"dependencies": {
"esprima-fb": "^15001.1.0-dev-harmony-fb",
"recast": "^0.10.13",
"source-map": "^0.4.2"
"lodash": "^4.5.1"
},
"engines": {
"node": ">= 0.8"
"scripts": {
"pragmatist": "pragmatist --es5",
"lint": "npm run pragmatist lint",
"test": "npm run pragmatist test",
"build": "npm run pragmatist build",
"watch": "npm run pragmatist watch",
"watch-lint": "npm run pragmatist watch-lint",
"watch-test": "npm run pragmatist watch-test",
"readme-add-assertions": "babel-node --presets es2015 ./bin/readmeAssertions",
"readme": "node ./node_modules/.bin/gitdown ./.README/README.md --output-file ./README.md; npm run readme-add-assertions",
"create-index": "create-index ./src --update-index"
},
"devDependencies": {
"babel-cli": "^6.5.1",
"babel-eslint": "^5.0.0",
"babel-preset-es2015": "^6.5.0",
"chai": "^3.5.0",
"create-index": "^0.1.2",
"eslint": "^2.2.0",
"gitdown": "^2.4.0",
"globby": "^4.0.0",
"mocha": "^2.4.5",
"pragmatist": "^3.0.9"
}
}

@@ -1,15 +0,195 @@

# eslint-plugin-flowtype
A plugin for ESLint that strips FlowType type annonations before linting the files.
<h1 id="eslint-plugin-flowtype">eslint-plugin-flowtype</h1>
If your code uses flow type annotations ( http://flowtype.org/ ) and you would like to lint it using ESLint currently the only option is using babel-eslint as ESLint parser instead of the default Espree.
[![NPM version](http://img.shields.io/npm/v/eslint-plugin-flowtype.svg?style=flat-square)](https://www.npmjs.org/package/eslint-plugin-flowtype)
[![Travis build status](http://img.shields.io/travis/gajus/eslint-plugin-flowtype/master.svg?style=flat-square)](https://travis-ci.org/gajus/eslint-plugin-flowtype)
[![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)
However, Babel-Eslint currently monkey patches ESLint and I had lots of issues with upgrading to newer versions of ESlint and Babel-Eslint.
[Flow type](http://flowtype.org/) linting rules for ESLint.
This plugins strips the type annotations before handing off the file for linting as such you are able to use the latest and greates ESLint parser: Espree on FlowType'd code.
* [eslint-plugin-flowtype](#eslint-plugin-flowtype)
* [Installation](#eslint-plugin-flowtype-installation)
* [Configuration](#eslint-plugin-flowtype-configuration)
* [Rules](#eslint-plugin-flowtype-rules)
* [`require-parameter-type`](#eslint-plugin-flowtype-rules-require-parameter-type)
* [`require-return-type`](#eslint-plugin-flowtype-rules-require-return-type)
* [`space-after-type-colon`](#eslint-plugin-flowtype-rules-space-after-type-colon)
* [`space-before-type-colon`](#eslint-plugin-flowtype-rules-space-before-type-colon)
* [`eslint-plugin-flowtype` v1](#eslint-plugin-flowtype-eslint-plugin-flowtype-v1)
Internally the plugin makes use of Recast for performing AST transforms and stripping the annotations together with esprima-fb parser( which is now deprecated but i couldn't get flow-parser to play nice with recast as such had to use esprima ).
The plugin also preserves the line numbers by using Recast source maps.
<h2 id="eslint-plugin-flowtype-installation">Installation</h2>
Know issues
Issues with max-len ESlint rule reporting the line/column number as "0:0"
1. Install [ESLint](https://www.github.com/eslint/eslint).
1. Install [`babel-eslint`](https://github.com/babel/babel-eslint) parser (ESLint parser [does not support type annotations](https://github.com/eslint/eslint/issues/2157)).
1. Install [`eslint-plugin-flowtype`](https://github.com/gajus/eslint-plugin-flowtype) plugin.
<!-- -->
```sh
npm install eslint
npm install babel-eslint
npm install eslint-plugin-flowtype
```
<h2 id="eslint-plugin-flowtype-configuration">Configuration</h2>
1. Set `parser` property to `babel-eslint`.
1. Add `plugins` section and specify `eslint-plugin-flowtype` as a plugin.
1. Enable rules.
<!-- -->
```json
{
"parser": "babel-eslint",
"plugins": [
"flowtype"
],
"rules": {
"flowtype/require-parameter-type": 1,
"flowtype/require-return-type": 1,
"flowtype/space-after-type-colon": 1,
"flowtype/space-before-type-colon": 1
}
}
```
<h2 id="eslint-plugin-flowtype-rules">Rules</h2>
<h3 id="eslint-plugin-flowtype-rules-require-parameter-type"><code>require-parameter-type</code></h3>
Requires that all function parameters have type annotations.
The following patterns are considered problems:
```js
(foo) => {}
// Message: Missing "foo" parameter type annotation.
(foo = 'FOO') => {}
// Message: Missing "foo" parameter type annotation.
(...foo) => {}
// Message: Missing "foo" parameter type annotation.
({foo}) => {}
// Message: Missing "{foo}" parameter type annotation.
```
The following patterns are not considered problems:
```js
(foo: string) => {}
(foo: string = 'FOO') => {}
(...foo: string) => {}
({foo}: {foo: string}) => {}
```
<h3 id="eslint-plugin-flowtype-rules-require-return-type"><code>require-return-type</code></h3>
Requires that functions have return type annotation.
The following patterns are considered problems:
```js
(foo) => {}
// Message: Missing return type annotation.
```
The following patterns are not considered problems:
```js
(foo): string => {}
```
<h3 id="eslint-plugin-flowtype-rules-space-after-type-colon"><code>space-after-type-colon</code></h3>
Enforces consistent spacing after the type annotation colon.
This rule takes one argument. If it is `'always'` then a problem is raised when there is no space after the type annotation colon. If it is `'never'` then a problem is raised when there is a space after the type annotation colon. The default value is `'always'`.
The following patterns are considered problems:
```js
// Options: ["never"]
(foo: string) => {}
// Message: There must be no space after "foo" parameter type annotation colon.
// Options: ["always"]
(foo:string) => {}
// Message: There must be a space after "foo" parameter type annotation colon.
// Options: ["always"]
(foo: string) => {}
// Message: There must be 1 space after "foo" parameter type annotation colon.
```
The following patterns are not considered problems:
```js
(foo) => {}
(foo: string) => {}
// Options: ["never"]
(foo:string) => {}
// Options: ["always"]
(foo: string) => {}
```
<h3 id="eslint-plugin-flowtype-rules-space-before-type-colon"><code>space-before-type-colon</code></h3>
Enforces consistent spacing before the type annotation colon.
This rule takes one argument. If it is `'always'` then a problem is raised when there is no space before the type annotation colon. If it is `'never'` then a problem is raised when there is a space before the type annotation colon. The default value is `'never'`.
The following patterns are considered problems:
```js
// Options: ["never"]
(foo : string) => {}
// Message: There must be no space before "foo" parameter type annotation colon.
// Options: ["always"]
(foo: string) => {}
// Message: There must be a space before "foo" parameter type annotation colon.
// Options: ["always"]
(foo : string) => {}
// Message: There must be 1 space before "foo" parameter type annotation colon.
```
The following patterns are not considered problems:
```js
(foo) => {}
(foo: string) => {}
// Options: ["never"]
(foo: string) => {}
// Options: ["always"]
(foo : string) => {}
```
<h2 id="eslint-plugin-flowtype-eslint-plugin-flowtype-v1"><code>eslint-plugin-flowtype</code> v1</h2>
`eslint-plugin-flowtype` v1 served a different purpose:
> A plugin for ESLint that strips FlowType type annonations before linting the files.
You can find the source code for v1 at:
https://github.com/gcazaciuc/eslint-plugin-flowtype
Reference to the original codebase included for historical reference purposes.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc