Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@briangonzalez
Last active December 14, 2017 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briangonzalez/9a2cbb8ac3840f7b8ee9a223e11348f7 to your computer and use it in GitHub Desktop.
Save briangonzalez/9a2cbb8ac3840f7b8ee9a223e11348f7 to your computer and use it in GitHub Desktop.
Custom Casing ESlint Rules
const checkAndReport (token, correct, context) {
if (token.toLowerCase().includes(correct.toLowerCase()) && !token.includes(correct))) {
context.report(node, `The standard variable casing is "${correct}", not ${node.id.name}`);
}
}
module.exports.rules = {
"paypal-casing": context => ({
VariableDeclarator: (node) => {
checkAndReport(node.id.name, 'Paypal', context)
}
}),
"braintree-casing": context => ({
VariableDeclarator: (node) => {
checkAndReport(node.id.name, 'Braintree', context)
}
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment