diff --git a/.eslintrc.cjs b/.eslintrc.cjs index e5a316339..854ae69ad 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -17,10 +17,15 @@ module.exports = { root: true, + plugins: [ + '@typescript-eslint', + ], + parser: 'vue-eslint-parser', parserOptions: { /* Allow new ECMAScript syntax but not globals. This is because vite/esbuild transforms syntax to es2015 (at the earliest) but does not pollyfill APIs. */ ecmaVersion: 'latest', + parser: '@typescript-eslint/parser' }, extends: [ 'standard', @@ -28,6 +33,7 @@ module.exports = { 'plugin:vue/vue3-essential', 'plugin:vuetify/base', 'plugin:cypress/recommended', + 'plugin:@typescript-eslint/recommended', ], rules: { 'comma-dangle': [ @@ -43,6 +49,35 @@ module.exports = { 'template-curly-spacing': [ 'off' ], + '@typescript-eslint/no-unused-vars': [ + 'error', + { + vars: 'all', + args: 'none', + } + ], + '@typescript-eslint/no-var-requires': [ + 'error', + { + allow: [ + '.*\\.cjs', + '.*\\.json', + ], + } + ], + '@typescript-eslint/no-explicit-any': [ + 'off', // Off while we migrate to TypeScript + ], + 'no-use-before-define': [ + 'off' // Handled by @typescript-eslint below + ], + '@typescript-eslint/no-use-before-define': [ + 'error', + { + functions: false, + variables: false, + } + ], 'vue/multi-word-component-names': [ 'off' ], @@ -60,6 +95,6 @@ module.exports = { ], 'cypress/unsafe-to-chain-command': [ 'off' - ] + ], }, } diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 45deb3ac1..758140387 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,6 +33,10 @@ jobs: run: | yarn run lint + - name: Type check + run: | + yarn run type-check + - name: Test run: | yarn run coverage:unit diff --git a/README.md b/README.md index 9ce5b468f..9d6970c3a 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ The project was originally created with [vue-cli](https://cli.vuejs.org/), but has switched to [Vite](https://vitejs.dev/) with the upgrade from Vue 2 to 3. The configuration for how the app is served and built is defined in -[`vite.config.js`](vite.config.js). +[`vite.config.ts`](vite.config.ts). We are currently using the [Vuetify component library](https://vuetifyjs.com/en/). Its configuration is defined in [`src/plugins/vuetify.js`](src/plugins/vuetify.js). @@ -211,10 +211,22 @@ testing the development version much easier. ### TypeScript -TypeScript is most likely the future for us. It can be adopted gradually. -At the moment we only have JSDoc comments which can provide type information +We are starting to adopt TypeScript, so have a mixture of `.ts` and `.js` files. +Vue single-file-components can use ` diff --git a/src/components/cylc/Header.vue b/src/components/cylc/Header.vue index 936e5ad66..9e9a153a9 100644 --- a/src/components/cylc/Header.vue +++ b/src/components/cylc/Header.vue @@ -117,7 +117,7 @@ along with this program. If not, see . - diff --git a/src/views/UserProfile.vue b/src/views/UserProfile.vue index 83f6e92dd..f9f80dd7f 100644 --- a/src/views/UserProfile.vue +++ b/src/views/UserProfile.vue @@ -246,9 +246,9 @@ import { mdiCog, mdiFormatFontSizeDecrease, mdiFormatFontSizeIncrease } from '@m import { useCyclePointsOrderDesc, useJobTheme, useReducedAnimation } from '@/composables/localStorage' import { getPageTitle } from '@/utils/index' import { decreaseFontSize, getCurrentFontSize, increaseFontSize, resetFontSize } from '@/utils/font-size' -import { allViews, useDefaultView } from '@/views/views.js' +import { allViews, useDefaultView } from '@/views/views' import Job from '@/components/cylc/Job.vue' -import JobState from '@/model/JobState.model' +import { JobStateNames } from '@/model/JobState.model' // TODO: update where user preferences are stored after #335 @@ -293,7 +293,7 @@ export default { }, }, - jobStates: JobState.enumValues.map(state => state.name), + jobStates: JobStateNames, jobThemes: [ 'default', diff --git a/src/views/Workspace.vue b/src/views/Workspace.vue index c8dfb9c3b..1d9220710 100644 --- a/src/views/Workspace.vue +++ b/src/views/Workspace.vue @@ -38,11 +38,11 @@ along with this program. If not, see .