From 96cafcb4e7bf01d9f52640dd1c09344f6d7cd858 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sun, 16 Jun 2019 23:09:22 +0800 Subject: [PATCH] chore: init --- .editorconfig | 19 +++++++++ .eslintrc.js | 95 +++++++++++++++++++++++++++++++++++++++++ .gitignore | 81 +++++++++++++++++++++++++++++++++++ .vscode/extensions.json | 6 +++ .vscode/settings.json | 43 +++++++++++++++++++ index.ts | 3 ++ package.json | 31 ++++++++++++++ renovate.json | 15 +++++++ tsconfig.json | 32 ++++++++++++++ 9 files changed, 325 insertions(+) create mode 100644 .editorconfig create mode 100644 .eslintrc.js create mode 100644 .gitignore create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 index.ts create mode 100644 package.json create mode 100644 renovate.json create mode 100644 tsconfig.json diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2ca5986 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{xml,xsd}] +max_line_length = off +end_of_line = lf +indent_style = space +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_size = 2 \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..06171e5 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,95 @@ +module.exports = { + root: true, + env: { + es6: true, + browser: true, + node: true, + }, + plugins: [ + '@typescript-eslint', + ], + parser: '@typescript-eslint/parser', + extends: [ + 'plugin:@typescript-eslint/recommended', + ], + // add your custom rules here + rules: { + 'semi': [2, 'never'], + 'curly': [2, 'multi-or-nest', 'consistent'], + 'quotes': ['error', 'single'], + 'no-unused-vars': 'warn', + 'no-param-reassign': 'off', + 'brace-style': ['error', 'stroustrup', { 'allowSingleLine': true }], + 'array-bracket-spacing': ['error', 'never'], + 'block-spacing': ['error', 'always'], + 'camelcase': 'off', + 'comma-spacing': ['error', { before: false, after: true }], + 'comma-style': ['error', 'last'], + 'comma-dangle': ['error', 'always-multiline'], + 'no-console': 'warn', + 'no-constant-condition': 'warn', + 'no-debugger': 'error', + 'no-cond-assign': ['error', 'always'], + 'func-call-spacing': ['off', 'never'], + 'key-spacing': ['error', { beforeColon: false, afterColon: true }], + 'indent': ['error', 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }], + 'no-restricted-syntax': [ + 'error', + 'DebuggerStatement', + 'ForInStatement', + 'LabeledStatement', + 'WithStatement', + ], + 'no-spaced-func': 'error', + 'object-curly-spacing': ['error', 'always'], + 'no-return-await': 'off', + + // es6 + 'arrow-spacing': ['error', { before: true, after: true }], + 'no-var': 'error', + 'prefer-const': ['error', { + destructuring: 'any', + ignoreReadBeforeAssign: true, + }], + 'prefer-arrow-callback': ['error', { + allowNamedFunctions: false, + allowUnboundThis: true, + }], + 'object-shorthand': ['error', 'always', { + ignoreConstructors: false, + avoidQuotes: true, + }], + 'prefer-rest-params': 'error', + 'prefer-spread': 'error', + 'prefer-template': 'error', + 'template-curly-spacing': 'error', + + // best-practice + 'array-callback-return': 'error', + 'block-scoped-var': 'error', + 'consistent-return': 'off', + 'complexity': ['off', 11], + 'eqeqeq': ['error', 'allow-null'], + 'no-alert': 'warn', + 'no-case-declarations': 'error', + 'no-multi-spaces': 'error', + 'no-multi-str': 'error', + 'no-with': 'error', + 'no-void': 'error', + 'no-useless-escape': 'error', + 'vars-on-top': 'error', + 'require-await': 'off', + 'no-return-assign': 'off', + 'operator-linebreak': [2, 'before'], + + // TS + '@typescript-eslint/no-unused-vars': [2, { args: 'none' }], + '@typescript-eslint/indent': ['error', 2], + '@typescript-eslint/member-delimiter-style': ['error', { multiline: { delimiter: 'none' } }], + '@typescript-eslint/type-annotation-spacing': ['error', {}], + '@typescript-eslint/camelcase': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-member-accessibility': 'off', + '@typescript-eslint/no-explicit-any': 'off', + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..29669c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,81 @@ +# Created by .ignore support plugin (hsz.mobi) +### Node template +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# Nuxt generate +dist + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless + +# IDE +.idea diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..2b4d942 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "dbaeumer.vscode-eslint", + "editorconfig.editorconfig", + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f8ebf6f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,43 @@ +{ + // Basic + "search.exclude": { + "**/.git": true, + "**/node_modules": true, + "**/bower_components": true, + "**/tmp": true, + "**/dist": true, + "**/logs": true, + "**/package-lock.json": true, + }, + "editor.tabSize": 2, + "editor.renderWhitespace": "boundary", + "editor.formatOnPaste": true, + "editor.formatOnSave": false, + + "[json]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "vscode.json-language-features" + }, + "[xml]": { + "editor.formatOnSave": true + }, + + // Eslint + "eslint.autoFixOnSave": true, + "eslint.validate": [ + "javascript", + "javascriptreact", + { + "language": "typescript", + "autoFix": true + }, + { + "language": "vue", + "autoFix": true + }, + { + "language": "html", + "autoFix": true + } + ], +} diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..3f54527 --- /dev/null +++ b/index.ts @@ -0,0 +1,3 @@ +(async () => { + +})() diff --git a/package.json b/package.json new file mode 100644 index 0000000..55531d1 --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "ts-node-starter", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "ts-node ./index.ts", + "dev": "nodemon -w . --exec 'ts-node' ./index.ts" + }, + "keywords": [], + "author": "", + "license": "MIT", + "dependencies": { + "ts-node": "^8.3.0", + "typescript": "^3.5.2", + "ts-optchain": "^0.1.7" + }, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^1.10.2", + "@typescript-eslint/parser": "^1.10.2", + "eslint": "^5.16.0", + "eslint-config-standard": "^12.0.0", + "eslint-loader": "^2.1.2", + "eslint-plugin-import": "^2.17.3", + "eslint-plugin-node": "^9.1.0", + "eslint-plugin-promise": "^4.1.1", + "eslint-plugin-standard": "^4.0.0", + "nodemon": "^1.19.1", + "rimraf": "^2.6.3" + } +} diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..50635dc --- /dev/null +++ b/renovate.json @@ -0,0 +1,15 @@ +{ + "extends": [ + "config:base", + ":preserveSemverRanges", + "schedule:weekly", + "group:allNonMajor", + ":maintainLockFilesWeekly" + ], + "lockFileMaintenance": { + "extends": [ + "group:allNonMajor" + ], + "commitMessageAction": "Update" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..43dfcd3 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "esModuleInterop": true, + "experimentalDecorators": true, + "module": "commonjs", + "moduleResolution": "node", + "noEmit": true, + "noImplicitAny": false, + "resolveJsonModule": true, + "sourceMap": true, + "strict": true, + "target": "es2017", + "lib": [ + "esnext", + "esnext.asynciterable", + ], + "paths": { + "~/*": ["./*"], + "@/*": ["./*"], + }, + "types": [ + "@types/node", + ], + "plugins": [ + { "transform": "ts-optchain/transform" }, + ], + }, + "include": [ + "**/*.ts", + ] +}