Skip to content

Commit

Permalink
refactor: migrate codebase on typescript
Browse files Browse the repository at this point in the history
BREAKING CHANGE: removed flowtype definitions; min supported nodejs version is 8
  • Loading branch information
nodkz committed Aug 17, 2020
1 parent 71894a3 commit f790124
Show file tree
Hide file tree
Showing 72 changed files with 2,104 additions and 12,925 deletions.
55 changes: 0 additions & 55 deletions .babelrc

This file was deleted.

3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
flow-typed
lib
mjs
.eslintrc.js
41 changes: 0 additions & 41 deletions .eslintrc

This file was deleted.

54 changes: 54 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const path = require('path');

module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
parserOptions: {
sourceType: 'module',
useJSXTextNode: true,
project: [
path.resolve(__dirname, 'tsconfig.json'),
path.resolve(__dirname, 'examples/tsconfig.json'),
],
},
rules: {
'no-underscore-dangle': 0,
'arrow-body-style': 0,
'no-unused-expressions': 0,
'no-plusplus': 0,
'no-console': 0,
'func-names': 0,
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'ignore',
},
],
'no-prototype-builtins': 0,
'prefer-destructuring': 0,
'no-else-return': 0,
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
'@typescript-eslint/explicit-member-accessibility': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-inferrable-types': 0,
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
},
env: {
jasmine: true,
jest: true,
},
};
49 changes: 0 additions & 49 deletions .flowconfig

This file was deleted.

1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ notifications:
node_js:
- "10"
- "12"
- "14"
script:
- yarn run test
- yarn run build
Expand Down
13 changes: 5 additions & 8 deletions examples/partialApi/index.js → examples/fullApi/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* @flow */
/* eslint-disable no-console */

import express from 'express';
import graphqlHTTP from 'express-graphql';
import schema from './schema';
Expand All @@ -10,14 +7,14 @@ const expressPort = process.env.port || process.env.PORT || 4000;
const server = express();
server.use(
'/',
(graphqlHTTP({
schema: (schema: any),
graphqlHTTP({
schema,
graphiql: true,
formatError: error => ({
customFormatErrorFn: (error) => ({
message: error.message,
stack: error.stack.split('\n'),
stack: error?.stack?.split('\n'),
}),
}): any)
})
);

server.listen(expressPort, () => {
Expand Down
2 changes: 0 additions & 2 deletions examples/fullApi/schema.js → examples/fullApi/schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* @flow */

import { GraphQLSchema, GraphQLObjectType } from 'graphql';
import awsSDK from 'aws-sdk';
import { AwsApiParser } from '../../src'; // from 'graphql-compose-aws';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* @flow */

import fs from 'fs';
import path from 'path';
import { printSchema } from 'graphql';
Expand Down
13 changes: 5 additions & 8 deletions examples/fullApi/index.js → examples/partialApi/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* @flow */
/* eslint-disable no-console */

import express from 'express';
import graphqlHTTP from 'express-graphql';
import schema from './schema';
Expand All @@ -10,14 +7,14 @@ const expressPort = process.env.port || process.env.PORT || 4000;
const server = express();
server.use(
'/',
(graphqlHTTP({
schema: (schema: any),
graphqlHTTP({
schema,
graphiql: true,
formatError: error => ({
customFormatErrorFn: (error) => ({
message: error.message,
stack: error.stack.split('\n'),
stack: error?.stack?.split('\n'),
}),
}): any)
})
);

server.listen(expressPort, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* @flow */

import { GraphQLSchema, GraphQLObjectType } from 'graphql';
import awsSDK from 'aws-sdk';
import { AwsApiParser } from '../../src'; // from 'graphql-compose-aws';
Expand Down
31 changes: 31 additions & 0 deletions examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"removeComments": true,
"resolveJsonModule": true,
"strict": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es2017", "esnext.asynciterable"],
"types": ["node", "jest"],
"baseUrl": ".",
"paths": {
"*" : ["types/*"]
},
"rootDir": "../",
},
"include": ["./**/*"],
"exclude": [
"node_modules"
]
}

0 comments on commit f790124

Please sign in to comment.