@arthurgeron/eslint-plugin-react-usememo
Advanced tools
Comparing version 2.1.4--beta0 to 2.1.4--beta1
@@ -137,2 +137,6 @@ 'use strict'; | ||
function getVariableInScope(context, name) { | ||
return context.getScope().variables.find(function (variable) { return variable.name === name; }); | ||
} | ||
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; | ||
@@ -375,3 +379,3 @@ | ||
function addReactImports(context, kind, reactImportData, fixer) { | ||
var _a, _b, _c, _d; | ||
var _a, _b, _c, _d, _e; | ||
var importsDisabled = ((_c = (_b = (_a = context.options) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.fix) === null || _c === void 0 ? void 0 : _c.addImports) === false; | ||
@@ -391,5 +395,12 @@ var specifier = undefined; | ||
var specifiers = reactImportData.importDeclaration.specifiers; | ||
var hasDefaultExport = ((_e = specifiers === null || specifiers === void 0 ? void 0 : specifiers[0]) === null || _e === void 0 ? void 0 : _e.type) === 'ImportDefaultSpecifier'; | ||
var isEmpty = !specifiers.length; | ||
// Default export counts as a specifier too | ||
var shouldCreateSpecifiersBracket = specifiers.length <= 1 && hasDefaultExport; | ||
var hasCurrentSpecifier = !isEmpty && !shouldCreateSpecifiersBracket && specifiers.find(function (x) { return x.local.name === kind; }); | ||
if (shouldCreateSpecifiersBracket) { | ||
specifiers.push(specifier); | ||
return fixer.insertTextAfter(specifiers[0], ", { ".concat(kind, " }")); | ||
} | ||
if (isEmpty) { | ||
specifiers.push(specifier); | ||
var importDeclaration = reactImportData.importDeclaration; | ||
@@ -399,4 +410,3 @@ var fixRange = importDeclaration.range[0] + defaultImportRangeStart.length - 1; | ||
} | ||
// Do not add specifier if exists. | ||
if (!specifiers.find(function (x) { return x.local.name === kind; })) { | ||
if (!hasCurrentSpecifier) { | ||
specifiers.push(specifier); | ||
@@ -586,5 +596,2 @@ var insertPosition = specifiers[specifiers.length - 2]; | ||
} | ||
function getVariableInScope(context, name) { | ||
return context.getScope().variables.find(function (variable) { return variable.name === name; }); | ||
} | ||
function getIdentifierMemoStatus(context, _a) { | ||
@@ -810,3 +817,3 @@ var _b, _c, _d, _e, _f; | ||
ImportDeclaration: function (node) { | ||
if (node.source.value === 'react') { | ||
if (node.source.value === 'react' && node.importKind !== 'type') { | ||
importData.reactImported = true; | ||
@@ -813,0 +820,0 @@ importData.importDeclaration = node; |
{ | ||
"name": "@arthurgeron/eslint-plugin-react-usememo", | ||
"version": "2.1.4--beta0", | ||
"version": "2.1.4--beta1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51220
867