Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 0 additions & 107 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion build/webpack/webpack.extension.browser.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const packageRoot = path.resolve(__dirname, '..', '..');
const outDir = path.resolve(packageRoot, 'dist');

/** @type {(env: any, argv: { mode: 'production' | 'development' | 'none' }) => import('webpack').Configuration} */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line no-unused-vars
const nodeConfig = (_, { mode }) => ({
context: packageRoot,
entry: {
Expand Down
173 changes: 173 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/**
* ESLint Configuration for VS Code Python Extension
* This file configures linting rules for the TypeScript/JavaScript codebase.
* It uses the new flat config format introduced in ESLint 8.21.0
*/

// Import essential ESLint plugins and configurations
import tseslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import noOnlyTests from 'eslint-plugin-no-only-tests';
import prettier from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';
import js from '@eslint/js';

export default [
{
ignores: ['**/node_modules/**', '**/out/**'],
},
// Base configuration for all files
{
ignores: ['**/node_modules/**', '**/out/**'],
linterOptions: {
reportUnusedDisableDirectives: 'off',
},
rules: {
...js.configs.recommended.rules,
'no-undef': 'off',
},
},
// TypeScript-specific configuration
{
files: ['**/*.ts', '**/*.tsx', 'src', 'pythonExtensionApi/src'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
globals: {
...(js.configs.recommended.languageOptions?.globals || {}),
mocha: true,
require: 'readonly',
process: 'readonly',
exports: 'readonly',
module: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
setTimeout: 'readonly',
setInterval: 'readonly',
clearTimeout: 'readonly',
clearInterval: 'readonly',
},
},
plugins: {
'@typescript-eslint': tseslint,
'no-only-tests': noOnlyTests,
import: importPlugin,
prettier: prettier,
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts'],
},
},
},
rules: {
// Base configurations
...tseslint.configs.recommended.rules,
...prettier.rules,

// TypeScript-specific rules
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description',
},
],
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-loss-of-precision': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{
functions: false,
},
],

// Import rules
'import/extensions': 'off',
'import/namespace': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'import/prefer-default-export': 'off',

// Testing rules
'no-only-tests/no-only-tests': [
'error',
{
block: ['test', 'suite'],
focus: ['only'],
},
],

// Code style rules
'linebreak-style': 'off',
'no-bitwise': 'off',
'no-console': 'off',
'no-underscore-dangle': 'off',
'operator-assignment': 'off',
'func-names': 'off',

// Error handling and control flow
'no-empty': ['error', { allowEmptyCatch: true }],
'no-async-promise-executor': 'off',
'no-await-in-loop': 'off',
'no-unreachable': 'off',
'no-void': 'off',

// Duplicates and overrides (TypeScript handles these)
'no-dupe-class-members': 'off',
'no-redeclare': 'off',
'no-undef': 'off',

// Miscellaneous rules
'no-control-regex': 'off',
'no-extend-native': 'off',
'no-inner-declarations': 'off',
'no-multi-str': 'off',
'no-param-reassign': 'off',
'no-prototype-builtins': 'off',
'no-empty-function': 'off',
'no-template-curly-in-string': 'off',
'no-useless-escape': 'off',
'no-extra-parentheses': 'off',
'no-extra-paren': 'off',
'@typescript-eslint/no-extra-parens': 'off',
strict: 'off',

// Restricted syntax
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message:
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'LabeledStatement',
message:
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message:
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
},
},
];
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1501,8 +1501,8 @@
"testSmoke": "cross-env INSTALL_JUPYTER_EXTENSION=true \"node ./out/test/smokeTest.js\"",
"testInsiders": "cross-env VSC_PYTHON_CI_TEST_VSC_CHANNEL=insiders INSTALL_PYLANCE_EXTENSION=true TEST_FILES_SUFFIX=insiders.test CODE_TESTS_WORKSPACE=src/testMultiRootWkspc/smokeTests \"node ./out/test/standardTest.js\"",
"lint-staged": "node gulpfile.js",
"lint": "eslint --ext .ts,.js src build pythonExtensionApi",
"lint-fix": "eslint --fix --ext .ts,.js src build pythonExtensionApi gulpfile.js",
"lint": "eslint src build pythonExtensionApi",
"lint-fix": "eslint --fix src build pythonExtensionApi gulpfile.js",
"format-check": "prettier --check 'src/**/*.ts' 'build/**/*.js' '.github/**/*.yml' gulpfile.js",
"format-fix": "prettier --write 'src/**/*.ts' 'build/**/*.js' '.github/**/*.yml' gulpfile.js",
"clean": "gulp clean",
Expand Down
4 changes: 2 additions & 2 deletions src/client/activation/node/analysisOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export class NodeLanguageServerAnalysisOptions extends LanguageServerAnalysisOpt

// eslint-disable-next-line class-methods-use-this
protected async getInitializationOptions(): Promise<LanguageClientOptions> {
return ({
return {
experimentationSupport: true,
trustedWorkspaceSupport: true,
} as unknown) as LanguageClientOptions;
} as unknown as LanguageClientOptions;
}
}
5 changes: 3 additions & 2 deletions src/client/activation/node/languageClientFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export class NodeLanguageClientFactory implements ILanguageClientFactory {
clientOptions: LanguageClientOptions,
): Promise<LanguageClient> {
// this must exist for node language client
const commandArgs = (clientOptions.connectionOptions
?.cancellationStrategy as FileBasedCancellationStrategy).getCommandLineArguments();
const commandArgs = (
clientOptions.connectionOptions?.cancellationStrategy as FileBasedCancellationStrategy
).getCommandLineArguments();

const extension = this.extensions.getExtension(PYLANCE_EXTENSION_ID);
const languageServerFolder = extension ? extension.extensionPath : '';
Expand Down
4 changes: 1 addition & 3 deletions src/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ export function buildApi(
* * When no resource is provided, the setting scoped to the first workspace folder is returned.
* * If no folder is present, it returns the global setting.
*/
getExecutionDetails(
resource?: Resource,
): {
getExecutionDetails(resource?: Resource): {
/**
* E.g of execution commands returned could be,
* * `['<path to the interpreter set in settings>']`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ class InvalidPythonPathInDebuggerDiagnostic extends BaseDiagnostic {
export const InvalidPythonPathInDebuggerServiceId = 'InvalidPythonPathInDebuggerServiceId';

@injectable()
export class InvalidPythonPathInDebuggerService extends BaseDiagnosticsService
implements IInvalidPythonPathInDebuggerService {
export class InvalidPythonPathInDebuggerService
extends BaseDiagnosticsService
implements IInvalidPythonPathInDebuggerService
{
constructor(
@inject(IServiceContainer) serviceContainer: IServiceContainer,
@inject(IWorkspaceService) private readonly workspace: IWorkspaceService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ export class DefaultShellDiagnostic extends BaseDiagnostic {
export const InvalidPythonInterpreterServiceId = 'InvalidPythonInterpreterServiceId';

@injectable()
export class InvalidPythonInterpreterService extends BaseDiagnosticsService
implements IExtensionSingleActivationService {
export class InvalidPythonInterpreterService
extends BaseDiagnosticsService
implements IExtensionSingleActivationService
{
public readonly supportedWorkspaceTypes = { untrustedWorkspace: false, virtualWorkspace: true };

constructor(
Expand Down
1 change: 1 addition & 0 deletions src/client/common/application/applicationEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class ApplicationEnvironment implements IApplicationEnvironment {
? path.join(this.process.env.APPDATA, vscodeFolderName, 'User', 'settings.json')
: undefined;
default:
// eslint-disable-next-line getter-return
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/common/application/commandManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class CommandManager implements ICommandManager {
// eslint-disable-next-line class-methods-use-this
public registerCommand<
E extends keyof ICommandNameArgumentTypeMapping,
U extends ICommandNameArgumentTypeMapping[E]
U extends ICommandNameArgumentTypeMapping[E],
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
>(command: E, callback: (...args: U) => any, thisArg?: any): Disposable {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -73,7 +73,7 @@ export class CommandManager implements ICommandManager {
public executeCommand<
T,
E extends keyof ICommandNameArgumentTypeMapping,
U extends ICommandNameArgumentTypeMapping[E]
U extends ICommandNameArgumentTypeMapping[E],
>(command: E, ...rest: U): Thenable<T | undefined> {
return commands.executeCommand<T>(command, ...rest);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class ReportIssueCommandHandler implements IExtensionSingleActivationServ
if (argSetting) {
if (typeof argSetting === 'object') {
let propertyHeaderAdded = false;
const argSettingsDict = (settings[property] as unknown) as Record<string, unknown>;
const argSettingsDict = settings[property] as unknown as Record<string, unknown>;
if (typeof argSettingsDict === 'object') {
Object.keys(argSetting).forEach((item) => {
const prop = argSetting[item];
Expand Down
Loading
Loading