Authored by 沈志敏

代码检查

  1 +const shelljs = require('shelljs');
  2 +const path = require('path');
  3 +
  4 +const ext = process.platform === 'win32' ? '.cmd' : ''; // Windows 平台需要加后缀
  5 +const lintPath = {
  6 + js: path.resolve('./node_modules/.bin/eslint'),
  7 + css: path.resolve('./node_modules/.bin/stylelint')
  8 +};
  9 +
  10 +const jsfiles = ['.', 'public/vue/**/*.vue'];
  11 +const cssfiles = ['public/scss/**/*.css', 'public/vue/**/*.vue'];
  12 +
  13 +jsfiles.forEach(function(filepath){
  14 + shelljs.exec(`${lintPath.js}${ext} -f table -c .eslintrc --cache ${filepath}`);
  15 +});
  16 +
  17 +cssfiles.forEach(function(filepath){
  18 + shelljs.exec(`${lintPath.css}${ext} --syntax scss --config .stylelintrc --custom-formatter ./node_modules/stylelint-formatter-table/index.js '${filepath}'`);
  19 +})
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 "lint-css": "stylelint --syntax scss --config .stylelintrc public/scss/**/*.css", 17 "lint-css": "stylelint --syntax scss --config .stylelintrc public/scss/**/*.css",
18 "lint-vue-js": "eslint -c .eslintrc --cache public/vue/**/*.vue", 18 "lint-vue-js": "eslint -c .eslintrc --cache public/vue/**/*.vue",
19 "lint-vue-css": "stylelint --syntax scss --extract --config .stylelintrc public/vue/**/*.vue", 19 "lint-vue-css": "stylelint --syntax scss --extract --config .stylelintrc public/vue/**/*.vue",
  20 + "lint-all": "node check.js",
20 "precommit": "node lint.js" 21 "precommit": "node lint.js"
21 }, 22 },
22 "license": "MIT", 23 "license": "MIT",
@@ -92,6 +93,7 @@ @@ -92,6 +93,7 @@
92 "shelljs": "^0.7.6", 93 "shelljs": "^0.7.6",
93 "stylelint": "^7.9.0", 94 "stylelint": "^7.9.0",
94 "stylelint-config-yoho": "^1.2.8", 95 "stylelint-config-yoho": "^1.2.8",
  96 + "stylelint-formatter-table": "^1.0.2",
95 "stylelint-processor-html": "^1.0.0", 97 "stylelint-processor-html": "^1.0.0",
96 "vue": "^2.1.10", 98 "vue": "^2.1.10",
97 "vue-loader": "^11.1.0", 99 "vue-loader": "^11.1.0",