diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..c24743d0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +[*.{js,jsx,ts,tsx,vue}] +indent_style = space +indent_size = 2 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 100 diff --git a/.eslintrc.js b/.eslintrc.js index b482d80b..a2035e1a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,6 +10,7 @@ module.exports = { 'prettier', 'plugin:prettier-vue/recommended', 'prettier/vue', + '@vue/typescript/recommended', ], parserOptions: { parser: 'babel-eslint', diff --git a/package.json b/package.json index cdaeb98d..2a93fb99 100644 --- a/package.json +++ b/package.json @@ -19,13 +19,16 @@ "vuex": "^3.4.0" }, "devDependencies": { - "@babel/polyfill": "^7.7.0", + "@typescript-eslint/eslint-plugin": "^2.33.0", + "@typescript-eslint/parser": "^2.33.0", "@vue/cli-plugin-babel": "~4.3.0", "@vue/cli-plugin-eslint": "~4.3.0", "@vue/cli-plugin-router": "^4.3.1", + "@vue/cli-plugin-typescript": "~4.4.0", "@vue/cli-plugin-vuex": "~4.3.0", "@vue/cli-service": "~4.3.0", "@vue/eslint-config-airbnb": "^5.0.2", + "@vue/eslint-config-typescript": "^5.0.2", "babel-eslint": "^10.1.0", "eslint": "^6.7.2", "eslint-config-airbnb": "^18.1.0", @@ -39,6 +42,7 @@ "prettier": "^2.0.5", "sass": "^1.19.0", "sass-loader": "^8.0.0", + "typescript": "~3.9.3", "vue-cli-plugin-bootstrap-vue": "~0.6.0", "vue-template-compiler": "^2.6.11" } diff --git a/src/main.js b/src/main.ts similarity index 100% rename from src/main.js rename to src/main.ts diff --git a/src/plugins/bootstrap-vue.js b/src/plugins/bootstrap-vue.ts similarity index 100% rename from src/plugins/bootstrap-vue.js rename to src/plugins/bootstrap-vue.ts diff --git a/src/shared/apiService.js b/src/shared/apiService.ts similarity index 96% rename from src/shared/apiService.js rename to src/shared/apiService.ts index 526751ae..831b69f0 100644 --- a/src/shared/apiService.js +++ b/src/shared/apiService.ts @@ -29,7 +29,7 @@ api.interceptors.response.use( console.log(err); if (err.response && err.response.status === 401) { console.log('Dispatching refresh_token...'); - apiStore.store.dispatch('user/refresh_token'); + apiStore.store.dispatch('user/refreshToken'); // maybe redirect to /login if needed ! } return new Promise((resolve, reject) => { diff --git a/src/shims.vue.d.ts b/src/shims.vue.d.ts new file mode 100644 index 00000000..54244845 --- /dev/null +++ b/src/shims.vue.d.ts @@ -0,0 +1,5 @@ +declare module '*.vue' { + import Vue from 'vue'; + + export default Vue; +} diff --git a/src/store/index.js b/src/store/index.ts similarity index 100% rename from src/store/index.js rename to src/store/index.ts diff --git a/src/store/modules/alerts.js b/src/store/modules/alerts.ts similarity index 100% rename from src/store/modules/alerts.js rename to src/store/modules/alerts.ts diff --git a/src/store/modules/ftbot.js b/src/store/modules/ftbot.ts similarity index 99% rename from src/store/modules/ftbot.js rename to src/store/modules/ftbot.ts index f0b06b49..a145f133 100644 --- a/src/store/modules/ftbot.js +++ b/src/store/modules/ftbot.ts @@ -6,7 +6,7 @@ export default { version: '', trades: [], openTrades: [], - trade_count: 0, + tradeCount: 0, performanceStats: [], whitelist: [], blacklist: [], @@ -28,7 +28,7 @@ export default { mutations: { updateTrades(state, trades) { state.trades = trades.trades; - state.trade_count = trades.trades_count; + state.tradeCount = trades.trades_count; }, updateOpenTrades(state, trades) { state.openTrades = trades; diff --git a/src/store/modules/user.js b/src/store/modules/user.ts similarity index 98% rename from src/store/modules/user.js rename to src/store/modules/user.ts index c7223a05..1c927985 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.ts @@ -89,7 +89,7 @@ export default { }) .catch(console.error); }, - refresh_token({ commit, dispatch }) { + refreshToken({ commit, dispatch }) { console.log('Refreshing token...'); const token = JSON.parse(localStorage.getItem(AUTH_REF_TOKEN)); axios diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..a3d4efa9 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + // this aligns with Vue's browser support + "target": "es5", + // this enables stricter inference for data properties on `this` + "strict": true, + // if using webpack 2+ or rollup, to leverage tree shaking: + "module": "es2015", + "moduleResolution": "node" + }, + "include": [ + "src/**/*.ts", + "src/**/*.tsx", + "src/**/*.vue", + "tests/**/*.ts", + "tests/**/*.tsx" + ] +}