Authored by ccbikai

增加代码检查

  1 +{
  2 + "extends": "yoho"
  3 +}
  1 +{
  2 + "extends": "stylelint-config-yoho"
  3 +}
@@ -5,8 +5,8 @@ @@ -5,8 +5,8 @@
5 */ 5 */
6 6
7 module.exports = app => { 7 module.exports = app => {
8 - //公共服务 8 + // 公共服务
9 9
10 - //业务模块 10 + // 业务模块
11 app.use('/guang', require('./apps/guang')); 11 app.use('/guang', require('./apps/guang'));
12 }; 12 };
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 "version": "0.0.1", 3 "version": "0.0.1",
  4 + "private": true,
4 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
5 "repository": { 6 "repository": {
6 "type": "git", 7 "type": "git",
7 "url": "http://git.dev.yoho.cn/web/yohobuy-node.git" 8 "url": "http://git.dev.yoho.cn/web/yohobuy-node.git"
8 }, 9 },
  10 + "scripts": {
  11 + "start": "node app.js",
  12 + "dev": "node_modules/.bin/nodemon -e js,hbs -i public/ app.js",
  13 + "online": "NODE_ENV=\"production\" node app.js",
  14 + "debug": "DEBUG=\"express:*\" node app.js",
  15 + "lint-js": "node_modules/.bin/eslint -c .eslintrc --cache --fix `git diff --cached --name-only --diff-filter=ACM | grep .js$` app.js",
  16 + "lint-css": "node_modules/.bin/stylelint --config .stylelintrc `git diff --cached --name-only --diff-filter=ACM | grep .css$`",
  17 + "precommit": "npm run lint-js && npm run lint-css"
  18 + },
9 "license": "MIT", 19 "license": "MIT",
10 "dependencies": { 20 "dependencies": {
11 "body-parser": "^1.15.0", 21 "body-parser": "^1.15.0",
@@ -15,17 +25,19 @@ @@ -15,17 +25,19 @@
15 "lodash": "^4.8.2", 25 "lodash": "^4.8.2",
16 "morgan": "^1.7.0", 26 "morgan": "^1.7.0",
17 "request-promise": "^2.0.1", 27 "request-promise": "^2.0.1",
18 - "serve-favicon": "^2.3.0",  
19 - "shelljs": "^0.7.0" 28 + "serve-favicon": "^2.3.0"
20 }, 29 },
21 "devDependencies": { 30 "devDependencies": {
22 "autoprefixer": "^6.3.6", 31 "autoprefixer": "^6.3.6",
  32 + "eslint": "^2.9.0",
  33 + "eslint-config-yoho": "^1.0.1",
23 "gulp": "^3.9.1", 34 "gulp": "^3.9.1",
24 "gulp-cssnano": "^2.1.2", 35 "gulp-cssnano": "^2.1.2",
25 "gulp-ftp": "^1.1.0", 36 "gulp-ftp": "^1.1.0",
26 "gulp-postcss": "^6.1.0", 37 "gulp-postcss": "^6.1.0",
27 "gulp-sourcemaps": "^2.0.0-alpha", 38 "gulp-sourcemaps": "^2.0.0-alpha",
28 "gulp-util": "^3.0.7", 39 "gulp-util": "^3.0.7",
  40 + "husky": "^0.11.4",
29 "postcss-assets": "^4.0.1", 41 "postcss-assets": "^4.0.1",
30 "postcss-cachebuster": "^0.1.2", 42 "postcss-cachebuster": "^0.1.2",
31 "postcss-calc": "^5.2.1", 43 "postcss-calc": "^5.2.1",
@@ -38,8 +50,11 @@ @@ -38,8 +50,11 @@
38 "postcss-sprites": "^3.1.2", 50 "postcss-sprites": "^3.1.2",
39 "postcss-use": "^2.0.2", 51 "postcss-use": "^2.0.2",
40 "precss": "^1.4.0", 52 "precss": "^1.4.0",
  53 + "stylelint": "^6.2.2",
  54 + "stylelint-config-yoho": "^1.2.0",
41 "webpack": "^1.13.0", 55 "webpack": "^1.13.0",
42 "webpack-dev-server": "^1.14.1", 56 "webpack-dev-server": "^1.14.1",
43 - "webpack-stream": "^3.1.0" 57 + "webpack-stream": "^3.1.0",
  58 + "shelljs": "^0.7.0"
44 } 59 }
45 } 60 }
@@ -61,7 +61,7 @@ const postcssPlugin = (et) => { @@ -61,7 +61,7 @@ const postcssPlugin = (et) => {
61 // assets & sprites config in both dev and pro 61 // assets & sprites config in both dev and pro
62 if (et === env.pro) { 62 if (et === env.pro) {
63 assets = { 63 assets = {
64 - loadPaths: [dist.img, dist.font], 64 + loadPaths: [dist.img, dist.font]
65 }; 65 };
66 66
67 Object.assign(sprites, { 67 Object.assign(sprites, {
@@ -80,7 +80,7 @@ const postcssPlugin = (et) => { @@ -80,7 +80,7 @@ const postcssPlugin = (et) => {
80 stylesheetPath: 'css/', 80 stylesheetPath: 'css/',
81 spritePath: 'img/' 81 spritePath: 'img/'
82 }); 82 });
83 - }; 83 + }
84 84
85 plugins = [ 85 plugins = [
86 require('autoprefixer')({ 86 require('autoprefixer')({
@@ -92,7 +92,7 @@ const postcssPlugin = (et) => { @@ -92,7 +92,7 @@ const postcssPlugin = (et) => {
92 require('postcss-calc'), 92 require('postcss-calc'),
93 require('postcss-opacity'), 93 require('postcss-opacity'),
94 94
95 - //可选 95 + // 可选
96 require('postcss-use')({ 96 require('postcss-use')({
97 modules: ['postcss-clearfix', 'postcss-crip', 'postcss-short', 'postcss-center', 'postcss-position'] 97 modules: ['postcss-clearfix', 'postcss-crip', 'postcss-short', 'postcss-center', 'postcss-position']
98 }) 98 })
@@ -145,7 +145,7 @@ gulp.task('img', () => { @@ -145,7 +145,7 @@ gulp.task('img', () => {
145 .pipe(gulp.dest(dist.img)); 145 .pipe(gulp.dest(dist.img));
146 }); 146 });
147 147
148 -//copy font 148 +// copy font
149 gulp.task('font', () => { 149 gulp.task('font', () => {
150 return gulp.src('font/*') 150 return gulp.src('font/*')
151 .pipe(gulp.dest(dist.font)); 151 .pipe(gulp.dest(dist.font));
@@ -15,9 +15,9 @@ require('shelljs/global'); @@ -15,9 +15,9 @@ require('shelljs/global');
15 15
16 var entries = {}; 16 var entries = {};
17 17
18 -//构建各模块子页面JS。生成规则module.page.js 18 +// 构建各模块子页面JS。生成规则module.page.js
19 ls(__dirname + '/js/**/*.page.js').forEach((f) => { 19 ls(__dirname + '/js/**/*.page.js').forEach((f) => {
20 - var dir = _.slice(f.split('/'), -2); //[modulename, xx.page.js] 20 + var dir = _.slice(f.split('/'), -2); // [modulename, xx.page.js]
21 21
22 // Important 22 // Important
23 // 生成规则:module.page: './js/module/xx.page.js' 23 // 生成规则:module.page: './js/module/xx.page.js'
@@ -27,7 +27,7 @@ ls(__dirname + '/js/**/*.page.js').forEach((f) => { @@ -27,7 +27,7 @@ ls(__dirname + '/js/**/*.page.js').forEach((f) => {
27 module.exports = { 27 module.exports = {
28 entry: entries, 28 entry: entries,
29 output: { 29 output: {
30 - path: path.join(__dirname, 'bundle'), //absolute path 30 + path: path.join(__dirname, 'bundle'), // absolute path
31 filename: '[name].js' 31 filename: '[name].js'
32 } 32 }
33 }; 33 };