add eslint to hygiene
This commit is contained in:
parent
dabf32b1b7
commit
ec463ce282
|
@ -9,6 +9,7 @@ const gulp = require('gulp');
|
||||||
const filter = require('gulp-filter');
|
const filter = require('gulp-filter');
|
||||||
const es = require('event-stream');
|
const es = require('event-stream');
|
||||||
const gulptslint = require('gulp-tslint');
|
const gulptslint = require('gulp-tslint');
|
||||||
|
const gulpeslint = require('gulp-eslint');
|
||||||
const tsfmt = require('typescript-formatter');
|
const tsfmt = require('typescript-formatter');
|
||||||
const tslint = require('tslint');
|
const tslint = require('tslint');
|
||||||
|
|
||||||
|
@ -95,6 +96,16 @@ const copyrightFilter = [
|
||||||
'!extensions/html/server/src/modes/typescript/*'
|
'!extensions/html/server/src/modes/typescript/*'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const eslintFilter = [
|
||||||
|
'src/**/*.js',
|
||||||
|
'!src/vs/css.js',
|
||||||
|
'!src/vs/loader.js',
|
||||||
|
'!src/vs/nls.js',
|
||||||
|
'!src/**/winjs.base.raw.js',
|
||||||
|
'!src/**/raw.marked.js',
|
||||||
|
'!**/test/**'
|
||||||
|
];
|
||||||
|
|
||||||
const tslintFilter = [
|
const tslintFilter = [
|
||||||
'src/**/*.ts',
|
'src/**/*.ts',
|
||||||
'extensions/**/*.ts',
|
'extensions/**/*.ts',
|
||||||
|
@ -124,6 +135,14 @@ function reportFailures(failures) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gulp.task('eslint', () => {
|
||||||
|
return gulp.src(all, { base: '.' })
|
||||||
|
.pipe(filter(eslintFilter))
|
||||||
|
.pipe(gulpeslint('src/.eslintrc'))
|
||||||
|
.pipe(gulpeslint.formatEach('compact'))
|
||||||
|
.pipe(gulpeslint.failAfterError());
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('tslint', () => {
|
gulp.task('tslint', () => {
|
||||||
const options = { summarizeFailureOutput: true };
|
const options = { summarizeFailureOutput: true };
|
||||||
|
|
||||||
|
@ -176,7 +195,6 @@ const hygiene = exports.hygiene = (some, options) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const formatting = es.map(function (file, cb) {
|
const formatting = es.map(function (file, cb) {
|
||||||
|
|
||||||
tsfmt.processString(file.path, file.contents.toString('utf8'), {
|
tsfmt.processString(file.path, file.contents.toString('utf8'), {
|
||||||
verify: true,
|
verify: true,
|
||||||
tsfmt: true,
|
tsfmt: true,
|
||||||
|
@ -209,17 +227,27 @@ const hygiene = exports.hygiene = (some, options) => {
|
||||||
this.emit('data', file);
|
this.emit('data', file);
|
||||||
});
|
});
|
||||||
|
|
||||||
return gulp.src(some || all, { base: '.' })
|
const result = gulp.src(some || all, { base: '.' })
|
||||||
.pipe(filter(f => !f.stat.isDirectory()))
|
.pipe(filter(f => !f.stat.isDirectory()))
|
||||||
.pipe(filter(eolFilter))
|
.pipe(filter(eolFilter))
|
||||||
.pipe(options.skipEOL ? es.through() : eol)
|
.pipe(options.skipEOL ? es.through() : eol)
|
||||||
.pipe(filter(indentationFilter))
|
.pipe(filter(indentationFilter))
|
||||||
.pipe(indentation)
|
.pipe(indentation)
|
||||||
.pipe(filter(copyrightFilter))
|
.pipe(filter(copyrightFilter))
|
||||||
.pipe(copyrights)
|
.pipe(copyrights);
|
||||||
|
|
||||||
|
const typescript = result
|
||||||
.pipe(filter(tslintFilter))
|
.pipe(filter(tslintFilter))
|
||||||
.pipe(formatting)
|
.pipe(formatting)
|
||||||
.pipe(tsl)
|
.pipe(tsl);
|
||||||
|
|
||||||
|
const javascript = result
|
||||||
|
.pipe(filter(eslintFilter))
|
||||||
|
.pipe(gulpeslint('src/.eslintrc'))
|
||||||
|
.pipe(gulpeslint.formatEach('compact'))
|
||||||
|
.pipe(gulpeslint.failAfterError());
|
||||||
|
|
||||||
|
return es.merge(typescript, javascript)
|
||||||
.pipe(es.through(null, function () {
|
.pipe(es.through(null, function () {
|
||||||
if (errorCount > 0) {
|
if (errorCount > 0) {
|
||||||
this.emit('error', 'Hygiene failed with ' + errorCount + ' errors. Check \'build/gulpfile.hygiene.js\'.');
|
this.emit('error', 'Hygiene failed with ' + errorCount + ' errors. Check \'build/gulpfile.hygiene.js\'.');
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
"gulp-buffer": "0.0.2",
|
"gulp-buffer": "0.0.2",
|
||||||
"gulp-concat": "^2.6.0",
|
"gulp-concat": "^2.6.0",
|
||||||
"gulp-cssnano": "^2.1.0",
|
"gulp-cssnano": "^2.1.0",
|
||||||
|
"gulp-eslint": "^3.0.1",
|
||||||
"gulp-filter": "^3.0.0",
|
"gulp-filter": "^3.0.0",
|
||||||
"gulp-flatmap": "^1.0.0",
|
"gulp-flatmap": "^1.0.0",
|
||||||
"gulp-image-resize": "^0.10.0",
|
"gulp-image-resize": "^0.10.0",
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
{
|
{
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 3
|
"ecmaVersion": 6
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"node": true,
|
"node": true,
|
||||||
"es6": true
|
"es6": true,
|
||||||
|
"browser": true,
|
||||||
|
"amd": true
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-console": 0,
|
"no-console": 0,
|
||||||
"no-cond-assign": 0,
|
"no-cond-assign": 0,
|
||||||
"no-unused-vars": 1,
|
"no-unused-vars": "error",
|
||||||
"no-extra-semi": "warn",
|
"no-extra-semi": "error",
|
||||||
"semi": "warn"
|
"semi": "error",
|
||||||
},
|
"no-inner-declarations": 0
|
||||||
"extends": "eslint:recommended"
|
}
|
||||||
}
|
}
|
|
@ -142,7 +142,7 @@ function getNodeCachedDataDir() {
|
||||||
|
|
||||||
var dir = path.join(app.getPath('userData'), 'CachedData', productJson.commit);
|
var dir = path.join(app.getPath('userData'), 'CachedData', productJson.commit);
|
||||||
|
|
||||||
return mkdirp(dir).then(undefined, function (err) { /*ignore*/ });
|
return mkdirp(dir).then(undefined, function () { /*ignore*/ });
|
||||||
}
|
}
|
||||||
|
|
||||||
function mkdirp(dir) {
|
function mkdirp(dir) {
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
var net = require('net'),
|
const net = require('net');
|
||||||
fs = require('fs'),
|
const fs = require('fs');
|
||||||
stream = require('stream'),
|
// const stream = require('stream');
|
||||||
util = require('util');
|
// const util = require('util');
|
||||||
|
|
||||||
var ENABLE_LOGGING = false;
|
var ENABLE_LOGGING = false;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ var log = (function() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.appendFileSync(LOG_LOCATION, str + '\n');
|
fs.appendFileSync(LOG_LOCATION, str + '\n');
|
||||||
}
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var stdInPipeName = process.env['STDIN_PIPE_NAME'];
|
var stdInPipeName = process.env['STDIN_PIPE_NAME'];
|
||||||
|
@ -63,7 +63,7 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
|
||||||
return fsWriteSyncBuffer(fd, buf, 0, buf.length);
|
return fsWriteSyncBuffer(fd, buf, 0, buf.length);
|
||||||
};
|
};
|
||||||
|
|
||||||
var fsWriteSyncBuffer = function(fd, buffer, off, len, position) {
|
var fsWriteSyncBuffer = function (fd, buffer, off, len/* , position */) {
|
||||||
off = Math.abs(off | 0);
|
off = Math.abs(off | 0);
|
||||||
len = Math.abs(len | 0);
|
len = Math.abs(len | 0);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
|
||||||
|
|
||||||
// handle fs.writeSync(1, ...) and fs.writeSync(2, ...)
|
// handle fs.writeSync(1, ...) and fs.writeSync(2, ...)
|
||||||
var originalWriteSync = fs.writeSync;
|
var originalWriteSync = fs.writeSync;
|
||||||
fs.writeSync = function(fd, data, position, encoding) {
|
fs.writeSync = function (fd, data/* , position, encoding */) {
|
||||||
if (fd !== 1 && fd !== 2) {
|
if (fd !== 1 && fd !== 2) {
|
||||||
return originalWriteSync.apply(fs, arguments);
|
return originalWriteSync.apply(fs, arguments);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,16 +3,9 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// Warning: Do not use the `let` declarator in this file, it breaks our minification
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/*global window,document,define*/
|
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const electron = require('electron');
|
|
||||||
const remote = electron.remote;
|
|
||||||
const ipc = electron.ipcRenderer;
|
|
||||||
|
|
||||||
function assign(destination, source) {
|
function assign(destination, source) {
|
||||||
return Object.keys(source)
|
return Object.keys(source)
|
||||||
|
|
|
@ -15,7 +15,7 @@ function createModuleDescription(name, exclude) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.collectModules = function (excludes) {
|
exports.collectModules = function () {
|
||||||
var modules = [
|
var modules = [
|
||||||
createModuleDescription('vs/workbench/parts/output/common/outputLinkComputer', ['vs/base/common/worker/simpleWorker', 'vs/editor/common/services/editorSimpleWorker']),
|
createModuleDescription('vs/workbench/parts/output/common/outputLinkComputer', ['vs/base/common/worker/simpleWorker', 'vs/editor/common/services/editorSimpleWorker']),
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ const ipc = electron.ipcRenderer;
|
||||||
process.lazyEnv = new Promise(function (resolve) {
|
process.lazyEnv = new Promise(function (resolve) {
|
||||||
const handle = setTimeout(function () {
|
const handle = setTimeout(function () {
|
||||||
resolve();
|
resolve();
|
||||||
console.warn('renderer did not receive lazyEnv in time')
|
console.warn('renderer did not receive lazyEnv in time');
|
||||||
}, 10000);
|
}, 10000);
|
||||||
ipc.once('vscode:acceptShellEnv', function (event, shellEnv) {
|
ipc.once('vscode:acceptShellEnv', function (event, shellEnv) {
|
||||||
clearTimeout(handle);
|
clearTimeout(handle);
|
||||||
|
@ -107,14 +107,14 @@ function registerListeners(enableDeveloperTools) {
|
||||||
window.addEventListener('keydown', listener);
|
window.addEventListener('keydown', listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('uncaughtException', function (error) { onError(error, enableDeveloperTools) });
|
process.on('uncaughtException', function (error) { onError(error, enableDeveloperTools); });
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
if (listener) {
|
if (listener) {
|
||||||
window.removeEventListener('keydown', listener);
|
window.removeEventListener('keydown', listener);
|
||||||
listener = void 0;
|
listener = void 0;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
@ -159,7 +159,7 @@ function main() {
|
||||||
|
|
||||||
// In the bundled version the nls plugin is packaged with the loader so the NLS Plugins
|
// In the bundled version the nls plugin is packaged with the loader so the NLS Plugins
|
||||||
// loads as soon as the loader loads. To be able to have pseudo translation
|
// loads as soon as the loader loads. To be able to have pseudo translation
|
||||||
const loaderTimer = startTimer('load:loader')
|
const loaderTimer = startTimer('load:loader');
|
||||||
createScript(rootUrl + '/vs/loader.js', function () {
|
createScript(rootUrl + '/vs/loader.js', function () {
|
||||||
define('fs', ['original-fs'], function (originalFS) { return originalFS; }); // replace the patched electron fs with the original node fs for all AMD code
|
define('fs', ['original-fs'], function (originalFS) { return originalFS; }); // replace the patched electron fs with the original node fs for all AMD code
|
||||||
loaderTimer.stop();
|
loaderTimer.stop();
|
||||||
|
@ -172,7 +172,7 @@ function main() {
|
||||||
'vs/nls': nlsConfig,
|
'vs/nls': nlsConfig,
|
||||||
recordStats: !!configuration.performance,
|
recordStats: !!configuration.performance,
|
||||||
nodeCachedDataDir: configuration.nodeCachedDataDir,
|
nodeCachedDataDir: configuration.nodeCachedDataDir,
|
||||||
onNodeCachedData: function () { onNodeCachedData.push(arguments) },
|
onNodeCachedData: function () { onNodeCachedData.push(arguments); },
|
||||||
nodeModules: [/*BUILD->INSERT_NODE_MODULES*/]
|
nodeModules: [/*BUILD->INSERT_NODE_MODULES*/]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ function main() {
|
||||||
beforeLoadWorkbenchMain: Date.now()
|
beforeLoadWorkbenchMain: Date.now()
|
||||||
};
|
};
|
||||||
|
|
||||||
const workbenchMainTimer = startTimer('load:workbench.main')
|
const workbenchMainTimer = startTimer('load:workbench.main');
|
||||||
require([
|
require([
|
||||||
'vs/workbench/electron-browser/workbench.main',
|
'vs/workbench/electron-browser/workbench.main',
|
||||||
'vs/nls!vs/workbench/electron-browser/workbench.main',
|
'vs/nls!vs/workbench/electron-browser/workbench.main',
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
function styleBody(body) {
|
function styleBody(body) {
|
||||||
if (!body) {
|
if (!body) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
body.classList.remove('vscode-light', 'vscode-dark', 'vscode-high-contrast');
|
body.classList.remove('vscode-light', 'vscode-dark', 'vscode-high-contrast');
|
||||||
body.classList.add(initData.activeTheme);
|
body.classList.add(initData.activeTheme);
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function (event) {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
ipcRenderer.on('baseUrl', function (event, value) {
|
ipcRenderer.on('baseUrl', function (event, value) {
|
||||||
initData.baseUrl = value;
|
initData.baseUrl = value;
|
||||||
});
|
});
|
||||||
|
@ -98,7 +98,7 @@
|
||||||
initData.activeTheme = activeTheme;
|
initData.activeTheme = activeTheme;
|
||||||
|
|
||||||
// webview
|
// webview
|
||||||
var target = getActiveFrame()
|
var target = getActiveFrame();
|
||||||
if (!target) {
|
if (!target) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -165,18 +165,18 @@
|
||||||
if (!isNaN(initData.initialScrollProgress)) {
|
if (!isNaN(initData.initialScrollProgress)) {
|
||||||
window.addEventListener('load', function () {
|
window.addEventListener('load', function () {
|
||||||
if (body.scrollTop === 0) {
|
if (body.scrollTop === 0) {
|
||||||
body.scrollTop = body.clientHeight * initData.initialScrollProgress
|
body.scrollTop = body.clientHeight * initData.initialScrollProgress;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
const scrollY = frame.contentDocument && frame.contentDocument.body ? frame.contentDocument.body.scrollTop : 0;
|
const scrollY = frame.contentDocument && frame.contentDocument.body ? frame.contentDocument.body.scrollTop : 0;
|
||||||
setInitialScrollPosition = function (body) {
|
setInitialScrollPosition = function (body) {
|
||||||
if (body.scrollTop === 0) {
|
if (body.scrollTop === 0) {
|
||||||
body.scrollTop = scrollY;
|
body.scrollTop = scrollY;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up old pending frames and set current one as new one
|
// Clean up old pending frames and set current one as new one
|
||||||
|
@ -195,7 +195,7 @@
|
||||||
|
|
||||||
// write new content onto iframe
|
// write new content onto iframe
|
||||||
newFrame.contentDocument.open('text/html', 'replace');
|
newFrame.contentDocument.open('text/html', 'replace');
|
||||||
newFrame.contentWindow.onbeforeunload = function (e) {
|
newFrame.contentWindow.onbeforeunload = function () {
|
||||||
console.log('prevented webview navigation');
|
console.log('prevented webview navigation');
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue