2016-05-12 157 views
0

如何使用WebPack配置獲取ESLint HTML報告。我目前使用eslint-loader。 ESLint格式化程序中的documentation不清楚。ESLint使用webpack的HTML報告

webpack.config.js中,我添加了以下作爲預加載器。

preLoaders: [{ 
     test: /\.jsx?$/, 
     exclude: /(node_modules|bower_components)/, 
     loaders: ['eslint-loader'], 
    }], 

它完美地完成了這項工作,並在運行WebPack時在控制檯中顯示錯誤。我還在WebPack中添加了

eslint: { 
     formatter: require("eslint/lib/formatters/html"), 
    }, 

它在控制檯本身中引發HTML輸出字符串。我想把它保存爲HTML文件。任何指針都會有幫助。

回答

-1

您可能還需要指定您webpack.config.js輸出文件,如:

... 
module: { 
    loaders: [ 
     { 
     test: /\.jsx?$/, 
     include: path.join(__dirname, 'src'), 
     loader: 'babel', 
     }, 
     { 
      test: /\.js$/, 
      exclude: /node_modules/, 
      loaders: ['babel-loader', 'eslint-loader' ] 
     }, 
     { 
     test: /\.css$/, 
     loader: 'style-loader!css-loader' 
     } 
    ] 
    }, 
    output: { 
    path: path.join(__dirname, "src"), 
    filename: "client.min.js" 
    }, 
    eslint: { 
    configFile: './.eslintrc', 
    outputReport: { 
     filePath: 'eslint_checkstyle_[hash].xml', 
     formatter: require('eslint/lib/formatters/checkstyle'), 
    } 
    }, 
...