├── .prettierrc.json ├── src └── index.ts ├── .prettierignore ├── tsconfig.eslint.json ├── .editorconfig ├── README.md ├── .eslintrc.js ├── LICENSE ├── .gitignore ├── package.json └── tsconfig.json /.prettierrc.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | function hello(name: string): string { 2 | return `Hello, ${name}!`; 3 | } 4 | 5 | console.log(hello("TypeScript!!!!!")); 6 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Ignore artifacts: 2 | /dist 3 | node_modules 4 | package.json 5 | package-lock.json 6 | tsconfig.json 7 | tsconfig.eslint.json 8 | -------------------------------------------------------------------------------- /tsconfig.eslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": [ 4 | "src/**/*.ts", 5 | ".eslintrc.js" 6 | ], 7 | "exclude": [ 8 | "node_modules", 9 | "dist" 10 | ] 11 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_size = 2 8 | indent_style = space 9 | trim_trailing_whitespace = true 10 | 11 | [Makefile] 12 | indent_size = 4 13 | indent_style = tab 14 | 15 | [*.{md,markdown}] 16 | insert_final_newline = false 17 | trim_trailing_whitespace = false 18 | 19 | [*.json] 20 | insert_final_newline = false 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # typescript-node-base-with-eslint-prettier 2 | 3 | * TypeScript + Node.js project boilerplate (with ESLint & Prettier) 4 | 5 | # Usage 6 | 7 | ``` 8 | git clone https://github.com/notakaos/typescript-node-base-with-eslint-prettier 9 | cd typescript-node-base-with-eslint-prettier 10 | npm install 11 | npm run dev 12 | 13 | # lint 14 | npm run lint:fix 15 | ``` 16 | 17 | # LICENSE 18 | 19 | ISC License 20 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | es6: true, 5 | node: true, 6 | }, 7 | parser: "@typescript-eslint/parser", 8 | parserOptions: { 9 | sourceType: "module", 10 | ecmaVersion: 2019, // Node.js 12の場合は2019、他のバージョンのNode.jsを利用している場合は場合は適宜変更する 11 | tsconfigRootDir: __dirname, 12 | project: ["./tsconfig.eslint.json"], 13 | }, 14 | plugins: ["@typescript-eslint"], 15 | extends: [ 16 | "eslint:recommended", 17 | "plugin:@typescript-eslint/recommended", 18 | "plugin:@typescript-eslint/recommended-requiring-type-checking", 19 | "prettier", 20 | "prettier/@typescript-eslint", 21 | ], 22 | rules: {}, 23 | }; 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) [YEAR], [YOUR_NAME] 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # macOS 2 | ### https://raw.github.com/github/gitignore/07c730e1fccfe0f92b29e039ba149d20bfb332e7/Global/macOS.gitignore 3 | .DS_Store 4 | .AppleDouble 5 | .LSOverride 6 | Icon 7 | ._* 8 | .DocumentRevisions-V100 9 | .fseventsd 10 | .Spotlight-V100 11 | .TemporaryItems 12 | .Trashes 13 | .VolumeIcon.icns 14 | .com.apple.timemachine.donotpresent 15 | .AppleDB 16 | .AppleDesktop 17 | Network Trash Folder 18 | Temporary Items 19 | .apdisk 20 | 21 | # Linux 22 | ### https://raw.github.com/github/gitignore/07c730e1fccfe0f92b29e039ba149d20bfb332e7/Global/Linux.gitignore 23 | *~ 24 | .fuse_hidden* 25 | .directory 26 | .Trash-* 27 | .nfs* 28 | 29 | # Windows 30 | ### https://raw.github.com/github/gitignore/07c730e1fccfe0f92b29e039ba149d20bfb332e7/Global/Windows.gitignore 31 | Thumbs.db 32 | ehthumbs.db 33 | ehthumbs_vista.db 34 | *.stackdump 35 | [Dd]esktop.ini 36 | $RECYCLE.BIN/ 37 | *.cab 38 | *.msi 39 | *.msm 40 | *.msp 41 | *.lnk 42 | 43 | # node.js 44 | ### https://raw.github.com/github/gitignore/07c730e1fccfe0f92b29e039ba149d20bfb332e7/Node.gitignore 45 | logs 46 | *.log 47 | npm-debug.log* 48 | yarn-debug.log* 49 | yarn-error.log* 50 | pids 51 | *.pid 52 | *.seed 53 | *.pid.lock 54 | lib-cov 55 | coverage 56 | .nyc_output 57 | .grunt 58 | bower_components 59 | .lock-wscript 60 | build/Release 61 | node_modules/ 62 | jspm_packages/ 63 | typings/ 64 | .npm 65 | .eslintcache 66 | .node_repl_history 67 | *.tgz 68 | .yarn-integrity 69 | .env 70 | .next 71 | 72 | /dist 73 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "typescript-node-base-with-eslint-prettier", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "dev": "ts-node src/index.ts", 8 | "dev:watch": "ts-node-dev --respawn src/index.ts", 9 | "clean": "rimraf dist/*", 10 | "tsc": "tsc", 11 | "build": "npm-run-all clean tsc", 12 | "start": "node .", 13 | "check-types": "tsc --noEmit", 14 | "format": "prettier --write 'src/**/*.{js,ts,json}'", 15 | "eslint": "eslint src/**/*.ts", 16 | "eslint:fix": "eslint src/**/*.ts --fix", 17 | "lint": "npm-run-all eslint check-types", 18 | "lint:fix": "npm-run-all eslint:fix check-types format" 19 | }, 20 | "keywords": [], 21 | "author": "", 22 | "license": "ISC", 23 | "devDependencies": { 24 | "@types/node": "^12.12.54", 25 | "@typescript-eslint/eslint-plugin": "^3.9.0", 26 | "@typescript-eslint/parser": "^3.9.0", 27 | "eslint": "^7.6.0", 28 | "eslint-config-prettier": "6.11.0", 29 | "husky": "^4.2.5", 30 | "lint-staged": "^10.2.11", 31 | "npm-run-all": "^4.1.5", 32 | "prettier": "2.0.5", 33 | "rimraf": "^3.0.2", 34 | "ts-node": "^8.10.2", 35 | "ts-node-dev": "^1.0.0-pre.56", 36 | "typescript": "^3.9.7" 37 | }, 38 | "husky": { 39 | "hooks": { 40 | "pre-commit": "lint-staged" 41 | } 42 | }, 43 | "lint-staged": { 44 | "*.{js,ts}": "eslint --cache --fix", 45 | "*.ts": "tsc --noEmit", 46 | "*.{js,ts,json}": "prettier --write" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Basic Options */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | "target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ 8 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ 9 | // "lib": [], /* Specify library files to be included in the compilation. */ 10 | // "allowJs": true, /* Allow javascript files to be compiled. */ 11 | // "checkJs": true, /* Report errors in .js files. */ 12 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ 13 | // "declaration": true, /* Generates corresponding '.d.ts' file. */ 14 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 15 | "sourceMap": true, /* Generates corresponding '.map' file. */ 16 | // "outFile": "./", /* Concatenate and emit output to single file. */ 17 | "outDir": "./dist", /* Redirect output structure to the directory. */ 18 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 19 | // "composite": true, /* Enable project compilation */ 20 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 21 | // "removeComments": true, /* Do not emit comments to output. */ 22 | // "noEmit": true, /* Do not emit outputs. */ 23 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 24 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 25 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 26 | 27 | /* Strict Type-Checking Options */ 28 | "strict": true, /* Enable all strict type-checking options. */ 29 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 30 | // "strictNullChecks": true, /* Enable strict null checks. */ 31 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 32 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 33 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 34 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 35 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 36 | 37 | /* Additional Checks */ 38 | // "noUnusedLocals": true, /* Report errors on unused locals. */ 39 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 40 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 41 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 42 | 43 | /* Module Resolution Options */ 44 | // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ 45 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 46 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 47 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 48 | // "typeRoots": [], /* List of folders to include type definitions from. */ 49 | // "types": [], /* Type declaration files to be included in compilation. */ 50 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 51 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 52 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 53 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 54 | 55 | /* Source Map Options */ 56 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 58 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 59 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 60 | 61 | /* Experimental Options */ 62 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 63 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 64 | 65 | /* Advanced Options */ 66 | "skipLibCheck": true, /* Skip type checking of declaration files. */ 67 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ 68 | }, 69 | "include": [ 70 | "src/**/*" 71 | ] 72 | } 73 | --------------------------------------------------------------------------------