20.0.3 • Published 4 months ago

@rdlabo/eslint-plugin-rules v20.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@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

RuleDescriptionAuto-fixable
@rdlabo/rules/deny-constructor-diPrevents Dependency Injection within constructors
@rdlabo/rules/deny-elementRestricts usage of specific HTML elements
@rdlabo/rules/deny-import-from-ionic-modulePrevents direct imports from @ionic/angular
@rdlabo/rules/implements-ionic-lifecycleEnsures proper implementation of Ionic lifecycle hooks
@rdlabo/rules/deny-soft-private-modifierPrevents usage of soft private modifiers
@rdlabo/rules/signal-use-as-signalValidates proper usage of Angular signals
@rdlabo/rules/signal-use-as-signal-templateEnforces correct usage of Angular Signals in templates
@rdlabo/rules/component-property-use-readonlyEnforces 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.

20.0.0-0

5 months ago

20.0.0-2

5 months ago

20.0.0-1

5 months ago

20.0.0-3

5 months ago

0.6.0-2

10 months ago

0.6.0-1

10 months ago

0.6.0-0

10 months ago

0.6.0-5

10 months ago

0.6.0-4

10 months ago

0.6.0-3

10 months ago

1.0.0-1

5 months ago

1.0.0-0

5 months ago

1.0.0-2

5 months ago

20.0.1

5 months ago

20.0.0

5 months ago

20.0.3

4 months ago

20.0.2

4 months ago

0.6.0

10 months ago

0.5.0

1 year ago

0.4.0

2 years ago

0.3.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.3

2 years ago

0.2.3

2 years ago

0.2.4

2 years ago

0.2.1

2 years ago

0.2.2

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago