Skip to content

Instantly share code, notes, and snippets.

@mintyPT
Last active October 30, 2019 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mintyPT/7ebf9e116e1561f520682103475ade21 to your computer and use it in GitHub Desktop.
Save mintyPT/7ebf9e116e1561f520682103475ade21 to your computer and use it in GitHub Desktop.
Bootstrap a typesript (node) project
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
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',
},
};
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 120,
tabWidth: 4,
};
console.log("hello world!");
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist"
},
"lib": ["es2015"],
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
".vscode"
]
}
// 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