Monorepo for all the tooling which enables ESLint to lint Angular projects
This project is made possible thanks to the continued hard work going into https://github.com/typescript-eslint/typescript-eslint, and brilliant work on the original TSLint rule implementations in https://github.com/mgechev/codelyzer.
-
Follow the latest Getting Started guide on https://angular.io/ in order to install the Angular CLI
-
Create a new Angular CLI workspace in the normal way, optionally using any of the supported command line arguments and following the interactive prompts:
ng new # --maybe --some --other --flags --here
- Change directory into your new workspace and then use the Angular CLI to add
@angular-eslint/schematics
.
ng add @angular-eslint/schematics
...and that's it!
As well as installing all relevant dependencies, the ng add
command will automatically detect that you have a workspace with a single project in it, which does not have a linter configured yet. It can therefore go ahead and wire everything up for you!
You will also see that it added the following in your angular.json:
"cli": {
"schematicCollections": ["@angular-eslint/schematics"]
}
Read the section on Using ESLint by default when generating new Projects within your Workspace to understand why this is useful.
As of v12, we aligned the major version of @angular-eslint
with Angular (and Angular CLI).
Therefore, as an example (because these versions may or may not exist yet when you read this):
@angular-eslint
packages at12.x.x
and@angular/cli@12.x.x
are compatible@angular-eslint
packages at13.x.x
and@angular/cli@13.x.x
are compatible@angular-eslint
packages at14.x.x
and@angular/cli@14.x.x
are compatible- ...and so on...
NOTE: the exact minor and patch versions of each library represented here by
x
's do not need to match each other, just the first (major) number
For an understanding of Angular CLI version support prior to v12, please see ./docs/ANGULAR_VERSION_SUPPORT.md
Please do not open issues related to unsupported versions of the Angular CLI.
See the specified peerDependency in any of our packages, such as the eslint-plugin
: https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/package.json
Nx leans on some, but not all of the packages from this project.
Specifically:
- It does not use the builder to execute ESLint
- It does not use the schematics to generate files and config, and is responsible for configuring ESLint via
.eslintrc.json
files in a way that makes sense for Nx workspaces.
We strongly recommend that you do not try and hand-craft setups with angular-eslint and Nx. It is easy to get things wrong.
- If using Angular CLI, use the angular-eslint tooling as instructed below
- If using Nx, defer to the Nx tooling itself to configure things for you, it has been designed and tested specifically for this purpose.
Issues specific to Nx's support of Angular + ESLint should be filed on the Nx repo: https://github.com/nrwl/nx
Please follow the links below for the packages you care about.
-
@angular-eslint/builder
- An Angular CLI Builder which is used to execute ESLint on your Angular projects using standard commands such asng lint
-
@angular-eslint/eslint-plugin
- An ESLint-specific plugin that contains rules which are specific to Angular projects. It can be combined with any other ESLint plugins in the normal way. -
@angular-eslint/eslint-plugin-template
- An ESLint-specific plugin which, when used in conjunction with@angular-eslint/template-parser
, allows for Angular template-specific linting rules to run. -
@angular-eslint/schematics
- Schematics which are used to add and update configuration files which are relevant for running ESLint on an Angular workspace. -
@angular-eslint/template-parser
- An ESLint-specific parser which leverages the@angular/compiler
to allow for custom ESLint rules to be written which assert things about your Angular templates. -
@angular-eslint/utils
- Utilities which are helpful when writing and testing custom ESLint rules for Angular workspaces.
< 8000 div class="markdown-heading" dir="auto">