added gulp-eslint7

pull/3729/head
Daniel 4 years ago
parent e8a7fbf782
commit c7eaefcd26

@ -4,11 +4,11 @@
/* eslint-disable unicorn/prefer-module */ /* eslint-disable unicorn/prefer-module */
const browserSync = require('browser-sync').create() const browserSync = require('browser-sync').create()
const cleanCss = require('gulp-clean-css')
const del = require('del') const del = require('del')
const esbuild = require('esbuild') const esbuild = require('esbuild')
const { ESLint } = require('eslint')
const { src, dest, lastRun, watch, series } = require('gulp') const { src, dest, lastRun, watch, series } = require('gulp')
const cleanCss = require('gulp-clean-css')
const eslint = require('gulp-eslint7')
const fileinclude = require('gulp-file-include') const fileinclude = require('gulp-file-include')
const npmDist = require('gulp-npm-dist') const npmDist = require('gulp-npm-dist')
const postcss = require('gulp-postcss') const postcss = require('gulp-postcss')
@ -140,12 +140,10 @@ const ts = () => {
} }
// Lint TS // Lint TS
async function lintTs() { const lintTs = () => {
const eslint = new ESLint() return src([paths.src.ts + '/**/*.ts'], { since: lastRun(lintTs) })
const results = await eslint.lintFiles([paths.src.ts + '/**/*.ts']) .pipe(eslint())
const formatter = await eslint.loadFormatter('stylish') .pipe(eslint.format())
const resultText = formatter.format(results)
console.log(resultText)
} }
const index = () => { const index = () => {
@ -190,9 +188,8 @@ const serve = () => {
server: paths.temp.base server: paths.temp.base
}) })
watch([paths.src.scss], series(scss)) watch([paths.src.scss], series(lintScss, scss))
watch([paths.src.scss], series(lintScss)) watch([paths.src.ts], series(lintTs, ts))
watch([paths.src.ts], series(ts))
watch([paths.src.html, paths.src.base + '*.html', paths.src.partials], series(html, index)) watch([paths.src.html, paths.src.base + '*.html', paths.src.partials], series(html, index))
watch([paths.src.assets], series(assets)) watch([paths.src.assets], series(assets))
watch([paths.src.vendor], series(vendor)) watch([paths.src.vendor], series(vendor))
@ -204,7 +201,7 @@ const minifyDistCss = () => {
paths.dist.css + '/**/*.css' paths.dist.css + '/**/*.css'
], { base: paths.dist.css }) ], { base: paths.dist.css })
.pipe(sourcemaps.init({ loadMaps: true })) .pipe(sourcemaps.init({ loadMaps: true }))
.pipe(cleanCss()) .pipe(cleanCss({ format: { breakWith: 'lf' } }))
.pipe(rename({ suffix: '.min' })) .pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.write('.')) .pipe(sourcemaps.write('.'))
.pipe(dest(paths.dist.css)) .pipe(dest(paths.dist.css))
@ -235,9 +232,12 @@ const cleanDist = () => {
return del([paths.dist.base]) return del([paths.dist.base])
} }
// Compile and copy scss/css // Compile and copy all scss/css
const copyDistCss = () => { const copyDistCssAll = () => {
return src([paths.src.scss + '/adminlte.scss']) return src([
paths.src.scss + '/adminlte.scss',
paths.src.scss + '/dark/*.scss'
], { base: paths.src.scss })
.pipe(wait(500)) .pipe(wait(500))
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError)) .pipe(sass(sassOptions).on('error', sass.logError))
@ -246,21 +246,8 @@ const copyDistCss = () => {
.pipe(dest(paths.dist.css)) .pipe(dest(paths.dist.css))
} }
const copyDistCssDark = () => {
return src([paths.src.scss + '/dark/*.scss'])
.pipe(wait(500))
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(postcss(postcssOptions))
.pipe(sourcemaps.write('.'))
.pipe(dest(paths.dist.css + '/dark'))
}
const copyDistCssRtl = () => { const copyDistCssRtl = () => {
return src([ return src(paths.dist.css + '/**/*.css')
paths.dist.css + '/*.css',
paths.dist.css + '/dark/*.css'
])
.pipe(wait(500)) .pipe(wait(500))
.pipe(sourcemaps.init({ loadMaps: true })) .pipe(sourcemaps.init({ loadMaps: true }))
.pipe(postcss(postcssRtlOptions)) .pipe(postcss(postcssRtlOptions))
@ -318,7 +305,7 @@ const copyDistVendor = () => {
.pipe(dest(paths.dist.vendor)) .pipe(dest(paths.dist.vendor))
} }
exports.build = series(lintScss, lintTs, cleanDist, copyDistCss, copyDistCssDark, copyDistCssRtl, minifyDistCss, copyDistJs, minifyDistJs, copyDistHtml, copyDistHtmlIndex, copyDistAssets, copyDistVendor) exports.build = series(lintScss, lintTs, cleanDist, copyDistCssAll, copyDistCssRtl, minifyDistCss, copyDistJs, minifyDistJs, copyDistHtml, copyDistHtmlIndex, copyDistAssets, copyDistVendor)
// Default // Default
exports.default = series(lintScss, scss, lintTs, ts, html, index, assets, vendor, serve) exports.default = series(lintScss, scss, lintTs, ts, html, index, assets, vendor, serve)

11
package-lock.json generated

@ -4622,6 +4622,17 @@
} }
} }
}, },
"gulp-eslint7": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/gulp-eslint7/-/gulp-eslint7-0.3.1.tgz",
"integrity": "sha512-4p6Ul5OGs/bR18C3bs2bK3ylbTI6rkDQXPwg2bq2at6L5Ffd6j4+6pjJ3YpDIlVsUq2UsGm3vlbdXY3T0sldrg==",
"dev": true,
"requires": {
"eslint": "^7.25.0",
"fancy-log": "^1.3.3",
"plugin-error": "^1.0.1"
}
},
"gulp-file-include": { "gulp-file-include": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/gulp-file-include/-/gulp-file-include-2.3.0.tgz", "resolved": "https://registry.npmjs.org/gulp-file-include/-/gulp-file-include-2.3.0.tgz",

@ -54,6 +54,7 @@
"eslint-plugin-unicorn": "^32.0.1", "eslint-plugin-unicorn": "^32.0.1",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0", "gulp-clean-css": "^4.3.0",
"gulp-eslint7": "^0.3.1",
"gulp-file-include": "^2.3.0", "gulp-file-include": "^2.3.0",
"gulp-npm-dist": "^1.0.3", "gulp-npm-dist": "^1.0.3",
"gulp-postcss": "^9.0.0", "gulp-postcss": "^9.0.0",

Loading…
Cancel
Save