Skip to content

Commit 76d1f98

Browse files
cellogtimdorr
authored andcommitted
scaffolding for typescript (#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
1 parent 9c9a4d2 commit 76d1f98

File tree

10 files changed

+404
-79
lines changed

10 files changed

+404
-79
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+
})

0 commit comments

Comments
 (0)