Angular CLI Schematics that automate the setup and configuration of ESLint in Angular workspaces
npx @tessl/cli install tessl/npm-angular-eslint--schematics@20.2.0@angular-eslint/schematics is a collection of Angular CLI schematics that automate the setup and configuration of ESLint in Angular workspaces. It provides schematics for adding ESLint to new and existing projects, creating workspace and project-level configurations, and migrating between versions.
ng add angular-eslintFor using utilities in custom schematics:
import {
readJsonInTree,
updateJsonInTree,
createESLintConfigForProject,
addESLintTargetToProject
} from "@angular-eslint/schematics";For using Angular Devkit types:
import { Rule, Tree, SchematicContext } from "@angular-devkit/schematics";The primary way to use this package is through Angular CLI commands:
# Add ESLint to an existing Angular workspace
ng add angular-eslint
# Create a new Angular application with ESLint pre-configured
ng generate @angular-eslint/schematics:application my-app
# Create a new Angular library with ESLint pre-configured
ng generate @angular-eslint/schematics:library my-lib
# Add ESLint to a specific project
ng generate @angular-eslint/schematics:add-eslint-to-project --project=my-projectThe package is built around several key components:
Add ESLint to existing Angular workspaces and configure workspace-level settings.
interface NgAddSchema {
skipInstall?: boolean;
}
export default function (options: NgAddSchema): Rule;Create new Angular applications and libraries with ESLint pre-configured.
interface ApplicationSchema extends AngularApplicationSchema {
setParserOptionsProject?: boolean;
}
interface LibrarySchema extends AngularLibrarySchema {
setParserOptionsProject?: boolean;
}
export default function (options: ApplicationSchema): Rule; // application schematic
export default function (options: LibrarySchema): Rule; // library schematicAdd ESLint configuration to existing Angular projects.
interface AddESLintToProjectSchema {
project?: string;
setParserOptionsProject?: boolean;
}
function addESLintToProject(schema: AddESLintToProjectSchema): Rule;Helper functions for custom schematics and ESLint configuration management.
function readJsonInTree<T>(host: Tree, path: string): T;
function updateJsonInTree<T, O>(path: string, callback: (json: T, context: SchematicContext) => O): Rule;
function createESLintConfigForProject(projectName: string, setParserOptionsProject: boolean): Rule;
function addESLintTargetToProject(projectName: string, targetName: 'eslint' | 'lint'): Rule;Automated migrations for updating @angular-eslint across major versions.
interface MigrationSchema {
version: string;
description: string;
factory: string;
}Legacy schematic for converting TSLint configurations to ESLint (hidden but available).
interface ConvertTSLintToESLintSchema {
project?: string;
ignoreExistingTslintConfig?: boolean;
removeTSLintIfNoMoreTSLintTargets?: boolean;
setParserOptionsProject?: boolean;
}
export default function (options: ConvertTSLintToESLintSchema): Rule;type TargetsConfig = Record<string, { builder: string; options: unknown }>;
type ProjectType = 'application' | 'library';
interface NgAddSchema {
skipInstall?: boolean;
}
interface AddESLintToProjectSchema {
project?: string;
setParserOptionsProject?: boolean;
}
interface ApplicationSchema extends AngularApplicationSchema {
setParserOptionsProject?: boolean;
}
interface LibrarySchema extends AngularLibrarySchema {
setParserOptionsProject?: boolean;
}
interface ConvertTSLintToESLintSchema {
project?: string;
ignoreExistingTslintConfig?: boolean;
removeTSLintIfNoMoreTSLintTargets?: boolean;
setParserOptionsProject?: boolean;
}
interface MigrationSchema {
version: string;
description: string;
factory: string;
}type Rule = import("@angular-devkit/schematics").Rule;
type Tree = import("@angular-devkit/schematics").Tree;
type SchematicContext = import("@angular-devkit/schematics").SchematicContext;
type Path = import("@angular-devkit/core").Path;
type ProjectConfiguration = import("@nx/devkit").ProjectConfiguration;type AngularApplicationSchema = import("@schematics/angular/application/schema").Schema;
type AngularLibrarySchema = import("@schematics/angular/library/schema").Schema;const supportedFlatConfigNames: string[] = [
'eslint.config.js',
'eslint.config.mjs',
'eslint.config.cjs',
'eslint.config.ts',
'eslint.config.mts',
'eslint.config.cts'
];
const DEFAULT_PREFIX = 'app';
const FIXED_ESLINT_V8_VERSION = '8.57.1';
const FIXED_TYPESCRIPT_ESLINT_V7_VERSION = '7.11.0';