From 42b1493931d89cbe15e2e932c661ca7e442a2f4a Mon Sep 17 00:00:00 2001 From: CzBiX Date: Thu, 26 Nov 2020 15:45:37 +0800 Subject: [PATCH] Update lint rules --- .eslintrc.js | 4 +++- src/Api.ts | 4 ++-- src/App.vue | 2 +- src/components/AddForm.vue | 4 ++-- src/components/Drawer.vue | 4 ++-- .../dialogs/searchDialog/PluginsManager.vue | 10 ++++---- .../dialogs/searchDialog/SearchDialog.vue | 24 +++++++++---------- .../dialogs/searchDialog/SearchDialogForm.vue | 12 +++++----- src/components/drawer/DrawerFooter.vue | 2 +- src/locale/en.ts | 4 ++-- src/locale/index.ts | 2 +- src/locale/ru.ts | 4 ++-- src/locale/zh-CN.ts | 4 ++-- src/registerServiceWorker.ts | 4 ++-- src/store/addForm.ts | 6 ++--- src/store/dialog.ts | 2 +- src/store/index.ts | 2 +- src/store/searchEngine.ts | 10 ++++---- vue.config.js | 6 ++--- 19 files changed, 56 insertions(+), 54 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index cd51f23..f62cf2c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -16,12 +16,14 @@ module.exports = { 'no-console': isProdEnv ? 'error' : 'warn', 'no-debugger': isProdEnv ? 'error' : 'warn', + "comma-dangle": ["error", "always-multiline"], + '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/no-explicit-any': 'off', 'vue/singleline-html-element-content-newline': ['warn', { ignores: ['pre', 'textarea', 'span', 'v-icon'], - }] + }], }, parserOptions: { parser: '@typescript-eslint/parser', diff --git a/src/Api.ts b/src/Api.ts index 76e2b60..3360e8c 100644 --- a/src/Api.ts +++ b/src/Api.ts @@ -311,7 +311,7 @@ class Api { { pattern: pattern || '', category: categoryName || 'all', - plugins: pluginName || 'all' + plugins: pluginName || 'all', }); return this.axios.post('/search/start', body).then(Api.handleResponse); } @@ -329,7 +329,7 @@ class Api { public enablePlugin(plugin: SearchPlugin, enable: boolean) { const body = new URLSearchParams({ names: plugin.name, - enable: JSON.stringify(enable) + enable: JSON.stringify(enable), }); return this.axios.post('/search/enablePlugin', body).then(Api.handleResponse); diff --git a/src/App.vue b/src/App.vue index 0e4dfc3..1478422 100644 --- a/src/App.vue +++ b/src/App.vue @@ -117,7 +117,7 @@ let appWrapEl: HTMLElement; 'setPasteUrl', 'updateNeedAuth', ]), - } + }, }) export default class App extends Vue { drawer = true diff --git a/src/components/AddForm.vue b/src/components/AddForm.vue index 4e4d77e..14f04fe 100644 --- a/src/components/AddForm.vue +++ b/src/components/AddForm.vue @@ -228,7 +228,7 @@ const defaultParams = { ...mapState({ pasteUrl: 'pasteUrl', prefs: 'preferences', - state: 'addForm' + state: 'addForm', }), ...mapGetters({ allCategories: 'allCategories', @@ -239,7 +239,7 @@ const defaultParams = { 'closeAddForm', 'openAddForm', ]), - } + }, }) export default class AddForm extends Vue { valid = false diff --git a/src/components/Drawer.vue b/src/components/Drawer.vue index ee6afcc..b922389 100644 --- a/src/components/Drawer.vue +++ b/src/components/Drawer.vue @@ -170,12 +170,12 @@ export default class Drawer extends Vue { const searchMenuItem = { icon: 'mdi-card-search-outline', title: tr('search'), - click: () => this.updateOptions('showSearch', true) + click: () => this.updateOptions('showSearch', true), }; if (this.phoneLayout) { this.endItems = this.endItems.concat([ - searchMenuItem + searchMenuItem, ]); return; diff --git a/src/components/dialogs/searchDialog/PluginsManager.vue b/src/components/dialogs/searchDialog/PluginsManager.vue index 9e5d33f..90498e1 100644 --- a/src/components/dialogs/searchDialog/PluginsManager.vue +++ b/src/components/dialogs/searchDialog/PluginsManager.vue @@ -29,14 +29,14 @@ import { mapActions, mapState } from "vuex"; @Component({ computed: { ...mapState({ - searchEngineState: "searchEngine" - }) + searchEngineState: "searchEngine", + }), }, methods: { ...mapActions({ - togglePluginAvailabilityAction: "togglePluginAvailability" - }) - } + togglePluginAvailabilityAction: "togglePluginAvailability", + }), + }, }) export default class PluginsManager extends Vue { searchEngineState!: SearchEnginePage; diff --git a/src/components/dialogs/searchDialog/SearchDialog.vue b/src/components/dialogs/searchDialog/SearchDialog.vue index 7f33703..329b546 100644 --- a/src/components/dialogs/searchDialog/SearchDialog.vue +++ b/src/components/dialogs/searchDialog/SearchDialog.vue @@ -78,20 +78,20 @@ interface GridConfig { @Component({ components: { SearchDialogForm, - PluginManager + PluginManager, }, computed: { ...mapGetters({ allCategories: "allCategories", - preferences: "preferences" - }) + preferences: "preferences", + }), }, methods: { ...mapMutations(["openAddForm", "setPasteUrl", "addFormDownloadItem", "openPluginManager"]), ...mapActions({ - loadSearchPlugins: 'fetchSearchPlugins' - }) - } + loadSearchPlugins: 'fetchSearchPlugins', + }), + }, }) export default class SearchDialog extends HasTask { private _searchId = 0; @@ -108,7 +108,7 @@ export default class SearchDialog extends HasTask { fileUrl: "", nbLeechers: 0, nbSeeders: 0, - siteUrl: "" + siteUrl: "", }, headers: [ { text: tr("name"), value: "fileName" }, @@ -116,8 +116,8 @@ export default class SearchDialog extends HasTask { { text: tr("seeds"), value: "nbSeeders" }, { text: tr("peers"), value: "nbLeechers" }, { text: tr("search_engine"), value: "siteUrl" }, - { text: tr("action", 2), value: "actions", sortable: false } - ] + { text: tr("action", 2), value: "actions", sortable: false }, + ], }; loading = false; @@ -136,8 +136,8 @@ export default class SearchDialog extends HasTask { this.addFormDownloadItem({ downloadItem: { title: item.fileName, - url: item.fileUrl - } + url: item.fileUrl, + }, }); this.openAddForm(); } @@ -171,7 +171,7 @@ export default class SearchDialog extends HasTask { const result = await api.startSearch( searchForm.pattern, searchForm.plugins, - searchForm.category + searchForm.category, ); return result; diff --git a/src/components/dialogs/searchDialog/SearchDialogForm.vue b/src/components/dialogs/searchDialog/SearchDialogForm.vue index a6cb0aa..c629175 100644 --- a/src/components/dialogs/searchDialog/SearchDialogForm.vue +++ b/src/components/dialogs/searchDialog/SearchDialogForm.vue @@ -122,7 +122,7 @@ const ALL_KEY = "all"; const ALL_CATEGORY: Category = { key: ALL_KEY, - name: tr("all") + name: tr("all"), }; interface Category { @@ -140,8 +140,8 @@ export interface SearchForm { @Component({ computed: { ...mapGetters({ - searchPlugins: "allSearchPlugins" - }) + searchPlugins: "allSearchPlugins", + }), }, }) export default class SearchDialogForm extends Vue { @@ -159,7 +159,7 @@ export default class SearchDialogForm extends Vue { valid: false, category: ALL_KEY, pattern: "", - plugins: [] + plugins: [], }; get hasSelectAllPlugins() { @@ -174,7 +174,7 @@ export default class SearchDialogForm extends Vue { const result: Category[] = [ALL_CATEGORY, { divider: true } as any]; const categories = intersection( - ...this.searchForm.plugins.map(p => p.supportedCategories) + ...this.searchForm.plugins.map(p => p.supportedCategories), ).map(c => ({ key: c, name: c })); result.push(...categories); @@ -206,7 +206,7 @@ export default class SearchDialogForm extends Vue { : this.searchForm.plugins.map(p => p.name).join("|"); const searchForm = Object.assign({}, this.searchForm, { - plugins + plugins, }); return searchForm; diff --git a/src/components/drawer/DrawerFooter.vue b/src/components/drawer/DrawerFooter.vue index 6884f29..eca5fe7 100644 --- a/src/components/drawer/DrawerFooter.vue +++ b/src/components/drawer/DrawerFooter.vue @@ -160,7 +160,7 @@ export default class DrawerFooter extends Vue { text: tr('auto'), value: 'auto', }, - ...locales + ...locales, ] } diff --git a/src/locale/en.ts b/src/locale/en.ts index 8813764..c87e966 100644 --- a/src/locale/en.ts +++ b/src/locale/en.ts @@ -109,7 +109,7 @@ export default { dialog: { trigger_exit_qb: { title: 'Exit qBittorrent', - text: 'Are you sure you want to exit qBittorrent?' + text: 'Are you sure you want to exit qBittorrent?', }, add_torrents: { placeholder: 'Upload torrents by drop them here,\nor click attachment button at right to select.', @@ -167,5 +167,5 @@ export default { active: 'Active', inactive: 'Inactive', errored: 'Errored', - } + }, } diff --git a/src/locale/index.ts b/src/locale/index.ts index e215299..849610d 100644 --- a/src/locale/index.ts +++ b/src/locale/index.ts @@ -14,7 +14,7 @@ export const translations = { export type LocaleKey = keyof typeof translations | null; const polyglot = new Polyglot({ - phrases: translations.en + phrases: translations.en, }); function matchLocale() { diff --git a/src/locale/ru.ts b/src/locale/ru.ts index 9344e0b..31d3489 100644 --- a/src/locale/ru.ts +++ b/src/locale/ru.ts @@ -109,7 +109,7 @@ export default { dialog: { trigger_exit_qb: { title: 'Выйти из qBittorrent', - text: 'Выйти из qBittorrent?' + text: 'Выйти из qBittorrent?', }, add_torrents: { placeholder: 'Начните скачивать торренты, переместив их сюда,\nили нажмите кнопку вложения справа, чтобы выбрать.', @@ -167,5 +167,5 @@ export default { active: 'Активный', inactive: 'Не активный', errored: 'Ошибочный', - } + }, } diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index 80dac7d..11e46a3 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -106,7 +106,7 @@ export default { dialog: { trigger_exit_qb: { title: '退出 qBittorrent', - text: '您确定要退出qBittorrent吗?' + text: '您确定要退出qBittorrent吗?', }, add_torrents: { placeholder: '将种子拖到这里上传,\n或者点击右边的附件图标来选择。', @@ -164,5 +164,5 @@ export default { active: '活动', inactive: '空闲', errored: '错误', - } + }, } diff --git a/src/registerServiceWorker.ts b/src/registerServiceWorker.ts index 76cede0..f2ad500 100644 --- a/src/registerServiceWorker.ts +++ b/src/registerServiceWorker.ts @@ -7,7 +7,7 @@ if (process.env.NODE_ENV === 'production') { ready () { console.log( 'App is being served from cache by a service worker.\n' + - 'For more details, visit https://goo.gl/AFskqB' + 'For more details, visit https://goo.gl/AFskqB', ) }, registered () { @@ -27,6 +27,6 @@ if (process.env.NODE_ENV === 'production') { }, error (error) { console.error('Error during service worker registration:', error) - } + }, }) } diff --git a/src/store/addForm.ts b/src/store/addForm.ts index 5128051..492db4c 100644 --- a/src/store/addForm.ts +++ b/src/store/addForm.ts @@ -5,13 +5,13 @@ export const addFormStore: Module = { state() { return { isOpen: false, - downloadItem: null + downloadItem: null, }; }, getters: { isOpen(state) { return state.isOpen; - } + }, }, mutations: { openAddForm(state) { @@ -24,6 +24,6 @@ export const addFormStore: Module = { addFormDownloadItem(state, payload) { const { downloadItem } = payload; state.downloadItem = downloadItem; - } + }, }, }; diff --git a/src/store/dialog.ts b/src/store/dialog.ts index 9a4fa6b..e4fe3ea 100644 --- a/src/store/dialog.ts +++ b/src/store/dialog.ts @@ -26,5 +26,5 @@ export const dialogStore: Module = { commit('showDialog', options); }) }, - } + }, }; diff --git a/src/store/index.ts b/src/store/index.ts index eb5c7df..162da23 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -21,7 +21,7 @@ const store = new Vuex.Store({ dialog: dialogStore, snackBar: snackBarStore, addForm: addFormStore, - searchEngine: searchEngineStore + searchEngine: searchEngineStore, }, state: { rid: 0, diff --git a/src/store/searchEngine.ts b/src/store/searchEngine.ts index f86f061..7a24bc5 100644 --- a/src/store/searchEngine.ts +++ b/src/store/searchEngine.ts @@ -6,7 +6,7 @@ import api from "@/Api"; export default { state: { searchPlugins: [], - isPluginManagerOpen: false + isPluginManagerOpen: false, }, mutations: { setSearchPlugins(state, plugins: SearchPlugin[] | undefined | null) { @@ -17,12 +17,12 @@ export default { }, closePluginManager(state) { state.isPluginManagerOpen = false; - } + }, }, getters: { allSearchPlugins(state): SearchPlugin[] | undefined | null { return state.searchPlugins; - } + }, }, actions: { fetchSearchPlugins({ dispatch }) { @@ -60,6 +60,6 @@ export default { }, enablePluginRequestSuccess({ dispatch }) { dispatch('fetchSearchPlugins'); // refresh the plugins - } - } + }, + }, } as Module; diff --git a/vue.config.js b/vue.config.js index b63caa3..927ca26 100644 --- a/vue.config.js +++ b/vue.config.js @@ -17,7 +17,7 @@ module.exports = { }, workboxOptions: { importWorkboxFrom: 'local', - } + }, }, devServer: { @@ -34,10 +34,10 @@ module.exports = { let arg = args[0] arg = { ...arg, - 'process.env.GIT_TAG': JSON.stringify(process.env.GIT_TAG) + 'process.env.GIT_TAG': JSON.stringify(process.env.GIT_TAG), } return [arg] }) - } + }, };