mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-25 04:36:23 +00:00
Start eslint 9 migration
For #230339 Starts migrating to eslint 9. Everything runs but it produces a number of errors
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* Checks for potentially unsafe usage of `DisposableStore` / `MutableDisposable`.
|
||||
*
|
||||
* These have been the source of leaks in the past.
|
||||
*/
|
||||
export = new class implements eslint.Rule.RuleModule {
|
||||
|
||||
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
|
||||
function checkVariableDeclaration(inNode: any) {
|
||||
context.report({
|
||||
node: inNode,
|
||||
message: `Use const for 'DisposableStore' to avoid leaks by accidental reassignment.`
|
||||
});
|
||||
}
|
||||
|
||||
function checkProperty(inNode: any) {
|
||||
context.report({
|
||||
node: inNode,
|
||||
message: `Use readonly for DisposableStore/MutableDisposable to avoid leaks through accidental reassignment.`
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
'VariableDeclaration[kind!="const"] NewExpression[callee.name="DisposableStore"]': checkVariableDeclaration,
|
||||
|
||||
'PropertyDefinition[readonly!=true][typeAnnotation.typeAnnotation.typeName.name=/DisposableStore|MutableDisposable/]': checkProperty,
|
||||
'PropertyDefinition[readonly!=true] NewExpression[callee.name=/DisposableStore|MutableDisposable/]': checkProperty,
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user