Registry / testing / markuplint-angular-parser

markuplint-angular-parser

JSON →
library3.0.2jsnpmunverified

markuplint-angular-parser is an official parser plugin for the `markuplint` HTML linter, specifically designed to understand Angular template syntax. It enables `markuplint` to accurately parse and lint `.html` files containing Angular-specific constructs such as interpolations (`{{...}}`), property bindings (`[...]`), event bindings (`(...)`), and structural directives (`*ngIf`, `*ngFor`). The current stable version is `3.0.2`, and its release cycle is closely tied to the major versions of `markuplint`, with patch releases addressing bug fixes. A key differentiator is its deep integration with `markuplint`'s architecture, providing robust linting capabilities for Angular projects by correctly interpreting template expressions and preventing false positives or missed errors that generic HTML parsers might encounter. It primarily serves as a configuration entry for `markuplint`, rather than a library for direct programmatic use.

npm install markuplint-angular-parser
INSTALL
IMPORT
SIG · MARKUPLINT-ANGULAR
M
markuplint-angular-parser
testingjavascriptv3.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

AngularParser
import AngularParser from 'markuplint-angular-parser';
const AngularParser = require('markuplint-angular-parser');
This is the default export for the parser object, primarily consumed internally by Markuplint or for advanced programmatic setups. The package is ESM-only since v3.
AngularParserOptions
import type { AngularParserOptions } from 'markuplint-angular-parser';
Hypothetical type definition for configuring the parser programmatically, if exposed. Use `import type` for type-only imports to avoid bundling issues.
version
import { version } from 'markuplint-angular-parser';
const { version } = require('markuplint-angular-parser');
The package version string, potentially exposed as a named export for programmatic checks. ESM-only since v3.

Demonstrates programmatic linting of an Angular HTML template using markuplint-angular-parser and common rules.

import { readFileSync, writeFileSync } from 'node:fs'; import { resolve } from 'node:path'; import { lint } from 'markuplint'; const angularTemplatePath = resolve(__dirname, 'src/app/my-component/my-component.component.html'); const angularTemplateContent = readFileSync(angularTemplatePath, 'utf8'); // Minimal .markuplintrc.json equivalent for programmatic use const config = { parser: { '.html$': 'markuplint-angular-parser' }, rules: { 'attr-validate': true, 'require-accessible-name': true } }; async function runLint() { console.log(`Linting file: ${angularTemplatePath}`); try { const results = await lint({ sourceCodes: [ { url: angularTemplatePath, extension: 'html', source: angularTemplateContent } ], config: config }); if (results[0] && results[0].violations.length > 0) { console.error('Linting violations found:'); results[0].violations.forEach(violation => { console.error(` - [${violation.severity}] ${violation.message} (line: ${violation.line}, col: ${violation.col})`); }); process.exit(1); } else { console.log('No linting violations found.'); } } catch (error) { console.error('An error occurred during linting:', error); process.exit(1); } } // Example Angular HTML file (src/app/my-component/my-component.component.html) // <div *ngIf="showContent"> // <span [attr.data-id]="itemId" (click)="doSomething()">{{ title | uppercase }}</span> // <img src="" alt="Missing alt text"> // </div> runLint();
markuplint --version
Debug
Known issues
breakingVersion 3.0.0 of `markuplint-angular-parser` (and v2.0.0 of `markuplint-angular-rules`) transitioned to being ESM-only. CommonJS `require()` statements will no longer work and will throw `ERR_REQUIRE_ESM`.
fix
Migrate your project to use ECMAScript Modules (ESM) syntax (`import/export`) or configure your environment to load ESM. Ensure your `package.json` specifies `"type": "module"` or use `.mjs` file extensions for ESM files.
affects: >=3.0.0
breakingVersion 3.0.0 introduced a breaking change by bumping its core dependency to `markuplint` v4. This may involve API changes within `markuplint` itself, which could affect advanced configurations or custom rules interacting with the parser.
fix
Review the `markuplint` v4 changelog and migration guide. Update `markuplint` and any related plugins or configurations to ensure compatibility with the new major version.
affects: >=3.0.0
breakingVersion 2.0.0 migrated to `markuplint` v3. This was a significant update that likely involved API changes for how parsers and rules interact with the core linter.
fix
If upgrading from `markuplint-angular-parser` v1.x, consult the `markuplint` v3 migration guide and update your configurations accordingly.
affects: >=2.0.0 <3.0.0
gotchaThis package is a parser plugin for `markuplint`. It does not provide linting functionality on its own and requires `markuplint` to be installed and configured correctly.
fix
Ensure `markuplint` is installed (`npm i -D markuplint`) and configured in your project's `.markuplintrc.*` file to use this parser for Angular HTML files.
affects: >=1.0.0
gotchaIncorrect configuration in `.markuplintrc` can lead to `markuplint` not applying the Angular parser, resulting in incorrect linting results (e.g., treating Angular syntax as plain HTML errors).
fix
Verify that your `.markuplintrc` file correctly maps your Angular template file extensions (e.g., `.html$`) to `"markuplint-angular-parser"` in the `parser` option.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'markuplint-angular-parser'
The package `markuplint-angular-parser` is not installed or not resolvable by Node.js.
fix
Run `npm install markuplint-angular-parser` or `yarn add markuplint-angular-parser` in your project.
ReferenceError: require is not defined in ES module scope
Attempting to use CommonJS `require()` to import `markuplint-angular-parser` in an environment configured for ESM, or directly in an ESM module.
fix
Use `import AngularParser from 'markuplint-angular-parser';` instead. Ensure your project's `package.json` has `"type": "module"` or your file uses the `.mjs` extension for ESM.
Linting errors like 'Parsing error: Unexpected token', 'Invalid attribute name' for valid Angular syntax.
Markuplint is not using the `markuplint-angular-parser` for your Angular template files, defaulting to a generic HTML parser.
fix
Check your `.markuplintrc.*` file. Ensure the `parser` option has an entry like `".html$": "markuplint-angular-parser"` to correctly associate HTML files with the Angular parser.
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies
markuplintrequiredThis package is a parser plugin for Markuplint and requires it as a peer dependency for core functionality.
Agent activity
2 hits · last 30 days
node
2
Resources
markuplint-angular-parser — npm install markuplint-angular-parser · libregistry