yaml-lint is a straightforward command-line interface (CLI) tool and programmatic API for validating YAML files against a specified schema or for general syntax correctness. It's currently stable at version 1.7.0. The package has seen consistent maintenance releases, with the latest significant update fixing glob pattern issues on Windows and migrating to TypeScript in version 1.3.0. Its key differentiators include the ability to specify different YAML schemas (DEFAULT, FAILSAFE, JSON, CORE), flexible configuration via JSON files, environment variables, or CLI arguments, and support for ignoring files using glob patterns. It processes multi-document YAML sources and provides clear error reporting for invalid files.
npm install yaml-lintVerified import paths — ran on the pinned version, not inferred.
Demonstrates both direct string linting and how to lint the content of a file using the programmatic API.
Upgrade your Node.js runtime to version 8 or higher. The current package targets modern Node.js environments.
Ensure all `ignore` glob patterns consistently use forward slashes. This was specifically fixed in v1.7.0 to enforce forward slashes, but user input still needs to adhere to this.
Adjust glob patterns to be explicit about case if necessary, as automatic case-insensitivity might not be applied as expected across all platforms.
Update to `yaml-lint` version 1.4.0 or newer to ensure all failing files are reported when using the CLI.
Set `YAMLLINT_SCHEMA` to one of the valid schema types: `DEFAULT_SCHEMA`, `FAILSAFE_SCHEMA`, `JSON_SCHEMA`, or `CORE_SCHEMA`.
Run `npm install --save-dev yaml-lint` for local project usage or `npm install -g yaml-lint` for global CLI use.
Ensure your Node.js environment supports ESM (Node.js 12+ with 'type: module' in package.json, or file extension .mjs). Alternatively, use `import yamlLint from 'yaml-lint';` in an ESM context.
No dependency data recorded yet.