Authored by ccbikai(👎🏻🍜)

eslint

@@ -14,9 +14,9 @@ @@ -14,9 +14,9 @@
14 "build": "webpack --config ./public/build/webpack.prod.config.js", 14 "build": "webpack --config ./public/build/webpack.prod.config.js",
15 "debug": "DEBUG=\"express:*\" nodemon -e js,hbs -i public/ app.js", 15 "debug": "DEBUG=\"express:*\" nodemon -e js,hbs -i public/ app.js",
16 "lint-js": "eslint -c .eslintrc --cache .", 16 "lint-js": "eslint -c .eslintrc --cache .",
17 - "lint-css": "stylelint --syntax scss --config .stylelintrc public/scss/*.css public/scss/**/*.css", 17 + "lint-css": "stylelint --syntax scss --config .stylelintrc 'public/scss/**/*.css'",
18 "lint-vue-js": "eslint -c .eslintrc --cache public/vue", 18 "lint-vue-js": "eslint -c .eslintrc --cache public/vue",
19 - "lint-vue-css": "stylelint --syntax scss --extract --config .stylelintrc public/vue/*.vue public/vue/**/*.vue", 19 + "lint-vue-css": "stylelint --syntax scss --extract --config .stylelintrc 'public/scss/**/*.vue'",
20 "precommit": "node lint.js" 20 "precommit": "node lint.js"
21 }, 21 },
22 "license": "MIT", 22 "license": "MIT",
@@ -63,6 +63,7 @@ @@ -63,6 +63,7 @@
63 "cssnano": "^3.10.0", 63 "cssnano": "^3.10.0",
64 "eslint": "^3.16.0", 64 "eslint": "^3.16.0",
65 "eslint-config-yoho": "^1.0.1", 65 "eslint-config-yoho": "^1.0.1",
  66 + "eslint-loader": "^1.6.3",
66 "eslint-plugin-html": "^2.0.1", 67 "eslint-plugin-html": "^2.0.1",
67 "extract-text-webpack-plugin": "^2.1.0", 68 "extract-text-webpack-plugin": "^2.1.0",
68 "handlebars-loader": "^1.4.0", 69 "handlebars-loader": "^1.4.0",
@@ -13,7 +13,6 @@ const shelljs = require('shelljs'); @@ -13,7 +13,6 @@ const shelljs = require('shelljs');
13 const webpack = require('webpack'); 13 const webpack = require('webpack');
14 const HappyPack = require('happypack'); 14 const HappyPack = require('happypack');
15 const ExtractTextPlugin = require('extract-text-webpack-plugin'); 15 const ExtractTextPlugin = require('extract-text-webpack-plugin');
16 -const StyleLintPlugin = require('stylelint-webpack-plugin');  
17 const postcssConfig = require('./postcss.config.js'); 16 const postcssConfig = require('./postcss.config.js');
18 const entries = { 17 const entries = {
19 index: path.join(__dirname, '../scss/index.css'), 18 index: path.join(__dirname, '../scss/index.css'),
@@ -98,7 +97,8 @@ module.exports = (env) => { @@ -98,7 +97,8 @@ module.exports = (env) => {
98 }] 97 }]
99 }, 98 },
100 resolve: { 99 resolve: {
101 - modules: [path.join(__dirname, '../../node_modules'), 100 + modules: [
  101 + path.join(__dirname, '../../node_modules'),
102 path.join(__dirname, '../vue'), 102 path.join(__dirname, '../vue'),
103 path.join(__dirname, '../hbs'), 103 path.join(__dirname, '../hbs'),
104 path.join(__dirname, '../scss'), 104 path.join(__dirname, '../scss'),
@@ -112,9 +112,6 @@ module.exports = (env) => { @@ -112,9 +112,6 @@ module.exports = (env) => {
112 children: false 112 children: false
113 }, 113 },
114 plugins: [ 114 plugins: [
115 - new StyleLintPlugin({  
116 - files: ['public/scss/*.css', 'public/scss/**/*.css', 'public/vue/*.vue', 'public/vue/**/*.vue']  
117 - }),  
118 new HappyPack({ 115 new HappyPack({
119 id: 'js', 116 id: 'js',
120 threadPool: happyThreadPool, 117 threadPool: happyThreadPool,
1 const path = require('path'); 1 const path = require('path');
2 const webpack = require('webpack'); 2 const webpack = require('webpack');
  3 +const StyleLintPlugin = require('stylelint-webpack-plugin');
3 let baseConfig = require('./webpack.base.config.js'); 4 let baseConfig = require('./webpack.base.config.js');
4 5
5 baseConfig = baseConfig('dev'); 6 baseConfig = baseConfig('dev');
6 baseConfig.devtool = '#eval'; 7 baseConfig.devtool = '#eval';
7 baseConfig.output.publicPath = 'http://localhost:5001/'; 8 baseConfig.output.publicPath = 'http://localhost:5001/';
  9 +baseConfig.module.rules.push({
  10 + enforce: 'pre',
  11 + test: /\.js$/,
  12 + exclude: /node_modules/,
  13 + loader: 'eslint-loader',
  14 + options: {
  15 + cache: true,
  16 + failOnError: true,
  17 + formatter: require('eslint/lib/formatters/table')
  18 + }
  19 +});
8 baseConfig.devServer = { 20 baseConfig.devServer = {
9 host: '0.0.0.0', 21 host: '0.0.0.0',
10 port: 5001, 22 port: 5001,
@@ -12,8 +24,6 @@ baseConfig.devServer = { @@ -12,8 +24,6 @@ baseConfig.devServer = {
12 publicPath: baseConfig.output.publicPath, 24 publicPath: baseConfig.output.publicPath,
13 hot: true, 25 hot: true,
14 inline: true, 26 inline: true,
15 - // quiet: true,  
16 - // clientLogLevel: 'error',  
17 compress: true, 27 compress: true,
18 stats: { 28 stats: {
19 colors: true, 29 colors: true,
@@ -25,6 +35,10 @@ baseConfig.devServer = { @@ -25,6 +35,10 @@ baseConfig.devServer = {
25 } 35 }
26 36
27 baseConfig.plugins.push( 37 baseConfig.plugins.push(
  38 + new StyleLintPlugin({
  39 + files: ['public/scss/**/*.css'],
  40 + failOnError: true
  41 + }),
28 new webpack.HotModuleReplacementPlugin() 42 new webpack.HotModuleReplacementPlugin()
29 ); 43 );
30 44