Last active
December 14, 2017 19:26
-
-
Save briangonzalez/9a2cbb8ac3840f7b8ee9a223e11348f7 to your computer and use it in GitHub Desktop.
Custom Casing ESlint Rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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