Skip to content

Commit

Permalink
style: update eslint config and lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
kuoruan committed Dec 25, 2023
1 parent 833be38 commit 5ab91b0
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 32 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ module.exports = {
"plugin:vue/recommended",
"@vue/prettier",
],
plugins: ["vue", "prettier", "simple-import-sort"],
rules: {
"no-console": "off",
"no-debugger": "off",
"no-undef": "off",

"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
},
plugins: ["vue", "prettier"],
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"scripts": {
"serve": "vite",
"build": "vite build",
"lint": "eslint --ext .js,.vue src",
"lint:fix": "eslint --fix --ext .js,.vue src"
"lint": "eslint --ext .js,.cjs,.vue .",
"lint:fix": "eslint --fix --ext .js,.cjs,.vue ."
},
"repository": {
"type": "git",
Expand All @@ -30,6 +30,7 @@
"chalk": "^5.3.0",
"eslint": "^8.56.0",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-vue": "^9.19.2",
"prettier": "^3.1.1",
"pug": "^3.0.2",
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/components/LinksPopup.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="pug">
popup(
popup-wrapper(
:z-index="zIndex",
@overlay-click="$emit('close')",
:middle="false",
Expand Down Expand Up @@ -27,13 +27,13 @@
</template>

<script>
import Popup from "@/components/Popup.vue";
import PopupWrapper from "@/components/PopupWrapper.vue";
import { getDefaultLinebreak } from "@/utils/misc";
export default {
name: "LinksPopup",
components: {
Popup,
PopupWrapper,
},
props: {
zIndex: {
Expand Down Expand Up @@ -120,7 +120,7 @@ export default {
try {
GM_setClipboard(
this.content,
"{ type: 'text', mimetype: 'text/plain'}"
"{ type: 'text', mimetype: 'text/plain'}",
);
this.$toast.display("复制成功!");
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Popup.vue → src/components/PopupWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<script>
export default {
name: "Popup",
name: "PopupWrapper",
props: {
zIndex: {
type: Number,
Expand All @@ -38,7 +38,7 @@ export default {
const { scrollTop, scrollHeight, clientHeight } = el;
const isAutoOrScroll = /(auto|scroll)/.test(
overflow + overflowX + overflowY
overflow + overflowX + overflowY,
); // overflow is auto or scroll
const scroll =
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toast.vue → src/components/ToastItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<script>
export default {
name: "Toast",
name: "ToastItem",
data() {
return {
text: "",
Expand Down
2 changes: 1 addition & 1 deletion src/components/TorrentDownloadItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default {
if (
responseText &&
(matches = responseText.match(
/<a href="((?:https?)?\/\/dl\.dmhy\.org\/[^"]+\.torrent)">(.+)?<\/a>/
/<a href="((?:https?)?\/\/dl\.dmhy\.org\/[^"]+\.torrent)">(.+)?<\/a>/,
)) &&
matches.length >= 3
) {
Expand Down
4 changes: 0 additions & 4 deletions src/components/TreeItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ const Documents = [
export default {
name: "TreeItem",
props: {
key: {
type: Number,
default: -1,
},
parentKey: {
type: Number,
default: -1,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tree.vue → src/components/TreeRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import TreeItem from "@/components/TreeItem.vue";
export default {
name: "Tree",
name: "TreeRoot",
components: {
TreeItem,
},
Expand Down
9 changes: 5 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import "@/assets/css/common.styl";

import Toast from "@/components/Toast.vue";
import Vue from "vue";
import { mountFileListElement } from "@/pages/view";

import ToastItem from "@/components/ToastItem.vue";
import { mountListElement } from "@/pages/list";
import { mountFileListElement } from "@/pages/view";

// Init toast item
const ToastVM = Vue.extend(Toast);
const ToastItemVM = Vue.extend(ToastItem);

const toast = new ToastVM().$mount();
const toast = new ToastItemVM().$mount();
document.body.appendChild(toast.$el);

Object.defineProperty(Vue.prototype, "$toast", { value: toast });
Expand Down
9 changes: 5 additions & 4 deletions src/pages/list.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import TorrentDownloadHeader from "@/components/TorrentDownloadHeader.vue";
import TorrentDownloadItem from "@/components/TorrentDownloadItem.vue";
import Vue from "vue";

import CheckboxHeader from "@/components/CheckboxHeader.vue";
import CheckboxItem from "@/components/CheckboxItem.vue";
import LinksPopup from "@/components/LinksPopup.vue";
import ToolBar from "@/components/ToolBar.vue";
import Vue from "vue";
import TorrentDownloadHeader from "@/components/TorrentDownloadHeader.vue";
import TorrentDownloadItem from "@/components/TorrentDownloadItem.vue";
import { magnetLinksWithOptions } from "@/utils/misc";

const CheckboxHeaderVM = Vue.extend(CheckboxHeader);
Expand Down Expand Up @@ -121,7 +122,7 @@ export function mountListElement(el) {

tableContainer.insertBefore(
headerToolbar.$el,
tableContainer.firstChild
tableContainer.firstChild,
);
tableContainer.appendChild(bottomToobar.$el);

Expand Down
11 changes: 6 additions & 5 deletions src/pages/view.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import XBytes from "xbytes";
import Tree from "@/components/Tree.vue";
import Vue from "vue";
import XBytes from "xbytes";

import TreeRoot from "@/components/TreeRoot.vue";
import { hashCode } from "@/utils/misc";

const TreeVM = Vue.extend(Tree);
const TreeRootVM = Vue.extend(TreeRoot);

function folderTreeFromNodeList(fileNodeList) {
const map = {};
Expand Down Expand Up @@ -49,7 +50,7 @@ function folderTreeFromNodeList(fileNodeList) {

let baseName = filePath.substring(
0,
filePath.indexOf(fileName) + fileName.length
filePath.indexOf(fileName) + fileName.length,
);
let key = hashCode(baseName);

Expand Down Expand Up @@ -98,7 +99,7 @@ export function mountFileListElement(el, title) {
return;
}

const tree = new TreeVM({
const tree = new TreeRootVM({
propsData: {
folders:
(folders.length > 1 || folders[0].size) && title
Expand Down
6 changes: 3 additions & 3 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from "fs";
import vue2 from "@vitejs/plugin-vue2";
import chalk from "chalk";
import { defineConfig } from "vite";
import fs from "fs";
import { fileURLToPath } from "url";
import vue2 from "@vitejs/plugin-vue2";
import { defineConfig } from "vite";
import banner from "vite-plugin-banner";

import { createBanner } from "./userscript";
Expand Down

0 comments on commit 5ab91b0

Please sign in to comment.