Skip to content

Commit 6fc3e21

Browse files
2 parents c40c5bc + 066d55d commit 6fc3e21

File tree

140 files changed

+29767
-853
lines changed

Some content is hidden

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

140 files changed

+29767
-853
lines changed

.eslint-ignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
**/build/*/**/*.js
2+
**/dist/**/*.js
3+
**/extensions/**/*.d.ts
4+
**/extensions/**/build/**
5+
**/extensions/**/colorize-fixtures/**
6+
**/extensions/css-language-features/server/test/pathCompletionFixtures/**
7+
**/extensions/html-language-features/server/lib/jquery.d.ts
8+
**/extensions/html-language-features/server/src/test/pathCompletionFixtures/**
9+
**/extensions/ipynb/notebook-out/**
10+
**/extensions/markdown-language-features/media/**
11+
**/extensions/markdown-language-features/notebook-out/**
12+
**/extensions/markdown-math/notebook-out/**
13+
**/extensions/notebook-renderers/renderer-out/index.js
14+
**/extensions/simple-browser/media/index.js
15+
**/extensions/typescript-language-features/test-workspace/**
16+
**/extensions/typescript-language-features/extension.webpack.config.js
17+
**/extensions/typescript-language-features/extension-browser.webpack.config.js
18+
**/extensions/typescript-language-features/package-manager/node-maintainer/**
19+
**/extensions/vscode-api-tests/testWorkspace/**
20+
**/extensions/vscode-api-tests/testWorkspace2/**
21+
**/fixtures/**
22+
**/node_modules/**
23+
**/out-*/**/*.js
24+
**/out-editor-*/**
25+
**/out/**/*.js
26+
**/src/**/dompurify.js
27+
**/src/**/marked.js
28+
**/src/**/semver.js
29+
**/src/typings/**/*.d.ts
30+
**/src/vs/*/**/*.d.ts
31+
**/src/vs/base/test/common/filters.perf.data.js
32+
**/src/vs/loader.js
33+
**/test/unit/assert.js
34+
**/test/automation/out/**
35+
**/typings/**
36+
!.vscode
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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 { join } from 'path';
8+
9+
10+
export = new class ApiProviderNaming implements eslint.Rule.RuleModule {
11+
12+
readonly meta: eslint.Rule.RuleMetaData = {
13+
messages: {
14+
amdX: 'Use `import type` for import declarations, use `amdX#importAMDNodeModule` for import expressions'
15+
},
16+
schema: false,
17+
};
18+
19+
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
20+
21+
const modules = new Set<string>();
22+
23+
try {
24+
const { dependencies, optionalDependencies } = require(join(__dirname, '../package.json'));
25+
const all = Object.keys(dependencies).concat(Object.keys(optionalDependencies));
26+
for (const key of all) {
27+
modules.add(key);
28+
}
29+
30+
} catch (e) {
31+
console.error(e);
32+
throw e;
33+
}
34+
35+
36+
const checkImport = (node: any) => {
37+
38+
if (node.type !== 'Literal' || typeof node.value !== 'string') {
39+
return;
40+
}
41+
42+
if (node.parent.importKind === 'type') {
43+
return;
44+
}
45+
46+
if (!modules.has(node.value)) {
47+
return;
48+
}
49+
50+
context.report({
51+
node,
52+
messageId: 'amdX'
53+
});
54+
}
55+
56+
return {
57+
['ImportExpression Literal']: checkImport,
58+
['ImportDeclaration Literal']: checkImport
59+
};
60+
}
61+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
8+
export = new class DeclareServiceBrand implements eslint.Rule.RuleModule {
9+
10+
readonly meta: eslint.Rule.RuleMetaData = {
11+
fixable: 'code',
12+
schema: false,
13+
};
14+
15+
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
16+
return {
17+
['PropertyDefinition[key.name="_serviceBrand"][value]']: (node: any) => {
18+
return context.report({
19+
node,
20+
message: `The '_serviceBrand'-property should not have a value`,
21+
fix: (fixer) => {
22+
return fixer.replaceText(node, 'declare _serviceBrand: undefined;')
23+
}
24+
});
25+
}
26+
};
27+
}
28+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 { Node } from 'estree';
8+
9+
export = new class EnsureNoDisposablesAreLeakedInTestSuite implements eslint.Rule.RuleModule {
10+
11+
readonly meta: eslint.Rule.RuleMetaData = {
12+
type: 'problem',
13+
messages: {
14+
ensure: 'Suites should include a call to `ensureNoDisposablesAreLeakedInTestSuite()` to ensure no disposables are leaked in tests.'
15+
},
16+
fixable: 'code',
17+
schema: false,
18+
};
19+
20+
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
21+
const config = <{ exclude: string[] }>context.options[0];
22+
23+
const needle = context.getFilename().replace(/\\/g, '/');
24+
if (config.exclude.some((e) => needle.endsWith(e))) {
25+
return {};
26+
}
27+
28+
return {
29+
[`Program > ExpressionStatement > CallExpression[callee.name='suite']`]: (node: Node) => {
30+
const src = context.getSourceCode().getText(node)
31+
if (!src.includes('ensureNoDisposablesAreLeakedInTestSuite(')) {
32+
context.report({
33+
node,
34+
messageId: 'ensure',
35+
fix: (fixer) => {
36+
const updatedSrc = src.replace(/(suite\(.*\n)/, '$1\n\tensureNoDisposablesAreLeakedInTestSuite();\n');
37+
return fixer.replaceText(node, updatedSrc);
38+
}
39+
});
40+
}
41+
},
42+
};
43+
}
44+
};

0 commit comments

Comments
 (0)