mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-06 13:34:50 +08:00
Add ESLint to Gulp workflow
This commit is contained in:
parent
ddb0e0bff8
commit
fe04c49f7e
33
.eslintrc.js
Normal file
33
.eslintrc.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
module.exports = {
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"rules": {
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
"quotes": ["warn", "single"],
|
||||||
|
"semi": ["error", "always"],
|
||||||
|
"object-curly-spacing": ["error", "always"],
|
||||||
|
"no-unused-vars": "warn",
|
||||||
|
"no-console": "off",
|
||||||
|
"comma-style": ["warn", "last"]
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"url": false,
|
||||||
|
"swal": false,
|
||||||
|
"fetch": false,
|
||||||
|
"trans": false,
|
||||||
|
"logout": false,
|
||||||
|
"toastr": false,
|
||||||
|
"isEmpty": false,
|
||||||
|
"showMsg": false,
|
||||||
|
"blessing": true,
|
||||||
|
"debounce": false,
|
||||||
|
"showModal": false,
|
||||||
|
"showAjaxError": false,
|
||||||
|
"getQueryString": false,
|
||||||
|
"TexturePreview": false
|
||||||
|
},
|
||||||
|
"env":{
|
||||||
|
"es6": true,
|
||||||
|
"browser": true,
|
||||||
|
"jquery": true
|
||||||
|
}
|
||||||
|
};
|
41
gulpfile.js
41
gulpfile.js
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
var gulp = require('gulp'),
|
var gulp = require('gulp'),
|
||||||
babel = require('gulp-babel'),
|
babel = require('gulp-babel'),
|
||||||
|
eslint = require('gulp-eslint'),
|
||||||
uglify = require('gulp-uglify'),
|
uglify = require('gulp-uglify'),
|
||||||
sass = require('gulp-sass'),
|
sass = require('gulp-sass'),
|
||||||
cleanCss = require('gulp-clean-css'),
|
cleanCss = require('gulp-clean-css'),
|
||||||
@ -29,7 +30,7 @@ var vendorScripts = [
|
|||||||
'es6-promise/dist/es6-promise.auto.min.js',
|
'es6-promise/dist/es6-promise.auto.min.js',
|
||||||
'sweetalert2/dist/sweetalert2.min.js',
|
'sweetalert2/dist/sweetalert2.min.js',
|
||||||
'jqPaginator/dist/1.2.0/jqPaginator.min.js',
|
'jqPaginator/dist/1.2.0/jqPaginator.min.js',
|
||||||
'resources/assets/dist/js/general.js',
|
'resources/assets/dist/js/common.js',
|
||||||
];
|
];
|
||||||
|
|
||||||
var vendorStyles = [
|
var vendorStyles = [
|
||||||
@ -73,8 +74,21 @@ var images = [
|
|||||||
gulp.task('default', ['build']);
|
gulp.task('default', ['build']);
|
||||||
|
|
||||||
// Build the things!
|
// Build the things!
|
||||||
gulp.task('build', function (callback) {
|
gulp.task('build', callback => {
|
||||||
runSequence('clean', ['compile-es6', 'compile-sass'], 'publish-vendor', callback);
|
runSequence('clean', 'lint', ['compile-es6', 'compile-sass'], 'publish-vendor', 'notify', callback);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Send a notification
|
||||||
|
gulp.task('notify', () => {
|
||||||
|
return gulp.src('').pipe(notify('Assets compiled!'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check JavaScript files with ESLint
|
||||||
|
gulp.task('lint', () => {
|
||||||
|
return gulp.src(`${srcPath}/js/**/*.js`)
|
||||||
|
.pipe(eslint())
|
||||||
|
.pipe(eslint.format())
|
||||||
|
.pipe(eslint.failAfterError());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Concentrate all vendor scripts & styles to one dist file
|
// Concentrate all vendor scripts & styles to one dist file
|
||||||
@ -114,11 +128,16 @@ gulp.task('compile-sass', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Compile ES6 scripts to ES5
|
// Compile ES6 scripts to ES5
|
||||||
gulp.task('compile-es6', () => {
|
gulp.task('compile-es6', callback => {
|
||||||
return gulp.src(`${srcPath}/js/*.js`)
|
['common', 'admin', 'auth', 'skinlib', 'user'].forEach(moduleName => {
|
||||||
.pipe(babel({ presets: ['es2015'] }))
|
return gulp.src(`${srcPath}/js/${moduleName}/*.js`)
|
||||||
.pipe(uglify())
|
.pipe(babel({ presets: ['es2015'] }))
|
||||||
.pipe(gulp.dest(`${distPath}/js`));
|
.pipe(concat(`${moduleName}.js`))
|
||||||
|
.pipe(uglify())
|
||||||
|
.pipe(gulp.dest(`${distPath}/js`));
|
||||||
|
});
|
||||||
|
|
||||||
|
callback();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete cache files
|
// Delete cache files
|
||||||
@ -176,10 +195,10 @@ gulp.task('zip', () => {
|
|||||||
|
|
||||||
gulp.task('watch', () => {
|
gulp.task('watch', () => {
|
||||||
// watch .scss files
|
// watch .scss files
|
||||||
gulp.watch(`${srcPath}/sass/*.scss`, ['compile-sass'], () => notify({ message: 'Sass files compiled!' }));
|
gulp.watch(`${srcPath}/sass/*.scss`, ['compile-sass'], () => notify('Sass files compiled!'));
|
||||||
// watch .js files
|
// watch .js files
|
||||||
gulp.watch(`${srcPath}/js/*.js`, ['compile-es6'], () => notify({ message: 'ES6 scripts compiled!' }));
|
gulp.watch(`${srcPath}/js/*.js`, ['compile-es6'], () => notify('ES6 scripts compiled!'));
|
||||||
gulp.watch(`${srcPath}/js/general.js`, ['build']);
|
gulp.watch(`${srcPath}/js/general.js`, ['publish-vendor']);
|
||||||
});
|
});
|
||||||
|
|
||||||
function convertNpmRelativePath(paths) {
|
function convertNpmRelativePath(paths) {
|
||||||
|
Loading…
Reference in New Issue
Block a user