eslint-plugin-magic-variables
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -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" | ||
}] | ||
}, | ||
], | ||
}); |
9490
183