Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TypeScript and other improvements on feature/apollo-pure #1723

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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