我正在推出一个反应应用程序,这是我的Webpack配置:
'use strict'
const ExtractPlugin = require('extract-text-webpack-plugin')
const HTMLPlugin = require('html-webpack-plugin')
module.exports = {
devtool: 'eval',
entry: `${__dirname}/src/main.js`,
output: {
filename: 'bundle-[hash].js',
path: `${__dirname}/build`,
publicPath: '/',
},
mode: 'development',
performance: {
hints: false
},
plugins: [
new HTMLPlugin(),
new ExtractPlugin('bundle-[hash].css'),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_module/,
loader: 'babel-loader',
},
{
test: /\.scss$/,
loader: ExtractPlugin.extract(['css-loader', 'sass-loader']),
},
],
},
}
Run Code Online (Sandbox Code Playgroud)
然后,我有一个package.json文件,这里是依赖项:
"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.1.6",
"@babel/preset-react": "^7.0.0",
"and": "0.0.3",
"babel-cli": "^6.26.0",
"babel-core": "^7.0.0-bridge.0", …Run Code Online (Sandbox Code Playgroud) 我已经将eslint airbnb标准应用于我的代码,所以现在这段代码:
handleSubmit = (event) => {
event.preventDefault();
this.props.onSearch(this.query.value);
event.target.blur();
}
Run Code Online (Sandbox Code Playgroud)
导致错误
[eslint]必须使用解构道具赋值(反应/解构 - 赋值)
onSearch基本上是一个将值传递给父组件的触发器.
如何重构此代码以满足eslint要求?
谢谢.