Skip to content

Commit 104da04

Browse files
authored
Merge branch 'main' into tyriar/node-pty-39
2 parents 4acd934 + 85e3a27 commit 104da04

File tree

1,846 files changed

+61883
-44462
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,846 files changed

+61883
-44462
lines changed

.config/guardian/.gdnbaselines renamed to .config/guardian/.gdnsuppress

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
2+
"hydrated": true,
23
"properties": {
3-
"helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/baselines"
4+
"helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/suppressions"
45
},
56
"version": "1.0.0",
6-
"baselines": {
7+
"suppressionSets": {
78
"default": {
89
"name": "default",
910
"createdDate": "2025-01-28 06:29:05Z",

.eslint-plugin-local/code-amd-node-module.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as eslint from 'eslint';
7+
import type * as ESTree from 'estree';
8+
import { readFileSync } from 'fs';
79
import { join } from 'path';
810

911

10-
export = new class ApiProviderNaming implements eslint.Rule.RuleModule {
12+
export default new class ApiProviderNaming implements eslint.Rule.RuleModule {
1113

1214
readonly meta: eslint.Rule.RuleMetaData = {
1315
messages: {
@@ -21,7 +23,8 @@ export = new class ApiProviderNaming implements eslint.Rule.RuleModule {
2123
const modules = new Set<string>();
2224

2325
try {
24-
const { dependencies, optionalDependencies } = require(join(__dirname, '../package.json'));
26+
const packageJson = JSON.parse(readFileSync(join(import.meta.dirname, '../package.json'), 'utf-8'));
27+
const { dependencies, optionalDependencies } = packageJson;
2528
const all = Object.keys(dependencies).concat(Object.keys(optionalDependencies));
2629
for (const key of all) {
2730
modules.add(key);
@@ -33,13 +36,13 @@ export = new class ApiProviderNaming implements eslint.Rule.RuleModule {
3336
}
3437

3538

36-
const checkImport = (node: any) => {
39+
const checkImport = (node: ESTree.Literal & { parent?: ESTree.Node & { importKind?: string } }) => {
3740

38-
if (node.type !== 'Literal' || typeof node.value !== 'string') {
41+
if (typeof node.value !== 'string') {
3942
return;
4043
}
4144

42-
if (node.parent.importKind === 'type') {
45+
if (node.parent?.type === 'ImportDeclaration' && node.parent.importKind === 'type') {
4346
return;
4447
}
4548

.eslint-plugin-local/code-declare-service-brand.ts

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

66
import * as eslint from 'eslint';
7+
import type * as ESTree from 'estree';
78

8-
export = new class DeclareServiceBrand implements eslint.Rule.RuleModule {
9+
export default new class DeclareServiceBrand implements eslint.Rule.RuleModule {
910

1011
readonly meta: eslint.Rule.RuleMetaData = {
1112
fixable: 'code',
@@ -14,7 +15,7 @@ export = new class DeclareServiceBrand implements eslint.Rule.RuleModule {
1415

1516
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
1617
return {
17-
['PropertyDefinition[key.name="_serviceBrand"][value]']: (node: any) => {
18+
['PropertyDefinition[key.name="_serviceBrand"][value]']: (node: ESTree.PropertyDefinition) => {
1819
return context.report({
1920
node,
2021
message: `The '_serviceBrand'-property should not have a value`,

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

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

66
import * as eslint from 'eslint';
7-
import { Node } from 'estree';
7+
import type * as estree from 'estree';
88

9-
export = new class EnsureNoDisposablesAreLeakedInTestSuite implements eslint.Rule.RuleModule {
9+
export default new class EnsureNoDisposablesAreLeakedInTestSuite implements eslint.Rule.RuleModule {
1010

1111
readonly meta: eslint.Rule.RuleMetaData = {
1212
type: 'problem',
@@ -18,15 +18,15 @@ export = new class EnsureNoDisposablesAreLeakedInTestSuite implements eslint.Rul
1818
};
1919

2020
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
21-
const config = <{ exclude: string[] }>context.options[0];
21+
const config = context.options[0] as { exclude: string[] };
2222

2323
const needle = context.getFilename().replace(/\\/g, '/');
2424
if (config.exclude.some((e) => needle.endsWith(e))) {
2525
return {};
2626
}
2727

2828
return {
29-
[`Program > ExpressionStatement > CallExpression[callee.name='suite']`]: (node: Node) => {
29+
[`Program > ExpressionStatement > CallExpression[callee.name='suite']`]: (node: estree.Node) => {
3030
const src = context.getSourceCode().getText(node);
3131
if (!src.includes('ensureNoDisposablesAreLeakedInTestSuite(')) {
3232
context.report({

.eslint-plugin-local/code-import-patterns.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import * as eslint from 'eslint';
77
import { TSESTree } from '@typescript-eslint/utils';
88
import * as path from 'path';
99
import minimatch from 'minimatch';
10-
import { createImportRuleListener } from './utils';
10+
import { createImportRuleListener } from './utils.ts';
1111

12-
const REPO_ROOT = path.normalize(path.join(__dirname, '../'));
12+
const REPO_ROOT = path.normalize(path.join(import.meta.dirname, '../'));
1313

1414
interface ConditionalPattern {
1515
when?: 'hasBrowser' | 'hasNode' | 'hasElectron' | 'test';
@@ -31,15 +31,15 @@ interface LayerAllowRule {
3131
type RawOption = RawImportPatternsConfig | LayerAllowRule;
3232

3333
function isLayerAllowRule(option: RawOption): option is LayerAllowRule {
34-
return !!((<LayerAllowRule>option).when && (<LayerAllowRule>option).allow);
34+
return !!((option as LayerAllowRule).when && (option as LayerAllowRule).allow);
3535
}
3636

3737
interface ImportPatternsConfig {
3838
target: string;
3939
restrictions: string[];
4040
}
4141

42-
export = new class implements eslint.Rule.RuleModule {
42+
export default new class implements eslint.Rule.RuleModule {
4343

4444
readonly meta: eslint.Rule.RuleMetaData = {
4545
messages: {
@@ -55,7 +55,7 @@ export = new class implements eslint.Rule.RuleModule {
5555
};
5656

5757
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
58-
const options = <RawOption[]>context.options;
58+
const options = context.options as RawOption[];
5959
const configs = this._processOptions(options);
6060
const relativeFilename = getRelativeFilename(context);
6161

@@ -217,7 +217,7 @@ export = new class implements eslint.Rule.RuleModule {
217217
configs.push(testConfig);
218218
}
219219
} else {
220-
configs.push({ target, restrictions: <string[]>restrictions.filter(r => typeof r === 'string') });
220+
configs.push({ target, restrictions: restrictions.filter(r => typeof r === 'string') as string[] });
221221
}
222222
}
223223
this._optionsCache.set(options, configs);

.eslint-plugin-local/code-layering.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
import * as eslint from 'eslint';
77
import { join, dirname } from 'path';
8-
import { createImportRuleListener } from './utils';
8+
import { createImportRuleListener } from './utils.ts';
99

1010
type Config = {
1111
allowed: Set<string>;
1212
disallowed: Set<string>;
1313
};
1414

15-
export = new class implements eslint.Rule.RuleModule {
15+
export default new class implements eslint.Rule.RuleModule {
1616

1717
readonly meta: eslint.Rule.RuleMetaData = {
1818
messages: {
@@ -38,8 +38,7 @@ export = new class implements eslint.Rule.RuleModule {
3838

3939
const fileDirname = dirname(context.getFilename());
4040
const parts = fileDirname.split(/\\|\//);
41-
const ruleArgs = <Record<string, string[]>>context.options[0];
42-
41+
const ruleArgs = context.options[0] as Record<string, string[]>;
4342
let config: Config | undefined;
4443
for (let i = parts.length - 1; i >= 0; i--) {
4544
if (ruleArgs[parts[i]]) {
@@ -91,4 +90,3 @@ export = new class implements eslint.Rule.RuleModule {
9190
});
9291
}
9392
};
94-

.eslint-plugin-local/code-limited-top-functions.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
import * as eslint from 'eslint';
77
import { dirname, relative } from 'path';
88
import minimatch from 'minimatch';
9+
import type * as ESTree from 'estree';
910

10-
export = new class implements eslint.Rule.RuleModule {
11+
export default new class implements eslint.Rule.RuleModule {
1112

1213
readonly meta: eslint.Rule.RuleMetaData = {
1314
messages: {
@@ -28,11 +29,11 @@ export = new class implements eslint.Rule.RuleModule {
2829
};
2930

3031
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
31-
let fileRelativePath = relative(dirname(__dirname), context.getFilename());
32+
let fileRelativePath = relative(dirname(import.meta.dirname), context.getFilename());
3233
if (!fileRelativePath.endsWith('/')) {
3334
fileRelativePath += '/';
3435
}
35-
const ruleArgs = <Record<string, string[]>>context.options[0];
36+
const ruleArgs = context.options[0] as Record<string, string[]>;
3637

3738
const matchingKey = Object.keys(ruleArgs).find(key => fileRelativePath.startsWith(key) || minimatch(fileRelativePath, key));
3839
if (!matchingKey) {
@@ -43,8 +44,8 @@ export = new class implements eslint.Rule.RuleModule {
4344
const restrictedFunctions = ruleArgs[matchingKey];
4445

4546
return {
46-
FunctionDeclaration: (node: any) => {
47-
const isTopLevel = node.parent.type === 'Program';
47+
FunctionDeclaration: (node: ESTree.FunctionDeclaration & { parent?: ESTree.Node }) => {
48+
const isTopLevel = node.parent?.type === 'Program';
4849
const functionName = node.id.name;
4950
if (isTopLevel && !restrictedFunctions.includes(node.id.name)) {
5051
context.report({
@@ -53,10 +54,10 @@ export = new class implements eslint.Rule.RuleModule {
5354
});
5455
}
5556
},
56-
ExportNamedDeclaration(node: any) {
57+
ExportNamedDeclaration(node: ESTree.ExportNamedDeclaration & { parent?: ESTree.Node }) {
5758
if (node.declaration && node.declaration.type === 'FunctionDeclaration') {
5859
const functionName = node.declaration.id.name;
59-
const isTopLevel = node.parent.type === 'Program';
60+
const isTopLevel = node.parent?.type === 'Program';
6061
if (isTopLevel && !restrictedFunctions.includes(node.declaration.id.name)) {
6162
context.report({
6263
node,

.eslint-plugin-local/code-must-use-result.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,30 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as eslint from 'eslint';
7+
import type * as ESTree from 'estree';
78
import { TSESTree } from '@typescript-eslint/utils';
89

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

14-
export = new class MustUseResults implements eslint.Rule.RuleModule {
15+
export default new class MustUseResults implements eslint.Rule.RuleModule {
1516
readonly meta: eslint.Rule.RuleMetaData = {
1617
schema: false
1718
};
1819

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

21-
const config = <{ message: string; functions: string[] }[]>context.options[0];
22+
const config = context.options[0] as { message: string; functions: string[] }[];
2223
const listener: eslint.Rule.RuleListener = {};
2324

2425
for (const { message, functions } of config) {
2526
for (const fn of functions) {
2627
const query = `CallExpression[callee.property.name='${fn}'], CallExpression[callee.name='${fn}']`;
27-
listener[query] = (node: any) => {
28-
const cast: TSESTree.CallExpression = node;
29-
if (!VALID_USES.has(cast.parent?.type)) {
28+
listener[query] = (node: ESTree.Node) => {
29+
const callExpression = node as TSESTree.CallExpression;
30+
if (!VALID_USES.has(callExpression.parent?.type)) {
3031
context.report({ node, message });
3132
}
3233
};

.eslint-plugin-local/code-must-use-super-dispose.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { TSESTree } from '@typescript-eslint/utils';
67
import * as eslint from 'eslint';
8+
import type * as ESTree from 'estree';
79

8-
export = new class NoAsyncSuite implements eslint.Rule.RuleModule {
10+
export default new class NoAsyncSuite implements eslint.Rule.RuleModule {
911

1012
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
11-
function doesCallSuperDispose(node: any) {
13+
function doesCallSuperDispose(node: TSESTree.MethodDefinition) {
1214

1315
if (!node.override) {
1416
return;
1517
}
1618

17-
const body = context.getSourceCode().getText(node);
19+
const body = context.getSourceCode().getText(node as ESTree.Node);
1820

1921
if (body.includes('super.dispose')) {
2022
return;

.eslint-plugin-local/code-no-any-casts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as eslint from 'eslint';
77
import { TSESTree } from '@typescript-eslint/utils';
88

9-
export = new class NoAnyCasts implements eslint.Rule.RuleModule {
9+
export default new class NoAnyCasts implements eslint.Rule.RuleModule {
1010

1111
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
1212
return {

0 commit comments

Comments
 (0)