瀏覽代碼

Updated usage of lint task.

Linting task is taken from `ckeditor5-dev-task-lint` package now.
Maksymilian Barnaś 9 年之前
父節點
當前提交
2f95560ca3
共有 3 個文件被更改,包括 5 次插入96 次删除
  1. 0 95
      dev/tasks/lint/tasks.js
  2. 4 1
      gulpfile.js
  3. 1 0
      package.json

+ 0 - 95
dev/tasks/lint/tasks.js

@@ -1,95 +0,0 @@
-/* jshint node: true, esnext: true */
-
-'use strict';
-
-const gulp = require( 'gulp' );
-const jshint = require( 'gulp-jshint' );
-const jscs = require( 'gulp-jscs' );
-const fs = require( 'fs' );
-const gulpFilter = require( 'gulp-filter' );
-const gutil = require( 'gulp-util' );
-
-module.exports = ( config ) => {
-	const src = [ '**/*.js' ].concat( config.IGNORED_FILES.map( i => '!' + i ), getGitIgnore() );
-
-	const tasks = {
-		/**
-		 * Returns stream containing jshint and jscs reporters.
-		 *
-		 * @returns {Stream}
-		 */
-		lint() {
-			return gulp.src( src )
-				.pipe( lint() );
-		},
-
-		/**
-		 * This method is executed on pre-commit hook, linting only files staged for current commit.
-		 *
-		 * @returns {Stream}
-		 */
-		lintStaged() {
-			const guppy = require( 'git-guppy' )( gulp );
-
-			return guppy.stream( 'pre-commit', { base: './' } )
-				.pipe( gulpFilter( src ) )
-				.pipe( lint() )
-
-				// Error reporting for gulp.
-				.pipe( jscs.reporter( 'fail' ) )
-				.on( 'error', errorHandler )
-				.pipe( jshint.reporter( 'fail' ) )
-				.on( 'error', errorHandler );
-
-			/**
-			 * Handles error from jscs and jshint fail reporters. Stops node process with error code
-			 * and prints error message to the console.
-			 */
-			function errorHandler() {
-				gutil.log( gutil.colors.red( 'Linting failed, commit aborted' ) );
-				process.exit( 1 );
-			}
-		},
-
-		register() {
-			gulp.task( 'lint', tasks.lint );
-			gulp.task( 'lint-staged', tasks.lintStaged );
-		}
-	};
-
-	return tasks;
-
-	/**
-	 * Gets the list of ignores from `.gitignore`.
-	 *
-	 * @returns {String[]} The list of ignores.
-	 */
-	function getGitIgnore( ) {
-		let gitIgnoredFiles = fs.readFileSync( '.gitignore', 'utf8' );
-
-		return gitIgnoredFiles
-			// Remove comment lines.
-			.replace( /^#.*$/gm, '' )
-			// Transform into array.
-			.split( /\n+/ )
-			// Remove empty entries.
-			.filter( ( path ) => !!path )
-			// Add `!` for ignore glob.
-			.map( i => '!' + i );
-	}
-
-	/**
-	 * Returns stream with all linting plugins combined.
-	 *
-	 * @returns {Stream}
-	 */
-	function lint() {
-		const stream = jshint();
-		stream
-			.pipe( jscs() )
-			.pipe( jscs.reporter() )
-			.pipe( jshint.reporter( 'jshint-reporter-jscs' ) );
-
-		return stream;
-	}
-};

+ 4 - 1
gulpfile.js

@@ -16,13 +16,16 @@ const config = {
 	]
 };
 
+const ckeditor5Lint = require( 'ckeditor5-dev-task-lint' )( config );
+
 require( './dev/tasks/build/tasks' )( config ).register();
 require( './dev/tasks/bundle/tasks' )( config ).register();
 require( './dev/tasks/dev/tasks' )( config ).register();
-require( './dev/tasks/lint/tasks' )( config ).register();
 require( './dev/tasks/test/tasks' )( config ).register();
 require( './dev/tasks/docs/tasks' )( config ).register();
 require( './dev/tasks/exec/tasks' )( config ).register();
 
+gulp.task( 'lint', ckeditor5Lint.lint );
+gulp.task( 'lint-staged', ckeditor5Lint.lintStaged );
 gulp.task( 'default', [ 'build' ] );
 gulp.task( 'pre-commit', [ 'lint-staged' ] );

+ 1 - 0
package.json

@@ -35,6 +35,7 @@
     "benderjs-promise": "^0.1.0",
     "benderjs-sinon": "^0.3.0",
     "chai": "^3.4.0",
+    "ckeditor5-dev-task-lint": "ckeditor/ckeditor5-dev-task-lint",
     "concat-stream": "^1.5.1",
     "del": "^2.0.2",
     "fs-extra": "^0.26.4",