first
This commit is contained in:
.browserslistrc.editorconfig.eslintignore.eslintrc.js.gitattributes.gitignoreREADME.mdbabel.config.jsonindex.htmljsconfig.jsonpackage.json
gulpfile.js
config
browser-sync-prod.jsbrowser-sync.jsdirectories.jsexternals-js.jsnodemon.jspug.jsrename.jssass.jsserver.jsusemin.jswebpack.js
index.jsprivate-tasks
backup--chunk-scripts.jsbuild--assets.jsbuild--locales.jsbuild--scripts-es6.jsbuild--scripts-external.jsbuild--styles-rtl.jsbuild--styles.jsbuild--views-min.jsbuild--views.jsbundle--scripts.jsbundle--styles.jsclean--output.jsclean--temp-scripts.jsclean--temp-styles.jscopy--assets.jslint--scripts.jsminify--chunk-scripts.jsminify--styles.jsprint--results.jsreload.jsrun--dev-server.jsrun--views.jsrun--watchers.jsversionfy.js
tasks
utils
server
src
assets
data
favicon
android-chrome-192x192.pngandroid-chrome-512x512.pngapple-touch-icon.pngbrowserconfig.xmlfavicon-16x16.pngfavicon-32x32.pngfavicon.icomstile-150x150.pngsafari-pinned-tab.svgsite.webmanifest
fonts
images
scripts
styles
$components
$libs.scss_cores
_libs
_utils
apps.scssviews
63
gulpfile.js/utils/errors.js
Normal file
63
gulpfile.js/utils/errors.js
Normal file
@ -0,0 +1,63 @@
|
||||
const cached = require('gulp-cached');
|
||||
|
||||
const list = {
|
||||
get totalIssue() {
|
||||
return this.totalError + this.totalWarning;
|
||||
},
|
||||
};
|
||||
exports.list = list;
|
||||
|
||||
function pushError(info) {
|
||||
list.data.push(info);
|
||||
list[info.type === 'Error' ? 'totalError' : 'totalWarning'] += 1;
|
||||
}
|
||||
|
||||
function handleError({ plugin, message, codeFrame = '' } = {}) {
|
||||
pushError({
|
||||
type: 'Error',
|
||||
plugin: plugin.toUpperCase(),
|
||||
message: message.trim(),
|
||||
code: codeFrame,
|
||||
});
|
||||
|
||||
if (typeof this.emit === 'function') {
|
||||
this.emit('end');
|
||||
} else if (typeof this === 'function') {
|
||||
this();
|
||||
}
|
||||
}
|
||||
|
||||
exports.handleError = handleError;
|
||||
|
||||
exports.handleESLintError = (results) => {
|
||||
results.forEach(({ filePath, messages } = {}) => {
|
||||
messages.forEach(({
|
||||
severity, line, column, message,
|
||||
} = {}) => {
|
||||
const type = severity === 2 ? 'Error' : 'Warning';
|
||||
|
||||
pushError({
|
||||
type,
|
||||
plugin: `ES Lint ${type}`,
|
||||
message: filePath,
|
||||
code: `[${line}:${column}] ${message}`,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
list.isJSValid = !results.errorCount;
|
||||
|
||||
if (results.errorCount || results.warningCount) {
|
||||
delete cached.caches.eslint;
|
||||
}
|
||||
};
|
||||
|
||||
function resetError() {
|
||||
list.data = [];
|
||||
list.totalError = 0;
|
||||
list.totalWarning = 0;
|
||||
list.isJSValid = true;
|
||||
}
|
||||
exports.resetError = resetError;
|
||||
|
||||
resetError();
|
Reference in New Issue
Block a user