add eslint to hygiene

This commit is contained in:
Joao Moreno 2017-06-20 16:21:44 +02:00
parent dabf32b1b7
commit ec463ce282
9 changed files with 78 additions and 54 deletions

View file

@ -9,6 +9,7 @@ const gulp = require('gulp');
const filter = require('gulp-filter');
const es = require('event-stream');
const gulptslint = require('gulp-tslint');
const gulpeslint = require('gulp-eslint');
const tsfmt = require('typescript-formatter');
const tslint = require('tslint');
@ -95,6 +96,16 @@ const copyrightFilter = [
'!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 = [
'src/**/*.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', () => {
const options = { summarizeFailureOutput: true };
@ -176,7 +195,6 @@ const hygiene = exports.hygiene = (some, options) => {
});
const formatting = es.map(function (file, cb) {
tsfmt.processString(file.path, file.contents.toString('utf8'), {
verify: true,
tsfmt: true,
@ -209,17 +227,27 @@ const hygiene = exports.hygiene = (some, options) => {
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(eolFilter))
.pipe(options.skipEOL ? es.through() : eol)
.pipe(filter(indentationFilter))
.pipe(indentation)
.pipe(filter(copyrightFilter))
.pipe(copyrights)
.pipe(copyrights);
const typescript = result
.pipe(filter(tslintFilter))
.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 () {
if (errorCount > 0) {
this.emit('error', 'Hygiene failed with ' + errorCount + ' errors. Check \'build/gulpfile.hygiene.js\'.');

View file

@ -71,6 +71,7 @@
"gulp-buffer": "0.0.2",
"gulp-concat": "^2.6.0",
"gulp-cssnano": "^2.1.0",
"gulp-eslint": "^3.0.1",
"gulp-filter": "^3.0.0",
"gulp-flatmap": "^1.0.0",
"gulp-image-resize": "^0.10.0",
@ -125,4 +126,4 @@
"windows-mutex": "^0.2.0",
"fsevents": "0.3.8"
}
}
}

View file

@ -1,17 +1,19 @@
{
"parserOptions": {
"ecmaVersion": 3
"ecmaVersion": 6
},
"env": {
"node": true,
"es6": true
"es6": true,
"browser": true,
"amd": true
},
"rules": {
"no-console": 0,
"no-cond-assign": 0,
"no-unused-vars": 1,
"no-extra-semi": "warn",
"semi": "warn"
},
"extends": "eslint:recommended"
}
"no-unused-vars": "error",
"no-extra-semi": "error",
"semi": "error",
"no-inner-declarations": 0
}
}

View file

@ -142,7 +142,7 @@ function getNodeCachedDataDir() {
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) {

View file

@ -3,16 +3,16 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var net = require('net'),
fs = require('fs'),
stream = require('stream'),
util = require('util');
const net = require('net');
const fs = require('fs');
// const stream = require('stream');
// const util = require('util');
var ENABLE_LOGGING = false;
var log = (function() {
var log = (function () {
if (!ENABLE_LOGGING) {
return function() {};
return function () { };
}
var isFirst = true;
var LOG_LOCATION = 'C:\\stdFork.log';
@ -23,7 +23,7 @@ var log = (function() {
return;
}
fs.appendFileSync(LOG_LOCATION, str + '\n');
}
};
})();
var stdInPipeName = process.env['STDIN_PIPE_NAME'];
@ -36,7 +36,7 @@ log('STDERR_PIPE_NAME: ' + stdErrPipeName);
log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
// stdout redirection to named pipe
(function() {
(function () {
log('Beginning stdout redirection...');
// Create a writing stream to the stdout pipe
@ -46,7 +46,7 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
stdOutStream.unref();
// handle process.stdout
process.__defineGetter__('stdout', function() { return stdOutStream; });
process.__defineGetter__('stdout', function () { return stdOutStream; });
// Create a writing stream to the stderr pipe
var stdErrStream = net.connect(stdErrPipeName);
@ -55,15 +55,15 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
stdErrStream.unref();
// handle process.stderr
process.__defineGetter__('stderr', function() { return stdErrStream; });
process.__defineGetter__('stderr', function () { return stdErrStream; });
var fsWriteSyncString = function(fd, str, position, encoding) {
var fsWriteSyncString = function (fd, str, position, encoding) {
// fs.writeSync(fd, string[, position[, encoding]]);
var buf = new Buffer(str, encoding || 'utf8');
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);
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, ...)
var originalWriteSync = fs.writeSync;
fs.writeSync = function(fd, data, position, encoding) {
fs.writeSync = function (fd, data/* , position, encoding */) {
if (fd !== 1 && fd !== 2) {
return originalWriteSync.apply(fs, arguments);
}
@ -124,17 +124,17 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
})();
// stdin redirection to named pipe
(function() {
(function () {
// Begin listening to stdin pipe
var server = net.createServer(function(stream) {
var server = net.createServer(function (stream) {
// Stop accepting new connections, keep the existing one alive
server.close();
log('Parent process has connected to my stdin. All should be good now.');
// handle process.stdin
process.__defineGetter__('stdin', function() {
process.__defineGetter__('stdin', function () {
return stream;
});
@ -156,7 +156,7 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
log('Finished loading program.');
var stdinIsReferenced = true;
var timer = setInterval(function() {
var timer = setInterval(function () {
var listenerCount = (
stream.listeners('data').length +
stream.listeners('end').length +
@ -189,7 +189,7 @@ log('ELECTRON_RUN_AS_NODE: ' + process.env['ELECTRON_RUN_AS_NODE']);
});
server.listen(stdInPipeName, function() {
server.listen(stdInPipeName, function () {
// signal via stdout that the parent process can now begin writing to stdin pipe
process.stdout.write('ready');
});

View file

@ -3,16 +3,9 @@
* 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';
/*global window,document,define*/
const path = require('path');
const electron = require('electron');
const remote = electron.remote;
const ipc = electron.ipcRenderer;
function assign(destination, source) {
return Object.keys(source)

View file

@ -15,7 +15,7 @@ function createModuleDescription(name, exclude) {
return result;
}
exports.collectModules = function (excludes) {
exports.collectModules = function () {
var modules = [
createModuleDescription('vs/workbench/parts/output/common/outputLinkComputer', ['vs/base/common/worker/simpleWorker', 'vs/editor/common/services/editorSimpleWorker']),

View file

@ -23,7 +23,7 @@ const ipc = electron.ipcRenderer;
process.lazyEnv = new Promise(function (resolve) {
const handle = setTimeout(function () {
resolve();
console.warn('renderer did not receive lazyEnv in time')
console.warn('renderer did not receive lazyEnv in time');
}, 10000);
ipc.once('vscode:acceptShellEnv', function (event, shellEnv) {
clearTimeout(handle);
@ -107,14 +107,14 @@ function registerListeners(enableDeveloperTools) {
window.addEventListener('keydown', listener);
}
process.on('uncaughtException', function (error) { onError(error, enableDeveloperTools) });
process.on('uncaughtException', function (error) { onError(error, enableDeveloperTools); });
return function () {
if (listener) {
window.removeEventListener('keydown', listener);
listener = void 0;
}
}
};
}
function main() {
@ -159,7 +159,7 @@ function main() {
// 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
const loaderTimer = startTimer('load:loader')
const loaderTimer = startTimer('load:loader');
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
loaderTimer.stop();
@ -172,7 +172,7 @@ function main() {
'vs/nls': nlsConfig,
recordStats: !!configuration.performance,
nodeCachedDataDir: configuration.nodeCachedDataDir,
onNodeCachedData: function () { onNodeCachedData.push(arguments) },
onNodeCachedData: function () { onNodeCachedData.push(arguments); },
nodeModules: [/*BUILD->INSERT_NODE_MODULES*/]
});
@ -192,7 +192,7 @@ function main() {
beforeLoadWorkbenchMain: Date.now()
};
const workbenchMainTimer = startTimer('load:workbench.main')
const workbenchMainTimer = startTimer('load:workbench.main');
require([
'vs/workbench/electron-browser/workbench.main',
'vs/nls!vs/workbench/electron-browser/workbench.main',

View file

@ -17,7 +17,7 @@
function styleBody(body) {
if (!body) {
return
return;
}
body.classList.remove('vscode-light', 'vscode-dark', 'vscode-high-contrast');
body.classList.add(initData.activeTheme);
@ -88,7 +88,7 @@
});
}
document.addEventListener('DOMContentLoaded', function (event) {
document.addEventListener('DOMContentLoaded', function () {
ipcRenderer.on('baseUrl', function (event, value) {
initData.baseUrl = value;
});
@ -98,7 +98,7 @@
initData.activeTheme = activeTheme;
// webview
var target = getActiveFrame()
var target = getActiveFrame();
if (!target) {
return;
}
@ -158,25 +158,25 @@
// keep current scrollTop around and use later
var setInitialScrollPosition;
if (firstLoad) {
if (firstLoad) {
firstLoad = false;
setInitialScrollPosition = function (body, window) {
body.scrollTop = 0;
if (!isNaN(initData.initialScrollProgress)) {
window.addEventListener('load', function () {
if (body.scrollTop === 0) {
body.scrollTop = body.clientHeight * initData.initialScrollProgress
body.scrollTop = body.clientHeight * initData.initialScrollProgress;
}
});
}
}
};
} else {
const scrollY = frame.contentDocument && frame.contentDocument.body ? frame.contentDocument.body.scrollTop : 0;
setInitialScrollPosition = function (body) {
if (body.scrollTop === 0) {
body.scrollTop = scrollY;
}
}
};
}
// Clean up old pending frames and set current one as new one
@ -195,7 +195,7 @@
// write new content onto iframe
newFrame.contentDocument.open('text/html', 'replace');
newFrame.contentWindow.onbeforeunload = function (e) {
newFrame.contentWindow.onbeforeunload = function () {
console.log('prevented webview navigation');
return false;
};