From b8c9ab00f9d22f96978d20e90490318f6011cd54 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Tue, 26 Apr 2022 15:25:48 +0900 Subject: [PATCH 1/2] Update lint rules and fix files --- frontend/.eslintrc.js | 12 ++++++------ frontend/components/auth/FormLogin.vue | 2 +- frontend/composables/useLabelList.ts | 4 +--- frontend/composables/useProjectItem.ts | 1 - frontend/middleware/check-admin.js | 1 - frontend/nuxt.config.js | 2 +- frontend/pages/projects/_id/dataset/import.vue | 4 ++-- frontend/plugins/services.ts | 2 +- .../repositories/comment/apiCommentRepository.ts | 2 +- .../repositories/project/apiProjectRepository.ts | 2 +- .../tasks/sequenceLabeling/apiRelationRepository.ts | 2 +- .../autoLabeling/configApplicationService.ts | 2 +- .../application/label/labelApplicationService.ts | 5 ----- .../application/tag/tagApplicationService.ts | 1 - .../tasks/toolbar/forms/formGuideline.spec.js | 2 +- 15 files changed, 17 insertions(+), 27 deletions(-) diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 84625c88..96da87ad 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -19,12 +19,12 @@ module.exports = { message: 'Unexpected property on console object was called' } ], - 'vue/valid-template-root': 'off', - 'space-before-function-paren': ['error', 'never'], + // 'vue/valid-template-root': 'off', + // 'space-before-function-paren': ['error', 'never'], 'no-useless-constructor': 'off', - '@typescript-eslint/no-useless-constructor': 'off', - 'no-unused-vars': 'off', - '@typescript-eslint/no-unused-vars': 'off', - camelcase: 'off' + // '@typescript-eslint/no-useless-constructor': 'off', + // 'no-unused-vars': 'off', + // '@typescript-eslint/no-unused-vars': 'off', + 'camelcase': 'off' } } diff --git a/frontend/components/auth/FormLogin.vue b/frontend/components/auth/FormLogin.vue index 21e3adb0..c561926c 100644 --- a/frontend/components/auth/FormLogin.vue +++ b/frontend/components/auth/FormLogin.vue @@ -54,7 +54,7 @@ export default Vue.extend({ props: { login: { type: Function, - default: (username: string, password: string) => Promise + default: () => Promise } }, data() { diff --git a/frontend/composables/useLabelList.ts b/frontend/composables/useLabelList.ts index 4a84b267..1bc025b7 100644 --- a/frontend/composables/useLabelList.ts +++ b/frontend/composables/useLabelList.ts @@ -1,4 +1,4 @@ -import { computed, reactive, useContext } from '@nuxtjs/composition-api' +import { computed, reactive } from '@nuxtjs/composition-api' import { LabelDTO } from '@/services/application/label/labelData' import { CreateLabelCommand , UpdateLabelCommand } from '@/services/application/label/labelCommand' import { LabelApplicationService } from '@/services/application/label/labelApplicationService' @@ -8,8 +8,6 @@ export const useLabelList = (service: LabelApplicationService) => { labels: [] as LabelDTO[] }) - const { app } = useContext() - const getLabelList = async( projectId: string ) => { diff --git a/frontend/composables/useProjectItem.ts b/frontend/composables/useProjectItem.ts index dc723a37..16065d0d 100644 --- a/frontend/composables/useProjectItem.ts +++ b/frontend/composables/useProjectItem.ts @@ -1,4 +1,3 @@ -import _ from 'lodash' import { reactive, useContext } from '@nuxtjs/composition-api' import { ProjectDTO } from '@/services/application/project/projectData' diff --git a/frontend/middleware/check-admin.js b/frontend/middleware/check-admin.js index 200137cc..f6028c0e 100644 --- a/frontend/middleware/check-admin.js +++ b/frontend/middleware/check-admin.js @@ -6,7 +6,6 @@ export default _.debounce(async function({ app, store, route, redirect }) { } catch(e) { redirect('/projects') } - const userId = store.getters['auth/getUserId'] const isProjectAdmin = await app.$services.member.isProjectAdmin(route.params.id) const projectRoot = app.localePath('/projects/' + route.params.id) const path = route.fullPath.replace(/\/$/g, '') diff --git a/frontend/nuxt.config.js b/frontend/nuxt.config.js index 7675fb3e..53c8832c 100644 --- a/frontend/nuxt.config.js +++ b/frontend/nuxt.config.js @@ -144,7 +144,7 @@ export default { ** You can extend webpack config here */ publicPath: process.env.PUBLIC_PATH || '/_nuxt/', - extend(config, ctx) { + extend(config, _) { // config.module.rules.push({ // test: /\.(txt|csv|conll|jsonl)$/i, // loader: 'file-loader', diff --git a/frontend/pages/projects/_id/dataset/import.vue b/frontend/pages/projects/_id/dataset/import.vue index c5a352a5..d48aa37e 100644 --- a/frontend/pages/projects/_id/dataset/import.vue +++ b/frontend/pages/projects/_id/dataset/import.vue @@ -165,12 +165,12 @@ export default { }, textFields() { const asArray = Object.entries(this.properties) - const textFields = asArray.filter(([key, value]) => !('enum' in value)) + const textFields = asArray.filter(([_, value]) => !('enum' in value)) return Object.fromEntries(textFields) }, selectFields() { const asArray = Object.entries(this.properties) - const textFields = asArray.filter(([key, value]) => 'enum' in value) + const textFields = asArray.filter(([_, value]) => 'enum' in value) return Object.fromEntries(textFields) }, acceptedFileTypes() { diff --git a/frontend/plugins/services.ts b/frontend/plugins/services.ts index e13257f5..9ceb191f 100644 --- a/frontend/plugins/services.ts +++ b/frontend/plugins/services.ts @@ -75,7 +75,7 @@ declare module 'vue/types/vue' { } } -const plugin: Plugin = (context, inject) => { +const plugin: Plugin = (_, inject) => { const memberRepository = new APIMemberRepository() const userRepository = new APIUserRepository() const roleRepository = new APIRoleRepository() diff --git a/frontend/repositories/comment/apiCommentRepository.ts b/frontend/repositories/comment/apiCommentRepository.ts index b6a08eb3..8b21b871 100644 --- a/frontend/repositories/comment/apiCommentRepository.ts +++ b/frontend/repositories/comment/apiCommentRepository.ts @@ -35,7 +35,7 @@ export class APICommentRepository implements CommentRepository { async delete(projectId: string, commentId: number): Promise { const url = `/projects/${projectId}/comments/${commentId}` - const response = await this.request.delete(url) + await this.request.delete(url) } async deleteBulk(projectId: string, items: number[]): Promise { diff --git a/frontend/repositories/project/apiProjectRepository.ts b/frontend/repositories/project/apiProjectRepository.ts index 6da0810f..848c60c9 100644 --- a/frontend/repositories/project/apiProjectRepository.ts +++ b/frontend/repositories/project/apiProjectRepository.ts @@ -29,7 +29,7 @@ export class APIProjectRepository implements ProjectRepository { async update(item: ProjectWriteItem): Promise { const url = `/projects/${item.id}` - const response = await this.request.patch(url, item.toObject()) + await this.request.patch(url, item.toObject()) } async bulkDelete(projectIds: number[]): Promise { diff --git a/frontend/repositories/tasks/sequenceLabeling/apiRelationRepository.ts b/frontend/repositories/tasks/sequenceLabeling/apiRelationRepository.ts index 93f30873..bfa60549 100644 --- a/frontend/repositories/tasks/sequenceLabeling/apiRelationRepository.ts +++ b/frontend/repositories/tasks/sequenceLabeling/apiRelationRepository.ts @@ -28,7 +28,7 @@ export class ApiRelationRepository implements RelationRepository { async delete(projectId: string, exampleId: number, relationId: number): Promise { const url = `/projects/${projectId}/examples/${exampleId}/relations/${relationId}` - const response = await this.request.delete(url) + await this.request.delete(url) } async bulkDelete(projectId: string, exampleId: number, relationIds: number[]): Promise { diff --git a/frontend/services/application/autoLabeling/configApplicationService.ts b/frontend/services/application/autoLabeling/configApplicationService.ts index a4db1700..9b740696 100644 --- a/frontend/services/application/autoLabeling/configApplicationService.ts +++ b/frontend/services/application/autoLabeling/configApplicationService.ts @@ -1,4 +1,4 @@ -import { ConfigRepository, ConfigTestResponse } from '~/domain/models/autoLabeling/configRepository' +import { ConfigRepository } from '~/domain/models/autoLabeling/configRepository' import { ConfigItemList, ConfigItem } from '~/domain/models/autoLabeling/config' export class ConfigApplicationService { diff --git a/frontend/services/application/label/labelApplicationService.ts b/frontend/services/application/label/labelApplicationService.ts index 15e0c498..f8a17f1a 100644 --- a/frontend/services/application/label/labelApplicationService.ts +++ b/frontend/services/application/label/labelApplicationService.ts @@ -63,11 +63,6 @@ export class LabelApplicationService { async upload(projectId: string, file: File) { const formData = new FormData() formData.append('file', file) - const config = { - headers: { - 'Content-Type': 'multipart/form-data' - } - } await this.repository.uploadFile(projectId, formData) } } diff --git a/frontend/services/application/tag/tagApplicationService.ts b/frontend/services/application/tag/tagApplicationService.ts index 87f7f25e..5b46b2d2 100644 --- a/frontend/services/application/tag/tagApplicationService.ts +++ b/frontend/services/application/tag/tagApplicationService.ts @@ -1,6 +1,5 @@ import { TagDTO } from './tagData' import { TagRepository } from '~/domain/models/tag/tagRepository' -import { TagItem } from '~/domain/models/tag/tag' export class TagApplicationService { diff --git a/frontend/test/unit/components/tasks/toolbar/forms/formGuideline.spec.js b/frontend/test/unit/components/tasks/toolbar/forms/formGuideline.spec.js index 0f68ceb3..5c6ed4d6 100644 --- a/frontend/test/unit/components/tasks/toolbar/forms/formGuideline.spec.js +++ b/frontend/test/unit/components/tasks/toolbar/forms/formGuideline.spec.js @@ -6,7 +6,7 @@ import FormGuideline from '@/components/tasks/toolbar/forms/FormGuideline' const $t = () => {} -const factory = (values = {}) => { +const factory = () => { return mount(FormGuideline, { propsData: { guidelineText: 'Hello' From b4fb19ae297389184e06b36d9845bf51914072b3 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Tue, 26 Apr 2022 15:26:08 +0900 Subject: [PATCH 2/2] Add a frontend job to workflow --- .github/workflows/ci.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15bd5e59..7592dea9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,13 +3,11 @@ name: doccano CI on: [push, pull_request] jobs: - build: - + backend: runs-on: ubuntu-latest defaults: run: working-directory: ./backend - steps: - uses: actions/checkout@v2 - name: Set up Python 3.8 @@ -40,3 +38,20 @@ jobs: - name: Run tests run: | poetry run task test + + frontend: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./frontend + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '16' + - name: Install Yarn + run: npm install -g yarn + - name: Install npm modules + run: yarn install + - name: Lint + run: yarn lint