@rdlabo/eslint-plugin-rules

20.1.0 • Public • Published

@rdlabo/eslint-plugin-rules

A collection of ESLint rules specifically designed for Angular applications. These rules help maintain code quality and enforce best practices in your Angular projects.

npm version License: MIT

✨ Features

  • 🛡️ Enforces best practices for Angular development
  • 🔍 Prevents common anti-patterns
  • 🎯 Improves code quality and maintainability
  • ⚡ Supports both modern and legacy ESLint configurations

📦 Installation

npm install @rdlabo/eslint-plugin-rules --save-dev

Note: If your project doesn't have angular-eslint packages installed, please install them first: angular-eslint

⚙️ Configuration

Configuration (eslint.config.js)

const rdlabo = require('@rdlabo/eslint-plugin-rules');

module.exports = tseslint.config(
  {
    files: ['*.ts'],
    plugins: {
      '@rdlabo/rules': rdlabo,
    },
    rules: {
      '@rdlabo/rules/deny-constructor-di': 'error',
      '@rdlabo/rules/deny-import-from-ionic-module': 'error',
      '@rdlabo/rules/implements-ionic-lifecycle': 'error',
      '@rdlabo/rules/deny-soft-private-modifier': 'error',
      '@rdlabo/rules/signal-use-as-signal': 'error',
      '@rdlabo/rules/signal-use-as-signal-template': 'error',
      '@rdlabo/rules/component-property-use-readonly': 'error',
    },
  },
  {
    files: ['*.html'],
    plugins: {
      '@rdlabo/rules': rdlabo,
    },
    rules: {
      '@rdlabo/rules/deny-element': [
        'error',
        {
          elements: [
            'ion-modal',
            'ion-popover',
            'ion-toast',
            'ion-alert',
            'ion-loading',
            'ion-picker',
            'ion-action-sheet',
          ],
        },
      ],
    },
  }
);

📋 Available Rules

Rule Description Auto-fixable
@rdlabo/rules/deny-constructor-di Prevents Dependency Injection within constructors
@rdlabo/rules/deny-element Restricts usage of specific HTML elements
@rdlabo/rules/deny-import-from-ionic-module Prevents direct imports from @ionic/angular
@rdlabo/rules/implements-ionic-lifecycle Ensures proper implementation of Ionic lifecycle hooks
@rdlabo/rules/deny-soft-private-modifier Prevents usage of soft private modifiers
@rdlabo/rules/signal-use-as-signal Validates proper usage of Angular signals
@rdlabo/rules/signal-use-as-signal-template Enforces correct usage of Angular Signals in templates
@rdlabo/rules/component-property-use-readonly Enforces readonly modifier for class properties

@rdlabo/rules/import-inject-object is removed. This is because we removed the auto-fixable feature from @rdlabo/rules/deny-constructor-di due to concerns about its compatibility with the new ng generate @angular/core:inject command.

🔧 Recommended Additional Rules

TypeScript Member Accessibility

Control the usage of explicit accessibility modifiers in class members:

"rules": {
  "@typescript-eslint/explicit-member-accessibility": ["error", { "accessibility": "no-public" }],
}

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📝 License

This project is licensed under the MIT License. See the LICENSE file for details.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
20.0.0-30next
20.1.029latest

Version History

VersionDownloads (Last 7 Days)Published
20.1.029
20.0.31
20.0.22
20.0.12
20.0.01
20.0.0-30
20.0.0-21
20.0.0-11
20.0.0-01
1.0.0-20
1.0.0-11
1.0.0-01
0.6.020
0.6.0-50
0.6.0-40
0.6.0-30
0.6.0-20
0.6.0-10
0.6.0-00
0.5.0307
0.4.0202
0.3.30
0.3.20
0.3.10
0.3.00
0.2.473
0.2.30
0.2.20
0.2.10
0.2.00
0.1.10
0.1.00

Package Sidebar

Install

npm i @rdlabo/eslint-plugin-rules

Weekly Downloads

464

Version

20.1.0

License

MIT

Unpacked Size

91.3 kB

Total Files

17

Last publish

Collaborators

  • rdlabo