Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update prettier version #867

Merged
merged 1 commit into from
Apr 10, 2023
Merged
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"url": "https://github.com/redhat-developer/yaml-language-server.git"
},
"optionalDependencies": {
"prettier": "2.0.5"
"prettier": "2.8.7"
},
"dependencies": {
"ajv": "^8.11.0",
Expand All @@ -49,7 +49,7 @@
"@types/chai": "^4.2.12",
"@types/mocha": "8.2.2",
"@types/node": "16.x",
"@types/prettier": "2.0.2",
"@types/prettier": "2.7.2",
"@types/sinon": "^9.0.5",
"@types/sinon-chai": "^3.2.5",
"@typescript-eslint/eslint-plugin": "^5.38.0",
Expand Down
6 changes: 4 additions & 2 deletions src/languageservice/parser/jsonParser07.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export const formats = {
},
'date-time': {
errorMessage: localize('dateTimeFormatWarning', 'String is not a RFC3339 date-time.'),
pattern: /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9]))$/i,
pattern:
/^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9]))$/i,
},
date: {
errorMessage: localize('dateFormatWarning', 'String is not a RFC3339 date.'),
Expand All @@ -55,7 +56,8 @@ export const formats = {
},
email: {
errorMessage: localize('emailFormatWarning', 'String is not an e-mail address.'),
pattern: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
pattern:
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
},
ipv4: {
errorMessage: localize('ipv4FormatWarning', 'String does not match IPv4 format.'),
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/services/yamlValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class YAMLValidation {

const validation = await this.jsonValidation.doValidation(textDocument, currentYAMLDoc);

const syd = (currentYAMLDoc as unknown) as SingleYAMLDocument;
const syd = currentYAMLDoc as unknown as SingleYAMLDocument;
if (syd.errors.length > 0) {
// TODO: Get rid of these type assertions (shouldn't need them)
validationResult.push(...syd.errors);
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/utils/astUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function isInComment(tokens: Token[], offset: number): boolean {
let inComment = false;
for (const token of tokens) {
if (token.type === 'document') {
_visit([], (token as unknown) as SourceToken, (item) => {
_visit([], token as unknown as SourceToken, (item) => {
if (isCollectionItem(item) && item.value?.type === 'comment') {
if (token.offset <= offset && item.value.source.length + item.value.offset >= offset) {
inComment = true;
Expand Down
4 changes: 2 additions & 2 deletions src/languageservice/utils/textBuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class TextBuffer {
}

getLineLength(lineNumber: number): number {
const lineOffsets = ((this.doc as unknown) as FullTextDocument).getLineOffsets();
const lineOffsets = (this.doc as unknown as FullTextDocument).getLineOffsets();
if (lineNumber >= lineOffsets.length) {
return this.doc.getText().length;
} else if (lineNumber < 0) {
Expand All @@ -30,7 +30,7 @@ export class TextBuffer {
}

getLineContent(lineNumber: number): string {
const lineOffsets = ((this.doc as unknown) as FullTextDocument).getLineOffsets();
const lineOffsets = (this.doc as unknown as FullTextDocument).getLineOffsets();
if (lineNumber >= lineOffsets.length) {
return this.doc.getText();
} else if (lineNumber < 0) {
Expand Down
8 changes: 3 additions & 5 deletions src/yamlServerInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ export class YAMLServerInit {
* Run when the client connects to the server after it is activated.
* The server receives the root path(s) of the workspace and the client capabilities.
*/
this.connection.onInitialize(
(params: InitializeParams): InitializeResult => {
return this.connectionInitialized(params);
}
);
this.connection.onInitialize((params: InitializeParams): InitializeResult => {
return this.connectionInitialized(params);
});
this.connection.onInitialized(() => {
if (this.yamlSettings.hasWsChangeWatchedFileDynamicRegistration) {
this.connection.workspace.onDidChangeWorkspaceFolders((changedFolders) => {
Expand Down
8 changes: 5 additions & 3 deletions test/autoCompletion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ describe('Auto Completion Tests', () => {
uri: 'http://google.com',
fileMatch: ['bad-schema.yaml'],
});
const { languageService: langService, languageHandler: langHandler, yamlSettings: settings } = setupLanguageService(
languageSettingsSetup.languageSettings
);
const {
languageService: langService,
languageHandler: langHandler,
yamlSettings: settings,
} = setupLanguageService(languageSettingsSetup.languageSettings);
languageService = langService;
languageHandler = langHandler;
yamlSettings = settings;
Expand Down
8 changes: 5 additions & 3 deletions test/autoCompletionFix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ describe('Auto Completion Fix Tests', () => {
uri: 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.4-standalone-strict/all.json',
fileMatch: [SCHEMA_ID],
});
const { languageService: langService, languageHandler: langHandler, yamlSettings: settings } = setupLanguageService(
languageSettingsSetup.languageSettings
);
const {
languageService: langService,
languageHandler: langHandler,
yamlSettings: settings,
} = setupLanguageService(languageSettingsSetup.languageSettings);
languageService = langService;
languageHandler = langHandler;
yamlSettings = settings;
Expand Down
8 changes: 5 additions & 3 deletions test/code-action-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ describe('Schema Errors Code Action Tests', () => {

before(() => {
languageSettingsSetup = new ServiceSetup().withValidate();
const { languageService: langService, validationHandler: valHandler, yamlSettings: settings } = setupLanguageService(
languageSettingsSetup.languageSettings
);
const {
languageService: langService,
validationHandler: valHandler,
yamlSettings: settings,
} = setupLanguageService(languageSettingsSetup.languageSettings);
languageService = langService;
validationHandler = valHandler;
yamlSettings = settings;
Expand Down
8 changes: 5 additions & 3 deletions test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ describe('Kubernetes Integration Tests', () => {
uri,
})
.withKubernetes();
const { validationHandler: valHandler, languageHandler: langHandler, yamlSettings: settings } = setupLanguageService(
languageSettingsSetup.languageSettings
);
const {
validationHandler: valHandler,
languageHandler: langHandler,
yamlSettings: settings,
} = setupLanguageService(languageSettingsSetup.languageSettings);
validationHandler = valHandler;
languageHandler = langHandler;
yamlSettings = settings;
Expand Down
56 changes: 28 additions & 28 deletions test/settingsHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Settings Handlers Tests', () => {

beforeEach(() => {
workspaceStub = sandbox.createStubInstance(TestWorkspace);
connection.workspace = (workspaceStub as unknown) as RemoteWorkspace;
connection.workspace = workspaceStub as unknown as RemoteWorkspace;
connection.onDidChangeConfiguration = sandbox.mock();
connection.client = {} as RemoteClient;
connection.client.register = sandbox.mock();
Expand All @@ -52,9 +52,9 @@ describe('Settings Handlers Tests', () => {
settingsState.hasConfigurationCapability = false;
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);

Expand All @@ -67,9 +67,9 @@ describe('Settings Handlers Tests', () => {
settingsState.hasConfigurationCapability = true;
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);

Expand All @@ -81,9 +81,9 @@ describe('Settings Handlers Tests', () => {
it(' reflect to the settings ', async () => {
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{ style: { flowMapping: 'forbid', flowSequence: 'forbid' } }, {}, {}, {}, {}]);
Expand All @@ -96,9 +96,9 @@ describe('Settings Handlers Tests', () => {
it(' reflect default values if no settings given', async () => {
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{}, {}, {}, {}, {}]);
Expand All @@ -114,9 +114,9 @@ describe('Settings Handlers Tests', () => {
it(' reflect to the settings ', async () => {
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{ keyOrdering: true }, {}, {}, {}, {}]);
Expand All @@ -128,9 +128,9 @@ describe('Settings Handlers Tests', () => {
it(' reflect default values if no settings given', async () => {
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{}, {}, {}, {}, {}]);
Expand All @@ -145,9 +145,9 @@ describe('Settings Handlers Tests', () => {
it('reflect to settings state', async () => {
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{}, {}, {}, {}, { associations: { '*.bu': 'yaml' } }]);
Expand All @@ -174,9 +174,9 @@ describe('Settings Handlers Tests', () => {
settingsState.fileExtensions.push('*.bu');
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]);
Expand Down Expand Up @@ -208,9 +208,9 @@ describe('Settings Handlers Tests', () => {
});
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]);
Expand Down Expand Up @@ -246,9 +246,9 @@ describe('Settings Handlers Tests', () => {
});
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]);
Expand All @@ -274,7 +274,7 @@ describe('Settings Handlers Tests', () => {
connection,
languageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
const configureSpy = sinon.spy(languageService, 'configure');
Expand Down Expand Up @@ -357,9 +357,9 @@ describe('Settings Handlers Tests', () => {
it('should fetch preferences', async () => {
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{}, {}, {}, {}, {}]);
Expand All @@ -381,9 +381,9 @@ describe('Settings Handlers Tests', () => {
settingsState.schemaStoreEnabled = true;
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);

Expand All @@ -398,9 +398,9 @@ describe('Settings Handlers Tests', () => {
it('detect indentation settings change', async () => {
const settingsHandler = new SettingsHandler(
connection,
(languageService as unknown) as LanguageService,
languageService as unknown as LanguageService,
settingsState,
(validationHandler as unknown) as ValidationHandler,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{}, {}, {}, { tabSize: 4, detectIndentation: false }]);
Expand Down
16 changes: 8 additions & 8 deletions test/yamlCodeLens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('YAML CodeLens', () => {
url: 'some://url/to/schema.json',
};
yamlSchemaService.getSchemaForResource.resolves({ schema });
const codeLens = new YamlCodeLens((yamlSchemaService as unknown) as YAMLSchemaService, telemetry);
const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry);
const result = await codeLens.getCodeLens(doc);
expect(result).is.not.empty;
expect(result[0].command).is.not.undefined;
Expand All @@ -68,7 +68,7 @@ describe('YAML CodeLens', () => {
url: 'some://url/to/schema.json',
};
yamlSchemaService.getSchemaForResource.resolves({ schema });
const codeLens = new YamlCodeLens((yamlSchemaService as unknown) as YAMLSchemaService, telemetry);
const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry);
const result = await codeLens.getCodeLens(doc);
expect(result[0].range).is.deep.equal(Range.create(0, 0, 0, 0));
expect(result[0].command).is.deep.equal(
Expand All @@ -82,7 +82,7 @@ describe('YAML CodeLens', () => {
url: 'some://url/to/schema.json',
};
yamlSchemaService.getSchemaForResource.resolves({ schema });
const codeLens = new YamlCodeLens((yamlSchemaService as unknown) as YAMLSchemaService, telemetry);
const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry);
const result = await codeLens.getCodeLens(doc);
expect(result.length).to.eq(1);
expect(result[0].range).is.deep.equal(Range.create(0, 0, 0, 0));
Expand All @@ -98,7 +98,7 @@ describe('YAML CodeLens', () => {
title: 'fooBar',
} as JSONSchema;
yamlSchemaService.getSchemaForResource.resolves({ schema });
const codeLens = new YamlCodeLens((yamlSchemaService as unknown) as YAMLSchemaService, telemetry);
const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry);
const result = await codeLens.getCodeLens(doc);
expect(result[0].command).is.deep.equal(
createCommand('fooBar (schema.json)', YamlCommands.JUMP_TO_SCHEMA, 'some://url/to/schema.json')
Expand All @@ -113,7 +113,7 @@ describe('YAML CodeLens', () => {
description: 'fooBarDescription',
} as JSONSchema;
yamlSchemaService.getSchemaForResource.resolves({ schema });
const codeLens = new YamlCodeLens((yamlSchemaService as unknown) as YAMLSchemaService, telemetry);
const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry);
const result = await codeLens.getCodeLens(doc);
expect(result[0].command).is.deep.equal(
createCommand('fooBar - fooBarDescription (schema.json)', YamlCommands.JUMP_TO_SCHEMA, 'some://url/to/schema.json')
Expand All @@ -133,7 +133,7 @@ describe('YAML CodeLens', () => {
],
} as JSONSchema;
yamlSchemaService.getSchemaForResource.resolves({ schema });
const codeLens = new YamlCodeLens((yamlSchemaService as unknown) as YAMLSchemaService, telemetry);
const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry);
const result = await codeLens.getCodeLens(doc);
expect(result).has.length(2);
expect(result).is.deep.equal([
Expand All @@ -155,7 +155,7 @@ describe('YAML CodeLens', () => {
],
} as JSONSchema;
yamlSchemaService.getSchemaForResource.resolves({ schema });
const codeLens = new YamlCodeLens((yamlSchemaService as unknown) as YAMLSchemaService, telemetry);
const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry);
const result = await codeLens.getCodeLens(doc);
expect(result).has.length(2);
expect(result).is.deep.equal([
Expand All @@ -177,7 +177,7 @@ describe('YAML CodeLens', () => {
],
} as JSONSchema;
yamlSchemaService.getSchemaForResource.resolves({ schema });
const codeLens = new YamlCodeLens((yamlSchemaService as unknown) as YAMLSchemaService, telemetry);
const codeLens = new YamlCodeLens(yamlSchemaService as unknown as YAMLSchemaService, telemetry);
const result = await codeLens.getCodeLens(doc);
expect(result).has.length(2);
expect(result).is.deep.equal([
Expand Down
Loading