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.1 to 0.0.2

6

lib/rules/no-magic-variables.js

@@ -54,3 +54,2 @@ /**

}
const cleanDecimals = (text) => text.replace(/\d/g, (match) => UNITS[match])

@@ -66,4 +65,7 @@ const cleanIntegers = (text) => text.replace(/(\d)+/g, (match) => capitalize(numberName(match)))

}
const cleanNegatives = () => {
return ''
}
const cleanName = (name) => {
return kebabCase(disambiguateDecimal(name).split(`Point`).map(cleanValues).join(`Point`))
return kebabCase(disambiguateDecimal(name).replace(/(negative|neg|minus)_?/gi, cleanNegatives).split(`Point`).map(cleanValues).join(`Point`))
}

@@ -70,0 +72,0 @@

{
"name": "eslint-plugin-magic-variables",
"version": "0.0.1",
"description": "prevent variables that are the number representation of a magic number from being used",
"version": "0.0.2",
"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.",
"keywords": [

@@ -6,0 +6,0 @@ "eslint",

# eslint-plugin-magic-variables
prevent variables that are the number representation of a magic number from being used
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 @@ ## Installation

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

]
}
},
{
code: "var NEGATIVE_10 = -10",
errors: [{
messageId: "avoidName"
}]
},
{
code: "var NEG_10 = -10",
errors: [{
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