Skip to content

Instantly share code, notes, and snippets.

@aigoncharov
Last active October 22, 2020 18:39
Show Gist options
  • Save aigoncharov/63b84d88301c2fd3f1151855f8874d08 to your computer and use it in GitHub Desktop.
Save aigoncharov/63b84d88301c2fd3f1151855f8874d08 to your computer and use it in GitHub Desktop.
Initializing new TypeScript project
# 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
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,
},
},
],
},
}
node_modules
*.log*
/dist
*.tgz
/coverage
{
"hooks": {
"pre-commit": "npx lint-staged"
}
}
{
"*.{js,ts,tsx,json,css,scss,less,yml}": [
"npx prettier --write",
],
"*.md": [
"npx doctoc",
"npx prettier --write",
]
}
node_modules
*.log*
/src
/tsconfig*
/tslint*
/index.ts
.prettierignore
.vscode
*.tgz
/coverage
{
"trailingComma": "all",
"semi": false,
"singleQuote": true,
"arrowParens": "always",
"printWidth": 140
}
language: node_js
node_js:
- 'lts/*'
script:
- npm run lint
- npm test
sudo: false
after_success:
- npm run coverage-report
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
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,
},
},
}
...
"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"
},
...
{
"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"]
}
{
"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