Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new rule to enforce the use of providedIn flag #558

Closed
wKoza opened this issue Apr 9, 2018 · 7 comments
Closed

add new rule to enforce the use of providedIn flag #558

wKoza opened this issue Apr 9, 2018 · 7 comments

Comments

@wKoza
Copy link
Collaborator

wKoza commented Apr 9, 2018

This is recognized as best practice for providers with Angular 6 (we can now perform tree shaking and remove services that aren't used by your app

@wKoza wKoza changed the title add new rule for enforce the use of providedIn flag add new rule to enforce the use of providedIn flag Apr 13, 2018
@rafaelss95
Copy link
Collaborator

Related to #135. Btw, any news on integrate material2#validateDecoratorsRule here?

@mgechev
Copy link
Owner

mgechev commented May 2, 2018

Following the feature request process that lodash has, I'm closing the issue and adding votes needed label.

Later we can prioritize the feature requests by popularity and include them in a future release.

@mohammedzamakhan
Copy link
Contributor

You can assign it to me

@mgechev
Copy link
Owner

mgechev commented Mar 13, 2019

GitHub does not allow this but since you're taking it I'll drop votes needed.

@rafaelss95
Copy link
Collaborator

@mgechev @wKoza
Currently we have the following rules to (dis)allow decorator properties values:

List of rules
no-host-metadata-property
no-inputs-metadata-property
no-outputs-metadata-property
no-queries-metadata-property
no-pipe-impure
prefer-on-push-component-change-detection
use-component-selector
use-component-view-encapsulation

... and this list is growing...

What's your opinion about implement something like material2#validateDecoratorsRule (it was already mentioned in this and other issues like #135)?

A default config would be:

{
  "rules": {
    "validate-decorators": [
      true, {
        "Component": {
          "changeDetection": "\\.OnPush$",
          "!encapsulation": "\\.None$",
          "!host": ".*",
          "!inputs": ".*",
          "!outputs": ".*",
          "!queries": ".*",
          "selector": ".*"
        },
        "Directive": {
          "selector": ".*"
        },
        "Pipe": {
          "!pure": ".*"
        }
      }
    ]
  }
}

... and of course we could allow users to customize it according to their project standards, and why not also their decorators.

@mgechev
Copy link
Owner

mgechev commented Mar 14, 2019

Sounds good. I can talk to @jelbourn to converge both rules.

@jscharett
Copy link

Does this rule allow for a non-singleton services? I haven't seen an example where provideIn is used for a component, only root/Modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants