admin管理员组文章数量:1426236
I have a webpack project wired with the jshint-loader which is defined like so:
postLoaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'jshint-loader'
}
],
and when I run webpack-dev-server I get the following warning in all of my files:
WARNING in ./js/main.js jshint results in errors Use the function form of "use strict". @ line 1 char 1 "use strict";
I tried using the "strict": false
option in my config file under jshint but it did not help.
Adding 'use strict'
in the files also did not help.
The only solution that I found was adding /*jshint globalstrict: true*/
in each js file in my project...
Does someone have a solution for it in the global scope?
Thanks.
I have a webpack project wired with the jshint-loader which is defined like so:
postLoaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'jshint-loader'
}
],
and when I run webpack-dev-server I get the following warning in all of my files:
WARNING in ./js/main.js jshint results in errors Use the function form of "use strict". @ line 1 char 1 "use strict";
I tried using the "strict": false
option in my config file under jshint but it did not help.
Adding 'use strict'
in the files also did not help.
The only solution that I found was adding /*jshint globalstrict: true*/
in each js file in my project...
Does someone have a solution for it in the global scope?
Thanks.
Share Improve this question asked Mar 11, 2015 at 14:25 Yoni DabushYoni Dabush 2204 silver badges13 bronze badges 04 Answers
Reset to default 2You can create a file called .jshintrc that defines the global settings that you want jshint to use.
This shows all the possible settings for a file https://github./jshint/jshint/blob/master/examples/.jshintrc
You would simply create a .jshintrc and set globalstrict: true
in that instead of in every js file.
The config section of jshint here: http://jshint./docs/ has more info if you need it.
turns out it is not that simple.
I found a great solution using eslint instead. Here is the example project: https://github./kriasoft/react-starter-kit/
I resolve this problem just adding the globalstrict: true
like @AR7.
the next problem was fixed: https://github./webpack/jshint-loader/issues/13
About your problem in the ment you can do something like this:
I decided to put the jshint config in the package.json
, another way to setup JSHint, so that way it's easier to read the config but if you want just create a new configuration there like jshint: { ... }
or read from the .jshint file and convert it to json.
The problem is Webpack need to knows the JSHint configuration check here how they setup the jshint-loader
var path = require('path');
var pkg = require(path.resolve(__dirname, './package.json'));
....
module: {
preLoaders: [{
test: /\.js$/,
loaders: [
'jshint'
],
include: [
path.resolve(__dirname, 'src')
]
}]
},
jshint: pkg['jshintConfig'] // This is the actually fix
you must setting hint to jshint
that you use "use strict";
global into your files, you can use jshint
options into webpack
configuration file.
webpack.config.js
file will be:
module.exports = {
//...
module: {
//...
postLoaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'jshint-loader'
}
]
},
jshint: {
strict: "global" // <-- adding strict mode option as global
}
};
本文标签: javascriptHow to get rid of usestrict warning when using webpack and jshintloaderStack Overflow
版权声明:本文标题:javascript - How to get rid of use-strict warning when using webpack and jshint-loader? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745471243a2659759.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论