Skip to content

Instantly share code, notes, and snippets.

@PranjalAgni
Last active April 17, 2021 17:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PranjalAgni/8dde905152edcf7bfc6c74b73f5c6fdd to your computer and use it in GitHub Desktop.
Save PranjalAgni/8dde905152edcf7bfc6c74b73f5c6fdd to your computer and use it in GitHub Desktop.
Setting up NodeJS + Typescript project
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"no-console": 1,
"prettier/prettier": 2
}
}
{
"semi": true,
"trailingComma": "none",
"singleQuote": false,
"printWidth": 80
}
{
"watch": ["src"],
"ext": ".ts,.js",
"ignore": [],
"exec": "ts-node --files ./src/index.ts"
}
{
"scripts": {
"build": "rimraf ./dist && tsc",
"start": "npm run build && node dist/server.js",
"start:dev": "nodemon",
"lint": "eslint . --ext .ts"
}
}
npm init -y
npm install -D typescript
npm install -D @types/node
npm install --save-dev ts-node nodemon
npm install -D prettier
npm install -D eslint-config-prettier eslint-plugin-prettier
npx eslint --init
Add tsconfig.json
Add nodemon.json
Add .eslintrc
Add .prettierrc
Sample package.json scripts
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": ["node_modules/*", "src/types/*"]
}
},
"include": ["src/**/*"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment