Registry / testing / ejs-lint

ejs-lint

JSON →
library2.0.1jsnpmunverified

Linter and syntax checker for EJS templates. Version 2.0.1 released September 2022. ESM-only since v2, requires Node 14+. Parses scriptlet and expression tags, replacing template output with whitespace to retain line/column numbers, then validates resulting JavaScript with acorn via node-syntax-error. Distinguishes itself from EJS core by providing meaningful syntax error messages with line context, supporting custom delimiters, CLI and API usage. Does not check for unclosed EJS tags but helps detect malformed scriptlets. Alternatives exist (e.g., eslint-plugin-ejs) but ejs-lint is the standalone, lightweight option.

testing
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.

ESM-only since v2; use dynamic import or upgrade to Node 14+.

import ejsLint from 'ejs-lint'

CLI is invoked via the 'ejslint' command, not as a programmatic export.

import { execSync } from 'child_process'; execSync('npx ejslint file.ejs', {stdio: 'inherit'})

ejs-lint does not export its own error type; returns node-syntax-error objects.

import type { SyntaxError } from 'node-syntax-error'

Shows how to use the ejsLint API to check an EJS template for syntax errors.

import ejsLint from 'ejs-lint'; const template = `<% if (user) { %> <h1><%= user.name %></h1> <% } else { %> <h1>No user</h1> <% } %>`; const err = ejsLint(template, { delimiter: '%' }); if (err) { console.error(`Syntax error at line ${err.line}, column ${err.column}: ${err.message}`); } else { console.log('Template is valid'); }
ejslint --version
Debug
Known footguns
breakingv2.0.0 switched to ESM-only; CommonJS require() will fail
breakingv2.0.0 dropped Node 12 support; requires Node 14+
breakingv1.0.0 removed deprecated .lint() alias; use ejsLint() instead
breakingv0.3.0 removed parse() method and --parse CLI option
gotchaDoes not detect unclosed EJS tags; will show confusing errors on lines without scriptlets
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
15 hits · last 30 days
ahrefsbot
4
claudebot
4
gptbot
3
amazonbot
3
bingbot
1
Resources