EmmanuelDemey / eslint-plugin-angular

ESLint plugin for AngularJS applications
https://www.npmjs.com/package/eslint-plugin-angular
618 stars 131 forks source link

angular/file-name rule: there is a way to ignore all prefixes except the last one on module filename? #534

Closed wdarking closed 6 years ago

wdarking commented 6 years ago

I have modules with submodules, so the linter tells me to use a very long module file name, even with the ignorePrefix option.

my config:

"angular/file-name": [2,
      {
        "typeSeparator": "dot",
        "nameStyle": "dash",
        "ignoreTypeSuffix": true,
        "ignorePrefix": "users.",
        "componentTypeMappings": {
          "factory": "factory",
          "provider": "provider"
        }
      }
    ]

example:

module named users submodule named users.admin submodule named users.admin.create submodule named users.admin.create.info

with the linter rules, i should name the modules like this: users.module.js, admin.module.js, admin.create.module.js, admin.create.info.module.js

so, there is a way to ignore all prefixes except the last one ? i've tried to use a match all regex on the ignorePrefix option but almost all returned some kind of error and couldn't run the linter https://stackoverflow.com/questions/6711971/regular-expressions-match-anything

expected valid module filenames:

users.module.js, -> users.module.js admin.module.js, -> admin.module.js admin.create.module.js, -> create.module.js admin.create.info.module.js, -> info.module.js

xdjinnx commented 6 years ago

I also have this problem.

Maybe we should be looking into adding an additional setting for the file-name rule which makes the rule ignore the module name prefix completely (As you want it). Or maybe make it possible to actually use regexp in the ignorePrefix.

What would you prefer?

wdarking commented 6 years ago

I prefer the additional setting idea, sounds simpler. But if there are good reasons to use regex, i think it wouldn't be a problem.