Skip to content

Commit c373ce1

Browse files
cellogtimdorr
authored andcommitted
scaffolding for typescript (reduxjs#3504)
* 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 Former-commit-id: 80cb6b8 Former-commit-id: c81ec47
1 parent 4b79881 commit c373ce1

10 files changed

+40
-16
lines changed

.babelrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { NODE_ENV } = process.env
22

33
module.exports = {
44
presets: [
5+
'@babel/typescript',
56
[
67
'@babel/env',
78
{

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
**/server.js
44
**/webpack.config*.js
55
**/flow-typed/**
6+
# TODO: figure out a way to lint this using flow instead of typescript
7+
examples/todos-flow

.eslintrc.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
11
module.exports = {
22
extends: 'react-app',
33

4+
parser: '@typescript-eslint/parser',
5+
6+
plugins: ['@typescript-eslint'],
7+
48
settings: {
59
react: {
610
version: '16.8'
11+
},
12+
'import/parsers': {
13+
'@typescript-eslint/parser': ['.ts', '.tsx']
14+
},
15+
'import/resolver': {
16+
// use <root>/tsconfig.json
17+
typescript: {}
718
}
819
},
920

1021
rules: {
11-
'jsx-a11y/href-no-hash': 'off'
22+
'jsx-a11y/href-no-hash': 'off',
23+
'no-unused-vars': 'off',
24+
'@typescript-eslint/no-unused-vars': [
25+
'error',
26+
{
27+
vars: 'all',
28+
args: 'after-used',
29+
ignoreRestSiblings: true,
30+
argsIgnorePattern: '^_' // ignore unused variables whose name is '_'
31+
}
32+
]
1233
},
1334

1435
overrides: [
1536
{
1637
files: 'test/**/*.js',
1738
env: {
18-
jest: true,
19-
},
20-
},
21-
],
39+
jest: true
40+
}
41+
}
42+
]
2243
}

examples/todomvc/src/components/App.spec.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import App from './App'
44
import Header from '../containers/Header'
55
import MainSection from '../containers/MainSection'
66

7-
8-
const setup = propOverrides => {
7+
const setup = _propOverrides => {
98
const renderer = createRenderer()
109
renderer.render(<App />)
1110
const output = renderer.getRenderOutput()
@@ -16,16 +15,16 @@ describe('components', () => {
1615
describe('Header', () => {
1716
it('should render', () => {
1817
const output = setup()
19-
const [ header ] = output.props.children
18+
const [header] = output.props.children
2019
expect(header.type).toBe(Header)
2120
})
2221
})
23-
22+
2423
describe('Mainsection', () => {
2524
it('should render', () => {
2625
const output = setup()
27-
const [ , mainSection ] = output.props.children
26+
const [, mainSection] = output.props.children
2827
expect(mainSection.type).toBe(MainSection)
2928
})
3029
})
31-
})
30+
})

package-lock.json.REMOVED.git-id

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json.REMOVED.git-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6dc69e8d7768ccf0b08dd7b6ed73f57ce5ba7510
1+
ef5ac9f665f536f99ba2aa3a6496314137850705

rollup.config.js.REMOVED.git-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
07297f2bc2205b6f21539ca6f1c50d96d4cb9096
1+
89d43764d3ce5f9d29428bc2040651d5d716261b
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2efdc9f83f119b0e3a042b05ba15fc1fad93db05
1+
f681dee0eed57b22e6c9a3ba6e87d8efb0eaa745
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6a837c0d1d9dcadcfbc483465a928cac701ff99d
1+
f3700e2d6d86c13c2302d46af03dbf9bfac16f4e

tsconfig.json.REMOVED.git-id

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
052d09d209c201be4d4cdbc8fcdf634b5172ab8c

0 commit comments

Comments
 (0)