jshint-loader
jshint-loader copied to clipboard
jshint-loader not working with webpack 4
In webpack 4 in the presence of packages jslint and jshint-loader error on the similarity of such:
ERROR in ./src/js/index.js
Module build failed: TypeError: Cannot read property 'jshint' of undefined
at Object.jsHint (D:\Harrix\GitHub\Harrix-HTML-Template\node_modules\jshint-loader\index.js:63:18)
at Object.<anonymous> (D:\Harrix\GitHub\Harrix-HTML-Template\node_modules\jshint-loader\index.js:149:11)
at Object.<anonymous> (D:\Harrix\GitHub\Harrix-HTML-Template\node_modules\jshint-loader\index.js:40:12)
at respond (D:\Harrix\GitHub\Harrix-HTML-Template\node_modules\rcloader\index.js:68:7)
at respond (D:\Harrix\GitHub\Harrix-HTML-Template\node_modules\rcfinder\index.js:140:7)
at next (D:\Harrix\GitHub\Harrix-HTML-Template\node_modules\rcfinder\index.js:164:16)
at process._tickCallback (internal/process/next_tick.js:112:11)
Example of rule:
{ // this is both for prod and dev environments
enforce: 'pre',
test: /\.js$/,
include: path.resolve(__dirname, 'src'),
use: [{ loader: 'jshint-loader' }]
},
Even with a .jshintrc populated and in the root of the project the node_module jshint index,js file has the this.options coming in as undefined. Boom exception. Have tried adding the option to the web.congig.js loader still same issue.
I use the Rules:
I added a console.log to the index.js file in jshint: { console.log("Warning this.options is undefined."); } else{ if(this.options.jshint) { for(var name in this.options.jshint) { options[name] = this.options.jshint[name]; } } }
Hey guys, this link talks about how this.options
was deprecated and what to switch it to: https://medium.com/webpack/webpack-4-migration-guide-for-plugins-loaders-20a79b927202
Ugh, I fucking hate javascript.
I created a PR, #51 which closes this shit.
If any of you guys need the fix for this before they merge the PR, you can use https://github.com/arizvisa/jshint-loader#webpack-4 in your packages for npm.
We're working on getting this repo up to date. Hang tight.
@arizvisa dial back the language please.
did anyone find a solution for this? I am having the exact same issue with "jshint": "^2.9.5", "jshint-loader": "^0.8.4", "webpack": "^4.5.0",
@AtanuMandal #53 and #51 address this. please take a look at Pull Requests next time around before dropping a followup comment
Current fix is risking, it will break old webpack 3 if user choose use options in webpack config. a better fix just simply do this.
if(this.options && this.options.jshint) {
for(var name in this.options.jshint) {
options[name] = this.options.jshint[name];
}
}
@russelyang (or anybody), mind creating a PR? My PR at #51 seems to have gone stale due to issues with the cla signature.
Still not working :/
@ybaruchel, you can use https://github.com/arizvisa/jshint-loader#webpack-4 in your packages for npm to get it working.
actually, once PR #55 is merged, my fix can be re-opened and rebased on top of it. The reason my PR wasn't merged is that despite my PR being a single-line fix, I was "given the honor" (https://github.com/webpack-contrib/jshint-loader/pull/51#issuecomment-387597209) of having to update the versions of the other packages which also included refactoring a bunch of other code that was completely unrelated to my initial fix. this required a lot more more work than i was willing to put in.
so, rather than committing more time to refactor the other unrelated parts in jshint-loader to accommodate the new package versions and pass these tests, I chose to close the PR instead as I can just use my forked repo with the webpack-4 fixes.
but since it looks like the author of PR #55 actually went through the required refactoring that I didn't care to. I should be able to just rebase my fix on top of it and then things should be good to go once it gets merged.