Skip to content

Commit

Permalink
Lint project
Browse files Browse the repository at this point in the history
  • Loading branch information
G4brym committed Dec 5, 2024
1 parent f26b3c5 commit d5b3a3c
Show file tree
Hide file tree
Showing 19 changed files with 129 additions and 153 deletions.
42 changes: 21 additions & 21 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off",
"noImplicitAnyLet": "off"
},
"style": {
"noParameterAssign": "off"
},
"complexity": {
"noForEach": "off",
"useLiteralKeys": "off"
},
"performance": {
"noAccumulatingSpread": "off",
"noDelete": "off"
}
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off",
"noImplicitAnyLet": "off"
},
"style": {
"noParameterAssign": "off"
},
"complexity": {
"noForEach": "off",
"useLiteralKeys": "off"
},
"performance": {
"noAccumulatingSpread": "off",
"noDelete": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
Expand Down
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "r2-explorer-root",
"version": "0.0.0",
"private": true,
"scripts": {
"prepare": "husky",
"workers-ci": "export WORKERS_CI=1 && node packages/github-action/prepareDeploy.js",
"lint": "npx @biomejs/biome check template/ packages/dashboard/src packages/worker/src || (npx @biomejs/biome check --write template/ packages/dashboard/src packages/worker/src/; exit 1)",
"build-dashboard": "pnpm run --filter r2-explorer-dashboard build",
"build-worker": "pnpm run --filter r2-explorer build",
"build": "pnpm build-dashboard && pnpm build-worker",
"deploy-dashboard": "pnpm run --filter r2-explorer-dashboard deploy",
"deploy-dashboard-dev": "pnpm run --filter r2-explorer-dashboard deploy-dev",
"deploy-dev-worker": "pnpm run --filter r2-explorer-dev-worker deploy",
"publish-npm": "pnpm run --filter worker publish"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"husky": "^9.1.7"
}
"name": "r2-explorer-root",
"version": "0.0.0",
"private": true,
"scripts": {
"prepare": "husky",
"workers-ci": "export WORKERS_CI=1 && node packages/github-action/prepareDeploy.js",
"lint": "npx @biomejs/biome check template/ packages/dashboard/src packages/worker/src || (npx @biomejs/biome check --write template/ packages/dashboard/src packages/worker/src/; exit 1)",
"build-dashboard": "pnpm run --filter r2-explorer-dashboard build",
"build-worker": "pnpm run --filter r2-explorer build",
"build": "pnpm build-dashboard && pnpm build-worker",
"deploy-dashboard": "pnpm run --filter r2-explorer-dashboard deploy",
"deploy-dashboard-dev": "pnpm run --filter r2-explorer-dashboard deploy-dev",
"deploy-dev-worker": "pnpm run --filter r2-explorer-dev-worker deploy",
"publish-npm": "pnpm run --filter worker publish"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"husky": "^9.1.7"
}
}
4 changes: 2 additions & 2 deletions packages/dashboard/src/appUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ export const bytesToSize = (bytes) => {
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
if (bytes === 0) return "0 Byte";
const i = Number.parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.round(bytes / Math.pow(1024, i), 2) + " " + sizes[i];
return `${Math.round(bytes / 1024 ** i, 2)} ${sizes[i]}`;
};

export const bytesToMegabytes = (bytes) => {
return Math.round(bytes / Math.pow(1024, 2));
return Math.round(bytes / 1024 ** 2);
};

export const encode = (key) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/components/files/CreateFolder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default defineComponent({
onSubmit: async function () {
this.loading = true;
await apiHandler.createFolder(
this.selectedFolder + this.newFolderName + "/",
`${this.selectedFolder + this.newFolderName}/`,
this.selectedBucket,
);
this.$bus.emit("fetchFiles");
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/components/files/FileOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default defineComponent({
},
onSubmit: async function () {
await apiHandler.createFolder(
this.selectedFolder + this.newFolderName + "/",
`${this.selectedFolder + this.newFolderName}/`,
this.selectedBucket,
);
this.$bus.emit("fetchFiles");
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/components/preview/FilePreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export default {
const notif = this.q.notify({
group: false,
spinner: true,
message: `Updating file...`,
message: "Updating file...",
caption: "0%",
timeout: 0,
});
Expand Down
26 changes: 12 additions & 14 deletions packages/dashboard/src/components/preview/PdfVuer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function isPDFDocumentLoadingTask(obj) {
}
export function createLoadingTask(src, options) {
var source;
let source;
if (typeof src === "string")
source = {
url: src,
Expand All @@ -37,14 +37,12 @@ export function createLoadingTask(src, options) {
source = Object.assign({}, src);
else throw new TypeError("invalid src type");
var loadingTask = getDocument(source).promise;
const loadingTask = getDocument(source).promise;
loadingTask.__PDFDocumentLoadingTask = true; // since PDFDocumentLoadingTask is not public
if (options && options.onPassword)
loadingTask.onPassword = options.onPassword;
if (options?.onPassword) loadingTask.onPassword = options.onPassword;
if (options && options.onProgress)
loadingTask.onProgress = options.onProgress;
if (options?.onProgress) loadingTask.onProgress = options.onProgress;
return loadingTask;
}
Expand Down Expand Up @@ -94,7 +92,7 @@ export default {
},
watch: {
pdf: function (val) {
var pdfInfo = val.pdfInfo || val._pdfInfo;
const pdfInfo = val.pdfInfo || val._pdfInfo;
this.$emit("numpages", pdfInfo.numPages);
},
page: function (val) {
Expand All @@ -119,8 +117,8 @@ export default {
this.$emit("loading", true);
}
var container = this.$refs.container;
var eventBus = new EventBus();
const container = this.$refs.container;
const eventBus = new EventBus();
// (Optionally) enable hyperlinks within PDF files.
this.pdfLinkService = new PDFLinkService({
Expand All @@ -134,8 +132,8 @@ export default {
linkService: this.pdfLinkService,
});
let annotationLayer = undefined,
textLayer = undefined;
let annotationLayer = undefined;
let textLayer = undefined;
if (this.annotation) {
annotationLayer = new DefaultAnnotationLayerFactory();
Expand Down Expand Up @@ -166,7 +164,7 @@ export default {
// Associates the actual page with the view, and drawing it
this.pdfViewer.setPdfPage(pdfPage);
// Set up a scrollPageIntoView function for our links
var viewer = {
const viewer = {
scrollPageIntoView: (params) => {
// Send an event when clicking internal links so we can handle loading/scrolling to the correct page
this.$emit("link-clicked", params);
Expand Down Expand Up @@ -203,8 +201,8 @@ export default {
},
calculateScaleHeight: function () {
this.pdfViewer.update(1, this.rotate); // Reset scaling to 1 so that "this.pdfViewer.viewport.width" gives proper width;
var height = this.$refs.container.offsetHeight;
var parentel = this.$refs.container.parentElement.parentElement;
const height = this.$refs.container.offsetHeight;
const parentel = this.$refs.container.parentElement.parentElement;
return parentel.offsetHeight / height;
},
drawScaled: function (newScale) {
Expand Down
4 changes: 2 additions & 2 deletions packages/dashboard/src/components/utils/DragAndDrop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default {
// }
if (folder !== "") {
const folderKey = this.selectedFolder + folder + "/";
const folderKey = `${this.selectedFolder + folder}/`;
await apiHandler.createFolder(folderKey, this.selectedBucket);
}
Expand Down Expand Up @@ -259,7 +259,7 @@ export default {
await filePromise;
} else if (item.isDirectory) {
const newPath = path ? path + "/" + item.name : item.name;
const newPath = path ? `${path}/${item.name}` : item.name;
if (folders[newPath] === undefined) {
folders[newPath] = [];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/layouts/MainLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default {
mainStore.loadUserDisks().then((buckets) => {
if (this.$route.path === "/") {
this.$router.push({
name: `files-home`,
name: "files-home",
params: { bucket: buckets[0].name },
});
}
Expand Down
7 changes: 4 additions & 3 deletions packages/dashboard/src/pages/email/EmailFilePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default defineComponent({
watch: {
selectedBucket(newVal) {
this.$router.push({
name: `email-folder`,
name: "email-folder",
params: { bucket: newVal, folder: encode(this.selectedFolder) },
});
},
Expand All @@ -139,9 +139,10 @@ export default defineComponent({
},
resizeIframe() {
if (this.$refs.renderWindow) {
this.$refs.renderWindow.style.height =
this.$refs.renderWindow.style.height = `${
this.$refs.renderWindow.contentWindow.document.documentElement
.scrollHeight + "px";
.scrollHeight
}px`;
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/pages/email/EmailFolderPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default defineComponent({
// const folder = row.key.replace(file, '')
this.$router.push({
name: `email-file`,
name: "email-file",
params: {
bucket: this.selectedBucket,
folder: this.selectedFolder,
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/pages/files/FileContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default {
});
} catch (err) {
this.q.notify({
message: "Failed to copy: " + err,
message: `Failed to copy: ${err}`,
timeout: 5000,
type: "negative",
});
Expand Down
43 changes: 20 additions & 23 deletions packages/dashboard/src/pages/files/FilesFolderPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,16 @@ export default defineComponent({
if (rowB.type === "folder") {
// both are folders
return a.localeCompare(b);
} else {
// only first is folder
return 1;
}
} else if (rowB.type === "folder") {
// only first is folder
return 1;
}
if (rowB.type === "folder") {
// only second is folder
return -1;
} else {
// none is folder
return a.localeCompare(b);
}
// none is folder
return a.localeCompare(b);
},
},
{
Expand Down Expand Up @@ -175,22 +174,20 @@ export default defineComponent({
.map((item, index, arr) => {
return {
name: item,
path:
arr
.slice(0, index + 1)
.join("/")
.replace("Home/", "") + "/",
path: `${arr
.slice(0, index + 1)
.join("/")
.replace("Home/", "")}/`,
};
}),
];
} else {
return [
{
name: this.selectedBucket,
path: "/",
},
];
}
return [
{
name: this.selectedBucket,
path: "/",
},
];
},
},
watch: {
Expand All @@ -212,14 +209,14 @@ export default defineComponent({
},
breadcrumbsClick: function (obj) {
this.$router.push({
name: `files-folder`,
name: "files-folder",
params: { bucket: this.selectedBucket, folder: encode(obj.path) },
});
},
rowClick: function (evt, row) {
if (row.type === "folder") {
this.$router.push({
name: `files-folder`,
name: "files-folder",
params: { bucket: this.selectedBucket, folder: encode(row.key) },
});
} else {
Expand All @@ -230,7 +227,7 @@ export default defineComponent({
openObject: function (row) {
if (row.type === "folder") {
this.$router.push({
name: `files-folder`,
name: "files-folder",
params: { bucket: this.selectedBucket, folder: encode(row.key) },
});
} else {
Expand All @@ -241,7 +238,7 @@ export default defineComponent({
renameObject: function (row) {
if (row.type === "folder") {
this.$router.push({
name: `files-folder`,
name: "files-folder",
params: { bucket: this.selectedBucket, folder: encode(row.key) },
});
} else {
Expand Down
Loading

0 comments on commit d5b3a3c

Please sign in to comment.