Skip to content

Commit f790124

Browse files
committed
refactor: migrate codebase on typescript
BREAKING CHANGE: removed flowtype definitions; min supported nodejs version is 8
1 parent 71894a3 commit f790124

File tree

72 files changed

+2104
-12925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2104
-12925
lines changed

.babelrc

-55
This file was deleted.

.eslintignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
flow-typed
21
lib
3-
mjs
2+
.eslintrc.js

.eslintrc

-41
This file was deleted.

.eslintrc.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['@typescript-eslint', 'prettier'],
6+
extends: [
7+
'plugin:@typescript-eslint/recommended',
8+
'prettier/@typescript-eslint',
9+
'plugin:prettier/recommended',
10+
],
11+
parserOptions: {
12+
sourceType: 'module',
13+
useJSXTextNode: true,
14+
project: [
15+
path.resolve(__dirname, 'tsconfig.json'),
16+
path.resolve(__dirname, 'examples/tsconfig.json'),
17+
],
18+
},
19+
rules: {
20+
'no-underscore-dangle': 0,
21+
'arrow-body-style': 0,
22+
'no-unused-expressions': 0,
23+
'no-plusplus': 0,
24+
'no-console': 0,
25+
'func-names': 0,
26+
'comma-dangle': [
27+
'error',
28+
{
29+
arrays: 'always-multiline',
30+
objects: 'always-multiline',
31+
imports: 'always-multiline',
32+
exports: 'always-multiline',
33+
functions: 'ignore',
34+
},
35+
],
36+
'no-prototype-builtins': 0,
37+
'prefer-destructuring': 0,
38+
'no-else-return': 0,
39+
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
40+
'@typescript-eslint/explicit-member-accessibility': 0,
41+
'@typescript-eslint/no-explicit-any': 0,
42+
'@typescript-eslint/no-inferrable-types': 0,
43+
'@typescript-eslint/explicit-function-return-type': 0,
44+
'@typescript-eslint/no-use-before-define': 0,
45+
'@typescript-eslint/no-empty-function': 0,
46+
'@typescript-eslint/camelcase': 0,
47+
'@typescript-eslint/ban-ts-comment': 0,
48+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
49+
},
50+
env: {
51+
jasmine: true,
52+
jest: true,
53+
},
54+
};

.flowconfig

-49
This file was deleted.

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ notifications:
99
node_js:
1010
- "10"
1111
- "12"
12+
- "14"
1213
script:
1314
- yarn run test
1415
- yarn run build

examples/partialApi/index.js renamed to examples/fullApi/index.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* @flow */
2-
/* eslint-disable no-console */
3-
41
import express from 'express';
52
import graphqlHTTP from 'express-graphql';
63
import schema from './schema';
@@ -10,14 +7,14 @@ const expressPort = process.env.port || process.env.PORT || 4000;
107
const server = express();
118
server.use(
129
'/',
13-
(graphqlHTTP({
14-
schema: (schema: any),
10+
graphqlHTTP({
11+
schema,
1512
graphiql: true,
16-
formatError: error => ({
13+
customFormatErrorFn: (error) => ({
1714
message: error.message,
18-
stack: error.stack.split('\n'),
15+
stack: error?.stack?.split('\n'),
1916
}),
20-
}): any)
17+
})
2118
);
2219

2320
server.listen(expressPort, () => {

examples/fullApi/schema.js renamed to examples/fullApi/schema.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* @flow */
2-
31
import { GraphQLSchema, GraphQLObjectType } from 'graphql';
42
import awsSDK from 'aws-sdk';
53
import { AwsApiParser } from '../../src'; // from 'graphql-compose-aws';

examples/introspection/generate.js renamed to examples/introspection/generate.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* @flow */
2-
31
import fs from 'fs';
42
import path from 'path';
53
import { printSchema } from 'graphql';

examples/fullApi/index.js renamed to examples/partialApi/index.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* @flow */
2-
/* eslint-disable no-console */
3-
41
import express from 'express';
52
import graphqlHTTP from 'express-graphql';
63
import schema from './schema';
@@ -10,14 +7,14 @@ const expressPort = process.env.port || process.env.PORT || 4000;
107
const server = express();
118
server.use(
129
'/',
13-
(graphqlHTTP({
14-
schema: (schema: any),
10+
graphqlHTTP({
11+
schema,
1512
graphiql: true,
16-
formatError: error => ({
13+
customFormatErrorFn: (error) => ({
1714
message: error.message,
18-
stack: error.stack.split('\n'),
15+
stack: error?.stack?.split('\n'),
1916
}),
20-
}): any)
17+
})
2118
);
2219

2320
server.listen(expressPort, () => {

examples/partialApi/schema.js renamed to examples/partialApi/schema.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* @flow */
2-
31
import { GraphQLSchema, GraphQLObjectType } from 'graphql';
42
import awsSDK from 'aws-sdk';
53
import { AwsApiParser } from '../../src'; // from 'graphql-compose-aws';

examples/tsconfig.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2016",
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"esModuleInterop": true,
7+
"sourceMap": true,
8+
"declaration": true,
9+
"declarationMap": true,
10+
"removeComments": true,
11+
"resolveJsonModule": true,
12+
"strict": true,
13+
"noImplicitAny": true,
14+
"noImplicitReturns": true,
15+
"noFallthroughCasesInSwitch": true,
16+
"noUnusedParameters": true,
17+
"noUnusedLocals": true,
18+
"forceConsistentCasingInFileNames": true,
19+
"lib": ["es2017", "esnext.asynciterable"],
20+
"types": ["node", "jest"],
21+
"baseUrl": ".",
22+
"paths": {
23+
"*" : ["types/*"]
24+
},
25+
"rootDir": "../",
26+
},
27+
"include": ["./**/*"],
28+
"exclude": [
29+
"node_modules"
30+
]
31+
}

0 commit comments

Comments
 (0)