What is @angular-eslint/template-parser?
@angular-eslint/template-parser is a parser for Angular templates that integrates with ESLint. It allows developers to lint Angular templates using ESLint rules, ensuring code quality and consistency in Angular projects.
What are @angular-eslint/template-parser's main functionalities?
Parsing Angular Templates
This feature allows you to parse Angular templates into an Abstract Syntax Tree (AST), which can then be analyzed or transformed. The code sample demonstrates how to parse a simple Angular template.
const parser = require('@angular-eslint/template-parser');
const ast = parser.parse('<div>{{ title }}</div>');
console.log(ast);
Integration with ESLint
This feature allows you to integrate the template parser with ESLint, enabling you to apply ESLint rules to Angular templates. The code sample shows a basic ESLint configuration using the @angular-eslint/template-parser.
module.exports = {
parser: '@angular-eslint/template-parser',
plugins: ['@angular-eslint'],
extends: ['plugin:@angular-eslint/recommended'],
rules: {
// custom rules
}
};
Other packages similar to @angular-eslint/template-parser
eslint-plugin-angular
eslint-plugin-angular is a plugin for ESLint that provides linting rules specific to AngularJS (Angular 1.x). While it offers similar functionality in terms of linting Angular code, it is designed for the older version of Angular and does not support Angular templates in the same way as @angular-eslint/template-parser.
codelyzer
Codelyzer is a set of TSLint rules for static code analysis of Angular TypeScript projects. It provides similar functionality in terms of linting Angular code, but it is based on TSLint, which has been deprecated in favor of ESLint. @angular-eslint/template-parser is part of the modern ESLint ecosystem.
@angular-eslint/template-parser
15.2.1 (2023-02-10)
Bug Fixes
- eslint-plugin-template: [i18n] handle ng-template properly (#1257) (7b0877d)
- update dependency @angular/compiler to v15.1.4 (#1282) (d1b3d59)
- update dependency eslint to v8.32.0 (#1276) (15d2e23)
- update dependency eslint to v8.33.0 (#1292) (bd82b42)
- update typescript-eslint packages to v5.48.2 (#1278) (69d56a7)