Last active
October 30, 2019 21:10
-
-
Save mintyPT/7ebf9e116e1561f520682103475ade21 to your computer and use it in GitHub Desktop.
Bootstrap a typesript (node) project
This file contains 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 init -y | |
npm install \ | |
tslint \ | |
eslint \ | |
ts-node \ | |
nodemon \ | |
prettier \ | |
typescript \ | |
eslint-config-prettier \ | |
eslint-plugin-prettier \ | |
@types/node \ | |
@typescript-eslint/parser \ | |
@typescript-eslint/eslint-plugin \ | |
eslint-plugin-import -D |
This file contains 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 = { | |
parser: '@typescript-eslint/parser', // Specifies the ESLint parser | |
extends: [ | |
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin | |
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier | |
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array | |
], | |
parserOptions: { | |
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features | |
sourceType: 'module', // Allows for the use of imports | |
}, | |
rules: { | |
'no-console': 'warn' | |
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs | |
// e.g. @typescript-eslint/explicit-function-return-type: 'off', | |
}, | |
}; |
This file contains 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 = { | |
semi: true, | |
trailingComma: 'all', | |
singleQuote: true, | |
printWidth: 120, | |
tabWidth: 4, | |
}; |
This file contains 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
console.log("hello world!"); |
This file contains 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": { | |
"module": "commonjs", | |
"esModuleInterop": true, | |
"target": "es6", | |
"moduleResolution": "node", | |
"sourceMap": true, | |
"outDir": "dist" | |
}, | |
"lib": ["es2015"], | |
"include": [ | |
"src/**/*.ts" | |
], | |
"exclude": [ | |
"node_modules", | |
".vscode" | |
] | |
} |
This file contains 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
// Change package.json with the following modifications | |
{ | |
"scripts": { | |
"start": "node --inspect=5858 -r ts-node/register ./src/app.ts", | |
"start:watch": "nodemon", | |
"build": "tsc", | |
"run": "node dist/app.js" | |
} | |
"main": "dist/app.js", | |
"nodemonConfig": { | |
"ignore": [ | |
"**/*.test.ts", | |
"**/*.spec.ts", | |
".git", | |
"node_modules" | |
], | |
"watch": [ | |
"src" | |
], | |
"exec": "npm start", | |
"ext": "ts" | |
}, | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment