Compare commits
6 Commits
tjs/step-0
...
tjs/step-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00eade470c | ||
|
|
dbbb2064b7 | ||
|
|
28545516e3 | ||
|
|
b0d4378a07 | ||
|
|
e88f4ba7af | ||
|
|
650e66fe3f |
3
.babelrc
3
.babelrc
@@ -7,6 +7,7 @@
|
|||||||
"node": "10"
|
"node": "10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"@babel/preset-typescript"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
15
.eslintrc
15
.eslintrc
@@ -12,5 +12,20 @@
|
|||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true
|
"browser": true
|
||||||
|
},
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": "**/*.+(ts|tsx)",
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"project": "./tsconfig.json"
|
||||||
|
},
|
||||||
|
"plugins": ["@typescript-eslint/eslint-plugin"],
|
||||||
|
"extends": [
|
||||||
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"eslint-config-prettier/@typescript-eslint"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
5
.huskyrc
Normal file
5
.huskyrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"hooks": {
|
||||||
|
"pre-commit": "npm run check-types && lint-staged"
|
||||||
|
}
|
||||||
|
}
|
||||||
9
.lintstagedrc
Normal file
9
.lintstagedrc
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"*.+(js|ts|tsx)": [
|
||||||
|
"eslint"
|
||||||
|
],
|
||||||
|
"*.+(js|json|ts|tsx)": [
|
||||||
|
"prettier --write",
|
||||||
|
"git add"
|
||||||
|
]
|
||||||
|
}
|
||||||
1454
package-lock.json
generated
1454
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@@ -4,16 +4,26 @@
|
|||||||
"author": "Kent C. Dodds (http://kentcdodds.com/)",
|
"author": "Kent C. Dodds (http://kentcdodds.com/)",
|
||||||
"license": "GPLv3",
|
"license": "GPLv3",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "babel src --out-dir dist",
|
"build": "babel src --extensions .js,.ts,.tsx --out-dir dist",
|
||||||
"lint": "eslint --ignore-path .gitignore .",
|
"lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
|
||||||
"format": "prettier --ignore-path .gitignore --write \"**/*.+(js|json)\""
|
"check-types": "tsc",
|
||||||
|
"prettier": "prettier --ignore-path .gitignore \"**/*.+(js|json|ts|tsx)\"",
|
||||||
|
"format": "npm run prettier -- --write",
|
||||||
|
"check-format": "npm run prettier -- --list-different",
|
||||||
|
"validate": "npm run check-types && npm run check-format && npm run lint && npm run build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.7.0",
|
"@babel/cli": "^7.7.0",
|
||||||
"@babel/core": "^7.7.2",
|
"@babel/core": "^7.7.2",
|
||||||
"@babel/preset-env": "^7.7.1",
|
"@babel/preset-env": "^7.7.1",
|
||||||
|
"@babel/preset-typescript": "^7.7.2",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^2.7.0",
|
||||||
|
"@typescript-eslint/parser": "^2.7.0",
|
||||||
"eslint": "^6.6.0",
|
"eslint": "^6.6.0",
|
||||||
"eslint-config-prettier": "^6.5.0",
|
"eslint-config-prettier": "^6.5.0",
|
||||||
"prettier": "^1.19.1"
|
"husky": "^3.0.9",
|
||||||
|
"lint-staged": "^9.4.2",
|
||||||
|
"prettier": "^1.19.1",
|
||||||
|
"typescript": "^3.7.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
src/typescript-example.ts
Normal file
21
src/typescript-example.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
function add(a: number, b: number): number {
|
||||||
|
return a + b
|
||||||
|
}
|
||||||
|
|
||||||
|
interface User {
|
||||||
|
name: {
|
||||||
|
first: string
|
||||||
|
middle: string
|
||||||
|
last: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function getFullName(user: User): string {
|
||||||
|
const {
|
||||||
|
name: {first, middle, last},
|
||||||
|
} = user
|
||||||
|
return [first, middle, last].filter(Boolean).join('')
|
||||||
|
}
|
||||||
|
|
||||||
|
add(1, 2)
|
||||||
|
|
||||||
|
getFullName({name: {first: 'Joe', middle: 'Bud', last: 'Matthews'}})
|
||||||
6
tsconfig.json
Normal file
6
tsconfig.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"noEmit": true,
|
||||||
|
"baseUrl": "./src"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user