10 Commits

Author SHA1 Message Date
Kent C. Dodds
d16442c1f4 add npm-run-all --parallel 2019-11-12 17:41:09 -07:00
Kent C. Dodds
00eade470c add lint-staged 2019-11-12 17:40:22 -07:00
Kent C. Dodds
dbbb2064b7 add husky 2019-11-12 17:39:35 -07:00
Kent C. Dodds
28545516e3 support eslint with typescript 2019-11-12 17:38:47 -07:00
Kent C. Dodds
b0d4378a07 add typescript 2019-11-12 17:37:54 -07:00
Kent C. Dodds
e88f4ba7af SETUP FOR TYPESCRIPT 2019-11-12 17:36:47 -07:00
Kent C. Dodds
650e66fe3f prettier --list-different 2019-11-12 17:36:05 -07:00
Kent C. Dodds
544df8b178 setup eslint-config-prettier 2019-11-12 17:35:22 -07:00
Kent C. Dodds
4fa1a97129 config prettier 2019-11-12 17:33:03 -07:00
Kent C. Dodds
fbb81df6c9 install and run prettier 2019-11-12 17:32:53 -07:00
9 changed files with 1762 additions and 9 deletions

View File

@@ -7,6 +7,7 @@
"node": "10"
}
}
]
],
"@babel/preset-typescript"
]
}
}

View File

@@ -6,11 +6,26 @@
"jsx": true
}
},
"extends": ["eslint:recommended"],
"extends": ["eslint:recommended", "eslint-config-prettier"],
"rules": {
"strict": ["error", "never"]
},
"env": {
"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
View File

@@ -0,0 +1,5 @@
{
"hooks": {
"pre-commit": "npm run check-types && lint-staged"
}
}

9
.lintstagedrc Normal file
View File

@@ -0,0 +1,9 @@
{
"*.+(js|ts|tsx)": [
"eslint"
],
"*.+(js|json|ts|tsx)": [
"prettier --write",
"git add"
]
}

17
.prettierrc Normal file
View File

@@ -0,0 +1,17 @@
{
"arrowParens": "avoid",
"bracketSpacing": false,
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "always",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}

1669
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,13 +4,27 @@
"author": "Kent C. Dodds (http://kentcdodds.com/)",
"license": "GPLv3",
"scripts": {
"build": "babel src --out-dir dist",
"lint": "eslint --ignore-path .gitignore ."
"build": "babel src --extensions .js,.ts,.tsx --out-dir dist",
"lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
"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-all --parallel check-types check-format lint build"
},
"devDependencies": {
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/preset-env": "^7.7.1",
"eslint": "^6.6.0"
"@babel/preset-typescript": "^7.7.2",
"@typescript-eslint/eslint-plugin": "^2.7.0",
"@typescript-eslint/parser": "^2.7.0",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.5.0",
"husky": "^3.0.9",
"lint-staged": "^9.4.2",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"typescript": "^3.7.2"
}
}

21
src/typescript-example.ts Normal file
View 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
View File

@@ -0,0 +1,6 @@
{
"compilerOptions": {
"noEmit": true,
"baseUrl": "./src"
}
}