* fix: emits use ev instead of e

* fix: errors use err instead of e

* fix: replace use of data where possible

* fix: events use evt instead of e

* fix: use strict equals

* fix: use emoji instead of e

* fix: vue lints
This commit is contained in:
Johann150
2022-05-26 15:53:09 +02:00
committed by GitHub
parent 9c80403072
commit 3dae18b93c
69 changed files with 255 additions and 257 deletions

View File

@ -175,10 +175,10 @@ const menu = (ev: MouseEvent) => {
type: 'info',
text: i18n.ts.exportRequested,
});
}).catch((e) => {
}).catch((err) => {
os.alert({
type: 'error',
text: e.message,
text: err.message,
});
});
}
@ -195,10 +195,10 @@ const menu = (ev: MouseEvent) => {
type: 'info',
text: i18n.ts.importRequested,
});
}).catch((e) => {
}).catch((err) => {
os.alert({
type: 'error',
text: e.message,
text: err.message,
});
});
}

View File

@ -265,10 +265,10 @@ const invite = () => {
type: 'info',
text: x.code
});
}).catch(e => {
}).catch(err => {
os.alert({
type: 'error',
text: e
text: err,
});
});
};

View File

@ -111,8 +111,8 @@ export default defineComponent({
}
},
setBannerImage(e) {
selectFile(e.currentTarget ?? e.target, null).then(file => {
setBannerImage(evt) {
selectFile(evt.currentTarget ?? evt.target, null).then(file => {
this.bannerId = file.id;
});
},

View File

@ -79,9 +79,9 @@ export default defineComponent({
}
if (this.selectedTags.size === 0) {
this.searchEmojis = this.customEmojis.filter(e => e.name.includes(this.q) || e.aliases.includes(this.q));
this.searchEmojis = this.customEmojis.filter(emoji => emoji.name.includes(this.q) || emoji.aliases.includes(this.q));
} else {
this.searchEmojis = this.customEmojis.filter(e => (e.name.includes(this.q) || e.aliases.includes(this.q)) && [...this.selectedTags].every(t => e.aliases.includes(t)));
this.searchEmojis = this.customEmojis.filter(emoji => (emoji.name.includes(this.q) || emoji.aliases.includes(this.q)) && [...this.selectedTags].every(t => emoji.aliases.includes(t)));
}
},

View File

@ -25,10 +25,10 @@ function menu(ev) {
type: 'info',
text: i18n.ts.exportRequested,
});
}).catch((e) => {
}).catch((err) => {
os.alert({
type: 'error',
text: e.message,
text: err.message,
});
});
}

View File

@ -20,7 +20,7 @@ export default defineComponent({
uri: acct
});
promise.then(res => {
if (res.type == 'User') {
if (res.type === 'User') {
this.follow(res.object);
} else if (res.type === 'Note') {
this.$router.push(`/notes/${res.object.id}`);

View File

@ -91,8 +91,8 @@ export default defineComponent({
},
methods: {
selectFile(e) {
selectFiles(e.currentTarget ?? e.target, null).then(files => {
selectFile(evt) {
selectFiles(evt.currentTarget ?? evt.target, null).then(files => {
this.files = this.files.concat(files);
});
},

View File

@ -119,8 +119,8 @@ export default defineComponent({
postId: this.postId
}).then(post => {
this.post = post;
}).catch(e => {
this.error = e;
}).catch(err => {
this.error = err;
});
},

View File

@ -90,14 +90,14 @@ export default defineComponent({
getAcct: Acct.toString,
isMe(message) {
return message.userId == this.$i.id;
return message.userId === this.$i.id;
},
onMessage(message) {
if (message.recipientId) {
this.messages = this.messages.filter(m => !(
(m.recipientId == message.recipientId && m.userId == message.userId) ||
(m.recipientId == message.userId && m.userId == message.recipientId)));
(m.recipientId === message.recipientId && m.userId === message.userId) ||
(m.recipientId === message.userId && m.userId === message.recipientId)));
this.messages.unshift(message);
} else if (message.groupId) {
@ -108,7 +108,7 @@ export default defineComponent({
onRead(ids) {
for (const id of ids) {
const found = this.messages.find(m => m.id == id);
const found = this.messages.find(m => m.id === id);
if (found) {
if (found.recipientId) {
found.isRead = true;

View File

@ -59,7 +59,7 @@ export default defineComponent({
return this.user ? 'user:' + this.user.id : 'group:' + this.group.id;
},
canSend(): boolean {
return (this.text != null && this.text != '') || this.file != null;
return (this.text != null && this.text !== '') || this.file != null;
},
room(): any {
return this.$parent;
@ -88,12 +88,11 @@ export default defineComponent({
}
},
methods: {
async onPaste(e: ClipboardEvent) {
const data = e.clipboardData;
const items = data.items;
async onPaste(evt: ClipboardEvent) {
const items = evt.clipboardData.items;
if (items.length == 1) {
if (items[0].kind == 'file') {
if (items.length === 1) {
if (items[0].kind === 'file') {
const file = items[0].getAsFile();
const lio = file.name.lastIndexOf('.');
const ext = lio >= 0 ? file.name.slice(lio) : '';
@ -101,7 +100,7 @@ export default defineComponent({
if (formatted) this.upload(file, formatted);
}
} else {
if (items[0].kind == 'file') {
if (items[0].kind === 'file') {
os.alert({
type: 'error',
text: this.$ts.onlyOneFileCanBeAttached
@ -110,23 +109,23 @@ export default defineComponent({
}
},
onDragover(e) {
const isFile = e.dataTransfer.items[0].kind == 'file';
const isDriveFile = e.dataTransfer.types[0] == _DATA_TRANSFER_DRIVE_FILE_;
onDragover(evt) {
const isFile = evt.dataTransfer.items[0].kind === 'file';
const isDriveFile = evt.dataTransfer.types[0] === _DATA_TRANSFER_DRIVE_FILE_;
if (isFile || isDriveFile) {
e.preventDefault();
e.dataTransfer.dropEffect = e.dataTransfer.effectAllowed == 'all' ? 'copy' : 'move';
evt.preventDefault();
evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === 'all' ? 'copy' : 'move';
}
},
onDrop(e): void {
onDrop(evt): void {
// ファイルだったら
if (e.dataTransfer.files.length == 1) {
e.preventDefault();
this.upload(e.dataTransfer.files[0]);
if (evt.dataTransfer.files.length === 1) {
evt.preventDefault();
this.upload(evt.dataTransfer.files[0]);
return;
} else if (e.dataTransfer.files.length > 1) {
e.preventDefault();
} else if (evt.dataTransfer.files.length > 1) {
evt.preventDefault();
os.alert({
type: 'error',
text: this.$ts.onlyOneFileCanBeAttached
@ -135,17 +134,17 @@ export default defineComponent({
}
//#region ドライブのファイル
const driveFile = e.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
if (driveFile != null && driveFile != '') {
const driveFile = evt.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
if (driveFile != null && driveFile !== '') {
this.file = JSON.parse(driveFile);
e.preventDefault();
evt.preventDefault();
}
//#endregion
},
onKeydown(e) {
onKeydown(evt) {
this.typing();
if ((e.which == 10 || e.which == 13) && (e.ctrlKey || e.metaKey) && this.canSend) {
if ((evt.which === 10 || evt.which === 13) && (evt.ctrlKey || evt.metaKey) && this.canSend) {
this.send();
}
},
@ -154,8 +153,8 @@ export default defineComponent({
this.typing();
},
chooseFile(e) {
selectFile(e.currentTarget ?? e.target, this.$ts.selectFile).then(file => {
chooseFile(evt) {
selectFile(evt.currentTarget ?? evt.target, this.$ts.selectFile).then(file => {
this.file = file;
});
},
@ -193,9 +192,9 @@ export default defineComponent({
},
saveDraft() {
const data = JSON.parse(localStorage.getItem('message_drafts') || '{}');
const drafts = JSON.parse(localStorage.getItem('message_drafts') || '{}');
data[this.draftKey] = {
drafts[this.draftKey] = {
updatedAt: new Date(),
data: {
text: this.text,
@ -203,15 +202,15 @@ export default defineComponent({
}
}
localStorage.setItem('message_drafts', JSON.stringify(data));
localStorage.setItem('message_drafts', JSON.stringify(drafts));
},
deleteDraft() {
const data = JSON.parse(localStorage.getItem('message_drafts') || '{}');
const drafts = JSON.parse(localStorage.getItem('message_drafts') || '{}');
delete data[this.draftKey];
delete drafts[this.draftKey];
localStorage.setItem('message_drafts', JSON.stringify(data));
localStorage.setItem('message_drafts', JSON.stringify(drafts));
},
async insertEmoji(ev) {

View File

@ -166,23 +166,23 @@ const Component = defineComponent({
});
},
onDragover(e) {
const isFile = e.dataTransfer.items[0].kind == 'file';
const isDriveFile = e.dataTransfer.types[0] == _DATA_TRANSFER_DRIVE_FILE_;
onDragover(evt) {
const isFile = evt.dataTransfer.items[0].kind === 'file';
const isDriveFile = evt.dataTransfer.types[0] === _DATA_TRANSFER_DRIVE_FILE_;
if (isFile || isDriveFile) {
e.dataTransfer.dropEffect = e.dataTransfer.effectAllowed == 'all' ? 'copy' : 'move';
evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === 'all' ? 'copy' : 'move';
} else {
e.dataTransfer.dropEffect = 'none';
evt.dataTransfer.dropEffect = 'none';
}
},
onDrop(e): void {
onDrop(evt): void {
// ファイルだったら
if (e.dataTransfer.files.length == 1) {
this.form.upload(e.dataTransfer.files[0]);
if (evt.dataTransfer.files.length === 1) {
this.form.upload(evt.dataTransfer.files[0]);
return;
} else if (e.dataTransfer.files.length > 1) {
} else if (evt.dataTransfer.files.length > 1) {
os.alert({
type: 'error',
text: this.$ts.onlyOneFileCanBeAttached
@ -191,8 +191,8 @@ const Component = defineComponent({
}
//#region ドライブのファイル
const driveFile = e.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
if (driveFile != null && driveFile != '') {
const driveFile = evt.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
if (driveFile != null && driveFile !== '') {
const file = JSON.parse(driveFile);
this.form.file = file;
}
@ -209,7 +209,7 @@ const Component = defineComponent({
limit: max + 1,
untilId: this.existMoreMessages ? this.messages[0].id : undefined
}).then(messages => {
if (messages.length == max + 1) {
if (messages.length === max + 1) {
this.existMoreMessages = true;
messages.pop();
} else {
@ -235,7 +235,7 @@ const Component = defineComponent({
const _isBottom = isBottom(this.$el, 64);
this.messages.push(message);
if (message.userId != this.$i.id && !document.hidden) {
if (message.userId !== this.$i.id && !document.hidden) {
this.connection.send('read', {
id: message.id
});
@ -246,7 +246,7 @@ const Component = defineComponent({
this.$nextTick(() => {
this.scrollToBottom();
});
} else if (message.userId != this.$i.id) {
} else if (message.userId !== this.$i.id) {
// Notify
this.notifyNewMessage();
}
@ -256,7 +256,7 @@ const Component = defineComponent({
if (this.user) {
if (!Array.isArray(x)) x = [x];
for (const id of x) {
if (this.messages.some(x => x.id == id)) {
if (this.messages.some(x => x.id === id)) {
const exist = this.messages.map(x => x.id).indexOf(id);
this.messages[exist] = {
...this.messages[exist],
@ -266,7 +266,7 @@ const Component = defineComponent({
}
} else if (this.group) {
for (const id of x.ids) {
if (this.messages.some(x => x.id == id)) {
if (this.messages.some(x => x.id === id)) {
const exist = this.messages.map(x => x.id).indexOf(id);
this.messages[exist] = {
...this.messages[exist],

View File

@ -136,8 +136,8 @@ export default defineComponent({
this.hasPrev = prev.length !== 0;
this.hasNext = next.length !== 0;
});
}).catch(e => {
this.error = e;
}).catch(err => {
this.error = err;
});
}
}

View File

@ -139,8 +139,8 @@ export default defineComponent({
username: this.username,
}).then(page => {
this.page = page;
}).catch(e => {
this.error = e;
}).catch(err => {
this.error = err;
});
},

View File

@ -121,10 +121,10 @@ function submit() {
}).then(() => {
os.success();
$i!.twoFactorEnabled = true;
}).catch(e => {
}).catch(err => {
os.alert({
type: 'error',
text: e
text: err,
});
});
}

View File

@ -43,7 +43,7 @@ async function install() {
let ast;
try {
ast = parse(code.value);
} catch (e) {
} catch (err) {
os.alert({
type: 'error',
text: 'Syntax error :('
@ -60,8 +60,8 @@ async function install() {
return;
}
const data = meta.get(null);
if (data == null) {
const metadata = meta.get(null);
if (metadata == null) {
os.alert({
type: 'error',
text: 'No metadata found :('
@ -69,7 +69,7 @@ async function install() {
return;
}
const { name, version, author, description, permissions, config } = data;
const { name, version, author, description, permissions, config } = metadata;
if (name == null || version == null || author == null) {
os.alert({
type: 'error',

View File

@ -29,7 +29,7 @@ function parseThemeCode(code: string) {
try {
theme = JSON5.parse(code);
} catch (e) {
} catch (err) {
os.alert({
type: 'error',
text: i18n.ts._theme.invalid

View File

@ -43,6 +43,14 @@ import * as os from '@/os';
import * as symbols from '@/symbols';
import { i18n } from '@/i18n';
defineExpose({
[symbols.PAGE_INFO]: {
title: 'Edit webhook',
icon: 'fas fa-bolt',
bg: 'var(--bg)',
},
});
const webhook = await os.api('i/webhooks/show', {
webhookId: new URLSearchParams(window.location.search).get('id')
});
@ -78,12 +86,4 @@ async function save(): Promise<void> {
active,
});
}
defineExpose({
[symbols.PAGE_INFO]: {
title: 'Edit webhook',
icon: 'fas fa-bolt',
bg: 'var(--bg)',
},
});
</script>

View File

@ -71,7 +71,7 @@ watch(hardMutedWords, () => {
async function save() {
const parseMutes = (mutes, tab) => {
// split into lines, remove empty lines and unnecessary whitespace
let lines = mutes.trim().split('\n').map(line => line.trim()).filter(line => line != '');
let lines = mutes.trim().split('\n').map(line => line.trim()).filter(line => line !== '');
// check each line if it is a RegExp or not
for (let i = 0; i < lines.length; i++) {

View File

@ -153,11 +153,11 @@ export default defineComponent({
);
}
//#endregion
} catch (e) {
} catch (err) {
os.alert({
type: 'error',
title: e.message,
text: e.name
title: err.message,
text: err.name
});
}

View File

@ -128,7 +128,7 @@ function showPreview() {
}
function setBgColor(color: typeof bgColors[number]) {
if (theme.base != color.kind) {
if (theme.base !== color.kind) {
const base = color.kind === 'dark' ? darkTheme : lightTheme;
for (const prop of Object.keys(base.props)) {
if (prop === 'accent') continue;

View File

@ -232,10 +232,10 @@ export default defineComponent({
await os.api('admin/delete-all-files-of-a-user', { userId: this.user.id });
os.success();
};
await process().catch(e => {
await process().catch(err => {
os.alert({
type: 'error',
text: e.toString()
text: err.toString(),
});
});
await this.refreshUser();

View File

@ -260,8 +260,8 @@ export default defineComponent({
this.user = null;
os.api('users/show', Acct.parse(this.acct)).then(user => {
this.user = user;
}).catch(e => {
this.error = e;
}).catch(err => {
this.error = err;
});
},