Last active
October 22, 2020 18:39
-
-
Save aigoncharov/63b84d88301c2fd3f1151855f8874d08 to your computer and use it in GitHub Desktop.
Initializing new TypeScript project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# don't ever lint node_modules | |
node_modules | |
# don't lint build output (make sure it's set to your correct build folder name) | |
dist | |
# don't lint nyc coverage output | |
coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
root: true, | |
parser: '@typescript-eslint/parser', | |
parserOptions: { | |
tsconfigRootDir: __dirname, | |
project: ['./tsconfig.json'], | |
}, | |
plugins: ['@typescript-eslint'], | |
extends: [ | |
'eslint:recommended', | |
'plugin:@typescript-eslint/recommended', | |
'plugin:@typescript-eslint/recommended-requiring-type-checking', | |
'prettier', | |
'prettier/@typescript-eslint', | |
], | |
rules: { | |
'@typescript-eslint/explicit-module-boundary-types': 'off', | |
'@typescript-eslint/ban-types': [ | |
'error', | |
{ | |
extendDefaults: true, | |
types: { | |
object: false, | |
}, | |
}, | |
], | |
}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
*.log* | |
/dist | |
*.tgz | |
/coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"hooks": { | |
"pre-commit": "npx lint-staged" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"*.{js,ts,tsx,json,css,scss,less,yml}": [ | |
"npx prettier --write", | |
], | |
"*.md": [ | |
"npx doctoc", | |
"npx prettier --write", | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
*.log* | |
/src | |
/tsconfig* | |
/tslint* | |
/index.ts | |
.prettierignore | |
.vscode | |
*.tgz | |
/coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"trailingComma": "all", | |
"semi": false, | |
"singleQuote": true, | |
"arrowParens": "always", | |
"printWidth": 140 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
language: node_js | |
node_js: | |
- 'lts/*' | |
script: | |
- npm run lint | |
- npm test | |
sudo: false | |
after_success: | |
- npm run coverage-report | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm i -D typescript eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-prettier prettier husky lint-staged doctoc jest @types/jest ts-jest shx coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
roots: ['<rootDir>'], | |
transform: { | |
'^.+\\.tsx?$': 'ts-jest', | |
}, | |
testRegex: '^.+\\.(test|spec)\\.tsx?$', | |
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | |
restoreMocks: true, | |
collectCoverage: true, | |
coveragePathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/node_modules/'], | |
coverageThreshold: { | |
global: { | |
branches: 80, | |
functions: 80, | |
lines: 80, | |
statements: 80, | |
}, | |
}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
"scripts": { | |
"test": "npx jest", | |
"compile": "npx shx rm -rf dist && npx tsc -p tsconfig.prod.json", | |
"lint": "npx eslint --ext .ts,.tsx .", | |
"prepack": "npm run compile", | |
"coverage-report": "npx shx cat coverage/lcov.info | coveralls" | |
}, | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"alwaysStrict": true, | |
"strict": true, | |
"noUnusedLocals": true, | |
"noFallthroughCasesInSwitch": true, | |
"target": "es2015", | |
"baseUrl": "./", | |
"moduleResolution": "node", | |
"declaration": true, | |
"removeComments": true, | |
"module": "commonjs", | |
"experimentalDecorators": true, | |
"emitDecoratorMetadata": true, | |
"esModuleInterop": true | |
}, | |
"include": ["./**/*.ts"] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"extends": "./tsconfig.json", | |
"compilerOptions": { | |
"outDir": "./dist" | |
}, | |
"include": ["./index.ts"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment