css-handbook icon indicating copy to clipboard operation
css-handbook copied to clipboard

[构建] Add more linters

Open gucong3000 opened this issue 8 years ago • 1 comments

很高兴见到ghooks被加入到项目中来,我想为本项目安装更多的linter,@doyoe ,请确认一下哪些是你愿意接受的。

  • [ ] eslint js代码静态错误分析与风格检查 http://cn.eslint.org/
  • [ ] stylelint css代码错误分析与风格检查 https://stylelint.io/
  • [ ] eclint 文件代码风格检查(换行,缩进,文件字符编码等) http://editorconfig.org/
  • [ ] gulp-reporter 针对以上工具的错误报告
    • [ ] 只汇报新增错误的功能,老错误不阻止git提交
    • [ ] 错误归咎功能,错误的作者非当前用户时,不阻止git提交

gucong3000 avatar Aug 10 '17 03:08 gucong3000

关键的代码时这样的:


	return gulp.src(globs, {
		stripBOM: false,
		base: process.cwd()
	})

		// 排除二进制文件
		.pipe(filter(file => !(file && file.isBuffer() && fileType(file.contents))))

		// 排除`.gitignore`中定义的文件
		.pipe(gitignore())

		// htmlhint
		.pipe(gulpif(file => /\.html?$/i.test(file.path), htmlhint(config)))

		// eslint
		.pipe(gulpif(file => /\.jsx?$/i.test(file.path), eslint(config)))

		// stylelint
		.pipe(gulpif(file => /\.s?css$/i.test(file.path), postcss([stylelint(config)])))

		// editorconfig
		.pipe(fix ? eclint.fix() : eclint.check())

		// 错误汇报
		.pipe(fix ? gulp.dest(".") : reporter());

gucong3000 avatar Aug 10 '17 11:08 gucong3000