Skip to content

Commit 0be64db

Browse files
authored
Merge branch 'main' into tyriar/228971
2 parents bd3bb20 + 9a129c0 commit 0be64db

File tree

1,729 files changed

+218027
-44906
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,729 files changed

+218027
-44906
lines changed

.eslintignore renamed to .eslint-ignore

Lines changed: 0 additions & 8 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 4 additions & 3 deletions
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
import * as path from 'path';
99
import minimatch from 'minimatch';
1010
import { createImportRuleListener } from './utils';
@@ -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 {
@@ -249,7 +250,7 @@ export = new class implements eslint.Rule.RuleModule {
249250
const relativeFilename = getRelativeFilename(context);
250251
importPath = path.posix.join(path.posix.dirname(relativeFilename), importPath);
251252
if (/^src\/vs\//.test(importPath)) {
252-
// resolve using AMD base url
253+
// resolve using base url
253254
importPath = importPath.substring('src/'.length);
254255
}
255256
}

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

Lines changed: 12 additions & 1 deletion
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 {
Lines changed: 70 additions & 0 deletions
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

.eslintplugin/code-no-test-async-suite.ts renamed to .eslint-plugin-local/code-no-test-async-suite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

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

99
function isCallExpression(node: TSESTree.Node): node is TSESTree.CallExpression {

.eslintplugin/code-no-unexternalized-strings.ts renamed to .eslint-plugin-local/code-no-unexternalized-strings.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

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

99
function isStringLiteral(node: TSESTree.Node | null | undefined): node is TSESTree.StringLiteral {
1010
return !!node && node.type === AST_NODE_TYPES.Literal && typeof node.value === 'string';
@@ -24,7 +24,8 @@ export = new class NoUnexternalizedStrings implements eslint.Rule.RuleModule {
2424
badKey: 'The key \'{{key}}\' doesn\'t conform to a valid localize identifier.',
2525
duplicateKey: 'Duplicate key \'{{key}}\' with different message value.',
2626
badMessage: 'Message argument to \'{{message}}\' must be a string literal.'
27-
}
27+
},
28+
schema: false,
2829
};
2930

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

.eslintplugin/code-no-unused-expressions.ts renamed to .eslint-plugin-local/code-no-unused-expressions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313

1414
import * as eslint from 'eslint';
15-
import { TSESTree } from '@typescript-eslint/experimental-utils';
15+
import { TSESTree } from '@typescript-eslint/utils';
1616
import * as ESTree from 'estree';
1717

1818
//------------------------------------------------------------------------------
@@ -141,7 +141,7 @@ module.exports = {
141141

142142
return {
143143
ExpressionStatement(node: TSESTree.ExpressionStatement) {
144-
if (!isValidExpression(node.expression) && !isDirective(node, <TSESTree.Node[]>context.getAncestors())) {
144+
if (!isValidExpression(node.expression) && !isDirective(node, <TSESTree.Node[]>context.sourceCode.getAncestors(node))) {
145145
context.report({ node: <ESTree.Node>node, message: `Expected an assignment or function call and instead saw an expression. ${node.expression}` });
146146
}
147147
}

.eslintplugin/code-parameter-properties-must-have-explicit-accessibility.ts renamed to .eslint-plugin-local/code-parameter-properties-must-have-explicit-accessibility.ts

Lines changed: 1 addition & 1 deletion
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
* Enforces that all parameter properties have an explicit access modifier (public, protected, private).

.eslintplugin/code-translation-remind.ts renamed to .eslint-plugin-local/code-translation-remind.ts

Lines changed: 3 additions & 2 deletions
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
import { readFileSync } from 'fs';
99
import { createImportRuleListener } from './utils';
1010

@@ -16,7 +16,8 @@ export = new class TranslationRemind implements eslint.Rule.RuleModule {
1616
readonly meta: eslint.Rule.RuleMetaData = {
1717
messages: {
1818
missing: 'Please add \'{{resource}}\' to ./build/lib/i18n.resources.json file to use translations here.'
19-
}
19+
},
20+
schema: false,
2021
};
2122

2223
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
File renamed without changes.

.eslint-plugin-local/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}
File renamed without changes.

.eslintplugin/utils.ts renamed to .eslint-plugin-local/utils.ts

Lines changed: 1 addition & 1 deletion
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 function createImportRuleListener(validateImport: (node: TSESTree.Literal, value: string) => any): eslint.Rule.RuleListener {
1010

.eslintplugin/vscode-dts-cancellation.ts renamed to .eslint-plugin-local/vscode-dts-cancellation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
*--------------------------------------------------------------------------------------------*/
55

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

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

1111
readonly meta: eslint.Rule.RuleMetaData = {
1212
messages: {
1313
noToken: 'Function lacks a cancellation token, preferable as last argument',
14-
}
14+
},
15+
schema: false,
1516
};
1617

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

.eslintplugin/vscode-dts-create-func.ts renamed to .eslint-plugin-local/vscode-dts-create-func.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
*--------------------------------------------------------------------------------------------*/
55

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

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

1111
readonly meta: eslint.Rule.RuleMetaData = {
1212
docs: { url: 'https://github.com/microsoft/vscode/wiki/Extension-API-guidelines#creating-objects' },
13-
messages: { sync: '`createXYZ`-functions are constructor-replacements and therefore must return sync', }
13+
messages: { sync: '`createXYZ`-functions are constructor-replacements and therefore must return sync', },
14+
schema: false,
1415
};
1516

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

.eslintplugin/vscode-dts-event-naming.ts renamed to .eslint-plugin-local/vscode-dts-event-naming.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

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

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

@@ -19,7 +19,8 @@ export = new class ApiEventNaming implements eslint.Rule.RuleModule {
1919
verb: 'Unknown verb \'{{verb}}\' - is this really a verb? Iff so, then add this verb to the configuration',
2020
subject: 'Unknown subject \'{{subject}}\' - This subject has not been used before but it should refer to something in the API',
2121
unknown: 'UNKNOWN event declaration, lint-rule needs tweaking'
22-
}
22+
},
23+
schema: false,
2324
};
2425

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

0 commit comments

Comments
 (0)