Skip to content
Open
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
12 changes: 12 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,22 @@ export default defineConfig(
},
},
rules: {
'sort-imports': ['error', { ignoreDeclarationSort: true }],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: false }],
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
'import-x/consistent-type-specifier-style': ['error', 'prefer-top-level'],
'import-x/first': 'error',
'import-x/newline-after-import': 'error',
'import-x/order': [
'error',
{
alphabetize: { order: 'asc' },
groups: ['type', 'builtin', 'external', ['parent', 'sibling', 'index']],
'newlines-between': 'always',
sortTypesGroup: true,
},
],
},
},
{
Expand Down
21 changes: 12 additions & 9 deletions src/languageserver/handlers/languageHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,44 @@
import type { Connection } from 'vscode-languageserver';
import type {
CodeActionParams,
CodeLensParams,
DefinitionParams,
DidChangeWatchedFilesParams,
DocumentFormattingParams,
DocumentLinkParams,
DocumentOnTypeFormattingParams,
DocumentSymbolParams,
FoldingRangeParams,
SelectionRangeParams,
TextDocumentPositionParams,
CodeLensParams,
DefinitionParams,
PrepareRenameParams,
RenameParams,
SelectionRangeParams,
TextDocumentPositionParams,
} from 'vscode-languageserver-protocol';
import type { TextDocument } from 'vscode-languageserver-textdocument';
import type {
CodeAction,
CodeLens,
CompletionList,
DefinitionLink,
DocumentLink,
DocumentSymbol,
Hover,
FoldingRange,
Hover,
Range,
SelectionRange,
SymbolInformation,
TextEdit,
WorkspaceEdit,
} from 'vscode-languageserver-types';
import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes';

import type { ValidationHandler } from './validationHandlers';
import type { LanguageService } from '../../languageservice/yamlLanguageService';
import type { SettingsState } from '../../yamlSettings';
import type { ValidationHandler } from './validationHandlers';
import { ResultLimitReachedNotification } from '../../requestTypes';

import * as path from 'path';
import type { TextDocument } from 'vscode-languageserver-textdocument';

import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes';
import { ResultLimitReachedNotification } from '../../requestTypes';

export class LanguageHandlers {
private languageService: LanguageService;
Expand Down
6 changes: 4 additions & 2 deletions src/languageserver/handlers/notificationHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { Connection } from 'vscode-languageserver';

import type { SettingsHandler } from './settingsHandlers';
import type { CustomSchemaProvider } from '../../languageservice/services/yamlSchemaService';
import type { LanguageService, SchemaConfiguration } from '../../languageservice/yamlLanguageService';
import type { SettingsState } from '../../yamlSettings';

import {
CustomSchemaRequest,
DynamicCustomSchemaRequestRegistration,
SchemaAssociationNotification,
SchemaSelectionRequests,
VSCodeContentRequestRegistration,
} from '../../requestTypes';
import type { SettingsState } from '../../yamlSettings';
import type { SettingsHandler } from './settingsHandlers';

export class NotificationHandlers {
private languageService: LanguageService;
Expand Down
4 changes: 3 additions & 1 deletion src/languageserver/handlers/requestHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { Connection } from 'vscode-languageserver';

import type { SchemaAdditions, SchemaDeletions, SchemaDeletionsAll } from '../../languageservice/services/yamlSchemaService';
import { MODIFICATION_ACTIONS } from '../../languageservice/services/yamlSchemaService';
import type { LanguageService } from '../../languageservice/yamlLanguageService';

import { MODIFICATION_ACTIONS } from '../../languageservice/services/yamlSchemaService';
import { SchemaModificationNotification } from '../../requestTypes';

export class RequestHandlers {
Expand Down
6 changes: 4 additions & 2 deletions src/languageserver/handlers/schemaSelectionHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
*--------------------------------------------------------------------------------------------*/

import type { Connection } from 'vscode-languageserver/node';

import type { JSONSchema } from '../../languageservice/jsonSchema';
import { yamlDocumentsCache } from '../../languageservice/parser/yaml-documents';
import type { YAMLSchemaService } from '../../languageservice/services/yamlSchemaService';
import type { SettingsState } from '../../yamlSettings';
import type { JSONSchemaDescription, JSONSchemaDescriptionExt } from '../../requestTypes';
import type { SettingsState } from '../../yamlSettings';

import { yamlDocumentsCache } from '../../languageservice/parser/yaml-documents';
import { SchemaSelectionRequests } from '../../requestTypes';

export class JSONSchemaSelection {
Expand Down
17 changes: 10 additions & 7 deletions src/languageserver/handlers/settingsHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { configure as configureHttpRequests, xhr } from 'request-light';
import type { Connection } from 'vscode-languageserver';

import type { ValidationHandler } from './validationHandlers';
import type { Telemetry } from '../../languageservice/telemetry';
import type { LanguageService, LanguageSettings, SchemasSettings } from '../../languageservice/yamlLanguageService';
import type { Settings, SettingsState } from '../../yamlSettings';

import { configure as configureHttpRequests, xhr } from 'request-light';
import { DidChangeConfigurationNotification, DocumentFormattingRequest } from 'vscode-languageserver';
import { CodeLensRefreshRequest } from 'vscode-languageserver-protocol';
import { isRelativePath, relativeToAbsolutePath } from '../../languageservice/utils/paths';
import { checkSchemaURI, EMPTY_SCHEMA_URL, isKubernetes, JSON_SCHEMASTORE_URL } from '../../languageservice/utils/schemaUrls';

import { equals } from '../../languageservice/utils/objects';
import type { LanguageService, LanguageSettings, SchemasSettings } from '../../languageservice/yamlLanguageService';
import { isRelativePath, relativeToAbsolutePath } from '../../languageservice/utils/paths';
import { EMPTY_SCHEMA_URL, JSON_SCHEMASTORE_URL, checkSchemaURI, isKubernetes } from '../../languageservice/utils/schemaUrls';
import { SchemaPriority } from '../../languageservice/yamlLanguageService';
import { SchemaSelectionRequests } from '../../requestTypes';
import type { Settings, SettingsState } from '../../yamlSettings';
import type { Telemetry } from '../../languageservice/telemetry';
import type { ValidationHandler } from './validationHandlers';

export class SettingsHandler {
private schemaSettings: SchemasSettings[] | undefined;
Expand Down
6 changes: 4 additions & 2 deletions src/languageserver/handlers/validationHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import type { Connection } from 'vscode-languageserver';
import type { TextDocument } from 'vscode-languageserver-textdocument';
import type { Diagnostic } from 'vscode-languageserver-types';
import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes';
import { removeDuplicatesObj } from '../../languageservice/utils/arrUtils';

import type { LanguageService } from '../../languageservice/yamlLanguageService';
import type { SettingsState } from '../../yamlSettings';

import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes';
import { removeDuplicatesObj } from '../../languageservice/utils/arrUtils';

export class ValidationHandler {
private languageService: LanguageService;
private yamlSettings: SettingsState;
Expand Down
3 changes: 2 additions & 1 deletion src/languageserver/handlers/workspaceHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import type { ExecuteCommandParams, Connection } from 'vscode-languageserver';
import type { Connection, ExecuteCommandParams } from 'vscode-languageserver';

import type { CommandExecutor } from '../commandExecutor';

export class WorkspaceHandlers {
Expand Down
4 changes: 3 additions & 1 deletion src/languageserver/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
*--------------------------------------------------------------------------------------------*/

import type { Connection } from 'vscode-languageserver';
import type { TelemetryEvent, Telemetry } from '../languageservice/telemetry';

import type { Telemetry, TelemetryEvent } from '../languageservice/telemetry';

import { convertErrorToTelemetryMsg } from '../languageservice/utils/objects';

export class TelemetryImpl implements Telemetry {
Expand Down
62 changes: 33 additions & 29 deletions src/languageservice/jsonLanguageTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,53 @@
// Forked from vscode-json-languageservice@6.0.0-next.1
// Source: https://github.com/microsoft/vscode-json-languageservice/blob/810471bbb462bb6b87351c2232e209a3bb4062ca/src/jsonLanguageTypes.ts

import { JSONSchema } from './jsonSchema';
import type { FormattingOptions as LSPFormattingOptions } from 'vscode-languageserver-types';
import type { Node, Pair } from 'yaml';

import type { CustomTagReturnType } from './utils/customTags';

import { TextDocument, TextDocumentContentChangeEvent } from 'vscode-languageserver-textdocument';
import {
Range,
Position,
DocumentUri,
MarkupContent,
MarkupKind,
CodeAction,
CodeActionContext,
CodeActionKind,
Color,
ColorInformation,
ColorPresentation,
FoldingRange,
FoldingRangeKind,
SelectionRange,
Diagnostic,
DiagnosticSeverity,
Command,
CompletionItem,
CompletionItemKind,
CompletionList,
CompletionItemTag,
InsertTextFormat,
SymbolInformation,
SymbolKind,
DocumentSymbol,
Location,
Hover,
MarkedString,
CompletionList,
DefinitionLink,
CodeActionContext,
Command,
CodeAction,
Diagnostic,
DiagnosticSeverity,
DocumentHighlight,
DocumentHighlightKind,
DocumentLink,
WorkspaceEdit,
TextEdit,
CodeActionKind,
DocumentSymbol,
DocumentUri,
FoldingRange,
FoldingRangeKind,
Hover,
InsertTextFormat,
Location,
MarkedString,
MarkupContent,
MarkupKind,
Position,
Range,
SelectionRange,
SymbolInformation,
SymbolKind,
TextDocumentEdit,
TextEdit,
VersionedTextDocumentIdentifier,
DocumentHighlightKind,
WorkspaceEdit,
} from 'vscode-languageserver-types';
import { TextDocument, TextDocumentContentChangeEvent } from 'vscode-languageserver-textdocument';
import type { Node, Pair } from 'yaml';
import type { CustomTagReturnType } from './utils/customTags';

import { JSONSchema } from './jsonSchema';

export {
TextDocument,
TextDocumentContentChangeEvent,
Expand Down
17 changes: 10 additions & 7 deletions src/languageservice/parser/ast-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import type { Node, Scalar, YAMLMap, Pair, YAMLSeq, Alias, Document, LineCounter } from 'yaml';
import { isScalar, isMap, isPair, isSeq, isNode, isAlias } from 'yaml';
import type { Alias, Document, LineCounter, Node, Pair, Scalar, YAMLMap, YAMLSeq } from 'yaml';

import type { ASTNode, YamlNode } from '../jsonLanguageTypes';
import { getCustomTagReturnType } from '../utils/customTags';

import { isAlias, isMap, isNode, isPair, isScalar, isSeq } from 'yaml';

import {
ArrayASTNodeImpl,
BooleanASTNodeImpl,
NullASTNodeImpl,
NumberASTNodeImpl,
ObjectASTNodeImpl,
PropertyASTNodeImpl,
StringASTNodeImpl,
ObjectASTNodeImpl,
NumberASTNodeImpl,
ArrayASTNodeImpl,
BooleanASTNodeImpl,
} from './jsonDocument';
import { getCustomTagReturnType } from '../utils/customTags';

type NodeRange = [number, number, number];

Expand Down
5 changes: 4 additions & 1 deletion src/languageservice/parser/custom-tag-provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { Tags, YAMLMap, YAMLSeq } from 'yaml';
import { isSeq, isMap, Scalar } from 'yaml';

import type { CustomTagInputType, CustomTagReturnType } from '../utils/customTags';

import { Scalar, isMap, isSeq } from 'yaml';

import { parseCustomTag, setCustomTagReturnType } from '../utils/customTags';

class CommonTagImpl {
Expand Down
4 changes: 3 additions & 1 deletion src/languageservice/parser/isKubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { TextDocument } from 'vscode-languageserver-textdocument';
import { FilePatternAssociation } from '../utils/filePatternAssociation';

import type * as Parser from './jsonDocument';

import { FilePatternAssociation } from '../utils/filePatternAssociation';

export function setKubernetesParserOption(jsonDocuments: Parser.JSONDocument[], option: boolean): void {
for (const jsonDoc of jsonDocuments) {
jsonDoc.isKubernetes = option;
Expand Down
16 changes: 9 additions & 7 deletions src/languageservice/parser/jsonDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { JSONSchema } from '../jsonSchema';
import type { TextDocument } from 'vscode-languageserver-textdocument';
import type { Diagnostic, Range } from 'vscode-languageserver-types';
import type { Node, Pair } from 'yaml';

import type {
ASTNode,
ObjectASTNode,
ArrayASTNode,
BooleanASTNode,
NumberASTNode,
StringASTNode,
NullASTNode,
NumberASTNode,
ObjectASTNode,
PropertyASTNode,
StringASTNode,
YamlNode,
} from '../jsonLanguageTypes';
import type { JSONSchema } from '../jsonSchema';
import type { CustomTagReturnType } from '../utils/customTags';
import type { Diagnostic, Range } from 'vscode-languageserver-types';
import type { TextDocument } from 'vscode-languageserver-textdocument';
import type { Node, Pair } from 'yaml';
import type { IApplicableSchema } from './schemaValidation/baseValidator';

import { findNodeAtOffset } from '../utils/astNodeUtils';
import { getValidator } from './schemaValidation/validatorFactory';

Expand Down
Loading
Loading