Registry / devops / directory-lint

directory-lint

JSON →
library2.0.3jsnpmunverified

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.

npm install directory-lint
INSTALL
IMPORT
SIG · DIRECTORY-LINT
D
directory-lint
devopsjavascriptv2.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DirectoryLint
import { DirectoryLint } from 'directory-lint'
const DirectoryLint = require('directory-lint')
ESM-only; CommonJS require will fail. Use TypeScript or ES modules.
ValidateSchema
import type { ValidateSchema } from 'directory-lint'
import { ValidateSchema } from 'directory-lint'
ValidateSchema is a type, not a runtime value. Use 'import type' for TypeScript.
GenerateSchema
import type { GenerateSchema } from 'directory-lint'
import { GenerateSchema } from 'directory-lint'
GenerateSchema is a type, not a runtime value. Use 'import type' for TypeScript.

Shows how to validate a directory structure against a schema using DirectoryLint.validate() with ignore patterns.

import { DirectoryLint } from 'directory-lint'; import type { ValidateSchema } from 'directory-lint'; const schema: ValidateSchema = { 'src': { type: 'directory', required: true, children: { 'index.ts': { type: 'file', required: true }, 'components': { type: 'directory', required: false } } }, 'package.json': { type: 'file', required: true } }; const linter = new DirectoryLint(); const result = await linter.validate('./my-project', schema, { ignore: ['node_modules', '.git'] }); console.log('Valid:', result.valid, 'Errors:', result.errors);
Debug
Known issues
breakingConstructor now requires no arguments; instantiate with 'new DirectoryLint()'
fix
Remove any previously passed options; use validate/generate options instead.
affects: >=2.0.0
breakingDropped CommonJS support — package is ESM-only
fix
Switch to ES modules or use dynamic import() if you must use CommonJS.
affects: >=2.0.0
breakingRenamed 'lint' method to 'validate'; 'generate' method added
fix
Replace all calls to .lint() with .validate().
affects: >=2.0.0
deprecatedBackend option 'fs' is no longer needed; use default file system backend
fix
Remove custom backend option; the library now includes a built-in filesystem backend.
affects: >=2.0.0
gotchaSchema keys are case-sensitive; file names must match exactly unless using patterns
fix
Ensure case matches filesystem. For case-insensitive matching, use regex patterns.
affects: *
gotchaThe 'validate' function expects an absolute or relative path with proper basePath
fix
Provide correct base path; the library does not resolve relative to cwd automatically.
affects: *
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module not supported
Package is ESM-only; using require() in CommonJS context.
fix
Use import statement or dynamic import('directory-lint') instead of require().
TypeError: (0 , directory_lint.DirectoryLint) is not a constructor
Default export incorrectly imported; must import named export.
fix
Use 'import { DirectoryLint } from "directory-lint"' instead of default import.
TS2305: Module '"directory-lint"' has no exported member 'ValidateSchema'
Using import instead of import type for a type-only export.
fix
Use 'import type { ValidateSchema } from "directory-lint"'.
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
6
Resources
directory-lint — npm install directory-lint · libregistry