UNPKG

@shayanthenerd/eslint-config

Version:

A modern, flexible ESLint configuration for enforcing best practices and maintaining a consistent coding style

20 lines (18 loc) 972 B
import { defaultOptions } from "./options/defaultOptions.js"; import path from "node:path"; import { styleText } from "node:util"; import { isPackageExists } from "local-pkg"; //#region src/utils/isPackageDetected.ts const detectedPackages = []; function logDetectedPackages() { if (detectedPackages.length > 0) console.info(styleText("green", "✔"), "Automatic dependency detection enabled ESLint configurations for", detectedPackages.map((packageName) => styleText("blue", packageName)).join(", ")); } function isPackageDetected(packageName, options = defaultOptions) { const { packageDir = defaultOptions.packageDir, autoDetectDeps = defaultOptions.autoDetectDeps } = options; if (!autoDetectDeps) return false; const isPackageInstalled = isPackageExists(packageName, { paths: [path.resolve(packageDir)] }); if (isPackageInstalled) detectedPackages.push(packageName); return isPackageInstalled; } //#endregion export { isPackageDetected, logDetectedPackages };