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.37.0 to 2.38.0

55

dist/rules/sortKeys.js

@@ -74,2 +74,52 @@ 'use strict';

var variances = {
minus: '-',
plus: '+'
};
var generateOrderedList = function generateOrderedList(context, sort, properties) {
return properties.map(function (property) {
var name = (0, _utilities.getParameterName)(property, context);
var value = void 0;
if (property.value.type === 'ObjectTypeAnnotation') {
value = generateFix(property.value, context, sort); // eslint-disable-line no-use-before-define
} else {
value = context.getSourceCode().getText(property.value);
}
return [(variances[property.variance] || '') + name + (property.optional ? '?' : ''), value];
}).sort(function (first, second) {
return sort(first[0], second[0]) ? -1 : 1;
}).map(function (item) {
return item[0] + ': ' + item[1];
});
};
var generateFix = function generateFix(node, context, sort) {
// this could be done much more cleanly in ESLint >=4
// as we can apply multiple fixes. That also means we can
// maintain code style in a much nicer way
var nodeText = void 0;
var newTypes = generateOrderedList(context, sort, node.properties);
var source = context.getSourceCode(node);
var originalSubstring = source.getText(node);
nodeText = originalSubstring;
node.properties.forEach(function (property, index) {
var subString = source.getText(property);
var addComma = subString[subString.length - 1] === ',';
nodeText = nodeText.replace(subString, '$' + index + (addComma ? ',' : ''));
});
newTypes.forEach(function (item, index) {
nodeText = nodeText.replace('$' + index, item);
});
return nodeText;
};
var create = function create(context) {

@@ -110,2 +160,7 @@ var order = _lodash2.default.get(context, ['options', 0], 'asc');

},
fix(fixer) {
var nodeText = generateFix(node, context, isValidOrder);
return fixer.replaceText(node, nodeText);
},
loc: identifierNode.loc,

@@ -112,0 +167,0 @@ message: 'Expected type annotations to be in {{natural}}{{insensitive}}{{order}}ending order. "{{current}}" should be before "{{last}}".',

2

package.json

@@ -56,3 +56,3 @@ {

},
"version": "2.37.0"
"version": "2.38.0"
}

Sorry, the diff of this file is too big to display

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