Skip to content

Commit

Permalink
Start eslint 9 migration
Browse files Browse the repository at this point in the history
For microsoft#230339

Starts migrating to eslint 9. Everything runs but it produces a number of errors
  • Loading branch information
mjbvz committed Oct 2, 2024
1 parent 14ac777 commit e456f4c
Show file tree
Hide file tree
Showing 48 changed files with 1,930 additions and 1,912 deletions.
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,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

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';
Expand Down Expand Up @@ -50,7 +50,8 @@ export = new class implements eslint.Rule.RuleModule {
},
docs: {
url: 'https://github.com/microsoft/vscode/wiki/Source-Code-Organization'
}
},
schema: false,
};

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
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
File renamed without changes.
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export = new class NoNlsInStandaloneEditorRule implements eslint.Rule.RuleModule
readonly meta: eslint.Rule.RuleMetaData = {
messages: {
noNls: 'Not allowed to import vs/nls in standalone editor modules. Use standaloneStrings.ts'
}
},
schema: false,
};

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export = new class NoNlsInStandaloneEditorRule implements eslint.Rule.RuleModule
},
docs: {
url: 'https://github.com/microsoft/vscode/wiki/Source-Code-Organization'
}
},
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';

/**
* WORKAROUND for https://github.com/evanw/esbuild/issues/3823
Expand All @@ -15,7 +15,7 @@ export = new class implements eslint.Rule.RuleModule {

function checkProperty(inNode: any) {

const classDeclaration = context.getAncestors().find(node => node.type === 'ClassDeclaration');
const classDeclaration = context.sourceCode.getAncestors(inNode).find(node => node.type === 'ClassDeclaration');
const propertyDefinition = <TSESTree.PropertyDefinition>inNode;

if (!classDeclaration || !classDeclaration.id?.name) {
Expand All @@ -33,7 +33,7 @@ export = new class implements eslint.Rule.RuleModule {
}

const name = classDeclaration.id.name;
const valueText = context.getSourceCode().getText(<any>propertyDefinition.value)
const valueText = context.sourceCode.getText(<any>propertyDefinition.value)

if (valueText.includes(name + '.')) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

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

function isCallExpression(node: TSESTree.Node): node is TSESTree.CallExpression {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

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

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

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

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

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -141,7 +141,7 @@ module.exports = {

return {
ExpressionStatement(node: TSESTree.ExpressionStatement) {
if (!isValidExpression(node.expression) && !isDirective(node, <TSESTree.Node[]>context.getAncestors())) {
if (!isValidExpression(node.expression) && !isDirective(node, <TSESTree.Node[]>context.sourceCode.getAncestors(node))) {
context.report({ node: <ESTree.Node>node, message: `Expected an assignment or function call and instead saw an expression. ${node.expression}` });
}
}
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';

/**
* Enforces that all parameter properties have an explicit access modifier (public, protected, private).
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';
import { readFileSync } from 'fs';
import { createImportRuleListener } from './utils';

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

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion .eslintplugin/utils.ts → .eslint-plugin-local/utils.ts
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 function createImportRuleListener(validateImport: (node: TSESTree.Literal, value: string) => any): eslint.Rule.RuleListener {

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

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

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

readonly meta: eslint.Rule.RuleMetaData = {
messages: {
noToken: 'Function lacks a cancellation token, preferable as last argument',
}
},
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,13 +4,14 @@
*--------------------------------------------------------------------------------------------*/

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

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

readonly meta: eslint.Rule.RuleMetaData = {
docs: { url: 'https://github.com/microsoft/vscode/wiki/Extension-API-guidelines#creating-objects' },
messages: { sync: '`createXYZ`-functions are constructor-replacements and therefore must return sync', }
messages: { sync: '`createXYZ`-functions are constructor-replacements and therefore must return sync', },
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, AST_NODE_TYPES } from '@typescript-eslint/experimental-utils';
import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/utils';

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

Expand All @@ -19,7 +19,8 @@ export = new class ApiEventNaming implements eslint.Rule.RuleModule {
verb: 'Unknown verb \'{{verb}}\' - is this really a verb? Iff so, then add this verb to the configuration',
subject: 'Unknown subject \'{{subject}}\' - This subject has not been used before but it should refer to something in the API',
unknown: 'UNKNOWN event declaration, lint-rule needs tweaking'
}
},
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 ApiInterfaceNaming implements eslint.Rule.RuleModule {

Expand All @@ -13,7 +13,8 @@ export = new class ApiInterfaceNaming implements eslint.Rule.RuleModule {
readonly meta: eslint.Rule.RuleMetaData = {
messages: {
naming: 'Interfaces must not be prefixed with uppercase `I`',
}
},
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,13 +4,14 @@
*--------------------------------------------------------------------------------------------*/

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

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

readonly meta: eslint.Rule.RuleMetaData = {
docs: { url: 'https://github.com/microsoft/vscode/wiki/Extension-API-guidelines#enums' },
messages: { useEnum: 'Use enums, not literal-or-types', }
messages: { useEnum: 'Use enums, not literal-or-types', },
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,14 +4,15 @@
*--------------------------------------------------------------------------------------------*/

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

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

readonly meta: eslint.Rule.RuleMetaData = {
messages: {
naming: 'A provider should only have functions like provideXYZ or resolveXYZ',
}
},
schema: false,
};

private static _providerFunctionNames = /^(provide|resolve|prepare).+/;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export = new class ApiEventNaming implements eslint.Rule.RuleModule {
readonly meta: eslint.Rule.RuleMetaData = {
messages: {
comment: 'region comments should start with a camel case identifier, `:`, then either a GH issue link or owner, e.g #region myProposalName: https://github.com/microsoft/vscode/issues/<number>',
}
},
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,21 +4,21 @@
*--------------------------------------------------------------------------------------------*/

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

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

readonly meta: eslint.Rule.RuleMetaData = {
docs: { url: 'https://github.com/microsoft/vscode/wiki/Extension-API-guidelines' },
messages: {
noTypeDiscrimination: 'Do not use type descrimination properties'
}
noTypeDiscrimination: 'Do not use type discrimination properties'
},
schema: false,
};

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
return {
['TSPropertySignature[optional=undefined] TSTypeAnnotation TSLiteralType Literal']: (node: any) => {

['TSPropertySignature[optional=false] TSTypeAnnotation TSLiteralType Literal']: (node: any) => {
const raw = String((<TSESTree.Literal>node).raw)

if (/^('|").*\1$/.test(raw)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export = new class ApiEventNaming implements eslint.Rule.RuleModule {
readonly meta: eslint.Rule.RuleMetaData = {
messages: {
usage: 'Use the Thenable-type instead of the Promise type',
}
},
schema: false,
};

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

0 comments on commit e456f4c

Please sign in to comment.