Skip to content

Commit 94e0ae4

Browse files
committed
First version.
0 parents  commit 94e0ae4

25 files changed

+812
-0
lines changed

.README/README.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# eslint-plugin-flowtype
2+
3+
[![NPM version](http://img.shields.io/npm/v/eslint-plugin-flowtype.svg?style=flat-square)](https://www.npmjs.org/package/eslint-plugin-flowtype)
4+
[![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)
5+
[![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)
6+
7+
[Flow type](http://flowtype.org/) linting rules for ESLint.
8+
9+
{"gitdown": "contents"}
10+
11+
## Installation
12+
13+
1. Install [ESLint](https://www.github.com/eslint/eslint).
14+
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)).
15+
1. Install [`eslint-plugin-flowtype`](https://github.com/gajus/eslint-plugin-flowtype) plugin.
16+
17+
<!-- -->
18+
19+
```sh
20+
npm install eslint
21+
npm install babel-eslint
22+
npm install eslint-plugin-flowtype
23+
```
24+
25+
## Configuration
26+
27+
1. Set `parser` property to `babel-eslint`.
28+
1. Add `plugins` section and specify `eslint-plugin-flowtype` as a plugin.
29+
1. Enable rules.
30+
31+
<!-- -->
32+
33+
```json
34+
{
35+
"parser": "babel-eslint",
36+
"plugins": [
37+
"flowtype"
38+
],
39+
"rules": {
40+
"flowtype/require-parameter-type": 1,
41+
"flowtype/require-return-type": 1,
42+
"flowtype/space-after-type-colon": 1,
43+
"flowtype/space-before-type-colon": 1
44+
}
45+
}
46+
```
47+
48+
## Rules
49+
50+
{"gitdown": "include", "file": "./rules/require-parameter-type.md"}
51+
{"gitdown": "include", "file": "./rules/require-return-type.md"}
52+
{"gitdown": "include", "file": "./rules/space-after-type-colon.md"}
53+
{"gitdown": "include", "file": "./rules/space-before-type-colon.md"}
54+
55+
## `eslint-plugin-flowtype` v1
56+
57+
`eslint-plugin-flowtype` v1 served a different purpose:
58+
59+
> A plugin for ESLint that strips FlowType type annonations before linting the files.
60+
61+
You can find the source code for v1 at:
62+
63+
https://github.com/gcazaciuc/eslint-plugin-flowtype
64+
65+
Reference to the original codebase included for historical reference purposes.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### `require-parameter-type`
2+
3+
Requires that all function parameters have type annotations.
4+
5+
<!-- assertions requireParameterType -->

.README/rules/require-return-type.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### `require-return-type`
2+
3+
Requires that functions have return type annotation.
4+
5+
<!-- assertions requireReturnType -->
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### `space-after-type-colon`
2+
3+
Enforces consistent spacing after the type annotation colon.
4+
5+
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'`.
6+
7+
<!-- assertions spaceAfterTypeColon -->
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### `space-before-type-colon`
2+
3+
Enforces consistent spacing before the type annotation colon.
4+
5+
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'`.
6+
7+
<!-- assertions spaceBeforeTypeColon -->

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules
2+
coverage
3+
dist
4+
*.log
5+
.*
6+
!.gitignore
7+
!.npmignore
8+
!.babelrc
9+
!.travis.yml
10+
!.README

.npmignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
src
2+
tests
3+
coverage
4+
.*
5+
*.log

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
node_js:
3+
- '5.0'
4+
- '4.0'
5+
notifications:
6+
email: false
7+
sudo: false

LICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2015, Gajus Kuizinas (http://gajus.com/)
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above copyright
9+
notice, this list of conditions and the following disclaimer in the
10+
documentation and/or other materials provided with the distribution.
11+
* Neither the name of the Gajus Kuizinas (http://gajus.com/) nor the
12+
names of its contributors may be used to endorse or promote products
13+
derived from this software without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
DISCLAIMED. IN NO EVENT SHALL ANUARY BE LIABLE FOR ANY
19+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
<h1 id="eslint-plugin-flowtype">eslint-plugin-flowtype</h1>
2+
3+
[![NPM version](http://img.shields.io/npm/v/eslint-plugin-flowtype.svg?style=flat-square)](https://www.npmjs.org/package/eslint-plugin-flowtype)
4+
[![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)
5+
[![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)
6+
7+
[Flow type](http://flowtype.org/) linting rules for ESLint.
8+
9+
* [eslint-plugin-flowtype](#eslint-plugin-flowtype)
10+
* [Installation](#eslint-plugin-flowtype-installation)
11+
* [Configuration](#eslint-plugin-flowtype-configuration)
12+
* [Rules](#eslint-plugin-flowtype-rules)
13+
* [`require-parameter-type`](#eslint-plugin-flowtype-rules-require-parameter-type)
14+
* [`require-return-type`](#eslint-plugin-flowtype-rules-require-return-type)
15+
* [`space-after-type-colon`](#eslint-plugin-flowtype-rules-space-after-type-colon)
16+
* [`space-before-type-colon`](#eslint-plugin-flowtype-rules-space-before-type-colon)
17+
* [`eslint-plugin-flowtype` v1](#eslint-plugin-flowtype-eslint-plugin-flowtype-v1)
18+
19+
20+
<h2 id="eslint-plugin-flowtype-installation">Installation</h2>
21+
22+
1. Install [ESLint](https://www.github.com/eslint/eslint).
23+
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)).
24+
1. Install [`eslint-plugin-flowtype`](https://github.com/gajus/eslint-plugin-flowtype) plugin.
25+
26+
<!-- -->
27+
28+
```sh
29+
npm install eslint
30+
npm install babel-eslint
31+
npm install eslint-plugin-flowtype
32+
```
33+
34+
<h2 id="eslint-plugin-flowtype-configuration">Configuration</h2>
35+
36+
1. Set `parser` property to `babel-eslint`.
37+
1. Add `plugins` section and specify `eslint-plugin-flowtype` as a plugin.
38+
1. Enable rules.
39+
40+
<!-- -->
41+
42+
```json
43+
{
44+
"parser": "babel-eslint",
45+
"plugins": [
46+
"flowtype"
47+
],
48+
"rules": {
49+
"flowtype/require-parameter-type": 1,
50+
"flowtype/require-return-type": 1,
51+
"flowtype/space-after-type-colon": 1,
52+
"flowtype/space-before-type-colon": 1
53+
}
54+
}
55+
```
56+
57+
<h2 id="eslint-plugin-flowtype-rules">Rules</h2>
58+
59+
<h3 id="eslint-plugin-flowtype-rules-require-parameter-type"><code>require-parameter-type</code></h3>
60+
61+
Requires that all function parameters have type annotations.
62+
63+
The following patterns are considered problems:
64+
65+
```js
66+
(foo) => {}
67+
// Message: Missing "foo" parameter type annotation.
68+
69+
(foo = 'FOO') => {}
70+
// Message: Missing "foo" parameter type annotation.
71+
72+
(...foo) => {}
73+
// Message: Missing "foo" parameter type annotation.
74+
75+
({foo}) => {}
76+
// Message: Missing "{foo}" parameter type annotation.
77+
```
78+
79+
The following patterns are not considered problems:
80+
81+
```js
82+
(foo: string) => {}
83+
84+
(foo: string = 'FOO') => {}
85+
86+
(...foo: string) => {}
87+
88+
({foo}: {foo: string}) => {}
89+
```
90+
91+
92+
<h3 id="eslint-plugin-flowtype-rules-require-return-type"><code>require-return-type</code></h3>
93+
94+
Requires that functions have return type annotation.
95+
96+
The following patterns are considered problems:
97+
98+
```js
99+
(foo) => {}
100+
// Message: Missing return type annotation.
101+
```
102+
103+
The following patterns are not considered problems:
104+
105+
```js
106+
(foo): string => {}
107+
```
108+
109+
110+
<h3 id="eslint-plugin-flowtype-rules-space-after-type-colon"><code>space-after-type-colon</code></h3>
111+
112+
Enforces consistent spacing after the type annotation colon.
113+
114+
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'`.
115+
116+
The following patterns are considered problems:
117+
118+
```js
119+
// Options: ["never"]
120+
(foo: string) => {}
121+
// Message: There must be no space after "foo" parameter type annotation colon.
122+
123+
// Options: ["always"]
124+
(foo:string) => {}
125+
// Message: There must be a space after "foo" parameter type annotation colon.
126+
127+
// Options: ["always"]
128+
(foo: string) => {}
129+
// Message: There must be 1 space after "foo" parameter type annotation colon.
130+
```
131+
132+
The following patterns are not considered problems:
133+
134+
```js
135+
(foo) => {}
136+
137+
(foo: string) => {}
138+
139+
// Options: ["never"]
140+
(foo:string) => {}
141+
142+
// Options: ["always"]
143+
(foo: string) => {}
144+
```
145+
146+
147+
<h3 id="eslint-plugin-flowtype-rules-space-before-type-colon"><code>space-before-type-colon</code></h3>
148+
149+
Enforces consistent spacing before the type annotation colon.
150+
151+
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'`.
152+
153+
The following patterns are considered problems:
154+
155+
```js
156+
// Options: ["never"]
157+
(foo : string) => {}
158+
// Message: There must be no space before "foo" parameter type annotation colon.
159+
160+
// Options: ["always"]
161+
(foo: string) => {}
162+
// Message: There must be a space before "foo" parameter type annotation colon.
163+
164+
// Options: ["always"]
165+
(foo : string) => {}
166+
// Message: There must be 1 space before "foo" parameter type annotation colon.
167+
```
168+
169+
The following patterns are not considered problems:
170+
171+
```js
172+
(foo) => {}
173+
174+
(foo: string) => {}
175+
176+
// Options: ["never"]
177+
(foo: string) => {}
178+
179+
// Options: ["always"]
180+
(foo : string) => {}
181+
```
182+
183+
184+
185+
<h2 id="eslint-plugin-flowtype-eslint-plugin-flowtype-v1"><code>eslint-plugin-flowtype</code> v1</h2>
186+
187+
`eslint-plugin-flowtype` v1 served a different purpose:
188+
189+
> A plugin for ESLint that strips FlowType type annonations before linting the files.
190+
191+
You can find the source code for v1 at:
192+
193+
https://github.com/gcazaciuc/eslint-plugin-flowtype
194+
195+
Reference to the original codebase included for historical reference purposes.

0 commit comments

Comments
 (0)