Browse Source
Merge pull request #1802 from doccano/enhancement/frontendLinter
[Enhancement] frontend linter
pull/1803/head
Hiroki Nakayama
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with
35 additions and
30 deletions
-
.github/workflows/ci.yml
-
frontend/.eslintrc.js
-
frontend/components/auth/FormLogin.vue
-
frontend/composables/useLabelList.ts
-
frontend/composables/useProjectItem.ts
-
frontend/middleware/check-admin.js
-
frontend/nuxt.config.js
-
frontend/pages/projects/_id/dataset/import.vue
-
frontend/plugins/services.ts
-
frontend/repositories/comment/apiCommentRepository.ts
-
frontend/repositories/project/apiProjectRepository.ts
-
frontend/repositories/tasks/sequenceLabeling/apiRelationRepository.ts
-
frontend/services/application/autoLabeling/configApplicationService.ts
-
frontend/services/application/label/labelApplicationService.ts
-
frontend/services/application/tag/tagApplicationService.ts
-
frontend/test/unit/components/tasks/toolbar/forms/formGuideline.spec.js
|
@ -3,13 +3,11 @@ name: doccano CI |
|
|
on: [push, pull_request] |
|
|
on: [push, pull_request] |
|
|
|
|
|
|
|
|
jobs: |
|
|
jobs: |
|
|
build: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backend: |
|
|
runs-on: ubuntu-latest |
|
|
runs-on: ubuntu-latest |
|
|
defaults: |
|
|
defaults: |
|
|
run: |
|
|
run: |
|
|
working-directory: ./backend |
|
|
working-directory: ./backend |
|
|
|
|
|
|
|
|
steps: |
|
|
steps: |
|
|
- uses: actions/checkout@v2 |
|
|
- uses: actions/checkout@v2 |
|
|
- name: Set up Python 3.8 |
|
|
- name: Set up Python 3.8 |
|
@ -40,3 +38,20 @@ jobs: |
|
|
- name: Run tests |
|
|
- name: Run tests |
|
|
run: | |
|
|
run: | |
|
|
poetry run task test |
|
|
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 |
|
@ -19,12 +19,12 @@ module.exports = { |
|
|
message: 'Unexpected property on console object was called' |
|
|
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', |
|
|
'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' |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -54,7 +54,7 @@ export default Vue.extend({ |
|
|
props: { |
|
|
props: { |
|
|
login: { |
|
|
login: { |
|
|
type: Function, |
|
|
type: Function, |
|
|
default: (username: string, password: string) => Promise |
|
|
|
|
|
|
|
|
default: () => Promise |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
data() { |
|
|
data() { |
|
|
|
@ -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 { LabelDTO } from '@/services/application/label/labelData' |
|
|
import { CreateLabelCommand , UpdateLabelCommand } from '@/services/application/label/labelCommand' |
|
|
import { CreateLabelCommand , UpdateLabelCommand } from '@/services/application/label/labelCommand' |
|
|
import { LabelApplicationService } from '@/services/application/label/labelApplicationService' |
|
|
import { LabelApplicationService } from '@/services/application/label/labelApplicationService' |
|
@ -8,8 +8,6 @@ export const useLabelList = (service: LabelApplicationService) => { |
|
|
labels: [] as LabelDTO[] |
|
|
labels: [] as LabelDTO[] |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
const { app } = useContext() |
|
|
|
|
|
|
|
|
|
|
|
const getLabelList = async( |
|
|
const getLabelList = async( |
|
|
projectId: string |
|
|
projectId: string |
|
|
) => { |
|
|
) => { |
|
|
|
@ -1,4 +1,3 @@ |
|
|
import _ from 'lodash' |
|
|
|
|
|
import { reactive, useContext } from '@nuxtjs/composition-api' |
|
|
import { reactive, useContext } from '@nuxtjs/composition-api' |
|
|
import { ProjectDTO } from '@/services/application/project/projectData' |
|
|
import { ProjectDTO } from '@/services/application/project/projectData' |
|
|
|
|
|
|
|
|
|
@ -6,7 +6,6 @@ export default _.debounce(async function({ app, store, route, redirect }) { |
|
|
} catch(e) { |
|
|
} catch(e) { |
|
|
redirect('/projects') |
|
|
redirect('/projects') |
|
|
} |
|
|
} |
|
|
const userId = store.getters['auth/getUserId'] |
|
|
|
|
|
const isProjectAdmin = await app.$services.member.isProjectAdmin(route.params.id) |
|
|
const isProjectAdmin = await app.$services.member.isProjectAdmin(route.params.id) |
|
|
const projectRoot = app.localePath('/projects/' + route.params.id) |
|
|
const projectRoot = app.localePath('/projects/' + route.params.id) |
|
|
const path = route.fullPath.replace(/\/$/g, '') |
|
|
const path = route.fullPath.replace(/\/$/g, '') |
|
|
|
@ -144,7 +144,7 @@ export default { |
|
|
** You can extend webpack config here |
|
|
** You can extend webpack config here |
|
|
*/ |
|
|
*/ |
|
|
publicPath: process.env.PUBLIC_PATH || '/_nuxt/', |
|
|
publicPath: process.env.PUBLIC_PATH || '/_nuxt/', |
|
|
extend(config, ctx) { |
|
|
|
|
|
|
|
|
extend(config, _) { |
|
|
// config.module.rules.push({
|
|
|
// config.module.rules.push({
|
|
|
// test: /\.(txt|csv|conll|jsonl)$/i,
|
|
|
// test: /\.(txt|csv|conll|jsonl)$/i,
|
|
|
// loader: 'file-loader',
|
|
|
// loader: 'file-loader',
|
|
|
|
@ -165,12 +165,12 @@ export default { |
|
|
}, |
|
|
}, |
|
|
textFields() { |
|
|
textFields() { |
|
|
const asArray = Object.entries(this.properties) |
|
|
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) |
|
|
return Object.fromEntries(textFields) |
|
|
}, |
|
|
}, |
|
|
selectFields() { |
|
|
selectFields() { |
|
|
const asArray = Object.entries(this.properties) |
|
|
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) |
|
|
return Object.fromEntries(textFields) |
|
|
}, |
|
|
}, |
|
|
acceptedFileTypes() { |
|
|
acceptedFileTypes() { |
|
|
|
@ -75,7 +75,7 @@ declare module 'vue/types/vue' { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const plugin: Plugin = (context, inject) => { |
|
|
|
|
|
|
|
|
const plugin: Plugin = (_, inject) => { |
|
|
const memberRepository = new APIMemberRepository() |
|
|
const memberRepository = new APIMemberRepository() |
|
|
const userRepository = new APIUserRepository() |
|
|
const userRepository = new APIUserRepository() |
|
|
const roleRepository = new APIRoleRepository() |
|
|
const roleRepository = new APIRoleRepository() |
|
|
|
@ -35,7 +35,7 @@ export class APICommentRepository implements CommentRepository { |
|
|
|
|
|
|
|
|
async delete(projectId: string, commentId: number): Promise<void> { |
|
|
async delete(projectId: string, commentId: number): Promise<void> { |
|
|
const url = `/projects/${projectId}/comments/${commentId}` |
|
|
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<void> { |
|
|
async deleteBulk(projectId: string, items: number[]): Promise<void> { |
|
|
|
@ -29,7 +29,7 @@ export class APIProjectRepository implements ProjectRepository { |
|
|
|
|
|
|
|
|
async update(item: ProjectWriteItem): Promise<void> { |
|
|
async update(item: ProjectWriteItem): Promise<void> { |
|
|
const url = `/projects/${item.id}` |
|
|
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<void> { |
|
|
async bulkDelete(projectIds: number[]): Promise<void> { |
|
|
|
@ -28,7 +28,7 @@ export class ApiRelationRepository implements RelationRepository { |
|
|
|
|
|
|
|
|
async delete(projectId: string, exampleId: number, relationId: number): Promise<void> { |
|
|
async delete(projectId: string, exampleId: number, relationId: number): Promise<void> { |
|
|
const url = `/projects/${projectId}/examples/${exampleId}/relations/${relationId}` |
|
|
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<void> { |
|
|
async bulkDelete(projectId: string, exampleId: number, relationIds: number[]): Promise<void> { |
|
|
|
@ -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' |
|
|
import { ConfigItemList, ConfigItem } from '~/domain/models/autoLabeling/config' |
|
|
|
|
|
|
|
|
export class ConfigApplicationService { |
|
|
export class ConfigApplicationService { |
|
|
|
@ -63,11 +63,6 @@ export class LabelApplicationService { |
|
|
async upload(projectId: string, file: File) { |
|
|
async upload(projectId: string, file: File) { |
|
|
const formData = new FormData() |
|
|
const formData = new FormData() |
|
|
formData.append('file', file) |
|
|
formData.append('file', file) |
|
|
const config = { |
|
|
|
|
|
headers: { |
|
|
|
|
|
'Content-Type': 'multipart/form-data' |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
await this.repository.uploadFile(projectId, formData) |
|
|
await this.repository.uploadFile(projectId, formData) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1,6 +1,5 @@ |
|
|
import { TagDTO } from './tagData' |
|
|
import { TagDTO } from './tagData' |
|
|
import { TagRepository } from '~/domain/models/tag/tagRepository' |
|
|
import { TagRepository } from '~/domain/models/tag/tagRepository' |
|
|
import { TagItem } from '~/domain/models/tag/tag' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class TagApplicationService { |
|
|
export class TagApplicationService { |
|
|
|
@ -6,7 +6,7 @@ import FormGuideline from '@/components/tasks/toolbar/forms/FormGuideline' |
|
|
|
|
|
|
|
|
const $t = () => {} |
|
|
const $t = () => {} |
|
|
|
|
|
|
|
|
const factory = (values = {}) => { |
|
|
|
|
|
|
|
|
const factory = () => { |
|
|
return mount(FormGuideline, { |
|
|
return mount(FormGuideline, { |
|
|
propsData: { |
|
|
propsData: { |
|
|
guidelineText: 'Hello' |
|
|
guidelineText: 'Hello' |
|
|