Skip to content

Commit

Permalink
Use TypeScript and other improvements on feature/apollo-pure (kriasof…
Browse files Browse the repository at this point in the history
…t#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
  • Loading branch information
piglovesyou authored and langpavel committed May 27, 2019
1 parent 000a954 commit 27035c7
Show file tree
Hide file tree
Showing 219 changed files with 1,987 additions and 30,869 deletions.
36 changes: 30 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@
// ESLint configuration
// http://eslint.org/docs/user-guide/configuring
module.exports = {
parser: 'babel-eslint',
parser: '@typescript-eslint/parser',

extends: [
'airbnb',
'plugin:flowtype/recommended',
'plugin:css-modules/recommended',
'prettier',
'prettier/flowtype',
'prettier/react',
],

plugins: ['flowtype', 'css-modules', 'prettier'],
plugins: ['@typescript-eslint/eslint-plugin', 'css-modules', 'prettier'],

parserOptions: {
sourceType: 'module',
project: './tsconfig.json',
},

globals: {
__DEV__: true,
Expand Down Expand Up @@ -51,7 +54,7 @@ module.exports = {
'no-underscore-dangle': [
'error',
{
allow: ['__typename'],
allow: ['__typename', '__DEV__'],
},
],

Expand Down Expand Up @@ -87,7 +90,7 @@ module.exports = {

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

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

'react/forbid-prop-types': 'off',
'react/destructuring-assignment': 'off',
// TypeScript types checks prop-types
'react/prop-types': 'off',

// PropTypes and states are typed by Flow basically, but Flow cannot type defaultProps.
'react/require-default-props': 'off',

// Cannot config .ts, .tsx resolution
'import/no-unresolved': 'off',

'import/no-webpack-loader-syntax': 'off',

'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'local',
args: 'after-used',
ignoreRestSiblings: false,
argsIgnorePattern: '^_',
},
],

// Type variables by Codegen can not be camelcase.
camelcase: 'off',
},
};
5 changes: 4 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ module.file_ext=.json
module.file_ext=.css
module.file_ext=.scss
module.file_ext=.graphql
module.name_mapper='^.*\.graphql$' -> 'empty/object'
module.name_mapper.extension='json' -> 'empty/object'
module.name_mapper.extension='css' -> 'empty/object'
module.name_mapper.extension='scss' -> 'empty/object'
module.name_mapper.extension='graphql' -> 'empty/object'
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ addons:
- g++-4.8
cache: yarn
script:
- yarn codegen
- yarn lint
- yarn test
- yarn build --release
14 changes: 0 additions & 14 deletions apollo.config.js

This file was deleted.

13 changes: 1 addition & 12 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
/**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/

// Babel configuration
// https://babeljs.io/docs/usage/api/
module.exports = {
presets: [
[
Expand All @@ -19,8 +8,8 @@ module.exports = {
},
},
],
'@babel/preset-flow',
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: [
'@babel/plugin-proposal-class-properties',
Expand Down
5 changes: 2 additions & 3 deletions docs/react-style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,13 @@ Navigation.propTypes = { items: PropTypes.array.isRequired };

```jsx
// Navigation.js
// @flow
import React from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './Navigation.scss';

type PropTypes = {|
type PropTypes = {
className: string,
|};
};

function Navigation(props: PropTypes) {
return (
Expand Down
5 changes: 2 additions & 3 deletions docs/recipes/how-to-integrate-disqus.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ https://disqus.com/admin/create/
#### `DisqusThread.js`

```js
// @flow
import React from 'react';

const SHORTNAME = 'example';
Expand All @@ -22,11 +21,11 @@ function renderDisqus() {
}
}

class DisqusThread extends React.Component<{|
class DisqusThread extends React.Component<{
id: string,
title: string,
path: string,
|}> {
}> {
shouldComponentUpdate(nextProps) {
return (
this.props.id !== nextProps.id ||
Expand Down
3 changes: 0 additions & 3 deletions flow-typed/global.js

This file was deleted.

Loading

0 comments on commit 27035c7

Please sign in to comment.