eslint-plugin-flowtype
Advanced tools
Comparing version 2.11.4 to 2.14.0
@@ -5,2 +5,52 @@ # Change Log | ||
<a name="2.14.0"></a> | ||
# [2.14.0](https://github.com/gajus/eslint-plugin-flowtype/compare/v2.13.0...v2.14.0) (2016-09-05) | ||
### Features | ||
* add new rule `no-weak-types` (#96) ([c1a94c5](https://github.com/gajus/eslint-plugin-flowtype/commit/c1a94c5)) | ||
<a name="2.13.0"></a> | ||
# [2.13.0](https://github.com/gajus/eslint-plugin-flowtype/compare/v2.12.1...v2.13.0) (2016-09-03) | ||
### Features | ||
* add new rule `boolean-style` (#98) ([1ab7902](https://github.com/gajus/eslint-plugin-flowtype/commit/1ab7902)) | ||
<a name="2.12.1"></a> | ||
## [2.12.1](https://github.com/gajus/eslint-plugin-flowtype/compare/v2.12.0...v2.12.1) (2016-09-01) | ||
### Bug Fixes | ||
* allow uppercase sequences in 'type-id-match' (#93) ([000b0d1](https://github.com/gajus/eslint-plugin-flowtype/commit/000b0d1)) | ||
<a name="2.12.0"></a> | ||
# [2.12.0](https://github.com/gajus/eslint-plugin-flowtype/compare/v2.11.5...v2.12.0) (2016-09-01) | ||
### Bug Fixes | ||
* add --no-verify to docs commit ([393643b](https://github.com/gajus/eslint-plugin-flowtype/commit/393643b)) | ||
* add --no-verify to standard-version ([22a0559](https://github.com/gajus/eslint-plugin-flowtype/commit/22a0559)) | ||
### Features | ||
* add new rule "semi" for semicolon linting (#95) ([ead974d](https://github.com/gajus/eslint-plugin-flowtype/commit/ead974d)) | ||
<a name="2.11.5"></a> | ||
## [2.11.5](https://github.com/gajus/eslint-plugin-flowtype/compare/v2.11.4...v2.11.5) (2016-09-01) | ||
<a name="2.11.4"></a> | ||
@@ -7,0 +57,0 @@ ## [2.11.4](https://github.com/gajus/eslint-plugin-flowtype/compare/v2.11.3...v2.11.4) (2016-08-23) |
@@ -15,2 +15,6 @@ 'use strict'; | ||
var _noWeakTypes = require('./rules/noWeakTypes'); | ||
var _noWeakTypes2 = _interopRequireDefault(_noWeakTypes); | ||
var _requireParameterType = require('./rules/requireParameterType'); | ||
@@ -28,2 +32,6 @@ | ||
var _semi = require('./rules/semi'); | ||
var _semi2 = _interopRequireDefault(_semi); | ||
var _spaceAfterTypeColon = require('./rules/spaceAfterTypeColon'); | ||
@@ -57,2 +65,6 @@ | ||
var _booleanStyle = require('./rules/booleanStyle'); | ||
var _booleanStyle2 = _interopRequireDefault(_booleanStyle); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -62,7 +74,10 @@ | ||
rules: { | ||
'boolean-style': _booleanStyle2.default, | ||
'define-flow-type': _defineFlowType2.default, | ||
'generic-spacing': _genericSpacing2.default, | ||
'no-weak-types': _noWeakTypes2.default, | ||
'require-parameter-type': _requireParameterType2.default, | ||
'require-return-type': _requireReturnType2.default, | ||
'require-valid-file-annotation': _requireValidFileAnnotation2.default, | ||
semi: _semi2.default, | ||
'space-after-type-colon': _spaceAfterTypeColon2.default, | ||
@@ -77,6 +92,9 @@ 'space-before-generic-bracket': _spaceBeforeGenericBracket2.default, | ||
rulesConfig: { | ||
'boolean-style': 0, | ||
'define-flow-type': 0, | ||
'generic-spacing': 0, | ||
'no-weak-types': 0, | ||
'require-parameter-type': 0, | ||
'require-return-type': 0, | ||
semi: 0, | ||
'space-after-type-colon': 0, | ||
@@ -83,0 +101,0 @@ 'space-before-generic-bracket': 0, |
@@ -11,3 +11,3 @@ 'use strict'; | ||
exports.default = function (context) { | ||
var pattern = new RegExp(context.options[0] || '^([A-Z][a-z0-9]+)+Type$'); | ||
var pattern = new RegExp(context.options[0] || '^([A-Z][a-z0-9]*)+Type$'); | ||
@@ -14,0 +14,0 @@ return { |
{ | ||
"name": "eslint-plugin-flowtype", | ||
"description": "Flowtype linting rules for ESLint.", | ||
"version": "2.11.4", | ||
"version": "2.14.0", | ||
"main": "./dist/index.js", | ||
@@ -33,3 +33,5 @@ "repository": { | ||
"documentation": "gitdown ./.README/README.md --output-file ./README.md; npm run documentation-add-assertions", | ||
"create-index": "create-index ./src --update-index" | ||
"create-index": "create-index ./src --update-index", | ||
"precommit": "npm run lint && npm run test", | ||
"commitmsg": "conventional-changelog-lint -e" | ||
}, | ||
@@ -44,2 +46,3 @@ "devDependencies": { | ||
"chai": "^3.5.0", | ||
"conventional-changelog-lint": "^1.0.1", | ||
"create-index": "^0.1.3", | ||
@@ -49,2 +52,3 @@ "eslint": "^3.3.1", | ||
"gitdown": "^2.4.10", | ||
"husky": "^0.11.6", | ||
"mocha": "^3.0.2", | ||
@@ -51,0 +55,0 @@ "standard-version": "^2.4.0", |
305
README.md
@@ -1,2 +0,3 @@ | ||
<h1 id="eslint-plugin-flowtype">eslint-plugin-flowtype</h1> | ||
<a name="eslint-plugin-flowtype"></a> | ||
# eslint-plugin-flowtype | ||
@@ -15,6 +16,9 @@ [![NPM version](http://img.shields.io/npm/v/eslint-plugin-flowtype.svg?style=flat-square)](https://www.npmjs.org/package/eslint-plugin-flowtype) | ||
* [Rules](#eslint-plugin-flowtype-rules) | ||
* [`boolean-style`](#eslint-plugin-flowtype-rules-boolean-style) | ||
* [`define-flow-type`](#eslint-plugin-flowtype-rules-define-flow-type) | ||
* [`no-weak-types`](#eslint-plugin-flowtype-rules-no-weak-types) | ||
* [`require-parameter-type`](#eslint-plugin-flowtype-rules-require-parameter-type) | ||
* [`require-return-type`](#eslint-plugin-flowtype-rules-require-return-type) | ||
* [`require-valid-file-annotation`](#eslint-plugin-flowtype-rules-require-valid-file-annotation) | ||
* [`semi`](#eslint-plugin-flowtype-rules-semi) | ||
* [`space-after-type-colon`](#eslint-plugin-flowtype-rules-space-after-type-colon) | ||
@@ -30,3 +34,4 @@ * [`space-before-type-colon`](#eslint-plugin-flowtype-rules-space-before-type-colon) | ||
<h2 id="eslint-plugin-flowtype-installation">Installation</h2> | ||
<a name="eslint-plugin-flowtype-installation"></a> | ||
## Installation | ||
@@ -45,3 +50,4 @@ 1. Install [ESLint](https://www.github.com/eslint/eslint). | ||
<h2 id="eslint-plugin-flowtype-configuration">Configuration</h2> | ||
<a name="eslint-plugin-flowtype-configuration"></a> | ||
## Configuration | ||
@@ -62,2 +68,3 @@ 1. Set `parser` property to `babel-eslint`. | ||
"flowtype/define-flow-type": 1, | ||
"flowtype/no-weak-types": 1, | ||
"flowtype/require-parameter-type": 1, | ||
@@ -71,2 +78,6 @@ "flowtype/require-return-type": [ | ||
], | ||
"flowtype/semi": [ | ||
1, | ||
"always" | ||
], | ||
"flowtype/space-after-type-colon": [ | ||
@@ -95,5 +106,7 @@ 1, | ||
<h2 id="eslint-plugin-flowtype-settings">Settings</h2> | ||
<a name="eslint-plugin-flowtype-settings"></a> | ||
## Settings | ||
<h3 id="eslint-plugin-flowtype-settings-onlyfileswithflowannotation"><code>onlyFilesWithFlowAnnotation</code></h3> | ||
<a name="eslint-plugin-flowtype-settings-onlyfileswithflowannotation"></a> | ||
### <code>onlyFilesWithFlowAnnotation</code> | ||
@@ -112,6 +125,50 @@ When `true`, only checks files with a [`@flow` annotation](http://flowtype.org/docs/about-flow.html#gradual) in the first comment. | ||
<h2 id="eslint-plugin-flowtype-rules">Rules</h2> | ||
<a name="eslint-plugin-flowtype-rules"></a> | ||
## Rules | ||
<h3 id="eslint-plugin-flowtype-rules-define-flow-type"><code>define-flow-type</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-boolean-style"></a> | ||
### <code>boolean-style</code> | ||
_The `--fix` option on the command line automatically fixes problems reported by this rule._ | ||
Enforces a particular style for boolean type annotations. This rule takes one argument. | ||
If it is `'boolean'` then a problem is raised when using `bool` instead of `boolean`. | ||
If it is `'bool'` then a problem is raised when using `boolean` instead of `bool`. | ||
The default value is `'boolean'`. | ||
The following patterns are considered problems: | ||
```js | ||
type X = bool | ||
// Message: Use "boolean", not "bool" | ||
// Options: ["boolean"] | ||
type X = bool | ||
// Message: Use "boolean", not "bool" | ||
// Options: ["bool"] | ||
type X = boolean | ||
// Message: Use "bool", not "boolean" | ||
``` | ||
The following patterns are not considered problems: | ||
```js | ||
type X = boolean | ||
// Options: ["boolean"] | ||
type X = boolean | ||
// Options: ["bool"] | ||
type X = bool | ||
``` | ||
<a name="eslint-plugin-flowtype-rules-define-flow-type"></a> | ||
### <code>define-flow-type</code> | ||
Marks Flow type identifiers as defined. | ||
@@ -235,7 +292,141 @@ | ||
<h3 id="eslint-plugin-flowtype-rules-require-parameter-type"><code>require-parameter-type</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-no-weak-types"></a> | ||
### <code>no-weak-types</code> | ||
Warns against weak type annotations *any*, *Object* and *Function*. | ||
These types can cause flow to silently skip over portions of your code, | ||
which would have otherwise caused type errors. | ||
The following patterns are considered problems: | ||
```js | ||
function foo(thing): any {} | ||
// Message: Unexpected use of weak type "any" | ||
function foo(thing): Promise<any> {} | ||
// Message: Unexpected use of weak type "any" | ||
function foo(thing): Promise<Promise<any>> {} | ||
// Message: Unexpected use of weak type "any" | ||
function foo(thing): Object {} | ||
// Message: Unexpected use of weak type "Object" | ||
function foo(thing): Promise<Object> {} | ||
// Message: Unexpected use of weak type "Object" | ||
function foo(thing): Promise<Promise<Object>> {} | ||
// Message: Unexpected use of weak type "Object" | ||
function foo(thing): Function {} | ||
// Message: Unexpected use of weak type "Function" | ||
function foo(thing): Promise<Function> {} | ||
// Message: Unexpected use of weak type "Function" | ||
function foo(thing): Promise<Promise<Function>> {} | ||
// Message: Unexpected use of weak type "Function" | ||
(foo: any) => {} | ||
// Message: Unexpected use of weak type "any" | ||
(foo: Function) => {} | ||
// Message: Unexpected use of weak type "Function" | ||
(foo?: any) => {} | ||
// Message: Unexpected use of weak type "any" | ||
(foo?: Function) => {} | ||
// Message: Unexpected use of weak type "Function" | ||
(foo: { a: any }) => {} | ||
// Message: Unexpected use of weak type "any" | ||
(foo: { a: Object }) => {} | ||
// Message: Unexpected use of weak type "Object" | ||
(foo: any[]) => {} | ||
// Message: Unexpected use of weak type "any" | ||
type Foo = any | ||
// Message: Unexpected use of weak type "any" | ||
type Foo = Function | ||
// Message: Unexpected use of weak type "Function" | ||
type Foo = { a: any } | ||
// Message: Unexpected use of weak type "any" | ||
type Foo = { a: Object } | ||
// Message: Unexpected use of weak type "Object" | ||
type Foo = { (a: Object): string } | ||
// Message: Unexpected use of weak type "Object" | ||
type Foo = { (a: string): Function } | ||
// Message: Unexpected use of weak type "Function" | ||
function foo(thing: any) {} | ||
// Message: Unexpected use of weak type "any" | ||
function foo(thing: Object) {} | ||
// Message: Unexpected use of weak type "Object" | ||
var foo: Function | ||
// Message: Unexpected use of weak type "Function" | ||
var foo: Object | ||
// Message: Unexpected use of weak type "Object" | ||
class Foo { props: any } | ||
// Message: Unexpected use of weak type "any" | ||
class Foo { props: Object } | ||
// Message: Unexpected use of weak type "Object" | ||
var foo: any | ||
// Message: Unexpected use of weak type "any" | ||
``` | ||
The following patterns are not considered problems: | ||
```js | ||
function foo(thing): string {} | ||
function foo(thing): Promise<string> {} | ||
function foo(thing): Promise<Promise<string>> {} | ||
(foo?: string) => {} | ||
(foo: ?string) => {} | ||
(foo: { a: string }) => {} | ||
(foo: { a: ?string }) => {} | ||
(foo: string[]) => {} | ||
type Foo = string | ||
type Foo = { a: string } | ||
type Foo = { (a: string): string } | ||
function foo(thing: string) {} | ||
var foo: string | ||
class Foo { props: string } | ||
``` | ||
<a name="eslint-plugin-flowtype-rules-require-parameter-type"></a> | ||
### <code>require-parameter-type</code> | ||
Requires that all function parameters have type annotations. | ||
<h4 id="eslint-plugin-flowtype-rules-require-parameter-type-options">Options</h4> | ||
<a name="eslint-plugin-flowtype-rules-require-parameter-type-options"></a> | ||
#### Options | ||
@@ -335,7 +526,9 @@ You can skip all arrow functions by providing the `excludeArrowFunctions` option with `true`. | ||
<h3 id="eslint-plugin-flowtype-rules-require-return-type"><code>require-return-type</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-require-return-type"></a> | ||
### <code>require-return-type</code> | ||
Requires that functions have return type annotation. | ||
<h4 id="eslint-plugin-flowtype-rules-require-return-type-options">Options</h4> | ||
<a name="eslint-plugin-flowtype-rules-require-return-type-options"></a> | ||
#### Options | ||
@@ -538,7 +731,9 @@ You can skip all arrow functions by providing the `excludeArrowFunctions` option with `true`. | ||
<h3 id="eslint-plugin-flowtype-rules-require-valid-file-annotation"><code>require-valid-file-annotation</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-require-valid-file-annotation"></a> | ||
### <code>require-valid-file-annotation</code> | ||
Makes sure that files have a valid `@flow` annotation. It will report annotations with typos (such as `// @floww`) or not placed at the top of the file, and optionaly missing annotations. | ||
<h4 id="eslint-plugin-flowtype-rules-require-valid-file-annotation-options">Options</h4> | ||
<a name="eslint-plugin-flowtype-rules-require-valid-file-annotation-options"></a> | ||
#### Options | ||
@@ -619,6 +814,58 @@ By default, this rule won't complain if there is no `@flow` annotation at all in the file. Passing a `"always"` option reports files missing those annotations as well. | ||
<h3 id="eslint-plugin-flowtype-rules-space-after-type-colon"><code>space-after-type-colon</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-semi"></a> | ||
### <code>semi</code> | ||
_The `--fix` option on the command line automatically fixes problems reported by this rule._ | ||
Enforces consistent use of semicolons after type aliases. | ||
This rule takes one argument. If it is `'never'` then a problem is raised when there is a semicolon after a type alias. If it is `'always'` then a problem is raised when there is no semicolon after a type alias. | ||
The default value is `'always'`. | ||
The following patterns are considered problems: | ||
```js | ||
// Options: [] | ||
type FooType = {} | ||
// Message: Missing semicolon. | ||
// Options: ["always"] | ||
type FooType = {} | ||
// Message: Missing semicolon. | ||
// Options: ["never"] | ||
type FooType = {}; | ||
// Message: Extra semicolon. | ||
``` | ||
The following patterns are not considered problems: | ||
```js | ||
type FooType = {}; | ||
// Options: ["always"] | ||
type FooType = {}; | ||
// Options: ["always"] | ||
type FooType = { a: number; | ||
b: string; | ||
}; | ||
// Options: ["never"] | ||
type FooType = { a: number; | ||
b: string; | ||
} | ||
// Options: ["never"] | ||
type FooType = {} | ||
``` | ||
<a name="eslint-plugin-flowtype-rules-space-after-type-colon"></a> | ||
### <code>space-after-type-colon</code> | ||
_The `--fix` option on the command line automatically fixes problems reported by this rule._ | ||
Enforces consistent spacing after the type annotation colon. | ||
@@ -1060,3 +1307,4 @@ | ||
<h3 id="eslint-plugin-flowtype-rules-space-before-type-colon"><code>space-before-type-colon</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-space-before-type-colon"></a> | ||
### <code>space-before-type-colon</code> | ||
@@ -1359,3 +1607,4 @@ _The `--fix` option on the command line automatically fixes problems reported by this rule._ | ||
<h3 id="eslint-plugin-flowtype-rules-space-before-generic-bracket"><code>space-before-generic-bracket</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-space-before-generic-bracket"></a> | ||
### <code>space-before-generic-bracket</code> | ||
@@ -1403,3 +1652,4 @@ _The `--fix` option on the command line automatically fixes problems reported by this rule._ | ||
<h3 id="eslint-plugin-flowtype-rules-union-intersection-spacing"><code>union-intersection-spacing</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-union-intersection-spacing"></a> | ||
### <code>union-intersection-spacing</code> | ||
@@ -1550,3 +1800,4 @@ _The `--fix` option on the command line automatically fixes problems reported by this rule._ | ||
<h3 id="eslint-plugin-flowtype-rules-generic-spacing"><code>generic-spacing</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-generic-spacing"></a> | ||
### <code>generic-spacing</code> | ||
@@ -1635,7 +1886,9 @@ _The `--fix` option on the command line automatically fixes problems reported by this rule._ | ||
<h3 id="eslint-plugin-flowtype-rules-type-id-match"><code>type-id-match</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-type-id-match"></a> | ||
### <code>type-id-match</code> | ||
Enforces a consistent naming pattern for type aliases. | ||
<h4 id="eslint-plugin-flowtype-rules-type-id-match-options">Options</h4> | ||
<a name="eslint-plugin-flowtype-rules-type-id-match-options"></a> | ||
#### Options | ||
@@ -1649,3 +1902,3 @@ This rule needs a text RegExp to operate with Its signature is as follows: | ||
2, | ||
"^([A-Z][a-z0-9]+)+Type$" | ||
"^([A-Z][a-z0-9]*)+Type$" | ||
] | ||
@@ -1656,3 +1909,3 @@ } | ||
`'^([A-Z][a-z0-9]+)+Type$'` is the default pattern. | ||
`'^([A-Z][a-z0-9]*)+Type$'` is the default pattern. | ||
@@ -1663,3 +1916,3 @@ The following patterns are considered problems: | ||
type foo = {}; | ||
// Message: Type identifier 'foo' does not match pattern '/^([A-Z][a-z0-9]+)+Type$/'. | ||
// Message: Type identifier 'foo' does not match pattern '/^([A-Z][a-z0-9]*)+Type$/'. | ||
@@ -1682,3 +1935,4 @@ // Options: ["^foo$"] | ||
<h3 id="eslint-plugin-flowtype-rules-use-flow-type"><code>use-flow-type</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-use-flow-type"></a> | ||
### <code>use-flow-type</code> | ||
@@ -1737,3 +1991,4 @@ Marks Flow [type alias](https://flowtype.org/docs/type-aliases.html) declarations as used. | ||
<h3 id="eslint-plugin-flowtype-rules-valid-syntax"><code>valid-syntax</code></h3> | ||
<a name="eslint-plugin-flowtype-rules-valid-syntax"></a> | ||
### <code>valid-syntax</code> | ||
@@ -1740,0 +1995,0 @@ Checks for simple Flow syntax errors. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126651
39
1158
1997
16