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.35.0 to 2.35.1

33

dist/rules/typeColonSpacing/reporter.js

@@ -9,2 +9,12 @@ 'use strict';

var hasLineBreak = function hasLineBreak(direction, colon, context) {
var sourceCode = context.getSourceCode();
if (direction === 'before') {
return colon.loc.start.line !== sourceCode.getTokenBefore(colon).loc.end.line;
} else {
return sourceCode.getTokenAfter(colon).loc.start.line !== colon.loc.end.line;
}
};
var getSpaces = function getSpaces(direction, colon, context) {

@@ -32,3 +42,4 @@ var sourceCode = context.getSourceCode();

var spaces = void 0;
var lineBreak = void 0,
spaces = void 0;

@@ -48,6 +59,9 @@ // Support optional names

var charAfter = context.getSourceCode().getText(colon, 0, 1).slice(1);
if (allowLineBreak && RegExp(/(\n|\r)+/).test(charAfter)) {
spaces = 1;
if (hasLineBreak(direction, colon, context)) {
if (allowLineBreak) {
spaces = 1;
} else {
lineBreak = true;
spaces = getSpaces(direction, colon, context);
}
} else {

@@ -57,5 +71,12 @@ spaces = getSpaces(direction, colon, context);

if (always && spaces > 1) {
if (always && lineBreak) {
context.report({
data,
fix: _utilities.spacingFixers.replaceWithSpace(direction, colon, spaces),
message: 'There must not be a line break {{direction}} {{name}}{{type}} colon.',
node
});
} else if (always && spaces > 1) {
context.report({
data,
fix: _utilities.spacingFixers.stripSpaces(direction, colon, spaces - 1),

@@ -62,0 +83,0 @@ message: 'There must be 1 space {{direction}} {{name}}{{type}} colon.',

@@ -30,2 +30,14 @@ 'use strict';

var replaceWithSpaceBefore = exports.replaceWithSpaceBefore = function replaceWithSpaceBefore(node, spaces) {
return function (fixer) {
return fixer.replaceTextRange([node.start - spaces, node.start], ' ');
};
};
var replaceWithSpaceAfter = exports.replaceWithSpaceAfter = function replaceWithSpaceAfter(node, spaces) {
return function (fixer) {
return fixer.replaceTextRange([node.end, node.end + spaces], ' ');
};
};
var stripSpaces = exports.stripSpaces = function stripSpaces(direction, node, spaces) {

@@ -45,2 +57,10 @@ if (direction === 'before') {

}
};
var replaceWithSpace = exports.replaceWithSpace = function replaceWithSpace(direction, node, spaces) {
if (direction === 'before') {
return replaceWithSpaceBefore(node, spaces);
} else {
return replaceWithSpaceAfter(node, spaces);
}
};

2

package.json

@@ -55,3 +55,3 @@ {

},
"version": "2.35.0"
"version": "2.35.1"
}
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