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

module-getter/module-setter: reversed settings #436

Open
jrencz opened this issue Jan 17, 2017 · 0 comments
Open

module-getter/module-setter: reversed settings #436

jrencz opened this issue Jan 17, 2017 · 0 comments

Comments

@jrencz
Copy link

jrencz commented Jan 17, 2017

My use case:
I'm preparing an ES6+ starter for Angular 1.
I'm using ES modules in it.

I'm assigning Angular module to a variable:

const module = angular.module('myModule', [])

and that's why I don't want angular/module-setter rule on.

I do export default module.name so in another module I can

import MyModule from './my-module'

and that's why I don't need angular/module-getter on.

But keeping those rules off is not best I can get to express my intentions. It came to my mind that I'd like not only not to check if getters are used or module is assigned, but actively disallow that.
IMO ES Modules are a valid use case of why would one want to do it.


I suggest that configuration of both angular/module-setter and angular/module-getter should be extended from no 2nd argument (as it is now) to 'always'and 'never' keywords.

Now:

{
  "rules": {
    "angular/module-getter": "error",
    "angular/module-setter": "error"
  }
}

What I suggest:

To express current configuration (that rules are on):

{
  "rules": {
    "angular/module-getter": ["error", "always"],
    "angular/module-setter": ["error", "never"]
  }
}

The choice of keywords:
If one has angular/module-getter enabled he "wants getter syntax to always be used"
If one has angular/module-setter enabled he "wants angular modules to never be assigned to variables"

(BTW: I think having angular/module-setter rule renamed to angular/no-module-variable-assignment or so will make configuration more straightforward because now name is far from self-explainatory because "angular/no-module-variable-assignment": ["error", "always"] seems to read a bit better than "angular/module-setter": ["error", "never"])

The opposite (outcome I'd like to achieve for my ES Modules NG1 configuration) would be:

{
  "rules": {
    "angular/module-getter": ["error", "never"],
    "angular/module-setter": ["error", "always"]
  }
}

Which states that:
I'd like to enforce NOT using angular module getter syntax and
I'd like to enforce assigning newly created angular module to a variable.

@jrencz jrencz changed the title module-getter/module-setter: extended configuration module-getter/module-setter: reversed settings Jan 17, 2017
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

2 participants