Socket
Socket
Sign inDemoInstall

eslint-plugin-flow-vars

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

2

package.json
{
"name": "eslint-plugin-flow-vars",
"version": "0.1.1",
"version": "0.1.2",
"description": "Solves the problem of false positives with `no-undef` and `no-unused-vars` when using babel-eslint",

@@ -5,0 +5,0 @@ "keywords": [

'use strict';
module.exports = function(context) {
var imported = Object.create(null);
var types = Object.create(null);
function markUsedIfType(ident) {
if (types[ident.name]) {
context.markVariableAsUsed(ident.name);
types[ident.name] = null;
}
}
function markTypeAsUsed(node) {
context.markVariableAsUsed(node.id.name);
}
function markUsedIfImported(ident) {
if (imported[ident.name]) {
context.markVariableAsUsed(ident.name);
imported[ident.name] = null;
}
}
return {

@@ -23,11 +23,14 @@ DeclareClass: markTypeAsUsed,

var specifier = node.specifiers[i];
imported[specifier.local.name] = true;
types[specifier.local.name] = true;
}
}
},
TypeAlias: function(node) {
types[node.id.name] = true;
},
GenericTypeAnnotation: function(node) {
if (node.id.type === 'Identifier') {
markUsedIfImported(node.id);
markUsedIfType(node.id);
} else if (node.id.type === 'QualifiedTypeIdentifier') {
markUsedIfImported(node.id.qualification);
markUsedIfType(node.id.qualification);
}

@@ -34,0 +37,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc