Skip to content

rdlabo-team/eslint-plugin-rules

Repository files navigation

@rdlabo/eslint-plugin-rules

This is a public version of the eslint rules I use in the app I created with Ionic Angular.

Installation

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

If your project does not install @angular-eslint packages, please do so: https://github.com/angular-eslint/angular-eslint

Configuration (legacy: .eslintrc*)

Recommend settings is here:

  {
    ...
+   "plugins": ["@rdlabo/rules"],
    "overrides": [
      {
        "files": [
          "*.ts"
        ],
      ...
        "rules": {
+         "@rdlabo/rules/deny-constructor-di": "error",
+         "@rdlabo/rules/import-inject-object": "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",
        }
      },
      {
        "files": [
          "*.html"
        ],
        "rules": {
+         "@rdlabo/rules/deny-element": [
+           "error",
+           {
+             "elements": [
+               "ion-modal",
+               "ion-popover",
+               "ion-toast",
+               "ion-alert",
+               "ion-loading",
+               "ion-picker",
+               "ion-action-sheet"
+             ]
+           }
+         ]
          ]
        }
      }
    ]
  }

List of supported rules

rule description auto fix
@rdlabo/rules/deny-constructor-di This plugin disallows Dependency Injection within the constructor.
@rdlabo/rules/import-inject-object This plugin automatically imports when inject is used but not imported.
@rdlabo/rules/deny-element This plugin disallows the use of certain HTML tags.
@rdlabo/rules/deny-import-from-ionic-module This plugin disallows import from @ionic/angular
@rdlabo/rules/implements-ionic-lifecycle This plugin checks the implementation of the Ionic lifecycle.
@rdlabo/rules/deny-soft-private-modifier This plugin disallows the use of soft private modifier.
@rdlabo/rules/signal-use-as-signal This plugin check to valid signal use as signal.

Recommend rules with this plugin

@typescript-eslint/explicit-member-accessibility

Control to allow / disallow placing explicit public, protected, and private accessibility modifiers in front of class members.

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