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

eslint-plugin-magic-variables

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-magic-variables - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

24

lib/rules/no-magic-variables.js

@@ -23,3 +23,3 @@ /**

messages: {
avoidName: "Avoid using variable names that are numeric or are the word form of a number '{{name}}' = {{value}}"
avoidName: "Avoid using variable names that are numeric or are the word form of a number i.e. '{{name}}' = {{value}}"
}

@@ -87,2 +87,7 @@ },

if (isNumeric(node)) {
const name = node.name
const operator = get(node, `parent.init.operator`, null)
const modifier = operator === '-' ? -1 : 1
let value = get(node, 'parent.init.value', get(node,'parent.init.argument.value', ''))
value = value * modifier
context.report({

@@ -92,10 +97,19 @@ node: node,

data: {
name: node.name,
value: get(node, 'parent.init.value', null)
name,
value,
},
});
}
}
};
},
// Literal(node){
// console.log(`Litral`, node)
// },
// VariableDeclarator(node){
// console.log(`Variable Declarator`, node)
// },
// UnaryExpression(node){
// console.log(`unary expresion`, node)
// }
};
},
};
{
"name": "eslint-plugin-magic-variables",
"version": "0.0.3",
"version": "0.0.4",
"description": "Prevent variable names that are numeric, or are the word form of a number from being used. i.e. FIFTY_TWO is not a valid variable name.",

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

@@ -53,3 +53,3 @@ /**

{
code: "var NEGATIVE_10 = -10",
code: "var NEGATIVE_10 = -10;",
errors: [{

@@ -60,3 +60,3 @@ messageId: "avoidName"

{
code: "var NEG_10 = -10",
code: "var NEG_10 = -10;",
errors: [{

@@ -63,0 +63,0 @@ messageId: "avoidName"

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