UNPKG

@mindfiredigital/eslint-plugin-hub

Version:

eslint-plugin-hub is a powerful, flexible ESLint plugin that provides a curated set of rules to enhance code readability, maintainability, and prevent common errors. Whether you're working with vanilla JavaScript, TypeScript, React, or Angular, eslint-plu

41 lines (37 loc) 1.07 kB
const lowerCaseRegex = /^[a-z][a-z0-9]*$/; module.exports = { rules: { 'vars-lowercase': { meta: { type: 'problem', docs: { description: 'Enforce lowercase naming convention for variables declared with var, let, or const', }, schema: [], // No options needed messages: { notLowerCase: "Variable '{{name}}' should be in lowercase.", }, }, create(context) { return { VariableDeclarator(node) { const variableName = node.id && node.id.name; // Ensure variableName is a string before proceeding if (typeof variableName !== 'string') { return; } // Check if variable name is in lowercase if (!lowerCaseRegex.test(variableName)) { context.report({ node: node.id, messageId: 'notLowerCase', data: { name: variableName }, }); } }, }; }, }, }, };