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

38 lines (34 loc) 961 B
const path = require('path'); module.exports = { rules: { 'folder-lowercase': { meta: { type: 'problem', docs: { description: 'Enforce lowercase naming convention for folder names', }, messages: { invalidFolderName: 'Folder "{{name}}" should be in lowercase.', }, }, create(context) { return { Program(node) { const filePath = context.getFilename(); const dirName = path.basename(path.dirname(filePath)); // Regex for lowercase only const lowerCaseRegex = /^[a-z0-9]+(-[a-z0-9]+)*$/; // Check if folder name is not lowercase if (!lowerCaseRegex.test(dirName)) { context.report({ node, messageId: 'invalidFolderName', data: { name: dirName }, }); } }, }; }, }, }, };