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

[ESLint] enable sonarjs/no-ignored-return #3119

Merged
merged 1 commit into from
Apr 14, 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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ module.exports = {
'sort-imports': 0,
'symbol-description': 1,

'sonarjs/no-ignored-return': 'error',
'unicorn/no-array-push-push': 'error',
'import/no-extraneous-dependencies': 'error',
'import/no-duplicates': 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,12 @@ export const getUtils = (source: string) => {
};

export const performForEachType = (source, test) => {
Object.keys(typesMap).map(type => {
const { value, kind, valueType } = typesMap[type];
for (const [type, { value, kind, valueType }] of Object.entries(typesMap)) {
const utils = getUtils(
source.replaceAll('__VALUE__', value).replaceAll('__TYPE__', type),
);
test(utils, { type, value, kind, valueType });
});
}
};

export const expectVarsDef = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const scalarTypesMap: { [key: string]: JSONSchema6TypeName } = {

class Marker {
private set = new Set<string>();

mark(name: string): boolean {
if (this.set.has(name)) {
return false;
Expand Down Expand Up @@ -238,9 +239,9 @@ function getJSONSchemaFromGraphQLType(
fieldDef.required!.push(fieldName);
}
if (typeDefinitions) {
Object.keys(typeDefinitions).map(defName => {
definitions[defName] = typeDefinitions[defName];
});
for (const [defName, value] of Object.entries(typeDefinitions)) {
definitions[defName] = value;
}
}
});
definitions[type.name] = fieldDef;
Expand Down Expand Up @@ -269,6 +270,7 @@ function getJSONSchemaFromGraphQLType(

return { required, definition, definitions };
}

/**
* Generates a JSONSchema6 valid document for operation(s) from a map of Map<string, GraphQLInputType>.
*
Expand Down
10 changes: 8 additions & 2 deletions packages/vscode-graphql-execution/src/providers/exec-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,22 @@ export class GraphQLContentProvider implements TextDocumentContentProvider {
this.html = err.toString();
});
}

validUrlFromSchema(pathOrUrl: string) {
return /^https?:\/\//.test(pathOrUrl);
}

reportError(message: string) {
this.outputChannel.appendLine(message);
this.setContentAndUpdate(message);
}

setContentAndUpdate(html: string) {
this.html = html;
this.update(this.uri);
this.updatePanel();
}

async loadEndpoint(
projectConfig?: GraphQLProjectConfig,
): Promise<Endpoint | null> {
Expand All @@ -144,11 +148,11 @@ export class GraphQLContentProvider implements TextDocumentContentProvider {
);
const { schema } = projectConfig;
if (schema && Array.isArray(schema)) {
schema.map(s => {
for (const s of schema) {
if (this.validUrlFromSchema(s as string)) {
endpoints.default.url = s.toString();
}
});
}
} else if (schema && this.validUrlFromSchema(schema as string)) {
endpoints.default.url = schema.toString();
}
Expand All @@ -174,6 +178,7 @@ export class GraphQLContentProvider implements TextDocumentContentProvider {
const endpointName = await this.getEndpointName(endpointNames);
return endpoints[endpointName] || endpoints.default;
}

async loadProvider() {
try {
const rootDir = workspace.getWorkspaceFolder(Uri.file(this.literal.uri));
Expand Down Expand Up @@ -240,6 +245,7 @@ export class GraphQLContentProvider implements TextDocumentContentProvider {
return;
}
}

async loadConfig() {
const { rootDir, literal } = this;
if (!rootDir) {
Expand Down