eslint-plugin-flowtype
Advanced tools
Comparing version 2.18.2 to 2.19.0
@@ -5,2 +5,17 @@ # Change Log | ||
<a name="2.19.0"></a> | ||
# [2.19.0](https://github.com/gajus/eslint-plugin-flowtype/compare/v2.18.2...v2.19.0) (2016-09-20) | ||
### Bug Fixes | ||
* parens in TypeCastExpression ([0e0081f](https://github.com/gajus/eslint-plugin-flowtype/commit/0e0081f)) | ||
### Features | ||
* add rule `sort-keys` (fixes #104) ([f6b8deb](https://github.com/gajus/eslint-plugin-flowtype/commit/f6b8deb)), closes [#104](https://github.com/gajus/eslint-plugin-flowtype/issues/104) | ||
* check TypeCastExpressions in type colon spacing rules ([98839f0](https://github.com/gajus/eslint-plugin-flowtype/commit/98839f0)) | ||
<a name="2.18.2"></a> | ||
@@ -7,0 +22,0 @@ ## [2.18.2](https://github.com/gajus/eslint-plugin-flowtype/compare/v2.18.1...v2.18.2) (2016-09-18) |
@@ -75,2 +75,6 @@ 'use strict'; | ||
var _sortKeys = require('./rules/sortKeys'); | ||
var _sortKeys2 = _interopRequireDefault(_sortKeys); | ||
var _recommended = require('./configs/recommended.json'); | ||
@@ -97,2 +101,3 @@ | ||
semi: _semi2.default, | ||
'sort-keys': _sortKeys2.default, | ||
'space-after-type-colon': _spaceAfterTypeColon2.default, | ||
@@ -116,2 +121,3 @@ 'space-before-generic-bracket': _spaceBeforeGenericBracket2.default, | ||
semi: 0, | ||
'sort-keys': 0, | ||
'space-after-type-colon': 0, | ||
@@ -118,0 +124,0 @@ 'space-before-generic-bracket': 0, |
@@ -216,6 +216,46 @@ 'use strict'; | ||
var typeCastEvaluator = function typeCastEvaluator(context) { | ||
var sourceCode = context.getSourceCode(); | ||
var _parseOptions4 = parseOptions(context); | ||
var always = _parseOptions4.always; | ||
return function (typeCastExpression) { | ||
var _sourceCode$getFirstT5 = sourceCode.getFirstTokens(typeCastExpression.typeAnnotation, 2); | ||
var _sourceCode$getFirstT6 = _slicedToArray(_sourceCode$getFirstT5, 2); | ||
var firstTokenOfType = _sourceCode$getFirstT6[1]; | ||
var spaces = firstTokenOfType.start - typeCastExpression.typeAnnotation.start - 1; | ||
if (always && spaces > 1) { | ||
context.report({ | ||
fix: _utilities.spacingFixers.stripSpacesBefore(firstTokenOfType, spaces - 1), | ||
message: 'There must be 1 space after type cast colon.', | ||
node: typeCastExpression | ||
}); | ||
} else if (always && spaces === 0) { | ||
context.report({ | ||
fix: _utilities.spacingFixers.addSpaceBefore(firstTokenOfType), | ||
message: 'There must be a space after type cast colon.', | ||
node: typeCastExpression | ||
}); | ||
} else if (!always && spaces > 0) { | ||
context.report({ | ||
fix: _utilities.spacingFixers.stripSpacesBefore(firstTokenOfType, spaces), | ||
message: 'There must be no space after type cast colon.', | ||
node: typeCastExpression | ||
}); | ||
} | ||
}; | ||
}; | ||
exports.default = function (context) { | ||
return _extends({}, functionEvaluators(context), { | ||
ClassProperty: propertyEvaluator(context, 'class property'), | ||
ObjectTypeProperty: objectTypePropertyEvaluator(context) | ||
ObjectTypeProperty: objectTypePropertyEvaluator(context), | ||
TypeCastExpression: typeCastEvaluator(context) | ||
}); | ||
@@ -222,0 +262,0 @@ }; |
@@ -162,6 +162,41 @@ 'use strict'; | ||
var typeCastEvaluator = function typeCastEvaluator(context) { | ||
var sourceCode = context.getSourceCode(); | ||
var _parseOptions3 = parseOptions(context); | ||
var always = _parseOptions3.always; | ||
return function (typeCastExpression) { | ||
var lastTokenOfIdentifier = sourceCode.getTokenBefore(typeCastExpression.typeAnnotation); | ||
var spaces = typeCastExpression.typeAnnotation.start - lastTokenOfIdentifier.end; | ||
if (always && spaces > 1) { | ||
context.report({ | ||
fix: _utilities.spacingFixers.stripSpacesAfter(lastTokenOfIdentifier, spaces - 1), | ||
message: 'There must be 1 space before type cast colon.', | ||
node: typeCastExpression | ||
}); | ||
} else if (always && spaces === 0) { | ||
context.report({ | ||
fix: _utilities.spacingFixers.addSpaceAfter(lastTokenOfIdentifier), | ||
message: 'There must be a space before type cast colon.', | ||
node: typeCastExpression | ||
}); | ||
} else if (!always && spaces > 0) { | ||
context.report({ | ||
fix: _utilities.spacingFixers.stripSpacesAfter(lastTokenOfIdentifier, spaces), | ||
message: 'There must be no space before type cast colon.', | ||
node: typeCastExpression | ||
}); | ||
} | ||
}; | ||
}; | ||
exports.default = function (context) { | ||
return _extends({}, functionEvaluators(context), { | ||
ClassProperty: propertyEvaluator(context, 'class property'), | ||
ObjectTypeProperty: objectTypePropertyEvaluator(context) | ||
ObjectTypeProperty: objectTypePropertyEvaluator(context), | ||
TypeCastExpression: typeCastEvaluator(context) | ||
}); | ||
@@ -168,0 +203,0 @@ }; |
@@ -6,2 +6,8 @@ 'use strict'; | ||
}); | ||
var stripSpacesBefore = exports.stripSpacesBefore = function stripSpacesBefore(node, spaces) { | ||
return function (fixer) { | ||
return fixer.removeRange([node.start - spaces, node.start]); | ||
}; | ||
}; | ||
var stripSpacesAfter = exports.stripSpacesAfter = function stripSpacesAfter(node, spaces) { | ||
@@ -13,2 +19,8 @@ return function (fixer) { | ||
var addSpaceBefore = exports.addSpaceBefore = function addSpaceBefore(node) { | ||
return function (fixer) { | ||
return fixer.insertTextBefore(node, ' '); | ||
}; | ||
}; | ||
var addSpaceAfter = exports.addSpaceAfter = function addSpaceAfter(node) { | ||
@@ -15,0 +27,0 @@ return function (fixer) { |
{ | ||
"name": "eslint-plugin-flowtype", | ||
"description": "Flowtype linting rules for ESLint.", | ||
"version": "2.18.2", | ||
"version": "2.19.0", | ||
"main": "./dist/index.js", | ||
@@ -6,0 +6,0 @@ "repository": { |
Sorry, the diff of this file is too big to display
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
140929
33
1510
2708