vscode/build/lib/layersChecker.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

337 lines
12 KiB
JavaScript
Raw Normal View History

"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
const ts = require("typescript");
const fs_1 = require("fs");
const path_1 = require("path");
const minimatch_1 = require("minimatch");
//
// #############################################################################################
//
// A custom typescript checker for the specific task of detecting the use of certain types in a
// layer that does not allow such use. For example:
// - using DOM globals in common/node/electron-main layer (e.g. HTMLElement)
// - using node.js globals in common/browser layer (e.g. process)
//
// Make changes to below RULES to lift certain files from these checks only if absolutely needed
//
// #############################################################################################
//
// Types we assume are present in all implementations of JS VMs (node.js, browsers)
// Feel free to add more core types as you see needed if present in node.js and browsers
const CORE_TYPES = [
'require', // from our AMD loader
'setTimeout',
'clearTimeout',
'setInterval',
'clearInterval',
'console',
2022-04-04 13:04:29 +00:00
'Console',
'Error',
2022-04-04 13:04:29 +00:00
'ErrorConstructor',
'String',
'TextDecoder',
'TextEncoder',
'self',
'queueMicrotask',
'Array',
'Uint8Array',
'Uint16Array',
'Uint32Array',
'Int8Array',
'Int16Array',
'Int32Array',
'Float32Array',
'Float64Array',
'Uint8ClampedArray',
'BigUint64Array',
'BigInt64Array',
'btoa',
'atob',
2022-08-04 23:26:18 +00:00
'AbortController',
'AbortSignal',
'MessageChannel',
'MessagePort',
'URL',
'URLSearchParams',
'ReadonlyArray',
'Event',
'EventTarget',
'BroadcastChannel',
'performance',
chore: update to electron 29 (#209818) * chore: update electron@29.1.0 * chore: update typings to 20.x * chore: bump electron@29.1.5 * ci: fix crash in compiling extensions-ci * chore: disable .d.ts check for build/ $ ../node_modules/.bin/tsc -p tsconfig.build.json node_modules/@types/chokidar/index.d.ts:21:14 - error TS2420: Class 'import("/Users/demohan/github/vscode/build/node_modules/@types/chokidar/index").FSWatcher' incorrectly implements interface 'import("fs").FSWatcher'. Type 'FSWatcher' is missing the following properties from type 'FSWatcher': ref, unref 21 export class FSWatcher extends EventEmitter implements fs.FSWatcher { ~~~~~~~~~ node_modules/chokidar/types/index.d.ts:8:14 - error TS2420: Class 'import("/Users/demohan/github/vscode/build/node_modules/chokidar/types/index").FSWatcher' incorrectly implements interface 'import("fs").FSWatcher'. Type 'FSWatcher' is missing the following properties from type 'FSWatcher': ref, unref 8 export class FSWatcher extends EventEmitter implements fs.FSWatcher { ~~~~~~~~~ Found 2 errors in 2 files. Errors Files 1 node_modules/@types/chokidar/index.d.ts:21 1 node_modules/chokidar/types/index.d.ts:8 Refs https://github.com/paulmillr/chokidar/commit/a0f9e09f64ce7ae70cc6ae1f5615f65cb35f532f * chore: update core types * temp: fix layer validation * chore: update nodejs checksums * ci: use latest v20 LTS for missing node-gyp Refs https://github.com/npm/cli/commit/eacec5f49060d3dfcdc3c7043115619e4bb22864 * ci: define LIBCPP_HARDENING_MODE * ci: fix crash in vscode-web-min-ci * chore: update rpm deps-list * chore: bump tree-sitter-typescript@0.20.5 * chore: bump electron@29.3.0 * chore: bump electron@29.3.1 * chore: update rpm deps-list for x86_64 * ci: disable io_uring UV backend on linux * ci: disable io_uring backend for oss as well * chore: update typings to 20.x * ci: add TODO for io_uring workaround * chore: bump distro * chore: update preinstall node version checks * chore: update @types/gulp Refs https://github.com/microsoft/vscode/issues/212442 * ci: disable io_uring in more test suites
2024-05-10 16:20:28 +00:00
'Blob',
'crypto',
'File',
'fetch',
'RequestInit',
'Headers',
'Response',
'__global'
];
// Types that are defined in a common layer but are known to be only
// available in native environments should not be allowed in browser
const NATIVE_TYPES = [
'NativeParsedArgs',
'INativeEnvironmentService',
'AbstractNativeEnvironmentService',
'INativeWindowConfiguration',
'ICommonNativeHostService',
'INativeHostService',
'IMainProcessService'
];
const RULES = [
// Tests: skip
{
target: '**/vs/**/test/**',
skip: true // -> skip all test files
},
// Common: vs/base/common/platform.ts
{
target: '**/vs/base/common/platform.ts',
allowedTypes: [
...CORE_TYPES,
// Safe access to postMessage() and friends
'MessageEvent',
],
disallowedTypes: NATIVE_TYPES,
disallowedDefinitions: [
'lib.dom.d.ts', // no DOM
'@types/node' // no node.js
]
},
// Common: vs/base/common/async.ts
{
target: '**/vs/base/common/async.ts',
allowedTypes: [
...CORE_TYPES,
// Safe access to requestIdleCallback & cancelIdleCallback
'requestIdleCallback',
'cancelIdleCallback'
],
disallowedTypes: NATIVE_TYPES,
disallowedDefinitions: [
'lib.dom.d.ts', // no DOM
'@types/node' // no node.js
]
},
// Common: vs/platform/environment/common/*
{
target: '**/vs/platform/environment/common/*.ts',
allowedTypes: CORE_TYPES,
chore: update to electron 16 (#137241) * chore: bump electron@15.3.0 * chore: bump node@16.x * chore: enable render process reuse * Revert "watcher - use `type` property for crash reporter location" This reverts commit bfa488dd8f23813bb7b52eaa768a748a4ecaa25c. * Revert "watcher - enable crash reports on linux (#136264)" This reverts commit af261488f85d90d7de5c651741f7fdf65c79cfce. * chore: enable crashpad on linux * chore: bump electron@15.3.1 * chore: update api changes * chore: bump @vscode/sqlite3@5.0.3 * spec: skip non-context aware module unittests * chore: fix perf hook integration with node environment * fix: adopt fs api changes * chore: fix integration tests * chore: bump electron@15.3.2 * chore: bump electron@16.0.0 * temp(macOS): kill test instances in OSS * Revert "temp(macOS): kill test instances in OSS" This reverts commit b0d796c8d64227a5ec012c060bbbee7d9da27568. * chore: update chromium version for clang downloader * some :lipstick: changes * align with changes * adopt more fs.rm * :lipstick: * chore: bump @vscode/sqlite3@5.0.4 * fix layers check to account for duplicated types from node.js * update todo for type casts * smoke - fix compile issue * chore: update module cache * watcher - fix unhandled rejection (fix #137416) * ci: update node version * enable stack dumping * update electron types to 16.x * chore: bump @vscode/sqlite3@5.0.5 Refs https://github.com/microsoft/vscode/issues/137496 * fix layer issue * add `AbortSignal` to core types * chore: update linux compile flags Refs https://github.com/electron/electron/pull/29895/commits/797723ec838709ddeba0c104e30727ee0b7ac8ca * ci: fix linux build * ci: update github ci cache * ci: fix remote build in github ci * ci: better fix for remote build * chore: bump azure cache * chore: fix merge conflict * :chore: update to electron@16.0.2 * chore: bump @vscode/sqlite3@5.0.7 * ci: update to gcc-4.9 for remote Refs https://github.com/microsoft/vscode/issues/137659 * ci: switch to buster for linux arm Refs https://github.com/microsoft/vscode/issues/137927 * ci: fix build on linux arm64 * ci: fix arm client compiler toolchain Refs #137927 * chore: bump electron@16.0.3 * ci: fix compile flags for the c toolchain * chore: bump electron@16.0.4 * Add experimental dark mode flag (#139109) * Add experimental dark mode flag * Apply PR feedback * chore: bump electron@16.0.6 * chore: bump electron@16.0.7 Fixes https://github.com/microsoft/vscode/issues/138792 Fixes https://github.com/microsoft/vscode/issues/139300 * chore: experimental highlight API * smoke - fix compile issue * FIXME: custom ELECTRON_RUN_AS_NODE with node worker * Revert "chore: bump electron@16.0.7" This reverts commit 5fd01cf37c75de247e4da158f517afada410648f. * Revert "Revert "chore: bump electron@16.0.7"" This reverts commit a7f1b7395175418c74fe0041560eb3f0423d4d27. * chore: fix github linux workflow * chore: address review feedback * chore: bump electron@16.0.8 * ci: revert to stretch distro for linux arm Refs https://github.com/microsoft/vscode/issues/137927 * ci: force build * chore: update yarn.lock * address feedback * Revert "FIXME: custom ELECTRON_RUN_AS_NODE with node worker" This reverts commit 7b48fa37329aa1eef59f8182d9da63c20e6fc1ee. * ci: fix remote folder build * chore: fix github linux ci * :up: `versionSpec` Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com> Co-authored-by: Raymond Zhao <raymondzhao@microsoft.com>
2022-02-08 19:09:00 +00:00
disallowedTypes: [ /* Ignore native types that are defined from here */],
disallowedDefinitions: [
'lib.dom.d.ts', // no DOM
'@types/node' // no node.js
]
},
2022-02-14 07:41:24 +00:00
// Common: vs/platform/window/common/window.ts
{
2022-02-14 07:41:24 +00:00
target: '**/vs/platform/window/common/window.ts',
allowedTypes: CORE_TYPES,
chore: update to electron 16 (#137241) * chore: bump electron@15.3.0 * chore: bump node@16.x * chore: enable render process reuse * Revert "watcher - use `type` property for crash reporter location" This reverts commit bfa488dd8f23813bb7b52eaa768a748a4ecaa25c. * Revert "watcher - enable crash reports on linux (#136264)" This reverts commit af261488f85d90d7de5c651741f7fdf65c79cfce. * chore: enable crashpad on linux * chore: bump electron@15.3.1 * chore: update api changes * chore: bump @vscode/sqlite3@5.0.3 * spec: skip non-context aware module unittests * chore: fix perf hook integration with node environment * fix: adopt fs api changes * chore: fix integration tests * chore: bump electron@15.3.2 * chore: bump electron@16.0.0 * temp(macOS): kill test instances in OSS * Revert "temp(macOS): kill test instances in OSS" This reverts commit b0d796c8d64227a5ec012c060bbbee7d9da27568. * chore: update chromium version for clang downloader * some :lipstick: changes * align with changes * adopt more fs.rm * :lipstick: * chore: bump @vscode/sqlite3@5.0.4 * fix layers check to account for duplicated types from node.js * update todo for type casts * smoke - fix compile issue * chore: update module cache * watcher - fix unhandled rejection (fix #137416) * ci: update node version * enable stack dumping * update electron types to 16.x * chore: bump @vscode/sqlite3@5.0.5 Refs https://github.com/microsoft/vscode/issues/137496 * fix layer issue * add `AbortSignal` to core types * chore: update linux compile flags Refs https://github.com/electron/electron/pull/29895/commits/797723ec838709ddeba0c104e30727ee0b7ac8ca * ci: fix linux build * ci: update github ci cache * ci: fix remote build in github ci * ci: better fix for remote build * chore: bump azure cache * chore: fix merge conflict * :chore: update to electron@16.0.2 * chore: bump @vscode/sqlite3@5.0.7 * ci: update to gcc-4.9 for remote Refs https://github.com/microsoft/vscode/issues/137659 * ci: switch to buster for linux arm Refs https://github.com/microsoft/vscode/issues/137927 * ci: fix build on linux arm64 * ci: fix arm client compiler toolchain Refs #137927 * chore: bump electron@16.0.3 * ci: fix compile flags for the c toolchain * chore: bump electron@16.0.4 * Add experimental dark mode flag (#139109) * Add experimental dark mode flag * Apply PR feedback * chore: bump electron@16.0.6 * chore: bump electron@16.0.7 Fixes https://github.com/microsoft/vscode/issues/138792 Fixes https://github.com/microsoft/vscode/issues/139300 * chore: experimental highlight API * smoke - fix compile issue * FIXME: custom ELECTRON_RUN_AS_NODE with node worker * Revert "chore: bump electron@16.0.7" This reverts commit 5fd01cf37c75de247e4da158f517afada410648f. * Revert "Revert "chore: bump electron@16.0.7"" This reverts commit a7f1b7395175418c74fe0041560eb3f0423d4d27. * chore: fix github linux workflow * chore: address review feedback * chore: bump electron@16.0.8 * ci: revert to stretch distro for linux arm Refs https://github.com/microsoft/vscode/issues/137927 * ci: force build * chore: update yarn.lock * address feedback * Revert "FIXME: custom ELECTRON_RUN_AS_NODE with node worker" This reverts commit 7b48fa37329aa1eef59f8182d9da63c20e6fc1ee. * ci: fix remote folder build * chore: fix github linux ci * :up: `versionSpec` Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com> Co-authored-by: Raymond Zhao <raymondzhao@microsoft.com>
2022-02-08 19:09:00 +00:00
disallowedTypes: [ /* Ignore native types that are defined from here */],
disallowedDefinitions: [
'lib.dom.d.ts', // no DOM
'@types/node' // no node.js
]
},
// Common: vs/platform/native/common/native.ts
{
target: '**/vs/platform/native/common/native.ts',
allowedTypes: CORE_TYPES,
chore: update to electron 16 (#137241) * chore: bump electron@15.3.0 * chore: bump node@16.x * chore: enable render process reuse * Revert "watcher - use `type` property for crash reporter location" This reverts commit bfa488dd8f23813bb7b52eaa768a748a4ecaa25c. * Revert "watcher - enable crash reports on linux (#136264)" This reverts commit af261488f85d90d7de5c651741f7fdf65c79cfce. * chore: enable crashpad on linux * chore: bump electron@15.3.1 * chore: update api changes * chore: bump @vscode/sqlite3@5.0.3 * spec: skip non-context aware module unittests * chore: fix perf hook integration with node environment * fix: adopt fs api changes * chore: fix integration tests * chore: bump electron@15.3.2 * chore: bump electron@16.0.0 * temp(macOS): kill test instances in OSS * Revert "temp(macOS): kill test instances in OSS" This reverts commit b0d796c8d64227a5ec012c060bbbee7d9da27568. * chore: update chromium version for clang downloader * some :lipstick: changes * align with changes * adopt more fs.rm * :lipstick: * chore: bump @vscode/sqlite3@5.0.4 * fix layers check to account for duplicated types from node.js * update todo for type casts * smoke - fix compile issue * chore: update module cache * watcher - fix unhandled rejection (fix #137416) * ci: update node version * enable stack dumping * update electron types to 16.x * chore: bump @vscode/sqlite3@5.0.5 Refs https://github.com/microsoft/vscode/issues/137496 * fix layer issue * add `AbortSignal` to core types * chore: update linux compile flags Refs https://github.com/electron/electron/pull/29895/commits/797723ec838709ddeba0c104e30727ee0b7ac8ca * ci: fix linux build * ci: update github ci cache * ci: fix remote build in github ci * ci: better fix for remote build * chore: bump azure cache * chore: fix merge conflict * :chore: update to electron@16.0.2 * chore: bump @vscode/sqlite3@5.0.7 * ci: update to gcc-4.9 for remote Refs https://github.com/microsoft/vscode/issues/137659 * ci: switch to buster for linux arm Refs https://github.com/microsoft/vscode/issues/137927 * ci: fix build on linux arm64 * ci: fix arm client compiler toolchain Refs #137927 * chore: bump electron@16.0.3 * ci: fix compile flags for the c toolchain * chore: bump electron@16.0.4 * Add experimental dark mode flag (#139109) * Add experimental dark mode flag * Apply PR feedback * chore: bump electron@16.0.6 * chore: bump electron@16.0.7 Fixes https://github.com/microsoft/vscode/issues/138792 Fixes https://github.com/microsoft/vscode/issues/139300 * chore: experimental highlight API * smoke - fix compile issue * FIXME: custom ELECTRON_RUN_AS_NODE with node worker * Revert "chore: bump electron@16.0.7" This reverts commit 5fd01cf37c75de247e4da158f517afada410648f. * Revert "Revert "chore: bump electron@16.0.7"" This reverts commit a7f1b7395175418c74fe0041560eb3f0423d4d27. * chore: fix github linux workflow * chore: address review feedback * chore: bump electron@16.0.8 * ci: revert to stretch distro for linux arm Refs https://github.com/microsoft/vscode/issues/137927 * ci: force build * chore: update yarn.lock * address feedback * Revert "FIXME: custom ELECTRON_RUN_AS_NODE with node worker" This reverts commit 7b48fa37329aa1eef59f8182d9da63c20e6fc1ee. * ci: fix remote folder build * chore: fix github linux ci * :up: `versionSpec` Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com> Co-authored-by: Raymond Zhao <raymondzhao@microsoft.com>
2022-02-08 19:09:00 +00:00
disallowedTypes: [ /* Ignore native types that are defined from here */],
disallowedDefinitions: [
'lib.dom.d.ts', // no DOM
'@types/node' // no node.js
]
},
// Common: vs/platform/native/common/nativeHostService.ts
{
target: '**/vs/platform/native/common/nativeHostService.ts',
allowedTypes: CORE_TYPES,
disallowedTypes: [ /* Ignore native types that are defined from here */],
disallowedDefinitions: [
'lib.dom.d.ts', // no DOM
'@types/node' // no node.js
]
},
// Common: vs/workbench/api/common/extHostExtensionService.ts
{
target: '**/vs/workbench/api/common/extHostExtensionService.ts',
allowedTypes: [
...CORE_TYPES,
// Safe access to global
'global'
],
disallowedTypes: NATIVE_TYPES,
disallowedDefinitions: [
'lib.dom.d.ts', // no DOM
'@types/node' // no node.js
]
},
// Common: vs/base/parts/sandbox/electron-sandbox/preload.js
chore: update to electron 29 (#209818) * chore: update electron@29.1.0 * chore: update typings to 20.x * chore: bump electron@29.1.5 * ci: fix crash in compiling extensions-ci * chore: disable .d.ts check for build/ $ ../node_modules/.bin/tsc -p tsconfig.build.json node_modules/@types/chokidar/index.d.ts:21:14 - error TS2420: Class 'import("/Users/demohan/github/vscode/build/node_modules/@types/chokidar/index").FSWatcher' incorrectly implements interface 'import("fs").FSWatcher'. Type 'FSWatcher' is missing the following properties from type 'FSWatcher': ref, unref 21 export class FSWatcher extends EventEmitter implements fs.FSWatcher { ~~~~~~~~~ node_modules/chokidar/types/index.d.ts:8:14 - error TS2420: Class 'import("/Users/demohan/github/vscode/build/node_modules/chokidar/types/index").FSWatcher' incorrectly implements interface 'import("fs").FSWatcher'. Type 'FSWatcher' is missing the following properties from type 'FSWatcher': ref, unref 8 export class FSWatcher extends EventEmitter implements fs.FSWatcher { ~~~~~~~~~ Found 2 errors in 2 files. Errors Files 1 node_modules/@types/chokidar/index.d.ts:21 1 node_modules/chokidar/types/index.d.ts:8 Refs https://github.com/paulmillr/chokidar/commit/a0f9e09f64ce7ae70cc6ae1f5615f65cb35f532f * chore: update core types * temp: fix layer validation * chore: update nodejs checksums * ci: use latest v20 LTS for missing node-gyp Refs https://github.com/npm/cli/commit/eacec5f49060d3dfcdc3c7043115619e4bb22864 * ci: define LIBCPP_HARDENING_MODE * ci: fix crash in vscode-web-min-ci * chore: update rpm deps-list * chore: bump tree-sitter-typescript@0.20.5 * chore: bump electron@29.3.0 * chore: bump electron@29.3.1 * chore: update rpm deps-list for x86_64 * ci: disable io_uring UV backend on linux * ci: disable io_uring backend for oss as well * chore: update typings to 20.x * ci: add TODO for io_uring workaround * chore: bump distro * chore: update preinstall node version checks * chore: update @types/gulp Refs https://github.com/microsoft/vscode/issues/212442 * ci: disable io_uring in more test suites
2024-05-10 16:20:28 +00:00
{
target: '**/vs/base/parts/sandbox/electron-sandbox/preload.js',
chore: update to electron 29 (#209818) * chore: update electron@29.1.0 * chore: update typings to 20.x * chore: bump electron@29.1.5 * ci: fix crash in compiling extensions-ci * chore: disable .d.ts check for build/ $ ../node_modules/.bin/tsc -p tsconfig.build.json node_modules/@types/chokidar/index.d.ts:21:14 - error TS2420: Class 'import("/Users/demohan/github/vscode/build/node_modules/@types/chokidar/index").FSWatcher' incorrectly implements interface 'import("fs").FSWatcher'. Type 'FSWatcher' is missing the following properties from type 'FSWatcher': ref, unref 21 export class FSWatcher extends EventEmitter implements fs.FSWatcher { ~~~~~~~~~ node_modules/chokidar/types/index.d.ts:8:14 - error TS2420: Class 'import("/Users/demohan/github/vscode/build/node_modules/chokidar/types/index").FSWatcher' incorrectly implements interface 'import("fs").FSWatcher'. Type 'FSWatcher' is missing the following properties from type 'FSWatcher': ref, unref 8 export class FSWatcher extends EventEmitter implements fs.FSWatcher { ~~~~~~~~~ Found 2 errors in 2 files. Errors Files 1 node_modules/@types/chokidar/index.d.ts:21 1 node_modules/chokidar/types/index.d.ts:8 Refs https://github.com/paulmillr/chokidar/commit/a0f9e09f64ce7ae70cc6ae1f5615f65cb35f532f * chore: update core types * temp: fix layer validation * chore: update nodejs checksums * ci: use latest v20 LTS for missing node-gyp Refs https://github.com/npm/cli/commit/eacec5f49060d3dfcdc3c7043115619e4bb22864 * ci: define LIBCPP_HARDENING_MODE * ci: fix crash in vscode-web-min-ci * chore: update rpm deps-list * chore: bump tree-sitter-typescript@0.20.5 * chore: bump electron@29.3.0 * chore: bump electron@29.3.1 * chore: update rpm deps-list for x86_64 * ci: disable io_uring UV backend on linux * ci: disable io_uring backend for oss as well * chore: update typings to 20.x * ci: add TODO for io_uring workaround * chore: bump distro * chore: update preinstall node version checks * chore: update @types/gulp Refs https://github.com/microsoft/vscode/issues/212442 * ci: disable io_uring in more test suites
2024-05-10 16:20:28 +00:00
allowedTypes: [
...CORE_TYPES,
// Safe access to a very small subset of node.js
'process',
'NodeJS'
chore: update to electron 29 (#209818) * chore: update electron@29.1.0 * chore: update typings to 20.x * chore: bump electron@29.1.5 * ci: fix crash in compiling extensions-ci * chore: disable .d.ts check for build/ $ ../node_modules/.bin/tsc -p tsconfig.build.json node_modules/@types/chokidar/index.d.ts:21:14 - error TS2420: Class 'import("/Users/demohan/github/vscode/build/node_modules/@types/chokidar/index").FSWatcher' incorrectly implements interface 'import("fs").FSWatcher'. Type 'FSWatcher' is missing the following properties from type 'FSWatcher': ref, unref 21 export class FSWatcher extends EventEmitter implements fs.FSWatcher { ~~~~~~~~~ node_modules/chokidar/types/index.d.ts:8:14 - error TS2420: Class 'import("/Users/demohan/github/vscode/build/node_modules/chokidar/types/index").FSWatcher' incorrectly implements interface 'import("fs").FSWatcher'. Type 'FSWatcher' is missing the following properties from type 'FSWatcher': ref, unref 8 export class FSWatcher extends EventEmitter implements fs.FSWatcher { ~~~~~~~~~ Found 2 errors in 2 files. Errors Files 1 node_modules/@types/chokidar/index.d.ts:21 1 node_modules/chokidar/types/index.d.ts:8 Refs https://github.com/paulmillr/chokidar/commit/a0f9e09f64ce7ae70cc6ae1f5615f65cb35f532f * chore: update core types * temp: fix layer validation * chore: update nodejs checksums * ci: use latest v20 LTS for missing node-gyp Refs https://github.com/npm/cli/commit/eacec5f49060d3dfcdc3c7043115619e4bb22864 * ci: define LIBCPP_HARDENING_MODE * ci: fix crash in vscode-web-min-ci * chore: update rpm deps-list * chore: bump tree-sitter-typescript@0.20.5 * chore: bump electron@29.3.0 * chore: bump electron@29.3.1 * chore: update rpm deps-list for x86_64 * ci: disable io_uring UV backend on linux * ci: disable io_uring backend for oss as well * chore: update typings to 20.x * ci: add TODO for io_uring workaround * chore: bump distro * chore: update preinstall node version checks * chore: update @types/gulp Refs https://github.com/microsoft/vscode/issues/212442 * ci: disable io_uring in more test suites
2024-05-10 16:20:28 +00:00
],
disallowedTypes: NATIVE_TYPES,
disallowedDefinitions: [
'@types/node' // no node.js
]
},
// Common
{
target: '**/vs/**/common/**',
allowedTypes: CORE_TYPES,
disallowedTypes: NATIVE_TYPES,
disallowedDefinitions: [
'lib.dom.d.ts', // no DOM
'@types/node' // no node.js
]
},
// Browser
{
target: '**/vs/**/browser/**',
allowedTypes: CORE_TYPES,
disallowedTypes: NATIVE_TYPES,
allowedDefinitions: [
'@types/node/stream/consumers.d.ts' // node.js started to duplicate types from lib.dom.d.ts so we have to account for that
],
disallowedDefinitions: [
'@types/node' // no node.js
]
},
// Browser (editor contrib)
{
target: '**/src/vs/editor/contrib/**',
allowedTypes: CORE_TYPES,
disallowedTypes: NATIVE_TYPES,
disallowedDefinitions: [
'@types/node' // no node.js
]
},
// node.js
{
target: '**/vs/**/node/**',
2022-04-04 13:04:29 +00:00
allowedTypes: CORE_TYPES,
disallowedDefinitions: [
'lib.dom.d.ts' // no DOM
]
},
// Electron (sandbox)
{
target: '**/vs/**/electron-sandbox/**',
allowedTypes: CORE_TYPES,
disallowedDefinitions: [
'@types/node' // no node.js
]
},
// Electron (main)
{
target: '**/vs/**/electron-main/**',
allowedTypes: [
...CORE_TYPES,
// --> types from electron.d.ts that duplicate from lib.dom.d.ts
'Event',
'Request'
],
2022-04-12 05:46:17 +00:00
disallowedTypes: [
'ipcMain' // not allowed, use validatedIpcMain instead
],
disallowedDefinitions: [
'lib.dom.d.ts' // no DOM
]
}
];
const TS_CONFIG_PATH = (0, path_1.join)(__dirname, '../../', 'src', 'tsconfig.json');
let hasErrors = false;
function checkFile(program, sourceFile, rule) {
checkNode(sourceFile);
function checkNode(node) {
if (node.kind !== ts.SyntaxKind.Identifier) {
return ts.forEachChild(node, checkNode); // recurse down
}
2022-04-04 13:04:29 +00:00
const checker = program.getTypeChecker();
const symbol = checker.getSymbolAtLocation(node);
if (!symbol) {
return;
}
let _parentSymbol = symbol;
while (_parentSymbol.parent) {
_parentSymbol = _parentSymbol.parent;
}
const parentSymbol = _parentSymbol;
const text = parentSymbol.getName();
2022-02-28 22:00:17 +00:00
if (rule.allowedTypes?.some(allowed => allowed === text)) {
return; // override
}
2022-02-28 22:00:17 +00:00
if (rule.disallowedTypes?.some(disallowed => disallowed === text)) {
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
console.log(`[build/lib/layersChecker.ts]: Reference to type '${text}' violates layer '${rule.target}' (${sourceFile.fileName} (${line + 1},${character + 1}). Learn more about our source code organization at https://github.com/microsoft/vscode/wiki/Source-Code-Organization.`);
hasErrors = true;
return;
}
2022-04-04 13:04:29 +00:00
const declarations = symbol.declarations;
if (Array.isArray(declarations)) {
DeclarationLoop: for (const declaration of declarations) {
if (declaration) {
const parent = declaration.parent;
if (parent) {
const parentSourceFile = parent.getSourceFile();
if (parentSourceFile) {
const definitionFileName = parentSourceFile.fileName;
if (rule.allowedDefinitions) {
for (const allowedDefinition of rule.allowedDefinitions) {
if (definitionFileName.indexOf(allowedDefinition) >= 0) {
continue DeclarationLoop;
chore: update to electron 16 (#137241) * chore: bump electron@15.3.0 * chore: bump node@16.x * chore: enable render process reuse * Revert "watcher - use `type` property for crash reporter location" This reverts commit bfa488dd8f23813bb7b52eaa768a748a4ecaa25c. * Revert "watcher - enable crash reports on linux (#136264)" This reverts commit af261488f85d90d7de5c651741f7fdf65c79cfce. * chore: enable crashpad on linux * chore: bump electron@15.3.1 * chore: update api changes * chore: bump @vscode/sqlite3@5.0.3 * spec: skip non-context aware module unittests * chore: fix perf hook integration with node environment * fix: adopt fs api changes * chore: fix integration tests * chore: bump electron@15.3.2 * chore: bump electron@16.0.0 * temp(macOS): kill test instances in OSS * Revert "temp(macOS): kill test instances in OSS" This reverts commit b0d796c8d64227a5ec012c060bbbee7d9da27568. * chore: update chromium version for clang downloader * some :lipstick: changes * align with changes * adopt more fs.rm * :lipstick: * chore: bump @vscode/sqlite3@5.0.4 * fix layers check to account for duplicated types from node.js * update todo for type casts * smoke - fix compile issue * chore: update module cache * watcher - fix unhandled rejection (fix #137416) * ci: update node version * enable stack dumping * update electron types to 16.x * chore: bump @vscode/sqlite3@5.0.5 Refs https://github.com/microsoft/vscode/issues/137496 * fix layer issue * add `AbortSignal` to core types * chore: update linux compile flags Refs https://github.com/electron/electron/pull/29895/commits/797723ec838709ddeba0c104e30727ee0b7ac8ca * ci: fix linux build * ci: update github ci cache * ci: fix remote build in github ci * ci: better fix for remote build * chore: bump azure cache * chore: fix merge conflict * :chore: update to electron@16.0.2 * chore: bump @vscode/sqlite3@5.0.7 * ci: update to gcc-4.9 for remote Refs https://github.com/microsoft/vscode/issues/137659 * ci: switch to buster for linux arm Refs https://github.com/microsoft/vscode/issues/137927 * ci: fix build on linux arm64 * ci: fix arm client compiler toolchain Refs #137927 * chore: bump electron@16.0.3 * ci: fix compile flags for the c toolchain * chore: bump electron@16.0.4 * Add experimental dark mode flag (#139109) * Add experimental dark mode flag * Apply PR feedback * chore: bump electron@16.0.6 * chore: bump electron@16.0.7 Fixes https://github.com/microsoft/vscode/issues/138792 Fixes https://github.com/microsoft/vscode/issues/139300 * chore: experimental highlight API * smoke - fix compile issue * FIXME: custom ELECTRON_RUN_AS_NODE with node worker * Revert "chore: bump electron@16.0.7" This reverts commit 5fd01cf37c75de247e4da158f517afada410648f. * Revert "Revert "chore: bump electron@16.0.7"" This reverts commit a7f1b7395175418c74fe0041560eb3f0423d4d27. * chore: fix github linux workflow * chore: address review feedback * chore: bump electron@16.0.8 * ci: revert to stretch distro for linux arm Refs https://github.com/microsoft/vscode/issues/137927 * ci: force build * chore: update yarn.lock * address feedback * Revert "FIXME: custom ELECTRON_RUN_AS_NODE with node worker" This reverts commit 7b48fa37329aa1eef59f8182d9da63c20e6fc1ee. * ci: fix remote folder build * chore: fix github linux ci * :up: `versionSpec` Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com> Co-authored-by: Raymond Zhao <raymondzhao@microsoft.com>
2022-02-08 19:09:00 +00:00
}
}
2022-04-04 13:04:29 +00:00
}
if (rule.disallowedDefinitions) {
for (const disallowedDefinition of rule.disallowedDefinitions) {
if (definitionFileName.indexOf(disallowedDefinition) >= 0) {
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
console.log(`[build/lib/layersChecker.ts]: Reference to symbol '${text}' from '${disallowedDefinition}' violates layer '${rule.target}' (${sourceFile.fileName} (${line + 1},${character + 1}) Learn more about our source code organization at https://github.com/microsoft/vscode/wiki/Source-Code-Organization.`);
2022-04-04 13:04:29 +00:00
hasErrors = true;
return;
}
}
}
}
}
}
}
}
}
}
function createProgram(tsconfigPath) {
const tsConfig = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
const configHostParser = { fileExists: fs_1.existsSync, readDirectory: ts.sys.readDirectory, readFile: file => (0, fs_1.readFileSync)(file, 'utf8'), useCaseSensitiveFileNames: process.platform === 'linux' };
const tsConfigParsed = ts.parseJsonConfigFileContent(tsConfig.config, configHostParser, (0, path_1.resolve)((0, path_1.dirname)(tsconfigPath)), { noEmit: true });
const compilerHost = ts.createCompilerHost(tsConfigParsed.options, true);
return ts.createProgram(tsConfigParsed.fileNames, tsConfigParsed.options, compilerHost);
}
//
// Create program and start checking
//
const program = createProgram(TS_CONFIG_PATH);
for (const sourceFile of program.getSourceFiles()) {
for (const rule of RULES) {
if ((0, minimatch_1.match)([sourceFile.fileName], rule.target).length > 0) {
if (!rule.skip) {
checkFile(program, sourceFile, rule);
}
break;
}
}
}
if (hasErrors) {
process.exit(1);
}
//# sourceMappingURL=layersChecker.js.map