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

RHOAIENG-14040: Replace 'any' with correct types in typescript code #85

Merged
merged 3 commits into from
Nov 28, 2024
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
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@typescript-eslint/no-unused-vars": ["warn", { "args": "none" }],
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-namespace": "off",
"header/header": [
Expand Down
17 changes: 8 additions & 9 deletions packages/code-snippet/src/CodeSnippetService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,23 @@
* limitations under the License.
*/

import { IMetadata } from '@elyra/metadata-common';
import { MetadataService } from '@elyra/services';
import { IMetadataResource, MetadataService } from '@elyra/services';

import { Dialog, showDialog } from '@jupyterlab/apputils';

export const CODE_SNIPPET_SCHEMASPACE = 'code-snippets';
export const CODE_SNIPPET_SCHEMA = 'code-snippet';

export class CodeSnippetService {
static async findAll(): Promise<IMetadata[]> {
return MetadataService.getMetadata(CODE_SNIPPET_SCHEMASPACE);
static async findAll(): Promise<IMetadataResource[]> {
return (await MetadataService.getMetadata(CODE_SNIPPET_SCHEMASPACE)) ?? [];
}

// TODO: Test this function
static async findByLanguage(language: string): Promise<IMetadata[]> {
static async findByLanguage(language: string): Promise<IMetadataResource[]> {
try {
const allCodeSnippets: IMetadata[] = await this.findAll();
const codeSnippetsByLanguage: IMetadata[] = [];
const allCodeSnippets = await this.findAll();
const codeSnippetsByLanguage: IMetadataResource[] = [];

for (const codeSnippet of allCodeSnippets) {
if (codeSnippet.metadata.language === language) {
Expand All @@ -54,11 +53,11 @@ export class CodeSnippetService {
* @returns A boolean promise that is true if the dialog confirmed
* the deletion, and false if the deletion was cancelled.
*/
static deleteCodeSnippet(codeSnippet: IMetadata): Promise<boolean> {
static deleteCodeSnippet(codeSnippet: IMetadataResource): Promise<boolean> {
return showDialog({
title: `Delete snippet '${codeSnippet.display_name}'?`,
buttons: [Dialog.cancelButton(), Dialog.okButton()]
}).then((result: any) => {
}).then((result) => {
// Do nothing if the cancel button is pressed
if (result.button.accept) {
return MetadataService.deleteMetadata(
Expand Down
Loading
Loading