Skip to content

Commit 1b4eee8

Browse files
committed
Enable more ESLint rules
1 parent 09a1226 commit 1b4eee8

File tree

8 files changed

+31
-29
lines changed

8 files changed

+31
-29
lines changed

.eslintrc.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,17 @@ overrides:
3636
- 'plugin:@typescript-eslint/recommended'
3737
- 'plugin:@typescript-eslint/recommended-requiring-type-checking'
3838
rules:
39-
# '@typescript-eslint/array-type': [error, { default: generic }]
39+
'@typescript-eslint/array-type': [error, { default: generic }]
4040
'@typescript-eslint/consistent-indexed-object-style':
4141
[error, index-signature]
4242

4343
# FIXME: remove below rules
44-
'react/jsx-no-target-blank': off
45-
'import/no-duplicates': off
4644
'import/no-extraneous-dependencies': off
4745
'@typescript-eslint/unbound-method': off
4846
'@typescript-eslint/no-floating-promises': off
4947
'@typescript-eslint/no-unused-vars': off
50-
'@typescript-eslint/array-type': off
51-
'@typescript-eslint/prefer-optional-chain': off
5248
'@typescript-eslint/no-base-to-string': off
5349
'@typescript-eslint/no-misused-promises': off
54-
'@typescript-eslint/consistent-type-definitions': off
5550
'@typescript-eslint/prefer-nullish-coalescing': off
5651

5752
# FIXME: blocked by improper type checking should be fixed

src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import * as yargs from 'yargs';
22

3-
type Options = {
3+
interface Options {
44
fileName: string | undefined;
55
port: number;
66
corsOrigin: string | true;
77
openEditor: boolean;
88
extendURL: string | undefined;
99
headers: { [key: string]: string };
1010
forwardHeaders: [string];
11-
};
11+
}
1212

1313
function builder(cmd) {
1414
return cmd

src/editor/GraphQLEditor/GraphQLEditor.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@ import 'codemirror/addon/fold/foldgutter';
1111
import 'codemirror/addon/hint/show-hint';
1212
import 'codemirror/addon/lint/lint';
1313
import 'codemirror/keymap/sublime';
14-
import 'codemirror/keymap/sublime';
1514

1615
import * as CodeMirror from 'codemirror';
1716
import { GraphQLList, GraphQLNonNull, GraphQLSchema } from 'graphql';
1817
import * as marked from 'marked';
1918
import * as React from 'react';
2019

21-
type GraphQLEditorProps = {
20+
interface GraphQLEditorProps {
2221
value: string;
2322
schema: GraphQLSchema | null;
2423
onEdit: (val: string) => void;
2524
onCommand: () => void;
26-
};
25+
}
2726

2827
export default class GraphQLEditor extends React.Component<GraphQLEditorProps> {
2928
editor: CodeMirror;

src/editor/icons.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as React from 'react';
2-
31
export const EditIcon = () => (
42
<svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
53
<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" />

src/editor/index.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { buildWithFakeDefinitions } from '../fake_definition';
1515
import GraphQLEditor from './GraphQLEditor/GraphQLEditor';
1616
import { ConsoleIcon, EditIcon, GithubIcon, VoyagerIcon } from './icons';
1717

18-
type FakeEditorState = {
18+
interface FakeEditorState {
1919
value: string | null;
2020
cachedValue: string | null;
2121
activeTab: number;
@@ -25,7 +25,7 @@ type FakeEditorState = {
2525
schema: GraphQLSchema | null;
2626
unsavedSchema: GraphQLSchema | null;
2727
remoteSDL: string | null;
28-
};
28+
}
2929

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

5454
window.onbeforeunload = () => {
55-
if (this.state.hasUnsavedChanges) return 'You have unsaved changes. Exit?';
55+
if (this.state.hasUnsavedChanges)
56+
return 'You have unsaved changes. Exit?';
5657
};
5758
}
5859

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

176177
render() {
177-
const { value, activeTab, schema, hasUnsavedChanges, unsavedSchema } = this.state;
178+
const { value, activeTab, schema, hasUnsavedChanges, unsavedSchema } =
179+
this.state;
178180
if (value == null || schema == null) {
179181
return <div className="faker-editor-container">Loading...</div>;
180182
}
@@ -183,7 +185,11 @@ class FakeEditor extends React.Component<any, FakeEditorState> {
183185
<div className="faker-editor-container">
184186
<nav>
185187
<div className="logo">
186-
<a href="https://github.com/graphql-kit/graphql-faker" target="_blank">
188+
<a
189+
href="https://github.com/graphql-kit/graphql-faker"
190+
target="_blank"
191+
rel="noreferrer"
192+
>
187193
{' '}
188194
<img src="./logo.svg" />{' '}
189195
</a>
@@ -220,7 +226,11 @@ class FakeEditor extends React.Component<any, FakeEditorState> {
220226
<VoyagerIcon />{' '}
221227
</li>
222228
<li className="-pulldown -link">
223-
<a href="https://github.com/graphql-kit/graphql-faker" target="_blank">
229+
<a
230+
href="https://github.com/graphql-kit/graphql-faker"
231+
target="_blank"
232+
rel="noreferrer"
233+
>
224234
{' '}
225235
<GithubIcon />{' '}
226236
</a>

src/fake_definition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ export function buildWithFakeDefinitions(
314314

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

319319
constructor(errors) {
320320
const message = errors.map((error) => error.message).join('\n\n');

src/fake_schema.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ import {
2222
stdScalarFakers,
2323
} from './fake';
2424

25-
type FakeArgs = {
25+
interface FakeArgs {
2626
type: string;
2727
options: { [key: string]: any };
2828
locale: string;
29-
};
30-
type ExamplesArgs = {
29+
}
30+
interface ExamplesArgs {
3131
values: [any];
32-
};
33-
type ListLengthArgs = {
32+
}
33+
interface ListLengthArgs {
3434
min: number;
3535
max: number;
36-
};
37-
type DirectiveArgs = {
36+
}
37+
interface DirectiveArgs {
3838
fake?: FakeArgs;
3939
examples?: ExamplesArgs;
4040
listLength?: ListLengthArgs;
41-
};
41+
}
4242

4343
export const fakeTypeResolver: GraphQLTypeResolver<unknown, unknown> = async (
4444
value,

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function runServer(
119119
app.get('/user-sdl', (_, res) => {
120120
res.status(200).json({
121121
userSDL: userSDL.body,
122-
remoteSDL: remoteSDL && remoteSDL.body,
122+
remoteSDL: remoteSDL?.body,
123123
});
124124
});
125125

0 commit comments

Comments
 (0)