2017-01-04 5 views
1

Webpack 1からWebpack 2にプロジェクトを移行しています。私はeslintの統合に問題があります。私のWebPACK 1設定では、私はこのように構成されているeslint:webpack 1.xからwebpack 2.xに移行する際の問題。 ESLint設定が見つかりません

eslint: { configFile: path.join(__dirname, "eslint.core.js"), useEslintrc: false }

上記の設定が正常に動作します。 WebPACKの2では、私はターミナルで財産

plugins: [
 new LoaderOptionsPlugin({
 options: {
 eslint: {
 configFile: path.join(__dirname, "eslint.core.js"),
 useEslintrc: false
 }
 }
 } )
]

プラグインの下にそれを持って、私はエラーModule build failed: Error: No ESLint configuration foundを受け付けております。私は間違って何をしていますか?どんな助けもありがとうございます。

私が使用しています: "webpack": "2.2.0-rc.3" "eslint": "3.5.0" "eslint-loader": "1.5.0" "eslint-plugin-mocha": "4.5.1" "eslint-plugin-react": "6.2.2"

答えて

1

を、私はあまりにもModule build failed: Error: No ESLint configuration foundを持っていました。 私にとって解決策は、すべてのeslint-loaderオプションをLoaderOptionsPlugin権限からルールに移動することでした。以下の私のwebpack.config.jsを見てください。 私のeslint構成ファイルeslint_conf.jsは、プロジェクトのルートカタログに置かれた通常の.eslintrc.jsの完全なコピーです。

// webpack.config.js 
 
var webpack = require('webpack'); 
 
var path = require('path'); 
 
var HtmlWebpackPlugin = require('html-webpack-plugin'); 
 
var ExtractTextPlugin = require('extract-text-webpack-plugin'); 
 
module.exports = { 
 
    context: __dirname + "/src", 
 
    entry: './app.js', 
 
    output: { 
 
     path: path.join(__dirname, 'dist'), 
 
     publicPath: '', 
 
     filename: 'bundle.js' 
 
    }, 
 
    module: { 
 
     rules: [ 
 
      { 
 
       test: /\.js$/, 
 
       enforce: 'pre', 
 
       loader: 'eslint-loader', 
 
       exclude: /node_modules/, 
 
       options: { 
 
        emitWarning: true, 
 
        emitError: true, 
 
        //failOnWarning: false, 
 
        //failOnError: true, 
 
        useEslintrc: false, 
 
        // configFile: path.join(__dirname, "eslint_conf.js") 
 
        configFile: "eslint_conf.js" 
 
       } 
 
      }, 
 
      { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }, 
 
      { test: /\.(png|jpg)$/, loader: 'file-loader?name=[path][name].[ext]&outputPath=../dist/' }, 
 
      { 
 
       test: /\.(scss|sass|css)$/, 
 
       loader: ExtractTextPlugin.extract({ 
 
        fallback: 'style-loader', 
 
        use: [{ 
 
          loader: "css-loader", 
 
          options: { 
 
           autoprefixer: true, 
 
           sourceMap: true, 
 
           importLoaders: true 
 
          } 
 
         }, 
 
         { 
 
          loader: "fast-sass-loader", 
 
          options: { 
 
           // sourceMap: true 
 
          } 
 
         } 
 
        ] 
 
       }) 
 
      } 
 
     ] 
 
    }, 
 

 
    plugins: [ 
 
     new HtmlWebpackPlugin({ 
 
      template: './index.html' 
 
     }), 
 
     new ExtractTextPlugin('style.css'), 
 
     new webpack.ProvidePlugin({ 
 
      $: "jquery", 
 
      jQuery: "jquery", 
 
      'window.jQuery': 'jquery', 
 
      'window.$': 'jquery' 
 
     }) 
 

 
    ] 
 
};

私はこのようなpackage.jsonでスクリプト持っnpm run lintjsによってeslint実行するには:私が使用

"scripts": { 
    "dev": "nodemon --watch webpack.config.js --exec \"webpack-dev-server --env development\"", 
    "lintjs": "eslint src --cache --no-eslintrc -c eslint_conf.js", 
    "build": "webpack --env production" 
    } 

"devDependencies": { 
    "autoprefixer": "^6.7.6", 
    "babel-core": "^6.23.1", 
    "babel-eslint": "^7.1.1", 
    "babel-loader": "^6.3.2", 
    "babel-preset-es2015": "^6.22.0", 
    "css-loader": "^0.26.2", 
    "eslint": "^3.17.1", 
    "eslint-loader": "^1.6.3", 
    "extract-text-webpack-plugin": "^2.1.0", 
    "fast-sass-loader": "^1.0.7", 
    "file-loader": "^0.10.1", 
    "html-loader": "^0.4.5", 
    "html-webpack-plugin": "^2.28.0", 
    "inuitcss": "^6.0.0-beta.4", 
    "node-sass": "^4.5.0", 
    "postcss-cssnext": "^2.9.0", 
    "postcss-import": "^9.1.0", 
    "postcss-loader": "^1.3.3", 
    "style-loader": "^0.13.2", 
    "webpack": "^2.2.1" 
    } 
0

実行eslint --initルートでの
これは設定ファイルを生成します
webpack conf内で次のものを使用します

{ 
    loaders: [ 
     { 
     test: /\.js$/, 
     loaders: eslint-loader 
     } 
    ] 
} 
関連する問題