{"id":25171,"library":"directory-lint","title":"directory-lint","description":"A TypeScript-first library for validating and generating directory structures based on schema definitions. Current stable version is 2.0.3, with a regular release cadence. Key differentiators include zero dependencies, full TypeScript support, pattern matching with wildcards and regex, and a pluggable backend system. It supports two schema types: ValidateSchema for checking existing structures and GenerateSchema for creating them. Unlike similar tools, it focuses on schema-driven, programmatic validation rather than config-file-based linting, making it suitable for integration into build pipelines or scaffolding tools.","status":"active","version":"2.0.3","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","linter","validation","filesystem","directory-structure","architecture","lint","typescript"],"install":[{"cmd":"npm install directory-lint","lang":"bash","label":"npm"},{"cmd":"yarn add directory-lint","lang":"bash","label":"yarn"},{"cmd":"pnpm add directory-lint","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; CommonJS require will fail. Use TypeScript or ES modules.","wrong":"const DirectoryLint = require('directory-lint')","symbol":"DirectoryLint","correct":"import { DirectoryLint } from 'directory-lint'"},{"note":"ValidateSchema is a type, not a runtime value. Use 'import type' for TypeScript.","wrong":"import { ValidateSchema } from 'directory-lint'","symbol":"ValidateSchema","correct":"import type { ValidateSchema } from 'directory-lint'"},{"note":"GenerateSchema is a type, not a runtime value. Use 'import type' for TypeScript.","wrong":"import { GenerateSchema } from 'directory-lint'","symbol":"GenerateSchema","correct":"import type { GenerateSchema } from 'directory-lint'"}],"quickstart":{"code":"import { DirectoryLint } from 'directory-lint';\nimport type { ValidateSchema } from 'directory-lint';\n\nconst schema: ValidateSchema = {\n  'src': {\n    type: 'directory',\n    required: true,\n    children: {\n      'index.ts': { type: 'file', required: true },\n      'components': { type: 'directory', required: false }\n    }\n  },\n  'package.json': { type: 'file', required: true }\n};\n\nconst linter = new DirectoryLint();\nconst result = await linter.validate('./my-project', schema, { ignore: ['node_modules', '.git'] });\nconsole.log('Valid:', result.valid, 'Errors:', result.errors);","lang":"typescript","description":"Shows how to validate a directory structure against a schema using DirectoryLint.validate() with ignore patterns."},"warnings":[{"fix":"Remove any previously passed options; use validate/generate options instead.","message":"Constructor now requires no arguments; instantiate with 'new DirectoryLint()'","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Switch to ES modules or use dynamic import() if you must use CommonJS.","message":"Dropped CommonJS support — package is ESM-only","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Replace all calls to .lint() with .validate().","message":"Renamed 'lint' method to 'validate'; 'generate' method added","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Remove custom backend option; the library now includes a built-in filesystem backend.","message":"Backend option 'fs' is no longer needed; use default file system backend","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Ensure case matches filesystem. For case-insensitive matching, use regex patterns.","message":"Schema keys are case-sensitive; file names must match exactly unless using patterns","severity":"gotcha","affected_versions":"*"},{"fix":"Provide correct base path; the library does not resolve relative to cwd automatically.","message":"The 'validate' function expects an absolute or relative path with proper basePath","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use import statement or dynamic import('directory-lint') instead of require().","cause":"Package is ESM-only; using require() in CommonJS context.","error":"ERR_REQUIRE_ESM: require() of ES Module not supported"},{"fix":"Use 'import { DirectoryLint } from \"directory-lint\"' instead of default import.","cause":"Default export incorrectly imported; must import named export.","error":"TypeError: (0 , directory_lint.DirectoryLint) is not a constructor"},{"fix":"Use 'import type { ValidateSchema } from \"directory-lint\"'.","cause":"Using import instead of import type for a type-only export.","error":"TS2305: Module '\"directory-lint\"' has no exported member 'ValidateSchema'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}