Skip to content

Commit

Permalink
Merge branch 'main' into prefer-arrow-callback
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina authored Jun 24, 2023
2 parents c227aae + 27ef6ec commit 216d2c0
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 36 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,12 @@ module.exports = {
'no-useless-computed-key': 'error',
'no-useless-constructor': 'off',
'no-useless-rename': 'error',
'object-shorthand': 'error',
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
'object-shorthand': [
'error',
'always',
{ avoidExplicitReturnArrows: true },
],
'prefer-numeric-literals': 'off',
'prefer-template': 'off',
'sort-imports': 'off',
Expand Down
2 changes: 1 addition & 1 deletion examples/cm6-graphql-parcel/src/testSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const TestType: GraphQLObjectType = new GraphQLObjectType({
},
isTest: {
type: GraphQLBoolean,
resolve: () => {
resolve() {
return true;
},
},
Expand Down
4 changes: 2 additions & 2 deletions examples/monaco-graphql-webpack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async function render() {
};

/**
* Add an reload operation to the command palette & keyboard shortcuts
* Add a reload operation to the command palette & keyboard shortcuts
*/
const reloadAction: monaco.editor.IActionDescriptor = {
id: 'graphql-reload',
Expand All @@ -206,7 +206,7 @@ async function render() {
keybindings: [
monaco.KeyMod.CtrlCmd | monaco.KeyCode?.KeyR, // eslint-disable-line no-bitwise
],
run: async () => {
async run() {
await schemaFetcher.loadSchema();
},
};
Expand Down
4 changes: 2 additions & 2 deletions packages/cm6-graphql/src/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { graphqlLanguage } from './language';
const AUTOCOMPLETE_CHARS = /^[a-zA-Z0-9_@(]$/;

export const completion = graphqlLanguage.data.of({
autocomplete: (ctx: CompletionContext) => {
autocomplete(ctx: CompletionContext) {
const schema = getSchema(ctx.state);
const opts = getOpts(ctx.state);
if (!schema) {
Expand Down Expand Up @@ -38,7 +38,7 @@ export const completion = graphqlLanguage.data.of({
return {
label: item.label,
detail: item.detail || '',
info: (completionData: Completion) => {
info(completionData: Completion) {
if (opts?.onCompletionInfoRender) {
return opts.onCompletionInfoRender(item, ctx, completionData);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/codemirror-graphql/src/__tests__/testSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const TestType: GraphQLObjectType = new GraphQLObjectType({
},
isTest: {
type: GraphQLBoolean,
resolve: () => {
resolve() {
return true;
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/graphiql-react/src/editor/query-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ export function useQueryEditor(
info: {
schema: undefined,
renderDescription: (text: string) => markdown.render(text),
onClick: (reference: SchemaReference) => {
onClick(reference: SchemaReference) {
onClickReferenceRef.current(reference);
},
},
jump: {
schema: undefined,
onClick: (reference: SchemaReference) => {
onClick(reference: SchemaReference) {
onClickReferenceRef.current(reference);
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/graphiql-toolkit/src/async-helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export function isPromise<T>(value: Promise<T> | any): value is Promise<T> {
function observableToPromise<T>(observable: Observable<T>): Promise<T> {
return new Promise((resolve, reject) => {
const subscription = observable.subscribe({
next: v => {
next(v) {
resolve(v);
subscription.unsubscribe();
},
error: reject,
complete: () => {
complete() {
reject(new Error('no value resolved'));
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-toolkit/src/create-fetcher/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const createWebsocketsFetcherFromClient =
makeAsyncIterableIteratorFromSink<ExecutionResult>(sink =>
wsClient.subscribe(graphQLParams, {
...sink,
error: err => {
error(err) {
if (err instanceof CloseEvent) {
sink.error(
new Error(
Expand Down
4 changes: 2 additions & 2 deletions packages/graphiql-toolkit/src/storage/__tests__/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('StorageAPI', () => {
it('returns any error while setting a value', () => {
// @ts-ignore
const throwingStorage = new StorageAPI({
setItem: () => {
setItem() {
throw new DOMException('Terrible Error');
},
length: 1,
Expand All @@ -86,7 +86,7 @@ describe('StorageAPI', () => {
it('returns isQuotaError to true if isQuotaError is thrown', () => {
// @ts-ignore
const throwingStorage = new StorageAPI({
setItem: () => {
setItem() {
throw new DOMException('Terrible Error', 'QuotaExceededError');
},
length: 1,
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-toolkit/src/storage/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class StorageAPI {
return keys;
},

clear: () => {
clear() {
// We only want to clear the namespaced items
for (const key in window.localStorage) {
if (key.indexOf(`${STORAGE_NAMESPACE}:`) === 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql/resources/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const resultConfig = {
// bypass simple localhost CORS restrictions by setting
// these to 127.0.0.1 in /etc/hosts
allowedHosts: ['local.example.com', 'graphiql.com'],
setupMiddlewares: (middlewares, devServer) => {
setupMiddlewares(middlewares, devServer) {
require('../test/beforeDevServer')(devServer.app);
require('../test/afterDevServer')();

Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql/test/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const TestInterface = new GraphQLInterfaceType({
description: 'Common name string.',
},
}),
resolveType: check => {
resolveType(check) {
return check ? UnionFirst : UnionSecond;
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ export class MessageProcessor {
const inlineFragments: string[] = [];
try {
visit(parse(query), {
FragmentDefinition: (node: FragmentDefinitionNode) => {
FragmentDefinition(node: FragmentDefinitionNode) {
inlineFragments.push(node.name.value);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ describe('MessageProcessor', () => {
});
messageProcessor._languageService = {
// @ts-ignore
getAutocompleteSuggestions: (query, position, uri) => {
getAutocompleteSuggestions(query, position, uri) {
return [{ label: `${query} at ${uri}` }];
},
// @ts-ignore
getDiagnostics: (_query, _uri) => {
getDiagnostics(_query, _uri) {
return [];
},
getDocumentSymbols: async (_query: string, uri: string) => {
async getDocumentSymbols(_query: string, uri: string) {
return [
{
name: 'item',
Expand All @@ -81,7 +81,7 @@ describe('MessageProcessor', () => {
},
];
},
getOutline: async (_query: string): Promise<Outline> => {
async getOutline(_query: string): Promise<Outline> {
return {
outlineTrees: [
{
Expand All @@ -94,11 +94,11 @@ describe('MessageProcessor', () => {
],
};
},
getDefinition: async (
async getDefinition(
_query,
position,
uri,
): Promise<DefinitionQueryResult> => {
): Promise<DefinitionQueryResult> {
return {
queryRange: [new Range(position, position)],
definitions: [
Expand All @@ -118,7 +118,7 @@ describe('MessageProcessor', () => {
// @ts-ignore
get workspace() {
return {
getConfiguration: async () => {
async getConfiguration() {
return [getConfigurationReturnValue];
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export function findGraphQLTags(

traverse(node, visitors);
},
TaggedTemplateExpression: (node: TaggedTemplateExpression) => {
TaggedTemplateExpression(node: TaggedTemplateExpression) {
const tagName = getGraphQLTagName(node.tag);
if (tagName) {
const { loc } = node.quasi.quasis[0];
Expand Down Expand Up @@ -250,7 +250,7 @@ export function findGraphQLTags(
}
}
},
TemplateLiteral: (node: TemplateLiteral) => {
TemplateLiteral(node: TemplateLiteral) {
const hasGraphQLPrefix =
node.quasis[0].value.raw.startsWith('#graphql\n');
const hasGraphQLComment = Boolean(
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql-language-service/benchmark/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ const runSplitTest = (name: string, schema: string) => {

suite.add({
maxTime: 0.1,
onStart: () => {
onStart() {
prevState = { ...state };
},
fn: () => {
fn() {
const stream = new CharacterStream(line);

while (!stream.eol()) {
Expand All @@ -54,7 +54,7 @@ const runSplitTest = (name: string, schema: string) => {
state = { ...prevState };
},
onError: console.log,
onComplete: (e: any) => {
onComplete(e) {
state = completeState;
stats.push(e.target.stats);
},
Expand Down
7 changes: 3 additions & 4 deletions packages/graphql-language-service/src/interface/getOutline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function outlineTreeConverter(docText: string): OutlineTreeConverterType {
};

return {
Field: (node: FieldNode) => {
Field(node: FieldNode) {
const tokenizedText = node.alias
? [buildToken('plain', node.alias), buildToken('plain', ': ')]
: [];
Expand Down Expand Up @@ -191,19 +191,18 @@ function outlineTreeConverter(docText: string): OutlineTreeConverterType {
],
...meta(node),
}),
InputValueDefinition: (node: InputValueDefinitionNode) => {
InputValueDefinition(node: InputValueDefinitionNode) {
return {
tokenizedText: [buildToken('plain', node.name)],
...meta(node),
};
},
FieldDefinition: (node: FieldDefinitionNode) => {
FieldDefinition(node: FieldDefinitionNode) {
return {
tokenizedText: [buildToken('plain', node.name)],
...meta(node),
};
},

InlineFragment: (node: InlineFragmentNode) => node.selectionSet,
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/monaco-graphql/src/languageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class DiagnosticsAdapter {
this._disposables.push(
editor.onDidCreateModel(onModelAdd),
{
dispose: () => {
dispose() {
clearTimeout(onChangeTimeout);
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-graphql/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function activate(context: ExtensionContext) {
outputChannel,
outputChannelName: 'GraphQL Language Server',
revealOutputChannelOn: RevealOutputChannelOn.Never,
initializationFailedHandler: err => {
initializationFailedHandler(err) {
outputChannel.appendLine('Initialization failed');
outputChannel.appendLine(err.message);
if (err.stack) {
Expand Down

0 comments on commit 216d2c0

Please sign in to comment.