A tool to lint HTML files for potential Content Security Policy (CSP) violations, targeting inline styles, inline JavaScript, style tags without nonce, and script tags without nonce. Current stable version is 1.0.13. It is designed to be used as a build step to catch violations early. Differentiators: simple CLI and programmatic API, zero dependencies, returns violations as array or detailed objects with location info. Offers a narrow but focused set of checks, suitable for integration into CI pipelines.
npm install csp-html-linterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows programmatic usage with parse() and options, including location info.
Use const cspHtmlLinter = require('csp-html-linter'); or use dynamic import() if your environment supports it.Always use --include with a glob, e.g., --include "src/**/*.html".
Check the options.includeLocationInfo value or use a type guard to handle both cases.
Always explicitly set all options you care about to avoid false positives.
Change import to require: const cspHtmlLinter = require('csp-html-linter');Use --include with double quotes around the glob, e.g., --include "src/**/*.html"
When includeLocationInfo is false, each violation is a string, not an object. Check your options or handle both types.
No dependency data recorded yet.