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

Using ng-annotate to detect namespace collisions? #243

Closed
parlarjb opened this issue May 10, 2016 · 2 comments
Closed

Using ng-annotate to detect namespace collisions? #243

parlarjb opened this issue May 10, 2016 · 2 comments

Comments

@parlarjb
Copy link

I'd like to use ng-annotate to detect something like this:

angular.module('foo')
    .factory('XYZ', function () {})
    .service('XYZ', function () {});

i.e. detecting if someone has accidentally assigned the same name to two different factories/controllers/services/directives/etc.

The way I was thinking about doing this is to write a plugin that keeps a list of all names that it sees, and throwing an error whenever it comes across a duplicate.

But I'm not sure of all the properties available on a given node passed to the plugin match, so I'm not sure yet what to look for.

Any pointers would be appreciated!

@olov
Copy link
Owner

olov commented Jun 8, 2016

#245

@schmod
Copy link

schmod commented Aug 1, 2016

This might be a better task for eslint-plugin-angular.

There's also ng-directive-parser, which could be adapted to this purpose, although it's worth noting that it's perfectly legal for multiple directives to have the same name.

Finally, I'd also suggest opening a bug in the Angular bug-tracker if this is a persistent problem for you. There are quite a few aspects of Angular's DI that seem to encourage bugs for no good reason (ie. angular.module('mod',[]) will clobber any existing modules named mod without warning).

@olov olov closed this as completed Oct 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants