Skip to content

Commit

Permalink
Enable more ESLint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 15, 2023
1 parent 09a1226 commit 1b4eee8
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 29 deletions.
7 changes: 1 addition & 6 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,17 @@ overrides:
- 'plugin:@typescript-eslint/recommended'
- 'plugin:@typescript-eslint/recommended-requiring-type-checking'
rules:
# '@typescript-eslint/array-type': [error, { default: generic }]
'@typescript-eslint/array-type': [error, { default: generic }]
'@typescript-eslint/consistent-indexed-object-style':
[error, index-signature]

# FIXME: remove below rules
'react/jsx-no-target-blank': off
'import/no-duplicates': off
'import/no-extraneous-dependencies': off
'@typescript-eslint/unbound-method': off
'@typescript-eslint/no-floating-promises': off
'@typescript-eslint/no-unused-vars': off
'@typescript-eslint/array-type': off
'@typescript-eslint/prefer-optional-chain': off
'@typescript-eslint/no-base-to-string': off
'@typescript-eslint/no-misused-promises': off
'@typescript-eslint/consistent-type-definitions': off
'@typescript-eslint/prefer-nullish-coalescing': off

# FIXME: blocked by improper type checking should be fixed
Expand Down
4 changes: 2 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as yargs from 'yargs';

type Options = {
interface Options {
fileName: string | undefined;
port: number;
corsOrigin: string | true;
openEditor: boolean;
extendURL: string | undefined;
headers: { [key: string]: string };
forwardHeaders: [string];
};
}

function builder(cmd) {
return cmd
Expand Down
5 changes: 2 additions & 3 deletions src/editor/GraphQLEditor/GraphQLEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ import 'codemirror/addon/fold/foldgutter';
import 'codemirror/addon/hint/show-hint';
import 'codemirror/addon/lint/lint';
import 'codemirror/keymap/sublime';
import 'codemirror/keymap/sublime';

import * as CodeMirror from 'codemirror';
import { GraphQLList, GraphQLNonNull, GraphQLSchema } from 'graphql';
import * as marked from 'marked';
import * as React from 'react';

type GraphQLEditorProps = {
interface GraphQLEditorProps {
value: string;
schema: GraphQLSchema | null;
onEdit: (val: string) => void;
onCommand: () => void;
};
}

export default class GraphQLEditor extends React.Component<GraphQLEditorProps> {
editor: CodeMirror;
Expand Down
2 changes: 0 additions & 2 deletions src/editor/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as React from 'react';

export const EditIcon = () => (
<svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" />
Expand Down
22 changes: 16 additions & 6 deletions src/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { buildWithFakeDefinitions } from '../fake_definition';
import GraphQLEditor from './GraphQLEditor/GraphQLEditor';
import { ConsoleIcon, EditIcon, GithubIcon, VoyagerIcon } from './icons';

type FakeEditorState = {
interface FakeEditorState {
value: string | null;
cachedValue: string | null;
activeTab: number;
Expand All @@ -25,7 +25,7 @@ type FakeEditorState = {
schema: GraphQLSchema | null;
unsavedSchema: GraphQLSchema | null;
remoteSDL: string | null;
};
}

class FakeEditor extends React.Component<any, FakeEditorState> {
constructor(props) {
Expand All @@ -52,7 +52,8 @@ class FakeEditor extends React.Component<any, FakeEditorState> {
});

window.onbeforeunload = () => {
if (this.state.hasUnsavedChanges) return 'You have unsaved changes. Exit?';
if (this.state.hasUnsavedChanges)
return 'You have unsaved changes. Exit?';
};
}

Expand Down Expand Up @@ -174,7 +175,8 @@ class FakeEditor extends React.Component<any, FakeEditorState> {
};

render() {
const { value, activeTab, schema, hasUnsavedChanges, unsavedSchema } = this.state;
const { value, activeTab, schema, hasUnsavedChanges, unsavedSchema } =
this.state;
if (value == null || schema == null) {
return <div className="faker-editor-container">Loading...</div>;
}
Expand All @@ -183,7 +185,11 @@ class FakeEditor extends React.Component<any, FakeEditorState> {
<div className="faker-editor-container">
<nav>
<div className="logo">
<a href="https://github.com/graphql-kit/graphql-faker" target="_blank">
<a
href="https://github.com/graphql-kit/graphql-faker"
target="_blank"
rel="noreferrer"
>
{' '}
<img src="./logo.svg" />{' '}
</a>
Expand Down Expand Up @@ -220,7 +226,11 @@ class FakeEditor extends React.Component<any, FakeEditorState> {
<VoyagerIcon />{' '}
</li>
<li className="-pulldown -link">
<a href="https://github.com/graphql-kit/graphql-faker" target="_blank">
<a
href="https://github.com/graphql-kit/graphql-faker"
target="_blank"
rel="noreferrer"
>
{' '}
<GithubIcon />{' '}
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/fake_definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export function buildWithFakeDefinitions(

// FIXME: move to 'graphql-js'
export class ValidationErrors extends Error {
subErrors: GraphQLError[];
subErrors: ReadonlyArray<GraphQLError>;

constructor(errors) {
const message = errors.map((error) => error.message).join('\n\n');
Expand Down
16 changes: 8 additions & 8 deletions src/fake_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ import {
stdScalarFakers,
} from './fake';

type FakeArgs = {
interface FakeArgs {
type: string;
options: { [key: string]: any };
locale: string;
};
type ExamplesArgs = {
}
interface ExamplesArgs {
values: [any];
};
type ListLengthArgs = {
}
interface ListLengthArgs {
min: number;
max: number;
};
type DirectiveArgs = {
}
interface DirectiveArgs {
fake?: FakeArgs;
examples?: ExamplesArgs;
listLength?: ListLengthArgs;
};
}

export const fakeTypeResolver: GraphQLTypeResolver<unknown, unknown> = async (
value,
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function runServer(
app.get('/user-sdl', (_, res) => {
res.status(200).json({
userSDL: userSDL.body,
remoteSDL: remoteSDL && remoteSDL.body,
remoteSDL: remoteSDL?.body,
});
});

Expand Down

0 comments on commit 1b4eee8

Please sign in to comment.