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

Wildcards in global list (regex or simple *) #45

Closed
davebalmer opened this issue Feb 21, 2011 · 1 comment
Closed

Wildcards in global list (regex or simple *) #45

davebalmer opened this issue Feb 21, 2011 · 1 comment

Comments

@davebalmer
Copy link

I've been experimenting with C-style "namespacing" in a couple of my frameworks, in particular, Jo. For example: joView, joContainer, joControl are all global widget classes. Since they are global, I do not need to specify var = joView, and so I prefer to save a good chunk of unzipped file size (it's a small framework).

I can solve this with the global flag, and that's cool, but I'd like to be able to specify something like:

/*jshint */
/*global jo*:true */
@Raynos
Copy link
Contributor

Raynos commented Feb 24, 2011

Matching a wildcard * could be implemented by refactoring out checks to predefined[key] === bool to an isPredefined(key) === bool check. Where

function() isPredefined(key) {
     if (typeof predefined[key] === "boolean") {
          return predefined[key];
     } else {
          var bool;
          for (var i = 1;i <= key.length; i++) {
               bool = predefined[key.slice(0,i) + "*"];
               if (typeof  bool === "boolean") {
                    return bool;
               }
          }
     }
     return false;
}

Refactoring isPredefined to implement regex checking is also possible but provides a lot of danger for false positives (This would also require a regex global option)

@valueof valueof closed this as completed Jul 28, 2011
danielctull pushed a commit to danielctull-forks/jshint that referenced this issue Jan 14, 2018
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