victorporof / Sublime-JSHint

JSHint Gutter for Sublime Text 2 and 3 via node.js
https://github.com/victorporof/Sublime-JSHint
682 stars 71 forks source link

Use JsHint's `extract` method to lint inline JavaScript, instead of our home-backed regexes #84

Open MaKleSoft opened 10 years ago

MaKleSoft commented 10 years ago

Linting inline JavaScript in HTML files does not seem to work for me in SublimeText 2. I noticed that you are extracting the JavaScript 'manually'. Why not use the functionality provided by jshint itself?

var extract = require('jshint/src/cli').extract;
var js = extract(html, 'auto');

See http://www.jshint.com/docs/cli/

victorporof commented 10 years ago

When I initially wrote this plugin, jshint didn't have that functionality IIRC. I'd be more than happy if we switched over to the new implementation.

victorporof commented 10 years ago

Linting JS inside HTML should work properly now. It'd still be nice to switch to jshint's extract method. At the moment, js is regexed out of the markup.

Fixed by https://github.com/victorporof/Sublime-JSHint/commit/5a24960ae9323fcd726c0da5d7ea09b59760a93a

Relevant code that wasn't used anymore: https://github.com/victorporof/Sublime-JSHint/blob/master/scripts/run.js#L67