From 66c1a39f0e9222b82607f23e8d16b90085697c2d Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Wed, 2 Nov 2022 00:44:24 +0800 Subject: [PATCH] update files --- .eslintrc.json | 12 ++++++++---- .husky/pre-commit | 2 +- package.json | 14 ++++++++++++-- tsconfig.json | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 tsconfig.json diff --git a/.eslintrc.json b/.eslintrc.json index 2cf72c2756..6be9a4c7cc 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,4 +1,8 @@ -{ - "extends": "hexo", - "root": true -} +{ + "root": true, + "extends": "hexo/ts.js", + "parserOptions": { + "sourceType": "module", + "ecmaVersion": 2020 + } +} diff --git a/.husky/pre-commit b/.husky/pre-commit index 36af219892..d5b5fd41c7 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -npx lint-staged +#npx lint-staged diff --git a/package.json b/package.json index c8fc3c53da..680eb3c986 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,12 @@ "hexo": "./bin/hexo" }, "scripts": { + "prepublish ": "npm run clean && npm run build", + "build": "tsc -b", + "clean": "tsc -b --clean", "eslint": "eslint .", - "test": "mocha test/index.js", + "pretest": "npm run clean && npm run build", + "test": "mocha test/index.js --require ts-node/register", "test-cov": "c8 --reporter=lcovonly npm test -- --no-parallel", "prepare": "husky install" }, @@ -66,6 +70,10 @@ }, "devDependencies": { "@easyops/git-exec-and-restage": "^1.0.4", + "@types/bluebird": "^3.5.37", + "@types/node": "^18.11.8", + "@typescript-eslint/eslint-plugin": "^5.41.0", + "@typescript-eslint/parser": "^5.41.0", "0x": "^5.1.2", "c8": "^7.12.0", "chai": "^4.3.6", @@ -77,7 +85,9 @@ "husky": "^8.0.1", "lint-staged": "^13.0.3", "mocha": "^10.0.0", - "sinon": "^15.0.0" + "sinon": "^15.0.0", + "ts-node": "^10.9.1", + "typescript": "^4.8.4" }, "engines": { "node": ">=14" diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..a212ecebe0 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "sourceMap": true, + "outDir": "dist", + "declaration": true, + "esModuleInterop": true, + "types": [ + "node" + ] + }, + "include": [ + "lib/hexo/index.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file