eslint-plugin-angular

raw JSON →
5.0.0 verified Sat Apr 25 auth: no javascript

ESLint plugin providing AngularJS (Angular 1.x) specific linting rules, covering best practices, conventions, and potential errors. Current stable version is 5.0.0, which requires ESLint ^9.32.0 and drops support for earlier versions. The plugin includes a shareable config based on John Papa's AngularJS style guide. It is the most established ESLint plugin for AngularJS, with over 150 rules organized into categories like possible errors, conventions, and style. Release cadence is low; updates are prompted by major ESLint changes. Key differentiator: specifically for AngularJS (not Angular 2+), with many rules directly mapping to the John Papa style guide.

error Error: Failed to load plugin 'angular' declared in '.eslintrc': Cannot find module 'eslint-plugin-angular'
cause The plugin is not installed in the project's node_modules.
fix
Run 'npm install --save-dev eslint-plugin-angular'.
error ESLint couldn't find the config 'angular' after extending from the plugin.
cause In flat config, 'extends' is not used; you must use the plugins object and spread the config.
fix
Replace 'extends: ['angular']' with 'plugins: { angular }, rules: { ...angular.configs.johnpapa.rules }'.
error Definition for rule 'angular/controller-name' was not found.
cause The plugin is not registered in the ESLint config, or the rule prefix is wrong.
fix
Ensure 'plugins: { angular }' is set in flat config, or 'plugins: ['angular']' in legacy config. Use 'angular/' prefix.
breaking Version 5.0.0 drops support for ESLint versions < 9.32.0
fix Upgrade ESLint to ^9.32.0 or pin eslint-plugin-angular to ^4.1.0 if you cannot upgrade.
breaking Version 4.0.0 removed the eslintrc-style config (extends) support; only flat config is supported.
fix Migrate from .eslintrc to eslint.config.js/.mjs using the flat config format shown in the quickstart.
gotcha The plugin's shareable config must be explicitly spread in the rules object, unlike ESLint's built-in 'extends'.
fix Use: rules: { ...angular.configs.johnpapa.rules } or specify individual rules.
gotcha Rules are prefixed with 'angular/', not 'angularjs/' or 'ng/'.
fix Use 'angular/controller-name', etc. in your rules configuration.
deprecated Some older rules (e.g., 'angular/definedundefined') are deprecated but may still be available for backward compatibility.
fix Check documentation and migrate to recommended replacements if available.
npm install eslint-plugin-angular
yarn add eslint-plugin-angular
pnpm add eslint-plugin-angular

Shows how to install and configure eslint-plugin-angular with ESLint v9 flat config, enabling three common rules.

npm init @eslint/config
npm install --save-dev eslint eslint-plugin-angular
# Create eslint.config.mjs:
import angular from 'eslint-plugin-angular';
export default defineConfig([{
  plugins: { angular },
  rules: {
    'angular/controller-name': ['error', { nameStyle: 'camelCase' }],
    'angular/module-getter': 'error',
    'angular/module-setter': 'error'
  }
}]);