Skip to content

Commit 095334e

Browse files
authored
Merge branch 'main' into fix-146732
2 parents 7f96f91 + 916afeb commit 095334e

File tree

1,900 files changed

+103561
-54800
lines changed

Some content is hidden

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

1,900 files changed

+103561
-54800
lines changed

.configurations/configuration.dsc.yaml

+1-12
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ properties:
1818
id: OpenJS.NodeJS.LTS
1919
version: "20.14.0"
2020
source: winget
21-
- resource: NpmDsc/NpmPackage
22-
id: yarn
23-
dependsOn:
24-
- npm
25-
directives:
26-
description: Install Yarn
27-
allowPrerelease: true
28-
settings:
29-
Name: 'yarn'
30-
Global: true
31-
PackageDirectory: '${WinGetConfigRoot}\..\'
3221
- resource: Microsoft.WinGet.DSC/WinGetPackage
3322
directives:
3423
description: Install Python 3.10
@@ -56,7 +45,7 @@ properties:
5645
includeRecommended: true
5746
components:
5847
- Microsoft.VisualStudio.Workload.VCTools
59-
- resource: YarnDsc/YarnInstall
48+
- resource: NpmDsc/NpmInstall
6049
dependsOn:
6150
- npm
6251
directives:

.devcontainer/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ RUN git config --system codespaces-theme.hide-status 1
77

88
USER node
99
RUN npm install -g node-gyp
10-
RUN YARN_CACHE="$(yarn cache dir)" && rm -rf "$YARN_CACHE" && ln -s /vscode-dev/yarn-cache "$YARN_CACHE"
10+
RUN NPM_CACHE="$(npm config get cache)" && rm -rf "$NPM_CACHE" && ln -s /vscode-dev/npm-cache "$NPM_CACHE"
1111
RUN echo 'export DISPLAY="${DISPLAY:-:1}"' | tee -a ~/.bashrc >> ~/.zshrc
1212

1313
USER root
14-
CMD chown node:node /vscode-dev && sudo -u node mkdir -p /vscode-dev/yarn-cache && sleep inf
14+
CMD chown node:node /vscode-dev && sudo -u node mkdir -p /vscode-dev/npm-cache && sleep inf

.devcontainer/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ If you already have VS Code and Docker installed, you can click the badge above
2424
2525
4. Press <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> or <kbd>F1</kbd> and select **Dev Containers: Clone Repository in Container Volume...**.
2626

27-
> **Tip:** While you can use your local source tree instead, operations like `yarn install` can be slow on macOS or when using the Hyper-V engine on Windows. We recommend using the WSL filesystem on Windows or the "clone repository in container" approach on Windows and macOS instead since it uses "named volume" rather than the local filesystem.
27+
> **Tip:** While you can use your local source tree instead, operations like `npm i` can be slow on macOS or when using the Hyper-V engine on Windows. We recommend using the WSL filesystem on Windows or the "clone repository in container" approach on Windows and macOS instead since it uses "named volume" rather than the local filesystem.
2828
2929
5. Type `https://github.com/microsoft/vscode` (or a branch or PR URL) in the input box and press <kbd>Enter</kbd>.
3030

@@ -85,7 +85,7 @@ To start working with Code - OSS, follow these steps:
8585
1. In your local VS Code client, open a terminal (<kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>\`</kbd>) and type the following commands:
8686

8787
```bash
88-
yarn install
88+
npm i
8989
bash scripts/code.sh
9090
```
9191

.devcontainer/post-create.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22

3-
yarn install --network-timeout 180000
4-
yarn electron
3+
npm i
4+
npm run electron

.eslintignore renamed to .eslint-ignore

-8
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,7 @@
3030
**/src/vs/*/**/*.d.ts
3131
**/src/vs/base/test/common/filters.perf.data.js
3232
**/src/vs/loader.js
33-
**/src2/**/dompurify.js
34-
**/src2/**/marked.js
35-
**/src2/**/semver.js
36-
**/src2/typings/**/*.d.ts
37-
**/src2/vs/*/**/*.d.ts
38-
**/src2/vs/base/test/common/filters.perf.data.js
39-
**/src2/vs/loader.js
4033
**/test/unit/assert.js
41-
**/test/unit/assert-esm.js
4234
**/test/automation/out/**
4335
**/typings/**
4436
!.vscode

.eslintplugin/code-amd-node-module.ts renamed to .eslint-plugin-local/code-amd-node-module.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export = new class ApiProviderNaming implements eslint.Rule.RuleModule {
1212
readonly meta: eslint.Rule.RuleMetaData = {
1313
messages: {
1414
amdX: 'Use `import type` for import declarations, use `amdX#importAMDNodeModule` for import expressions'
15-
}
15+
},
16+
schema: false,
1617
};
1718

1819
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {

.eslintplugin/code-declare-service-brand.ts renamed to .eslint-plugin-local/code-declare-service-brand.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import * as eslint from 'eslint';
88
export = new class DeclareServiceBrand implements eslint.Rule.RuleModule {
99

1010
readonly meta: eslint.Rule.RuleMetaData = {
11-
fixable: 'code'
11+
fixable: 'code',
12+
schema: false,
1213
};
1314

1415
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {

.eslintplugin/code-ensure-no-disposables-leak-in-test.ts renamed to .eslint-plugin-local/code-ensure-no-disposables-leak-in-test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export = new class EnsureNoDisposablesAreLeakedInTestSuite implements eslint.Rul
1313
messages: {
1414
ensure: 'Suites should include a call to `ensureNoDisposablesAreLeakedInTestSuite()` to ensure no disposables are leaked in tests.'
1515
},
16-
fixable: 'code'
16+
fixable: 'code',
17+
schema: false,
1718
};
1819

1920
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {

.eslintplugin/code-import-patterns.ts renamed to .eslint-plugin-local/code-import-patterns.ts

+20-9
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as eslint from 'eslint';
7-
import { TSESTree } from '@typescript-eslint/experimental-utils';
7+
import { TSESTree } from '@typescript-eslint/utils';
88
import * as path from 'path';
99
import minimatch from 'minimatch';
1010
import { createImportRuleListener } from './utils';
1111

1212
const REPO_ROOT = path.normalize(path.join(__dirname, '../'));
1313

1414
interface ConditionalPattern {
15-
when?: 'hasBrowser' | 'hasNode' | 'test';
15+
when?: 'hasBrowser' | 'hasNode' | 'hasElectron' | 'test';
1616
pattern: string;
1717
}
1818

1919
interface RawImportPatternsConfig {
2020
target: string;
21-
layer?: 'common' | 'worker' | 'browser' | 'electron-sandbox' | 'node' | 'electron-main';
21+
layer?: 'common' | 'worker' | 'browser' | 'electron-sandbox' | 'node' | 'electron-utility' | 'electron-main';
2222
test?: boolean;
2323
restrictions: string | (string | ConditionalPattern)[];
2424
}
2525

2626
interface LayerAllowRule {
27-
when: 'hasBrowser' | 'hasNode' | 'test';
27+
when: 'hasBrowser' | 'hasNode' | 'hasElectron' | 'test';
2828
allow: string[];
2929
}
3030

@@ -50,7 +50,8 @@ export = new class implements eslint.Rule.RuleModule {
5050
},
5151
docs: {
5252
url: 'https://github.com/microsoft/vscode/wiki/Source-Code-Organization'
53-
}
53+
},
54+
schema: false,
5455
};
5556

5657
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
@@ -79,13 +80,14 @@ export = new class implements eslint.Rule.RuleModule {
7980
return this._optionsCache.get(options)!;
8081
}
8182

82-
type Layer = 'common' | 'worker' | 'browser' | 'electron-sandbox' | 'node' | 'electron-main';
83+
type Layer = 'common' | 'worker' | 'browser' | 'electron-sandbox' | 'node' | 'electron-utility' | 'electron-main';
8384

8485
interface ILayerRule {
8586
layer: Layer;
8687
deps: string;
8788
isBrowser?: boolean;
8889
isNode?: boolean;
90+
isElectron?: boolean;
8991
}
9092

9193
function orSegment(variants: Layer[]): string {
@@ -98,18 +100,22 @@ export = new class implements eslint.Rule.RuleModule {
98100
{ layer: 'browser', deps: orSegment(['common', 'browser']), isBrowser: true },
99101
{ layer: 'electron-sandbox', deps: orSegment(['common', 'browser', 'electron-sandbox']), isBrowser: true },
100102
{ layer: 'node', deps: orSegment(['common', 'node']), isNode: true },
101-
{ layer: 'electron-main', deps: orSegment(['common', 'node', 'electron-main']), isNode: true },
103+
{ layer: 'electron-utility', deps: orSegment(['common', 'node', 'electron-utility']), isNode: true, isElectron: true },
104+
{ layer: 'electron-main', deps: orSegment(['common', 'node', 'electron-utility', 'electron-main']), isNode: true, isElectron: true },
102105
];
103106

104107
let browserAllow: string[] = [];
105108
let nodeAllow: string[] = [];
109+
let electronAllow: string[] = [];
106110
let testAllow: string[] = [];
107111
for (const option of options) {
108112
if (isLayerAllowRule(option)) {
109113
if (option.when === 'hasBrowser') {
110114
browserAllow = option.allow.slice(0);
111115
} else if (option.when === 'hasNode') {
112116
nodeAllow = option.allow.slice(0);
117+
} else if (option.when === 'hasElectron') {
118+
electronAllow = option.allow.slice(0);
113119
} else if (option.when === 'test') {
114120
testAllow = option.allow.slice(0);
115121
}
@@ -137,9 +143,13 @@ export = new class implements eslint.Rule.RuleModule {
137143
restrictions.push(...nodeAllow);
138144
}
139145

146+
if (layerRule.isElectron) {
147+
restrictions.push(...electronAllow);
148+
}
149+
140150
for (const rawRestriction of rawRestrictions) {
141151
let importPattern: string;
142-
let when: 'hasBrowser' | 'hasNode' | 'test' | undefined = undefined;
152+
let when: 'hasBrowser' | 'hasNode' | 'hasElectron' | 'test' | undefined = undefined;
143153
if (typeof rawRestriction === 'string') {
144154
importPattern = rawRestriction;
145155
} else {
@@ -149,6 +159,7 @@ export = new class implements eslint.Rule.RuleModule {
149159
if (typeof when === 'undefined'
150160
|| (when === 'hasBrowser' && layerRule.isBrowser)
151161
|| (when === 'hasNode' && layerRule.isNode)
162+
|| (when === 'hasElectron' && layerRule.isElectron)
152163
) {
153164
restrictions.push(importPattern.replace(/\/\~$/, `/${layerRule.deps}/**`));
154165
testRestrictions.push(importPattern.replace(/\/\~$/, `/test/${layerRule.deps}/**`));
@@ -239,7 +250,7 @@ export = new class implements eslint.Rule.RuleModule {
239250
const relativeFilename = getRelativeFilename(context);
240251
importPath = path.posix.join(path.posix.dirname(relativeFilename), importPath);
241252
if (/^src\/vs\//.test(importPath)) {
242-
// resolve using AMD base url
253+
// resolve using base url
243254
importPath = importPath.substring('src/'.length);
244255
}
245256
}

.eslintplugin/code-layering.ts renamed to .eslint-plugin-local/code-layering.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,18 @@ export = new class implements eslint.Rule.RuleModule {
2020
},
2121
docs: {
2222
url: 'https://github.com/microsoft/vscode/wiki/Source-Code-Organization'
23-
}
23+
},
24+
schema: [
25+
{
26+
type: 'object',
27+
additionalProperties: {
28+
type: 'array',
29+
items: {
30+
type: 'string'
31+
}
32+
}
33+
}
34+
]
2435
};
2536

2637
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as eslint from 'eslint';
7+
import { dirname, relative } from 'path';
8+
import minimatch from 'minimatch';
9+
10+
export = new class implements eslint.Rule.RuleModule {
11+
12+
readonly meta: eslint.Rule.RuleMetaData = {
13+
messages: {
14+
layerbreaker: 'You are only allowed to define limited top level functions.'
15+
},
16+
schema: {
17+
type: "array",
18+
items: {
19+
type: "object",
20+
additionalProperties: {
21+
type: "array",
22+
items: {
23+
type: "string"
24+
}
25+
}
26+
}
27+
}
28+
};
29+
30+
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
31+
let fileRelativePath = relative(dirname(__dirname), context.getFilename());
32+
if (!fileRelativePath.endsWith('/')) {
33+
fileRelativePath += '/';
34+
}
35+
const ruleArgs = <Record<string, string[]>>context.options[0];
36+
37+
const matchingKey = Object.keys(ruleArgs).find(key => fileRelativePath.startsWith(key) || minimatch(fileRelativePath, key));
38+
if (!matchingKey) {
39+
// nothing
40+
return {};
41+
}
42+
43+
const restrictedFunctions = ruleArgs[matchingKey];
44+
45+
return {
46+
FunctionDeclaration: (node: any) => {
47+
const isTopLevel = node.parent.type === 'Program';
48+
const functionName = node.id.name;
49+
if (isTopLevel && !restrictedFunctions.includes(node.id.name)) {
50+
context.report({
51+
node,
52+
message: `Top-level function '${functionName}' is restricted in this file. Allowed functions are: ${restrictedFunctions.join(', ')}.`
53+
});
54+
}
55+
},
56+
ExportNamedDeclaration(node: any) {
57+
if (node.declaration && node.declaration.type === 'FunctionDeclaration') {
58+
const functionName = node.declaration.id.name;
59+
const isTopLevel = node.parent.type === 'Program';
60+
if (isTopLevel && !restrictedFunctions.includes(node.declaration.id.name)) {
61+
context.report({
62+
node,
63+
message: `Top-level function '${functionName}' is restricted in this file. Allowed functions are: ${restrictedFunctions.join(', ')}.`
64+
});
65+
}
66+
}
67+
}
68+
}
69+
}
70+
};

.eslintplugin/code-must-use-result.ts renamed to .eslint-plugin-local/code-must-use-result.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as eslint from 'eslint';
7-
import { TSESTree } from '@typescript-eslint/experimental-utils';
7+
import { TSESTree } from '@typescript-eslint/utils';
88

99
const VALID_USES = new Set<TSESTree.AST_NODE_TYPES | undefined>([
1010
TSESTree.AST_NODE_TYPES.AwaitExpression,
1111
TSESTree.AST_NODE_TYPES.VariableDeclarator,
1212
]);
1313

1414
export = new class MustUseResults implements eslint.Rule.RuleModule {
15+
readonly meta: eslint.Rule.RuleMetaData = {
16+
schema: false
17+
}
1518

1619
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
1720

.eslintplugin/code-no-dangerous-type-assertions.ts renamed to .eslint-plugin-local/code-no-dangerous-type-assertions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as eslint from 'eslint';
7-
import { TSESTree } from '@typescript-eslint/experimental-utils';
7+
import { TSESTree } from '@typescript-eslint/utils';
88

99
export = new class NoDangerousTypeAssertions implements eslint.Rule.RuleModule {
1010

.eslintplugin/code-no-native-private.ts renamed to .eslint-plugin-local/code-no-native-private.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export = new class ApiProviderNaming implements eslint.Rule.RuleModule {
1010
readonly meta: eslint.Rule.RuleMetaData = {
1111
messages: {
1212
slow: 'Native private fields are much slower and should only be used when needed. Ignore this warning if you know what you are doing, use compile-time private otherwise. See https://github.com/microsoft/vscode/issues/185991#issuecomment-1614468158 for details',
13-
}
13+
},
14+
schema: false,
1415
};
1516

1617
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {

.eslintplugin/code-no-nls-in-standalone-editor.ts renamed to .eslint-plugin-local/code-no-nls-in-standalone-editor.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export = new class NoNlsInStandaloneEditorRule implements eslint.Rule.RuleModule
1212
readonly meta: eslint.Rule.RuleMetaData = {
1313
messages: {
1414
noNls: 'Not allowed to import vs/nls in standalone editor modules. Use standaloneStrings.ts'
15-
}
15+
},
16+
schema: false,
1617
};
1718

1819
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {

.eslintplugin/code-no-standalone-editor.ts renamed to .eslint-plugin-local/code-no-standalone-editor.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export = new class NoNlsInStandaloneEditorRule implements eslint.Rule.RuleModule
1515
},
1616
docs: {
1717
url: 'https://github.com/microsoft/vscode/wiki/Source-Code-Organization'
18-
}
18+
},
19+
schema: false,
1920
};
2021

2122
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {

.eslintplugin/code-no-static-self-ref.ts renamed to .eslint-plugin-local/code-no-static-self-ref.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as eslint from 'eslint';
7-
import { TSESTree } from '@typescript-eslint/experimental-utils';
7+
import { TSESTree } from '@typescript-eslint/utils';
88

99
/**
1010
* WORKAROUND for https://github.com/evanw/esbuild/issues/3823
@@ -15,7 +15,7 @@ export = new class implements eslint.Rule.RuleModule {
1515

1616
function checkProperty(inNode: any) {
1717

18-
const classDeclaration = context.getAncestors().find(node => node.type === 'ClassDeclaration');
18+
const classDeclaration = context.sourceCode.getAncestors(inNode).find(node => node.type === 'ClassDeclaration');
1919
const propertyDefinition = <TSESTree.PropertyDefinition>inNode;
2020

2121
if (!classDeclaration || !classDeclaration.id?.name) {
@@ -33,7 +33,7 @@ export = new class implements eslint.Rule.RuleModule {
3333
}
3434

3535
const name = classDeclaration.id.name;
36-
const valueText = context.getSourceCode().getText(<any>propertyDefinition.value)
36+
const valueText = context.sourceCode.getText(<any>propertyDefinition.value)
3737

3838
if (valueText.includes(name + '.')) {
3939

0 commit comments

Comments
 (0)