Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[构建] Add more linters #137

Open
6 tasks
gucong3000 opened this issue Aug 10, 2017 · 1 comment
Open
6 tasks

[构建] Add more linters #137

gucong3000 opened this issue Aug 10, 2017 · 1 comment

Comments

@gucong3000
Copy link

gucong3000 commented Aug 10, 2017

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

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

关键的代码时这样的:

	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());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant