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

Allow linting of inline module scripts in html file #3489

Open
rbruckheimer opened this issue Jun 30, 2020 · 5 comments
Open

Allow linting of inline module scripts in html file #3489

rbruckheimer opened this issue Jun 30, 2020 · 5 comments

Comments

@rbruckheimer
Copy link

Forgive me if this is duplicate, but I could not find this issue anywhere.

JSHint 2.11.0
Using jshint --extract-always *.html to scan and lint inline scripts in my html files works for plain old script tags, but if type="module" it will not lint what's inside.

Is there a switch for this?

@jugglinmike
Copy link
Member

Thanks for reporting! This ticket is not a duplicate, and the behavior is certainly something we need to fix.

Notes for any potential contributors:

  • it should be safe to do this without an switch or any other opt-in
  • when linting code in this context, JSHint should automatically enable the module option. It may make sense to also set esversion to 6, but only if the user hasn't set it to some other value

@rbruckheimer if you'd like to take a shot at implementing this, I'd be happy to guide you.

@rbruckheimer
Copy link
Author

rbruckheimer commented Jul 2, 2020

I was thinking the logic ought to be as follows:

If found a script tag {
  If type missing or type==text/javascript or (type==module && esversion>=6) {
     parse the inner code
  }else if type not missing {
     print an error "detected script tag with invalid type "{type}" (new error code?)
  }
}

Do you think there should be a way to ignore such an error?

@jugglinmike
Copy link
Member

Other values for the "type" attribute are valid, so we should not emit an error or warning if we encounter them. If you remove the "else if" clause from your proposal, I think that should be good.

@rbruckheimer
Copy link
Author

I have this all set to go but was wondering why you suggested defaulting esversion to 6 if the user hasn't set it to some other value. Did you mean 5?

@rbruckheimer
Copy link
Author

PR #3492 has been opened.

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