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

eslint-plugin-inker

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-inker - npm Package Compare versions

Comparing version 2.5.4 to 2.5.5

19

dist/rules/react-ref-name.js

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

create(context) {
const isVariableNameTaken = (name) => {
const scope = context.getScope();
return scope.variables.some(variable => variable.name === name);
};
const getVariableUsages = (name) => {
const scope = context.getScope();
return scope.references.filter(ref => ref.identifier.name === name);
};
return {

@@ -35,3 +27,5 @@ VariableDeclarator(node) {

const suggestedName = `${id.name}Ref`;
const suggest = isVariableNameTaken(suggestedName)
const scope = context.getScope();
const isNameTaken = scope.variables.some(variable => variable.name === suggestedName);
const suggest = isNameTaken
? undefined

@@ -42,6 +36,7 @@ : [

fix(fixer) {
const usages = getVariableUsages(id.name);
const referenceIdentifiers = usages.map(ref => ref.identifier);
var _a, _b;
const references = (_b = (_a = context.getDeclaredVariables(node)[0]) === null || _a === void 0 ? void 0 : _a.references) !== null && _b !== void 0 ? _b : [];
const referenceIdentifiers = references.map(ref => ref.identifier);
return [
// id,
id,
...referenceIdentifiers,

@@ -48,0 +43,0 @@ ].map(identifier => fixer.replaceText(identifier, suggestedName));

{
"name": "eslint-plugin-inker",
"version": "2.5.4",
"version": "2.5.5",
"description": "",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

@@ -12,12 +12,2 @@ // eslint-disable-next-line import/no-extraneous-dependencies

create(context) {
const isVariableNameTaken = (name: string) => {
const scope = context.getScope()
return scope.variables.some(variable => variable.name === name)
}
const getVariableUsages = (name: string) => {
const scope = context.getScope()
return scope.references.filter(ref => ref.identifier.name === name)
}
return {

@@ -50,5 +40,7 @@ VariableDeclarator(node) {

const scope = context.getScope()
const isNameTaken = scope.variables.some(variable => variable.name === suggestedName)
type Suggest = Parameters<typeof context.report>[0]['suggest']
const suggest: Suggest = isVariableNameTaken(suggestedName)
const suggest: Suggest = isNameTaken
? undefined

@@ -59,6 +51,6 @@ : [

fix(fixer) {
const usages = getVariableUsages(id.name)
const referenceIdentifiers = usages.map(ref => ref.identifier)
const references = context.getDeclaredVariables(node)[0]?.references ?? []
const referenceIdentifiers = references.map(ref => ref.identifier)
return [
// id,
id,
...referenceIdentifiers,

@@ -65,0 +57,0 @@ ].map(identifier => fixer.replaceText(identifier, suggestedName))

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