Skip to content

Commit

Permalink
scaffolding for typescript (reduxjs#3504)
Browse files Browse the repository at this point in the history
* scaffolding for typescript

* add jest types so tests will compile

* remove rollup-plugin-typescript2, probably don't need it

* add missing eslint-import

* fix linting errors
  • Loading branch information
cellog authored and timdorr committed Aug 15, 2019
1 parent 0435ce1 commit 80cb6b8
Show file tree
Hide file tree
Showing 10 changed files with 404 additions and 79 deletions.
1 change: 1 addition & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { NODE_ENV } = process.env

module.exports = {
presets: [
'@babel/typescript',
[
'@babel/env',
{
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
**/server.js
**/webpack.config*.js
**/flow-typed/**
# TODO: figure out a way to lint this using flow instead of typescript
examples/todos-flow
31 changes: 26 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
module.exports = {
extends: 'react-app',

parser: '@typescript-eslint/parser',

plugins: ['@typescript-eslint'],

settings: {
react: {
version: '16.8'
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx']
},
'import/resolver': {
// use <root>/tsconfig.json
typescript: {}
}
},

rules: {
'jsx-a11y/href-no-hash': 'off'
'jsx-a11y/href-no-hash': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_' // ignore unused variables whose name is '_'
}
]
},

overrides: [
{
files: 'test/**/*.js',
env: {
jest: true,
},
},
],
jest: true
}
}
]
}
11 changes: 5 additions & 6 deletions examples/todomvc/src/components/App.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import App from './App'
import Header from '../containers/Header'
import MainSection from '../containers/MainSection'


const setup = propOverrides => {
const setup = _propOverrides => {
const renderer = createRenderer()
renderer.render(<App />)
const output = renderer.getRenderOutput()
Expand All @@ -16,16 +15,16 @@ describe('components', () => {
describe('Header', () => {
it('should render', () => {
const output = setup()
const [ header ] = output.props.children
const [header] = output.props.children
expect(header.type).toBe(Header)
})
})

describe('Mainsection', () => {
it('should render', () => {
const output = setup()
const [ , mainSection ] = output.props.children
const [, mainSection] = output.props.children
expect(mainSection.type).toBe(MainSection)
})
})
})
})
Loading

0 comments on commit 80cb6b8

Please sign in to comment.