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 8.0.0 to 8.0.1

9

dist/bin/addAssertions.js

@@ -32,5 +32,5 @@ #!/usr/bin/env node

if (setup.errors) {
setup.errors.forEach(message => {
for (const message of setup.errors) {
paragraphs.push('// Message: ' + message.message);
});
}
}

@@ -53,2 +53,3 @@

const assertionCodes = _lodash.default.map(assertionFiles, filePath => {
// eslint-disable-next-line import/no-dynamic-require
const codes = require(filePath);

@@ -70,5 +71,5 @@

documentBody = _fs.default.readFileSync(readmeDocumentPath, 'utf8');
documentBody = documentBody.replace(/<!-- assertions ([a-z]+?) -->/gi, assertionsBlock => {
documentBody = documentBody.replace(/<!-- assertions ([a-z]+?) -->/ugi, assertionsBlock => {
let exampleBody;
const ruleName = assertionsBlock.match(/assertions ([a-z]+)/i)[1];
const ruleName = assertionsBlock.match(/assertions ([a-z]+)/ui)[1];
const ruleAssertions = assertions[ruleName];

@@ -75,0 +76,0 @@

@@ -27,3 +27,3 @@ #!/usr/bin/env node

const rules = content.split('\n').map(line => {
const match = /^{"gitdown": "include", "file": "([^"]+)"}$/.exec(line);
const match = /^{"gitdown": "include", "file": "([^"]+)"}$/u.exec(line);

@@ -49,3 +49,3 @@ if (match === null) {

const match = /<!-- assertions ([A-Za-z]+) -->/.exec(content);
const match = /<!-- assertions ([A-Za-z]+) -->/u.exec(content);

@@ -52,0 +52,0 @@ if (match === null) {

@@ -13,4 +13,5 @@ "use strict";

const getTestIndexRules = () => {
const content = _fs.default.readFileSync(_path.default.resolve(__dirname, '../../tests/rules/index.js'), 'utf-8');
const content = _fs.default.readFileSync(_path.default.resolve(__dirname, '../../tests/rules/index.js'), 'utf-8'); // eslint-disable-next-line unicorn/no-array-reduce
const result = content.split('\n').reduce((acc, line) => {

@@ -21,3 +22,3 @@ if (acc.inRulesArray) {

} else {
acc.rules.push(line.replace(/^\s*'([^']+)',?$/, '$1'));
acc.rules.push(line.replace(/^\s*'([^']+)',?$/u, '$1'));
}

@@ -24,0 +25,0 @@ } else if (line === 'const reportingRules = [') {

@@ -20,3 +20,3 @@ "use strict";

const inlineType = type => {
const inlined = type.replace(/\s+/g, ' ');
const inlined = type.replace(/\s+/ug, ' ');

@@ -23,0 +23,0 @@ if (inlined.length <= 50) {

@@ -27,3 +27,3 @@ "use strict";

*/
const simpleTypePatterns = [/^(?:Any|Array|Boolean|Generic|Mixed|Number|String|Void)TypeAnnotation$/, /.+LiteralTypeAnnotation$/];
const simpleTypePatterns = [/^(?:Any|Array|Boolean|Generic|Mixed|Number|String|Void)TypeAnnotation$/u, /.+LiteralTypeAnnotation$/u];

@@ -30,0 +30,0 @@ var _default = node => {

@@ -74,5 +74,5 @@ "use strict";

TypeParameterDeclaration(node) {
node.params.forEach(param => {
for (const param of node.params) {
makeDefined(param);
});
}
}

@@ -79,0 +79,0 @@

@@ -12,3 +12,3 @@ "use strict";

const create = context => {
const pattern = new RegExp(context.options[0] || '^([A-Z][a-z0-9]*)+Type$');
const pattern = new RegExp(context.options[0] || '^([A-Z][a-z0-9]*)+Type$', 'u');

@@ -15,0 +15,0 @@ const checkInterface = interfaceDeclarationNode => {

@@ -13,3 +13,3 @@ "use strict";

const looksLikeFlowFileAnnotation = comment => {
return /@(?:no)?flo/i.test(comment);
return /@(?:no)?flo/ui.test(comment);
};

@@ -16,0 +16,0 @@

@@ -85,3 +85,3 @@ "use strict";

_lodash.default.forEach(identifierNodes, identifierNode => {
for (const identifierNode of identifierNodes) {
const needle = {

@@ -106,3 +106,3 @@ name: (0, _utilities.getParameterName)(identifierNode, context)

}
});
}
};

@@ -109,0 +109,0 @@

@@ -17,3 +17,3 @@ "use strict";

const create = context => {
const allowedPattern = context.options[0] ? new RegExp(context.options[0]) : null;
const allowedPattern = context.options[0] ? new RegExp(context.options[0], 'u') : null;
const extraMessage = allowedPattern ? ' Fix it or match `' + allowedPattern.toString() + '`.' : '';

@@ -32,3 +32,3 @@

if (value.match(/\$FlowFixMe/) && !passesExtraRegex(value)) {
if (/\$FlowFixMe/u.test(value) && !passesExtraRegex(value)) {
context.report(comment, message + extraMessage);

@@ -40,3 +40,3 @@ }

GenericTypeAnnotation(node) {
if (isIdentifier(node.id, /\$FlowFixMe/)) {
if (isIdentifier(node.id, /\$FlowFixMe/u)) {
context.report({

@@ -50,5 +50,7 @@ message,

Program() {
context.getSourceCode().getAllComments().filter(comment => {
return comment.type === 'Block' || comment.type === 'Line';
}).forEach(handleComment);
for (const comment of context.getSourceCode().getAllComments().filter(node => {
return node.type === 'Block' || node.type === 'Line';
})) {
handleComment(comment);
}
}

@@ -55,0 +57,0 @@

@@ -15,3 +15,3 @@ "use strict";

Identifier(node) {
const match = node.name.match(/^React\$(?<internalTypeName>.+)/);
const match = node.name.match(/^React\$(?<internalTypeName>.+)/u);

@@ -18,0 +18,0 @@ if (match !== null && match.groups !== null && match.groups !== undefined) {

@@ -15,3 +15,3 @@ "use strict";

const create = context => {
const regex = /^(Boolean|Number|String)$/;
const regex = /^(Boolean|Number|String)$/u;
return {

@@ -18,0 +18,0 @@ GenericTypeAnnotation: node => {

@@ -21,4 +21,5 @@ "use strict";

return;
}
} // eslint-disable-next-line @babel/new-cap
coreChecks.ExpressionStatement(node);

@@ -25,0 +26,0 @@ }

@@ -21,3 +21,3 @@ "use strict";

if (!node.hasOwnProperty('inexact')) {
if (!Object.prototype.hasOwnProperty.call(node, 'inexact')) {
return;

@@ -24,0 +24,0 @@ }

@@ -29,3 +29,3 @@ "use strict";

const excludeParameterMatch = new RegExp(_lodash.default.get(context, 'options[0].excludeParameterMatch', 'a^'));
const excludeParameterMatch = new RegExp(_lodash.default.get(context, 'options[0].excludeParameterMatch', 'a^'), 'u');
return functionNode => {

@@ -44,4 +44,5 @@ // It is save to ignore FunctionTypeAnnotation nodes in this rule.

return;
}
} // eslint-disable-next-line unicorn/no-array-for-each
_lodash.default.forEach(functionNode.params, identifierNode => {

@@ -48,0 +49,0 @@ const parameterName = (0, _utilities.getParameterName)(identifierNode, context);

@@ -21,4 +21,4 @@ "use strict";

}];
const reComponentName = /^(Pure)?Component$/;
const reReadOnly = /^\$(ReadOnly|FlowFixMe)$/;
const reComponentName = /^(Pure)?Component$/u;
const reReadOnly = /^\$(ReadOnly|FlowFixMe)$/u;

@@ -25,0 +25,0 @@ const isReactComponent = node => {

@@ -42,3 +42,3 @@ "use strict";

const makeRegExp = str => {
return new RegExp(str);
return new RegExp(str, 'u');
};

@@ -53,6 +53,7 @@

const annotateUndefined = _lodash.default.get(context, 'options[1].annotateUndefined') || 'never';
const skipArrows = _lodash.default.get(context, 'options[1].excludeArrowFunctions') || false;
const skipArrows = _lodash.default.get(context, 'options[1].excludeArrowFunctions') || false; // eslint-disable-next-line unicorn/no-array-callback-reference
const excludeMatching = _lodash.default.get(context, 'options[1].excludeMatching', []).map(makeRegExp);
const excludeMatching = _lodash.default.get(context, 'options[1].excludeMatching', []).map(makeRegExp); // eslint-disable-next-line unicorn/no-array-callback-reference
const includeOnlyMatching = _lodash.default.get(context, 'options[1].includeOnlyMatching', []).map(makeRegExp);

@@ -59,0 +60,0 @@

@@ -20,3 +20,3 @@ "use strict";

const looksLikeFlowFileAnnotation = comment => {
return /@(?:no)?flo/i.test(comment);
return /@(?:no)?flo/ui.test(comment);
};

@@ -33,11 +33,11 @@

const checkAnnotationSpelling = comment => {
return /@[a-z]+\b/.test(comment) && (0, _utilities.fuzzyStringMatch)(comment.replace(/no/i, ''), '@flow', 0.2);
return /@[a-z]+\b/u.test(comment) && (0, _utilities.fuzzyStringMatch)(comment.replace(/no/ui, ''), '@flow', 0.2);
};
const isFlowStrict = comment => {
return /^@flow\sstrict\b/.test(comment);
return /^@flow\sstrict\b/u.test(comment);
};
const noFlowAnnotation = comment => {
return /^@noflow\b/.test(comment);
return /^@noflow\b/u.test(comment);
};

@@ -44,0 +44,0 @@

@@ -46,3 +46,3 @@ "use strict";

const excludeVariableMatch = new RegExp(_lodash.default.get(context, 'options[0].excludeVariableMatch', 'a^'));
const excludeVariableMatch = new RegExp(_lodash.default.get(context, 'options[0].excludeVariableMatch', 'a^'), 'u');

@@ -57,4 +57,5 @@ const excludeVariableTypes = _lodash.default.get(context, 'options[0].excludeVariableTypes', {});

return;
}
} // eslint-disable-next-line unicorn/no-array-for-each
_lodash.default.forEach(variableDeclaration.declarations, variableDeclarator => {

@@ -61,0 +62,0 @@ const identifierNode = _lodash.default.get(variableDeclarator, 'id');

@@ -94,3 +94,4 @@ "use strict";

let itemGroupIndex = 0;
items.forEach(item => {
for (const item of items) {
if (item[0].type === 'ObjectTypeSpreadProperty') {

@@ -104,5 +105,7 @@ ++itemGroupIndex;

}
});
}
const orderedList = [];
itemGroups.forEach(itemGroup => {
for (const itemGroup of itemGroups) {
if (itemGroup[0] && itemGroup[0].type !== 'ObjectTypeSpreadProperty') {

@@ -122,3 +125,4 @@ // console.log('itemGroup', itemGroup);

}));
});
}
return orderedList;

@@ -136,3 +140,4 @@ };

nodeText = originalSubstring;
node.properties.forEach((property, index) => {
for (const [index, property] of node.properties.entries()) {
const nextPunctuator = source.getTokenAfter(property, {

@@ -150,6 +155,8 @@ filter: token => {

nodeText = nodeText.replace(subString, '$' + index);
});
newTypes.forEach((item, index) => {
}
for (const [index, item] of newTypes.entries()) {
nodeText = nodeText.replace('$' + index, item);
});
}
return nodeText;

@@ -164,5 +171,5 @@ };

const checkKeyOrder = node => {
prev = null;
prev = null; // eslint-disable-next-line unicorn/no-array-for-each
_lodash.default.forEach(node.properties, identifierNode => {
node.properties.forEach(identifierNode => {
const current = (0, _utilities.getParameterName)(identifierNode, context);

@@ -169,0 +176,0 @@ const last = prev; // keep track of the last token

@@ -18,3 +18,4 @@ "use strict";

} = node;
properties.forEach(property => {
for (const property of properties) {
const {

@@ -39,3 +40,3 @@ type

}
});
}
}

@@ -42,0 +43,0 @@

@@ -8,4 +8,2 @@ "use strict";

var _lodash = _interopRequireDefault(require("lodash"));
var _utilities = require("../../utilities");

@@ -23,3 +21,5 @@

return functionNode => {
_lodash.default.forEach(functionNode.params, checkParam);
for (const param of functionNode.params) {
checkParam(param);
}

@@ -26,0 +26,0 @@ checkReturnType(functionNode);

@@ -19,3 +19,3 @@ "use strict";

_lodash.default.forEach(declarations, leaf => {
for (const leaf of declarations) {
const typeAnnotation = _lodash.default.get(leaf, 'id.typeAnnotation');

@@ -31,3 +31,3 @@

}
});
}
};

@@ -34,0 +34,0 @@ };

@@ -12,3 +12,3 @@ "use strict";

const create = context => {
const pattern = new RegExp(context.options[0] || '^([A-Z][a-z0-9]*)+Type$');
const pattern = new RegExp(context.options[0] || '^([A-Z][a-z0-9]*)+Type$', 'u');

@@ -15,0 +15,0 @@ const checkType = typeAliasNode => {

@@ -25,3 +25,3 @@ "use strict";

if (node.importKind !== 'type') {
node.specifiers.forEach(specifier => {
for (const specifier of node.specifiers) {
if (specifier.importKind === 'type') {

@@ -33,3 +33,3 @@ context.report({

}
});
}
}

@@ -36,0 +36,0 @@ }

@@ -20,5 +20,5 @@ "use strict";

const check = node => {
node.types.forEach((type, index) => {
for (const [index, type] of node.types.entries()) {
if (index + 1 === node.types.length) {
return;
continue;
}

@@ -72,3 +72,3 @@

}
});
}
};

@@ -75,0 +75,0 @@

@@ -47,3 +47,3 @@ "use strict";

TypeParameterDeclaration(node) {
node.params.forEach(param => {
for (const param of node.params) {
if (param.default && param.default.typeParameters) {

@@ -54,9 +54,9 @@ if (param.default.type === 'GenericTypeAnnotation') {

param.default.typeParameters.params.forEach(typeParameterNode => {
for (const typeParameterNode of param.default.typeParameters.params) {
if (typeParameterNode.type === 'GenericTypeAnnotation') {
markTypeAsUsedWithGenericType(typeParameterNode);
}
});
}
}
});
}
}

@@ -63,0 +63,0 @@

@@ -17,3 +17,3 @@ "use strict";

return functionNode => {
_lodash.default.forEach(functionNode.params, identifierNode => {
for (const identifierNode of functionNode.params) {
const nodeType = _lodash.default.get(identifierNode, 'type');

@@ -34,3 +34,3 @@

}
});
}
};

@@ -37,0 +37,0 @@ });

@@ -21,4 +21,5 @@ "use strict";

return () => {};
}
} // eslint-disable-next-line promise/prefer-await-to-callbacks -- not a promise callback
return cb(context);

@@ -25,0 +26,0 @@ };

@@ -8,2 +8,4 @@ "use strict";

/* eslint-disable import/no-dynamic-require */
/**

@@ -10,0 +12,0 @@ * Adopted from https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/rules/utils/get-builtin-rule.js.

@@ -12,3 +12,3 @@ "use strict";

const FLOW_MATCHER = /^@(?:no)?flow$/;
const FLOW_MATCHER = /^@(?:no)?flow$/u;

@@ -18,3 +18,3 @@ var _default = (comment, strict) => {

// See https://github.com/facebook/flow/blob/a96249b93541f2f7bfebd8d62085bf7a75de02f2/src/parsing/docblock.ml#L39
return _lodash.default.some(comment.split(/[\t\n\r */\\]+/), commentPart => {
return _lodash.default.some(comment.split(/[\t\n\r */\\]+/u), commentPart => {
const match = commentPart.match(FLOW_MATCHER);

@@ -21,0 +21,0 @@

@@ -12,3 +12,3 @@ "use strict";

const FLOW_MATCHER = /^@noflow$/;
const FLOW_MATCHER = /^@noflow$/u;

@@ -18,3 +18,3 @@ var _default = (comment, strict) => {

// See https://github.com/facebook/flow/blob/a96249b93541f2f7bfebd8d62085bf7a75de02f2/src/parsing/docblock.ml#L39
return _lodash.default.some(comment.split(/[\t\n\r */\\]+/), commentPart => {
return _lodash.default.some(comment.split(/[\t\n\r */\\]+/u), commentPart => {
const match = commentPart.match(FLOW_MATCHER);

@@ -21,0 +21,0 @@

@@ -25,2 +25,3 @@ {

"eslint": "^8.1.0",
"eslint-config-canonical": "^32.6.0",
"eslint-plugin-eslint-plugin": "^4.0.1",

@@ -68,3 +69,3 @@ "gitdown": "^3.1.4",

},
"version": "8.0.0"
"version": "8.0.1"
}

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