From c79f43b6137564b8b9d02a193c6d649a8e3533d7 Mon Sep 17 00:00:00 2001 From: Pavel Rybalko Date: Thu, 23 Sep 2021 11:18:01 +0700 Subject: [PATCH] fix #35 migrate to Typescript --- .eslintrc.js | 3 +- .nvmrc | 1 + jest.config.js | 4 +- package.json | 15 +- src/App.vue | 19 +- src/components/CanvasText.vue | 20 +- src/components/ForkMe.vue | 2 +- src/components/GeneralInfo.vue | 10 +- src/components/GoOfflineInfo.vue | 2 +- src/components/SavePageInfo.vue | 2 +- src/components/ShardInfo.vue | 28 +- src/components/ShardQrCode.vue | 7 +- src/{main.js => main.ts} | 10 + src/plugins/{online.js => online.ts} | 4 +- src/{router.js => router.ts} | 6 +- src/util/{crypto.js => crypto.ts} | 110 +- src/util/{passPhrase.js => passPhrase.ts} | 9 +- src/views/Combine.vue | 93 +- src/views/Info.vue | 2 +- src/views/Share.vue | 27 +- tests/unit/{crypto.spec.js => crypto.spec.ts} | 0 tsconfig.json | 64 + yarn.lock | 3904 +++++++++++------ 23 files changed, 2882 insertions(+), 1460 deletions(-) create mode 100644 .nvmrc rename src/{main.js => main.ts} (75%) rename src/plugins/{online.js => online.ts} (86%) rename src/{router.js => router.ts} (75%) rename src/util/{crypto.js => crypto.ts} (56%) rename src/util/{passPhrase.js => passPhrase.ts} (99%) rename tests/unit/{crypto.spec.js => crypto.spec.ts} (100%) create mode 100644 tsconfig.json diff --git a/.eslintrc.js b/.eslintrc.js index cb77944..abf2e6c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,7 +13,8 @@ module.exports = { globalReturn: false, impliedStrict: false, jsx: false - } + }, + parser: "@typescript-eslint/parser" }, env: { browser: true, diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..4ec320b --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v14.17.6 diff --git a/jest.config.js b/jest.config.js index 8140477..5682c38 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,10 +1,10 @@ module.exports = { - moduleFileExtensions: ["js", "jsx", "json", "vue"], + moduleFileExtensions: ["js", "jsx", "ts", "tsx", "json", "vue"], transform: { "^.+\\.vue$": "vue-jest", ".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$": "jest-transform-stub", - "^.+\\.jsx?$": "babel-jest" + "^.+\\.(js|jsx|ts|tsx)$": "ts-jest" }, moduleNameMapper: { "^@/(.*)$": "/src/$1" diff --git a/package.json b/package.json index 30625c0..90fe9c0 100644 --- a/package.json +++ b/package.json @@ -19,17 +19,20 @@ "scryptsy": "^2.0.0", "secrets.js-grempe": "^1.1.0", "tweetnacl": "^1.0.0", + "typescript": "^4.4.3", "vue": "^2.5.17", "vue-qrcode-reader": "^1.3.1", "vue-qriously": "^1.1.1", "vue-router": "^3.0.1" }, "devDependencies": { - "@vue/cli-plugin-eslint": "^3.1.5", - "@vue/cli-plugin-unit-jest": "^3.1.1", + "@types/jest": "^26.0.24", + "@typescript-eslint/parser": "^4.31.2", + "@vue/cli-plugin-eslint": "^4.5.13", + "@vue/cli-plugin-typescript": "^4.5.13", + "@vue/cli-plugin-unit-jest": "^4.5.13", "@vue/cli-service": "^3.1.4", "@vue/test-utils": "^1.0.0-beta.20", - "babel-eslint": "^10.0.1", "eslint": "^5.8.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-prettier": "^3.1.4", @@ -40,7 +43,9 @@ "html-webpack-inline-source-plugin": "1.0.0-beta.2", "html-webpack-plugin": "4.0.0-beta.4", "jest-junit": "^6.0.1", - "vue-template-compiler": "^2.5.17" + "ts-jest": "^26.4.4", + "vue-template-compiler": "^2.5.17", + "vuetype": "^0.3.2" }, "postcss": { "plugins": { @@ -50,7 +55,7 @@ "browserslist": [ "> 1%", "last 2 versions", - "not ie <= 8" + "not ie <= 11" ], "jest-junit": { "outputDirectory": ".test-results/jest", diff --git a/src/App.vue b/src/App.vue index e32452d..dc375b0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -35,22 +35,23 @@ -