Skip to content

Commit 2f4cf13

Browse files
committed
Merge remote-tracking branch 'origin/main' into tyriar/258480
2 parents 7871785 + 737e8bb commit 2f4cf13

File tree

186 files changed

+1389
-1911
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+1389
-1911
lines changed

build/buildfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5+
// @ts-check
56

67
/**
78
* @param {string} name

build/eslint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5-
5+
// @ts-check
66
const es = require('event-stream');
77
const vfs = require('vinyl-fs');
88
const { eslintFilter } = require('./filters');

build/filters.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5+
// @ts-check
56

67
/**
78
* Hygiene works by creating cascading subsets of all our files and

build/gulp-eslint.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,28 @@
66
'use strict';
77

88
const { ESLint } = require('eslint');
9-
const { Transform } = require('stream');
9+
const { Transform, default: Stream } = require('stream');
1010
const { relative } = require('path');
1111
const fancyLog = require('fancy-log');
1212

1313
/**
14-
* @param {Function} action - A function to handle all ESLint results
15-
* @returns {stream} gulp file stream
14+
* @typedef {ESLint.LintResult[] & { errorCount: number, warningCount: number}} ESLintResults
15+
*/
16+
17+
/**
18+
* @param {(results: ESLintResults) => void} action - A function to handle all ESLint results
1619
*/
1720
function eslint(action) {
1821
const linter = new ESLint({});
1922
const formatter = linter.loadFormatter('compact');
2023

24+
/** @type {ESLintResults} results */
2125
const results = [];
2226
results.errorCount = 0;
2327
results.warningCount = 0;
2428

2529
return transform(
26-
async (file, enc, cb) => {
30+
async (file, _enc, cb) => {
2731
const filePath = relative(process.cwd(), file.path);
2832

2933
if (file.isNull()) {
@@ -67,6 +71,10 @@ function eslint(action) {
6771
});
6872
}
6973

74+
/**
75+
* @param {Stream.TransformOptions['transform']} transform
76+
* @param {Stream.TransformOptions['flush']} flush
77+
*/
7078
function transform(transform, flush) {
7179
return new Transform({
7280
objectMode: true,

build/gulpfile.cli.js

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const fancyLog = require('fancy-log');
1212
const ansiColors = require('ansi-colors');
1313
const cp = require('child_process');
1414
const { tmpdir } = require('os');
15-
const { promises: fs, existsSync, mkdirSync, rmSync } = require('fs');
15+
const { existsSync, mkdirSync, rmSync } = require('fs');
1616

1717
const task = require('./lib/task');
1818
const watcher = require('./lib/watch');
@@ -58,36 +58,6 @@ const hasLocalRust = (() => {
5858
};
5959
})();
6060

61-
const debounceEsStream = (fn, duration = 100) => {
62-
let handle = undefined;
63-
let pending = [];
64-
const sendAll = (pending) => (event, ...args) => {
65-
for (const stream of pending) {
66-
pending.emit(event, ...args);
67-
}
68-
};
69-
70-
return es.map(function (_, callback) {
71-
console.log('defer');
72-
if (handle !== undefined) {
73-
clearTimeout(handle);
74-
}
75-
76-
handle = setTimeout(() => {
77-
handle = undefined;
78-
79-
const previous = pending;
80-
pending = [];
81-
fn()
82-
.on('error', sendAll('error'))
83-
.on('data', sendAll('data'))
84-
.on('end', sendAll('end'));
85-
}, duration);
86-
87-
pending.push(this);
88-
});
89-
};
90-
9161
const compileFromSources = (callback) => {
9262
const proc = cp.spawn('cargo', ['--color', 'always', 'build'], {
9363
cwd: root,

build/gulpfile.extensions.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,6 @@ const tasks = compilations.map(function (tsconfigFile) {
9292
const out = path.join(srcRoot, 'out');
9393
const baseUrl = getBaseUrl(out);
9494

95-
let headerId, headerOut;
96-
const index = relativeDirname.indexOf('/');
97-
if (index < 0) {
98-
headerId = 'vscode.' + relativeDirname;
99-
headerOut = 'out';
100-
} else {
101-
headerId = 'vscode.' + relativeDirname.substr(0, index);
102-
headerOut = relativeDirname.substr(index + 1) + '/out';
103-
}
104-
10595
function createPipeline(build, emitError, transpileOnly) {
10696
const tsb = require('./lib/tsb');
10797
const sourcemaps = require('gulp-sourcemaps');
@@ -248,7 +238,7 @@ const bundleMarketplaceExtensionsBuildTask = task.define('bundle-marketplace-ext
248238
*/
249239
const compileNonNativeExtensionsBuildTask = task.define('compile-non-native-extensions-build', task.series(
250240
bundleMarketplaceExtensionsBuildTask,
251-
task.define('bundle-non-native-extensions-build', () => ext.packageNonNativeLocalExtensionsStream().pipe(gulp.dest('.build')))
241+
task.define('bundle-non-native-extensions-build', () => ext.packageNonNativeLocalExtensionsStream(false, false).pipe(gulp.dest('.build')))
252242
));
253243
gulp.task(compileNonNativeExtensionsBuildTask);
254244
exports.compileNonNativeExtensionsBuildTask = compileNonNativeExtensionsBuildTask;
@@ -257,7 +247,7 @@ exports.compileNonNativeExtensionsBuildTask = compileNonNativeExtensionsBuildTas
257247
* Compiles the native extensions for the build
258248
* @note this does not clean the directory ahead of it. See {@link cleanExtensionsBuildTask} for that.
259249
*/
260-
const compileNativeExtensionsBuildTask = task.define('compile-native-extensions-build', () => ext.packageNativeLocalExtensionsStream().pipe(gulp.dest('.build')));
250+
const compileNativeExtensionsBuildTask = task.define('compile-native-extensions-build', () => ext.packageNativeLocalExtensionsStream(false, false).pipe(gulp.dest('.build')));
261251
gulp.task(compileNativeExtensionsBuildTask);
262252
exports.compileNativeExtensionsBuildTask = compileNativeExtensionsBuildTask;
263253

build/gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require('events').EventEmitter.defaultMaxListeners = 100;
1111
const gulp = require('gulp');
1212
const util = require('./lib/util');
1313
const task = require('./lib/task');
14-
const { transpileClientSWC, transpileTask, compileTask, watchTask, compileApiProposalNamesTask, watchApiProposalNamesTask } = require('./lib/compilation');
14+
const { transpileTask, compileTask, watchTask, compileApiProposalNamesTask, watchApiProposalNamesTask } = require('./lib/compilation');
1515
const { monacoTypecheckTask/* , monacoTypecheckWatchTask */ } = require('./gulpfile.editor');
1616
const { compileExtensionsTask, watchExtensionsTask, compileExtensionMediaTask } = require('./gulpfile.extensions');
1717

build/gulpfile.vscode.web.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ const vscodeWebEntryPoints = [
9393
* @param {object} product The parsed product.json file contents
9494
*/
9595
const createVSCodeWebFileContentMapper = (extensionsRoot, product) => {
96+
/**
97+
* @param {string} path
98+
* @returns {((content: string) => string) | undefined}
99+
*/
96100
return path => {
97101
if (path.endsWith('vs/platform/product/common/product.js')) {
98102
return content => {
@@ -138,6 +142,10 @@ const minifyVSCodeWebTask = task.define('minify-vscode-web', task.series(
138142
));
139143
gulp.task(minifyVSCodeWebTask);
140144

145+
/**
146+
* @param {string} sourceFolderName
147+
* @param {string} destinationFolderName
148+
*/
141149
function packageTask(sourceFolderName, destinationFolderName) {
142150
const destination = path.join(BUILD_ROOT, destinationFolderName);
143151

build/gulpfile.vscode.win32.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5-
65
'use strict';
76

87
const gulp = require('gulp');

build/hygiene.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5+
// @ts-check
56

67
const filter = require('gulp-filter');
78
const es = require('event-stream');
@@ -20,6 +21,10 @@ const copyrightHeaderLines = [
2021
' *--------------------------------------------------------------------------------------------*/',
2122
];
2223

24+
/**
25+
* @param {string[] | NodeJS.ReadWriteStream} some
26+
* @param {boolean} linting
27+
*/
2328
function hygiene(some, linting = true) {
2429
const eslint = require('./gulp-eslint');
2530
const gulpstylelint = require('./stylelint');
@@ -39,6 +44,7 @@ function hygiene(some, linting = true) {
3944
});
4045

4146
const unicode = es.through(function (file) {
47+
/** @type {string[]} */
4248
const lines = file.contents.toString('utf8').split(/\r\n|\r|\n/);
4349
file.__lines = lines;
4450
const allowInComments = lines.some(line => /allow-any-unicode-comment-file/.test(line));
@@ -76,6 +82,7 @@ function hygiene(some, linting = true) {
7682
});
7783

7884
const indentation = es.through(function (file) {
85+
/** @type {string[]} */
7986
const lines = file.__lines || file.contents.toString('utf8').split(/\r\n|\r|\n/);
8087
file.__lines = lines;
8188

@@ -125,14 +132,13 @@ function hygiene(some, linting = true) {
125132
);
126133
errorCount++;
127134
}
128-
cb(null, file);
135+
cb(undefined, file);
129136
} catch (err) {
130137
cb(err);
131138
}
132139
});
133140

134141
let input;
135-
136142
if (Array.isArray(some) || typeof some === 'string' || !some) {
137143
const options = { base: '.', follow: true, allowEmpty: true };
138144
if (some) {
@@ -164,6 +170,7 @@ function hygiene(some, linting = true) {
164170
.pipe(filter(copyrightFilter))
165171
.pipe(copyrights);
166172

173+
/** @type {import('stream').Stream[]} */
167174
const streams = [
168175
result.pipe(filter(tsFormattingFilter)).pipe(formatting)
169176
];
@@ -220,6 +227,9 @@ function hygiene(some, linting = true) {
220227

221228
module.exports.hygiene = hygiene;
222229

230+
/**
231+
* @param {string[]} paths
232+
*/
223233
function createGitIndexVinyls(paths) {
224234
const cp = require('child_process');
225235
const repositoryPath = process.cwd();
@@ -294,12 +304,14 @@ if (require.main === module) {
294304

295305
createGitIndexVinyls(some)
296306
.then(
297-
(vinyls) =>
298-
new Promise((c, e) =>
307+
(vinyls) => {
308+
/** @type {Promise<void>} */
309+
return (new Promise((c, e) =>
299310
hygiene(es.readArray(vinyls).pipe(filter(all)))
300311
.on('end', () => c())
301312
.on('error', e)
302-
)
313+
))
314+
}
303315
)
304316
.catch((err) => {
305317
console.error();

0 commit comments

Comments
 (0)