Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-jsx-control-statements

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-jsx-control-statements - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

8

CHANGELOG.md

@@ -12,2 +12,10 @@ # Changelog

## v1.0.1
### Changed
- Internal: Refactor code.
### Fixed
- Fix build on node v0.x and iojs.
## v1.0.0

@@ -14,0 +22,0 @@

18

lib/rules/jsx-for-require-each.js

@@ -16,11 +16,4 @@ /**

module.exports = function(context) {
function isForComponent(node) {
return utils.isTag("For", node);
}
function eachAttr(decl) {
if (decl.type === 'JSXSpreadAttribute') {
return false;
}
return (decl.name.name === 'each');
return utils.isAttr(decl, 'each');
}

@@ -37,8 +30,9 @@

if (!isForComponent(node)) return;
if (!utils.isForComponent(node)) return;
if (attr) {
let scope = context.getScope();
scope.through = scope.through.filter((v) => attr.value.value !== v.identifier.name);
context.markVariableAsUsed(attr.value.value);
var scope = context.getScope();
scope.through = scope.through.filter(function(v) {
return attr.value.value !== v.identifier.name;
});
return;

@@ -45,0 +39,0 @@ }

@@ -16,11 +16,4 @@ /**

module.exports = function(context) {
function isForComponent(node) {
return utils.isTag("For", node);
}
function indexAttr(decl) {
if (decl.type === 'JSXSpreadAttribute') {
return false;
}
return (decl.name.name === 'index');
return utils.isAttr(decl, 'index');
}

@@ -37,8 +30,9 @@

if (!isForComponent(node)) return;
if (!utils.isForComponent(node)) return;
if (attr) {
let scope = context.getScope();
scope.through = scope.through.filter((v) => attr.value.value !== v.identifier.name);
context.markVariableAsUsed(attr.value.value);
var scope = context.getScope();
scope.through = scope.through.filter(function(v) {
return attr.value.value !== v.identifier.name;
});
return;

@@ -45,0 +39,0 @@ }

@@ -15,11 +15,4 @@ /**

module.exports = function(context) {
function isForComponent(node) {
return utils.isTag("For", node);
}
function hasOfAttr(decl) {
if (decl.type === 'JSXSpreadAttribute') {
return false;
}
return (decl.name.name === 'of');
return utils.isAttr(decl, 'of');
}

@@ -35,3 +28,3 @@

if (!isForComponent(node) || attributes.some(hasOfAttr)) {
if (!utils.isForComponent(node) || attributes.some(hasOfAttr)) {
return;

@@ -38,0 +31,0 @@ }

@@ -15,6 +15,2 @@ /**

module.exports = function(context) {
function isForComponent(node) {
return utils.isTag("For", node);
}
//--------------------------------------------------------------------------

@@ -26,3 +22,3 @@ // Public

JSXOpeningElement: function(node) {
if (!isForComponent(node)) return node;
if (!utils.isForComponent(node)) return node;

@@ -29,0 +25,0 @@ if (!utils.hasSingleChild(node)) {

@@ -15,11 +15,4 @@ /**

module.exports = function(context) {
function isIfComponent(node) {
return utils.isTag("If", node);
}
function hasConditionAttr(decl) {
if (decl.type === 'JSXSpreadAttribute') {
return false;
}
return (decl.name.name === 'condition');
return utils.isAttr(decl, 'condition');
}

@@ -35,3 +28,3 @@

if (!isIfComponent(node) || attributes.some(hasConditionAttr)) {
if (!utils.isIfComponent(node) || attributes.some(hasConditionAttr)) {
return;

@@ -38,0 +31,0 @@ }

@@ -16,7 +16,2 @@ /**

module.exports = function(context) {
function isIfComponent(node) {
return utils.isTag("If", node);
}
function isElseComponent(child) {

@@ -44,3 +39,3 @@ return child.type === 'JSXElement' && child.openingElement.name.name === 'Else';

JSXOpeningElement: function(node) {
if (!isIfComponent(node)) return node;
if (!utils.isIfComponent(node)) return node;

@@ -47,0 +42,0 @@ var children = utils.filterChildren(node.parent.children),

@@ -18,2 +18,9 @@ "use strict";

function isAttr(decl, name) {
if (decl.type === 'JSXSpreadAttribute') {
return false;
}
return (decl.name.name === name);
}
function isTag(tag, node) {

@@ -23,4 +30,15 @@ return node.name && node.name.type === "JSXIdentifier" && node.name.name === tag;

function isForComponent(node) {
return isTag("For", node);
}
function isIfComponent(node) {
return isTag("If", node);
}
exports.hasSingleChild = hasSingleChild;
exports.filterChildren = filterChildren;
exports.isTag = isTag;
exports.isAttr = isAttr;
exports.isForComponent = isForComponent;
exports.isIfComponent = isIfComponent;
{
"name": "eslint-plugin-jsx-control-statements",
"version": "1.0.0",
"version": "1.0.1",
"author": "Vivek Kumar Bansal <vkb0310@gmail.com>",

@@ -5,0 +5,0 @@ "description": "jsx-control-statements specific linting rules for ESLint",

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