eslint-plugin-magic-variables
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -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" |
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
10138
199