Skip to content

Commit

Permalink
Merge upstream 1.95 into Positron (#5678)
Browse files Browse the repository at this point in the history
Merges upstream changes from vscode-server and VS Code 1.95 into
Positron.

---------

Co-authored-by: positron-bot[bot] <173392469+positron-bot[bot]@users.noreply.github.com>
Co-authored-by: Brian Lambert <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2024
1 parent b63cb63 commit 476ac29
Show file tree
Hide file tree
Showing 5,723 changed files with 241,610 additions and 153,669 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
13 changes: 1 addition & 12 deletions .configurations/configuration.dsc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ properties:
id: OpenJS.NodeJS.LTS
version: "20.14.0"
source: winget
- resource: NpmDsc/NpmPackage
id: yarn
dependsOn:
- npm
directives:
description: Install Yarn
allowPrerelease: true
settings:
Name: 'yarn'
Global: true
PackageDirectory: '${WinGetConfigRoot}\..\'
- resource: Microsoft.WinGet.DSC/WinGetPackage
directives:
description: Install Python 3.10
Expand Down Expand Up @@ -56,7 +45,7 @@ properties:
includeRecommended: true
components:
- Microsoft.VisualStudio.Workload.VCTools
- resource: YarnDsc/YarnInstall
- resource: NpmDsc/NpmInstall
dependsOn:
- npm
directives:
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ RUN git config --system codespaces-theme.hide-status 1

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

USER root
CMD chown node:node /vscode-dev && sudo -u node mkdir -p /vscode-dev/yarn-cache && sleep inf
CMD chown node:node /vscode-dev && sudo -u node mkdir -p /vscode-dev/npm-cache && sleep inf
4 changes: 2 additions & 2 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ If you already have VS Code and Docker installed, you can click the badge above
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...**.

> **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.
> **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.
5. Type `https://github.com/microsoft/vscode` (or a branch or PR URL) in the input box and press <kbd>Enter</kbd>.

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

```bash
yarn install
npm i
bash scripts/code.sh
```

Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh

yarn install --network-timeout 180000
yarn electron
npm i
npm run electron
8 changes: 0 additions & 8 deletions .eslintignore → .eslint-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,7 @@
**/src/vs/*/**/*.d.ts
**/src/vs/base/test/common/filters.perf.data.js
**/src/vs/loader.js
**/src2/**/dompurify.js
**/src2/**/marked.js
**/src2/**/semver.js
**/src2/typings/**/*.d.ts
**/src2/vs/*/**/*.d.ts
**/src2/vs/base/test/common/filters.perf.data.js
**/src2/vs/loader.js
**/test/unit/assert.js
**/test/unit/assert-esm.js
**/test/automation/out/**
**/typings/**
**/src/react.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export = new class ApiProviderNaming implements eslint.Rule.RuleModule {
readonly meta: eslint.Rule.RuleMetaData = {
messages: {
amdX: 'Use `import type` for import declarations, use `amdX#importAMDNodeModule` for import expressions'
}
},
schema: false,
};

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import * as eslint from 'eslint';
export = new class DeclareServiceBrand implements eslint.Rule.RuleModule {

readonly meta: eslint.Rule.RuleMetaData = {
fixable: 'code'
fixable: 'code',
schema: false,
};

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export = new class EnsureNoDisposablesAreLeakedInTestSuite implements eslint.Rul
messages: {
ensure: 'Suites should include a call to `ensureNoDisposablesAreLeakedInTestSuite()` to ensure no disposables are leaked in tests.'
},
fixable: 'code'
fixable: 'code',
schema: false,
};

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
*--------------------------------------------------------------------------------------------*/

import * as eslint from 'eslint';
import { TSESTree } from '@typescript-eslint/experimental-utils';
import { TSESTree } from '@typescript-eslint/utils';
import * as path from 'path';
import minimatch from 'minimatch';
import { createImportRuleListener } from './utils';

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

interface ConditionalPattern {
when?: 'hasBrowser' | 'hasNode' | 'test';
when?: 'hasBrowser' | 'hasNode' | 'hasElectron' | 'test';
pattern: string;
}

interface RawImportPatternsConfig {
target: string;
layer?: 'common' | 'worker' | 'browser' | 'electron-sandbox' | 'node' | 'electron-main';
layer?: 'common' | 'worker' | 'browser' | 'electron-sandbox' | 'node' | 'electron-utility' | 'electron-main';
test?: boolean;
restrictions: string | (string | ConditionalPattern)[];
}

interface LayerAllowRule {
when: 'hasBrowser' | 'hasNode' | 'test';
when: 'hasBrowser' | 'hasNode' | 'hasElectron' | 'test';
allow: string[];
}

Expand All @@ -44,11 +44,14 @@ export = new class implements eslint.Rule.RuleModule {
readonly meta: eslint.Rule.RuleMetaData = {
messages: {
badImport: 'Imports violates \'{{restrictions}}\' restrictions. See https://github.com/microsoft/vscode/wiki/Source-Code-Organization',
badFilename: 'Missing definition in `code-import-patterns` for this file. Define rules at https://github.com/microsoft/vscode/blob/main/.eslintrc.json'
badFilename: 'Missing definition in `code-import-patterns` for this file. Define rules at https://github.com/microsoft/vscode/blob/main/.eslintrc.json',
badAbsolute: 'Imports have to be relative to support ESM',
badExtension: 'Imports have to end with `.js` or `.css` to support ESM',
},
docs: {
url: 'https://github.com/microsoft/vscode/wiki/Source-Code-Organization'
}
},
schema: false,
};

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
Expand Down Expand Up @@ -77,13 +80,14 @@ export = new class implements eslint.Rule.RuleModule {
return this._optionsCache.get(options)!;
}

type Layer = 'common' | 'worker' | 'browser' | 'electron-sandbox' | 'node' | 'electron-main';
type Layer = 'common' | 'worker' | 'browser' | 'electron-sandbox' | 'node' | 'electron-utility' | 'electron-main';

interface ILayerRule {
layer: Layer;
deps: string;
isBrowser?: boolean;
isNode?: boolean;
isElectron?: boolean;
}

function orSegment(variants: Layer[]): string {
Expand All @@ -96,18 +100,22 @@ export = new class implements eslint.Rule.RuleModule {
{ layer: 'browser', deps: orSegment(['common', 'browser']), isBrowser: true },
{ layer: 'electron-sandbox', deps: orSegment(['common', 'browser', 'electron-sandbox']), isBrowser: true },
{ layer: 'node', deps: orSegment(['common', 'node']), isNode: true },
{ layer: 'electron-main', deps: orSegment(['common', 'node', 'electron-main']), isNode: true },
{ layer: 'electron-utility', deps: orSegment(['common', 'node', 'electron-utility']), isNode: true, isElectron: true },
{ layer: 'electron-main', deps: orSegment(['common', 'node', 'electron-utility', 'electron-main']), isNode: true, isElectron: true },
];

let browserAllow: string[] = [];
let nodeAllow: string[] = [];
let electronAllow: string[] = [];
let testAllow: string[] = [];
for (const option of options) {
if (isLayerAllowRule(option)) {
if (option.when === 'hasBrowser') {
browserAllow = option.allow.slice(0);
} else if (option.when === 'hasNode') {
nodeAllow = option.allow.slice(0);
} else if (option.when === 'hasElectron') {
electronAllow = option.allow.slice(0);
} else if (option.when === 'test') {
testAllow = option.allow.slice(0);
}
Expand Down Expand Up @@ -135,9 +143,13 @@ export = new class implements eslint.Rule.RuleModule {
restrictions.push(...nodeAllow);
}

if (layerRule.isElectron) {
restrictions.push(...electronAllow);
}

for (const rawRestriction of rawRestrictions) {
let importPattern: string;
let when: 'hasBrowser' | 'hasNode' | 'test' | undefined = undefined;
let when: 'hasBrowser' | 'hasNode' | 'hasElectron' | 'test' | undefined = undefined;
if (typeof rawRestriction === 'string') {
importPattern = rawRestriction;
} else {
Expand All @@ -147,6 +159,7 @@ export = new class implements eslint.Rule.RuleModule {
if (typeof when === 'undefined'
|| (when === 'hasBrowser' && layerRule.isBrowser)
|| (when === 'hasNode' && layerRule.isNode)
|| (when === 'hasElectron' && layerRule.isElectron)
) {
restrictions.push(importPattern.replace(/\/\~$/, `/${layerRule.deps}/**`));
testRestrictions.push(importPattern.replace(/\/\~$/, `/test/${layerRule.deps}/**`));
Expand Down Expand Up @@ -181,8 +194,8 @@ export = new class implements eslint.Rule.RuleModule {

if (targetIsVS) {
// Always add "vs/nls" and "vs/amdX"
restrictions.push('vs/nls');
restrictions.push('vs/amdX'); // TODO@jrieken remove after ESM is real
restrictions.push('vs/nls.js');
restrictions.push('vs/amdX.js'); // TODO@jrieken remove after ESM is real
}

if (targetIsVS && option.layer) {
Expand Down Expand Up @@ -212,13 +225,32 @@ export = new class implements eslint.Rule.RuleModule {
}

private _checkImport(context: eslint.Rule.RuleContext, config: ImportPatternsConfig, node: TSESTree.Node, importPath: string) {
const targetIsVS = /^src\/vs\//.test(getRelativeFilename(context));
if (targetIsVS) {

// ESM: check for import ending with ".js" or ".css"
if (importPath[0] === '.' && !importPath.endsWith('.js') && !importPath.endsWith('.css')) {
context.report({
loc: node.loc,
messageId: 'badExtension',
});
}

// check for import being relative
if (importPath.startsWith('vs/')) {
context.report({
loc: node.loc,
messageId: 'badAbsolute',
});
}
}

// resolve relative paths
if (importPath[0] === '.') {
const relativeFilename = getRelativeFilename(context);
importPath = path.posix.join(path.posix.dirname(relativeFilename), importPath);
if (/^src\/vs\//.test(importPath)) {
// resolve using AMD base url
// resolve using base url
importPath = importPath.substring('src/'.length);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ export = new class implements eslint.Rule.RuleModule {
},
docs: {
url: 'https://github.com/microsoft/vscode/wiki/Source-Code-Organization'
}
},
schema: [
{
type: 'object',
additionalProperties: {
type: 'array',
items: {
type: 'string'
}
}
}
]
};

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
Expand Down
70 changes: 70 additions & 0 deletions .eslint-plugin-local/code-limited-top-functions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as eslint from 'eslint';
import { dirname, relative } from 'path';
import minimatch from 'minimatch';

export = new class implements eslint.Rule.RuleModule {

readonly meta: eslint.Rule.RuleMetaData = {
messages: {
layerbreaker: 'You are only allowed to define limited top level functions.'
},
schema: {
type: "array",
items: {
type: "object",
additionalProperties: {
type: "array",
items: {
type: "string"
}
}
}
}
};

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
let fileRelativePath = relative(dirname(__dirname), context.getFilename());
if (!fileRelativePath.endsWith('/')) {
fileRelativePath += '/';
}
const ruleArgs = <Record<string, string[]>>context.options[0];

const matchingKey = Object.keys(ruleArgs).find(key => fileRelativePath.startsWith(key) || minimatch(fileRelativePath, key));
if (!matchingKey) {
// nothing
return {};
}

const restrictedFunctions = ruleArgs[matchingKey];

return {
FunctionDeclaration: (node: any) => {
const isTopLevel = node.parent.type === 'Program';
const functionName = node.id.name;
if (isTopLevel && !restrictedFunctions.includes(node.id.name)) {
context.report({
node,
message: `Top-level function '${functionName}' is restricted in this file. Allowed functions are: ${restrictedFunctions.join(', ')}.`
});
}
},
ExportNamedDeclaration(node: any) {
if (node.declaration && node.declaration.type === 'FunctionDeclaration') {
const functionName = node.declaration.id.name;
const isTopLevel = node.parent.type === 'Program';
if (isTopLevel && !restrictedFunctions.includes(node.declaration.id.name)) {
context.report({
node,
message: `Top-level function '${functionName}' is restricted in this file. Allowed functions are: ${restrictedFunctions.join(', ')}.`
});
}
}
}
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
*--------------------------------------------------------------------------------------------*/

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

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

export = new class MustUseResults implements eslint.Rule.RuleModule {
readonly meta: eslint.Rule.RuleMetaData = {
schema: false
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export = new class ApiProviderNaming implements eslint.Rule.RuleModule {
readonly meta: eslint.Rule.RuleMetaData = {
messages: {
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',
}
},
schema: false,
};

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
Expand Down
Loading

0 comments on commit 476ac29

Please sign in to comment.