Skip to content

Commit 27035c7

Browse files
piglovesyoulangpavel
authored andcommitted
Use TypeScript and other improvements on feature/apollo-pure (#1723)
* update apollo packages * bye apollo-link-state * fix: jest error by updating jest * mod: Make `yarn codegen` always executable * mod: Take care non-js import in flowconfig * suppress 'sequelize deprecated String based operators' error * suppress 'Please use `require("history").PathUtils' error * refac: make all components functional * Flow to Typescript (#13) * get available port on codegen (#14) * improve tyeps (#15) * refactor typings * remove unnecessary babel plugin * Type models * pass `eslint --ext .ts --ext .tsx` * mod: clear old type defs before codegen improve eslint defs * ignore Node12 build * Sqlite3 is still working on supporting Node12 TryGhost/node-sqlite3#1151 * Fix Node 12 build failure
1 parent 000a954 commit 27035c7

File tree

219 files changed

+1987
-30869
lines changed

Some content is hidden

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

219 files changed

+1987
-30869
lines changed

.eslintrc.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
// ESLint configuration
1111
// http://eslint.org/docs/user-guide/configuring
1212
module.exports = {
13-
parser: 'babel-eslint',
13+
parser: '@typescript-eslint/parser',
1414

1515
extends: [
1616
'airbnb',
17-
'plugin:flowtype/recommended',
1817
'plugin:css-modules/recommended',
1918
'prettier',
20-
'prettier/flowtype',
2119
'prettier/react',
2220
],
2321

24-
plugins: ['flowtype', 'css-modules', 'prettier'],
22+
plugins: ['@typescript-eslint/eslint-plugin', 'css-modules', 'prettier'],
23+
24+
parserOptions: {
25+
sourceType: 'module',
26+
project: './tsconfig.json',
27+
},
2528

2629
globals: {
2730
__DEV__: true,
@@ -51,7 +54,7 @@ module.exports = {
5154
'no-underscore-dangle': [
5255
'error',
5356
{
54-
allow: ['__typename'],
57+
allow: ['__typename', '__DEV__'],
5558
},
5659
],
5760

@@ -87,7 +90,7 @@ module.exports = {
8790

8891
// Allow .js files to use JSX syntax
8992
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
90-
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.jsx'] }],
93+
'react/jsx-filename-extension': [1, { extensions: ['.ts', '.tsx'] }],
9194

9295
// Functional and class components are equivalent from React’s point of view
9396
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
@@ -99,8 +102,29 @@ module.exports = {
99102

100103
'react/forbid-prop-types': 'off',
101104
'react/destructuring-assignment': 'off',
105+
// TypeScript types checks prop-types
106+
'react/prop-types': 'off',
102107

103108
// PropTypes and states are typed by Flow basically, but Flow cannot type defaultProps.
104109
'react/require-default-props': 'off',
110+
111+
// Cannot config .ts, .tsx resolution
112+
'import/no-unresolved': 'off',
113+
114+
'import/no-webpack-loader-syntax': 'off',
115+
116+
'no-unused-vars': 'off',
117+
'@typescript-eslint/no-unused-vars': [
118+
'error',
119+
{
120+
vars: 'local',
121+
args: 'after-used',
122+
ignoreRestSiblings: false,
123+
argsIgnorePattern: '^_',
124+
},
125+
],
126+
127+
// Type variables by Codegen can not be camelcase.
128+
camelcase: 'off',
105129
},
106130
};

.flowconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ module.file_ext=.json
1414
module.file_ext=.css
1515
module.file_ext=.scss
1616
module.file_ext=.graphql
17-
module.name_mapper='^.*\.graphql$' -> 'empty/object'
17+
module.name_mapper.extension='json' -> 'empty/object'
18+
module.name_mapper.extension='css' -> 'empty/object'
19+
module.name_mapper.extension='scss' -> 'empty/object'
20+
module.name_mapper.extension='graphql' -> 'empty/object'

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ addons:
1313
- g++-4.8
1414
cache: yarn
1515
script:
16-
- yarn codegen
1716
- yarn lint
1817
- yarn test
1918
- yarn build --release

apollo.config.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

babel.config.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
/**
2-
* React Starter Kit (https://www.reactstarterkit.com/)
3-
*
4-
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
5-
*
6-
* This source code is licensed under the MIT license found in the
7-
* LICENSE.txt file in the root directory of this source tree.
8-
*/
9-
10-
// Babel configuration
11-
// https://babeljs.io/docs/usage/api/
121
module.exports = {
132
presets: [
143
[
@@ -19,8 +8,8 @@ module.exports = {
198
},
209
},
2110
],
22-
'@babel/preset-flow',
2311
'@babel/preset-react',
12+
'@babel/preset-typescript',
2413
],
2514
plugins: [
2615
'@babel/plugin-proposal-class-properties',

docs/react-style-guide.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,13 @@ Navigation.propTypes = { items: PropTypes.array.isRequired };
125125

126126
```jsx
127127
// Navigation.js
128-
// @flow
129128
import React from 'react';
130129
import withStyles from 'isomorphic-style-loader/lib/withStyles';
131130
import s from './Navigation.scss';
132131

133-
type PropTypes = {|
132+
type PropTypes = {
134133
className: string,
135-
|};
134+
};
136135

137136
function Navigation(props: PropTypes) {
138137
return (

docs/recipes/how-to-integrate-disqus.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ https://disqus.com/admin/create/
55
#### `DisqusThread.js`
66

77
```js
8-
// @flow
98
import React from 'react';
109

1110
const SHORTNAME = 'example';
@@ -22,11 +21,11 @@ function renderDisqus() {
2221
}
2322
}
2423

25-
class DisqusThread extends React.Component<{|
24+
class DisqusThread extends React.Component<{
2625
id: string,
2726
title: string,
2827
path: string,
29-
|}> {
28+
}> {
3029
shouldComponentUpdate(nextProps) {
3130
return (
3231
this.props.id !== nextProps.id ||

flow-typed/global.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)