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

eslint-plugin-flowtype - npm Package Compare versions

Comparing version 2.2.5 to 2.2.6

dist/utilities/isFlowFile.js

14

dist/rules/requireParameterType.js

@@ -7,2 +7,6 @@ 'use strict';

var _forEach2 = require('lodash/forEach');
var _forEach3 = _interopRequireDefault(_forEach2);
var _get2 = require('lodash/get');

@@ -12,6 +16,2 @@

var _forEach2 = require('lodash/forEach');
var _forEach3 = _interopRequireDefault(_forEach2);
var _utilities = require('./../utilities');

@@ -22,2 +22,8 @@

exports.default = (0, _utilities.iterateFunctionNodes)(function (context) {
var checkThisFile = !(0, _get3.default)(context, 'settings.flowtype.onlyFilesWithFlowAnnotation') || (0, _utilities.isFlowFile)(context);
if (!checkThisFile) {
return function () {};
}
return function (functionNode) {

@@ -24,0 +30,0 @@ (0, _forEach3.default)(functionNode.params, function (identifierNode) {

@@ -11,5 +11,13 @@ 'use strict';

var _utilities = require('./../utilities');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (context) {
var checkThisFile = !(0, _get3.default)(context, 'settings.flowtype.onlyFilesWithFlowAnnotation') || (0, _utilities.isFlowFile)(context);
if (!checkThisFile) {
return function () {};
}
var annotateReturn = ((0, _get3.default)(context, 'options[0]') || 'always') === 'always';

@@ -16,0 +24,0 @@ var annotateUndefined = ((0, _get3.default)(context, 'options[1].annotateUndefined') || 'never') === 'always';

@@ -7,3 +7,3 @@ 'use strict';

});
exports.iterateFunctionNodes = exports.getParameterName = undefined;
exports.iterateFunctionNodes = exports.isFlowFile = exports.getParameterName = undefined;

@@ -14,2 +14,6 @@ var _getParameterName2 = require('./getParameterName.js');

var _isFlowFile2 = require('./isFlowFile.js');
var _isFlowFile3 = _interopRequireDefault(_isFlowFile2);
var _iterateFunctionNodes2 = require('./iterateFunctionNodes.js');

@@ -22,3 +26,4 @@

exports.getParameterName = _getParameterName3.default;
exports.isFlowFile = _isFlowFile3.default;
exports.iterateFunctionNodes = _iterateFunctionNodes3.default;
//# sourceMappingURL=index.js.map
{
"name": "eslint-plugin-flowtype",
"description": "Flowtype linting rules for ESLint.",
"version": "2.2.5",
"version": "2.2.6",
"main": "./dist/index.js",

@@ -25,3 +25,3 @@ "repository": {

"dependencies": {
"lodash": "^4.6.1"
"lodash": "^4.9.0"
},

@@ -39,9 +39,9 @@ "scripts": {

"devDependencies": {
"babel-cli": "^6.6.5",
"babel-eslint": "^6.0.0-beta.6",
"babel-cli": "^6.7.5",
"babel-eslint": "^6.0.2",
"babel-preset-es2015": "^6.6.0",
"chai": "^3.5.0",
"create-index": "^0.1.2",
"eslint": "^2.4.0",
"gitdown": "^2.4.0",
"eslint": "^2.7.0",
"gitdown": "^2.4.8",
"globby": "^4.0.0",

@@ -48,0 +48,0 @@ "mocha": "^2.4.5",

@@ -12,8 +12,4 @@ <h1 id="eslint-plugin-flowtype">eslint-plugin-flowtype</h1>

* [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)
* [`type-id-match`](#eslint-plugin-flowtype-rules-type-id-match)
* [Settings](#eslint-plugin-flowtype-settings)
* [`onlyFilesWithFlowAnnotation`](#eslint-plugin-flowtype-settings-onlyfileswithflowannotation)

@@ -70,2 +66,7 @@

]
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": false
}
}

@@ -75,6 +76,22 @@ }

<h2 id="eslint-plugin-flowtype-rules">Rules</h2>
<h2 id="eslint-plugin-flowtype-settings">Settings</h2>
<h3 id="eslint-plugin-flowtype-rules-require-parameter-type"><code>require-parameter-type</code></h3>
<h3 id="eslint-plugin-flowtype-settings-onlyfileswithflowannotation"><code>onlyFilesWithFlowAnnotation</code></h3>
When `true`, only checks files with a [`@flow` annotation](http://flowtype.org/docs/about-flow.html#gradual) in the first comment.
```js
{
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": true
}
}
}
```
## Rules
### `require-parameter-type`
Requires that all function parameters have type annotations.

@@ -102,2 +119,6 @@

// Message: Missing "{foo = 1}" parameter type annotation.
// @flow
(foo) => {}
// Message: Missing "foo" parameter type annotation.
```

@@ -117,6 +138,8 @@

([foo]: Array) => {}
(foo) => {}
```
<h3 id="eslint-plugin-flowtype-rules-require-return-type"><code>require-return-type</code></h3>
### `require-return-type`

@@ -138,5 +161,11 @@ Requires that functions have return type annotation.

(foo): void => { return; }
// Message: Must not annotate undefined return type.
(foo): undefined => { return undefined; }
// Message: Must not annotate undefined return type.
(foo): void => { return void 0; }
// Message: Must not annotate undefined return type.
// Options: ["always",{"annotateUndefined":"never"}]

@@ -146,2 +175,6 @@ (foo): undefined => { return; }

// Options: ["always",{"annotateUndefined":"never"}]
(foo): void => { return; }
// Message: Must not annotate undefined return type.
// Options: ["always",{"annotateUndefined":"always"}]

@@ -158,2 +191,15 @@ (foo) => { return; }

// Message: Must annotate undefined return type.
// Options: ["always",{"annotateUndefined":"always"}]
(foo) => { return void 0; }
// Message: Must annotate undefined return type.
// @flow
(foo) => { return 1; }
// Message: Missing return type annotation.
// Options: ["always",{"annotateUndefined":"always"}]
// @flow
(foo) => { return undefined; }
// Message: Must annotate undefined return type.
```

@@ -173,5 +219,10 @@

(foo) => { return void 0; }
// Options: ["always",{"annotateUndefined":"always"}]
(foo): undefined => { return; }
// Options: ["always",{"annotateUndefined":"always"}]
(foo): void => { return; }
// Options: ["always",{"annotateUndefined":"never"}]

@@ -183,8 +234,20 @@ (foo) => { return; }

// Options: ["always",{"annotateUndefined":"never"}]
(foo) => { return void 0; }
// Options: ["always",{"annotateUndefined":"always"}]
(foo): undefined => { return undefined; }
// Options: ["always",{"annotateUndefined":"always"}]
(foo): void => { return void 0; }
// Options: ["always"]
(foo) => { return 1; }
// Options: ["always",{"annotateUndefined":"always"}]
(foo) => { return undefined; }
```
<h3 id="eslint-plugin-flowtype-rules-space-after-type-colon"><code>space-after-type-colon</code></h3>
### `space-after-type-colon`

@@ -217,2 +280,14 @@ Enforces consistent spacing after the type annotation colon.

// Message: There must be 1 space after "foo" parameter type annotation colon.
// Options: ["always"]
():Object => {}
// Message: There must be a space after return type colon.
// Options: ["never"]
(): Object => {}
// Message: There must be no space after return type colon.
// Options: ["always"]
(): Object => {}
// Message: There must be 1 space after return type colon.
```

@@ -232,6 +307,12 @@

(foo: string) => {}
// Options: ["never"]
():Object => {}
// Options: ["always"]
(): Object => {}
```
<h3 id="eslint-plugin-flowtype-rules-space-before-type-colon"><code>space-before-type-colon</code></h3>
### `space-before-type-colon`

@@ -273,7 +354,7 @@ Enforces consistent spacing before the type annotation colon.

<h3 id="eslint-plugin-flowtype-rules-type-id-match"><code>type-id-match</code></h3>
### `type-id-match`
Enforces a consistent naming pattern for type aliases.
<h4 id="eslint-plugin-flowtype-rules-type-id-match-options">Options</h4>
#### Options

@@ -280,0 +361,0 @@ This rule needs a text RegExp to operate with Its signature is as follows:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc