1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-19 08:26:23 -07:00

Add no-trailing-spaces eslint rule

This commit is contained in:
Eggbertx 2023-06-22 07:46:04 -07:00
parent d1c539a2c1
commit fba38c859b
13 changed files with 79 additions and 78 deletions

View file

@ -1,55 +1,56 @@
module.exports = {
"parser": "@typescript-eslint/parser",
"env": {
"browser": true,
"jest": true,
"node": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
],
"ignorePatterns": ["**/legacy/**"],
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": ["warn", "tab"],
"linebreak-style": ["error", "unix"],
"quotes": ["warn", "double", {
"allowTemplateLiterals": true,
"avoidEscape": true
}],
"semi": ["error", "always"],
"no-var": ["error"],
"brace-style": ["error"],
"array-bracket-spacing": ["error", "never"],
"block-spacing": ["error", "always"],
"no-spaced-func": ["error"],
"no-whitespace-before-property": ["error"],
"space-before-blocks": ["error", "always"],
"keyword-spacing": ["error", {
"overrides": {
"if": {"after": false},
"for": {"after": false},
"catch": {"after": false},
"switch": {"after": false},
"while": {"after": false}
}
}],
"no-constant-condition": ["off"],
"eqeqeq": ["error"],
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/no-unused-vars": ["warn", {
"argsIgnorePattern": "^_"
}],
}
"parser": "@typescript-eslint/parser",
"env": {
"browser": true,
"jest": true,
"node": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
],
"ignorePatterns": ["**/legacy/**"],
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": ["warn", "tab"],
"linebreak-style": ["error", "unix"],
"quotes": ["warn", "double", {
"allowTemplateLiterals": true,
"avoidEscape": true
}],
"semi": ["error", "always"],
"no-var": ["error"],
"brace-style": ["error"],
"array-bracket-spacing": ["error", "never"],
"block-spacing": ["error", "always"],
"no-spaced-func": ["error"],
"no-whitespace-before-property": ["error"],
"space-before-blocks": ["error", "always"],
"keyword-spacing": ["error", {
"overrides": {
"if": {"after": false},
"for": {"after": false},
"catch": {"after": false},
"switch": {"after": false},
"while": {"after": false}
}
}],
"no-constant-condition": ["off"],
"eqeqeq": ["error"],
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/no-unused-vars": ["warn", {
"argsIgnorePattern": "^_"
}],
"no-trailing-spaces": "warn"
}
};

View file

@ -55,7 +55,7 @@ export async function getThread(board = "", thread = 0) {
threadInfo.board = board;
if(thread > 0)
threadInfo.id = thread;
if(threadInfo.board === "") {
return Promise.reject("not in a board");
}

View file

@ -32,7 +32,7 @@ export function getBooleanCookie(name: string, defaultVal = "true") {
function randomPassword(len = 8) {
const validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&'*+-.^_`|~";
let pass = "";
for(let p = 0; p < len; p++) {
pass += validChars[Math.floor(Math.random() * validChars.length)];

View file

@ -88,7 +88,7 @@ export function createPostElement(post: ThreadPost, boardDir: string, elementCla
width: post.tn_w,
height: post.tn_h
})
)
)
);
shrinkOriginalFilenames($post);
}

View file

@ -25,7 +25,7 @@ export function isPostVisible(id: number) {
*/
export function setPostVisibility(id: number|string, visibility: boolean, onComplete = noop) {
const $post = $(`div#op${id}.op-post, div#reply${id}.reply`);
if($post.length === 0)
return false;
const $toSet = $post.find(".file-info,.post-text,.upload,.file-deleted-box,br");

View file

@ -22,7 +22,7 @@ export let $qr: JQuery<HTMLElement> = null;
let threadCooldown = 0;
let replyCooldown = 0;
const qrButtonHTML =
const qrButtonHTML =
'<input type="file" id="imagefile" name="imagefile" accept="image/jpeg,image/png,image/gif,video/webm,video/mp4"/>' +
'<input type="submit" value="Post" style="float:right;min-width:50px"/>';
@ -166,7 +166,7 @@ export function initQR() {
);
let qrTop = 32;
const pintopbar = getBooleanStorageVal("pintopbar", true);
if(pintopbar)
qrTop = $topbar.outerHeight() + 16;
@ -206,7 +206,7 @@ export function initQR() {
$("form#qrpostform").on("submit", function(_e) {
copyCaptchaResponse($(this));
});
return;
return;
}
$postform.on("submit", function(e) {
const $form = $<HTMLFormElement>(this as HTMLFormElement);
@ -233,7 +233,7 @@ export function initQR() {
$.get({
url: data.thread,
success: updateThreadSuccess
})
});
return false;
},
error: (_jqXHR, _status, error) => {
@ -244,13 +244,13 @@ export function initQR() {
});
}
function updateThreadSuccess(data: any, status: string, xhr: JQueryXHR) {
function updateThreadSuccess(data: any) {
const $doc = $(data);
const $replyContainers = $("div.reply-container");
$doc.find("div.reply-container").each((_i, el: HTMLElement) => {
const idSelector = `#${el.id}`;
const prevIDselector = `#${el.previousElementSibling.id}`;
if($replyContainers.filter(idSelector).length == 0) {
if($replyContainers.filter(idSelector).length === 0) {
// new post
$(el).insertAfter($replyContainers.filter(prevIDselector));
}

View file

@ -30,7 +30,7 @@ export class TopBarButton {
}).text(title + "▼");
const $before = $topbar.find(beforeAfter.before);
const $after = $topbar.find(beforeAfter.after);
const $after = $topbar.find(beforeAfter.after);
if($before.length > 0) {
this.button.insertBefore($before);
} else if($after.length > 0) {

View file

@ -53,7 +53,7 @@ function addManageEvents(_i: number, el: HTMLSelectElement) {
$el.append("<option>Posts from this IP</option>");
}
if(!dropdownHasItem(el, "Ban IP address")) {
$el.append("<option>Ban IP address</option>")
$el.append("<option>Ban IP address</option>");
}
const filenameOrig = $post.find("div.file-info a.file-orig").text();
if(filenameOrig !== "" && !dropdownHasItem(el, "Ban filename")) {
@ -71,9 +71,9 @@ function setupManagementEvents() {
$(document).on("postDropdownAdded", function(_e, data) {
if(!data.dropdown) return;
data.dropdown.append("<option>Posts from this IP</option>");
data.dropdown.append("<option>Ban IP address</option>")
data.dropdown.append("<option>Ban IP address</option>");
});
})
});
}
interface BanFileJSON {
@ -141,7 +141,7 @@ export async function initStaff() {
}
return info;
});
}
export async function getStaffInfo(): Promise<StaffInfo> {
@ -271,7 +271,7 @@ export function createStaffMenu(staff = staffInfo) {
}
function createStaffButton() {
if($staffBtn !== null || staffInfo == null || staffInfo.Rank === 0)
if($staffBtn !== null || staffInfo === null || staffInfo.Rank === 0)
return;
$staffBtn = new TopBarButton("Staff", () => {
$topbar.trigger("menuButtonClick", [$staffMenu, $(document).find($staffMenu).length === 0]);

View file

@ -78,7 +78,7 @@ function addButtons() {
$(() => {
if(window.location.pathname !== webroot + "manage/boardsections")
return;
$sectionsTable = $("table#sections");
$sectionsTable.prev().append(" (drag to rearrange)");
$sectionsTable.find("tbody").sortable({

View file

@ -35,7 +35,7 @@ function updateLogFilter($log: JQuery<HTMLTextAreaElement>, filter: LogFilter) {
const bObj = JSON.parse(b);
if(aObj.time === undefined || bObj.time === undefined)
return 0;
if(filter.sortDesc)
return Date.parse(bObj.time) - Date.parse(aObj.time);
return Date.parse(aObj.time) - Date.parse(bObj.time);

View file

@ -50,7 +50,7 @@ function updateThreadHTML() {
const elementExists = $(selector).length > 0;
if(elementExists)
continue; // TODO: check for edits
const $post = createPostElement(post, thread.board, "reply");
const $replyContainer = $("<div/>").prop({
id: `replycontainer${post.no}`,
@ -171,7 +171,7 @@ export function prepareThumbnails($parent: JQuery<HTMLElement> = null) {
$thumb.removeAttr("width").removeAttr("height");
const $fileInfo = $a.prevAll(".file-info:first");
if(videoTestRE.test(thumbURL + uploadURL)) {
// Upload is a video
$thumb.hide();
@ -216,7 +216,7 @@ export function quote(no: number) {
if(getBooleanStorageVal("useqr", true)) {
openQR();
}
const msgboxID = "postmsg";
const msgboxID = "postmsg";
let msgbox = document.getElementById("qr" + msgboxID) as HTMLInputElement;
if(msgbox === null)
msgbox = document.getElementById(msgboxID) as HTMLInputElement;
@ -233,7 +233,7 @@ export function quote(no: number) {
if(quoted !== "") quoted += "\n";
msgbox.value = msgbox.value.slice(0, cursor) + `>>${no}\n` +
quoted + msgbox.value.slice(cursor);
if(msgbox.id === "postmsg")
window.scroll(0,msgbox.offsetTop - 48);
msgbox.focus();

View file

@ -23,7 +23,7 @@ declare global {
defaultStyle: string;
webroot: string;
serverTZ: number;
openQR: () => void;
closeQR: () => void;
toTop: () => void;
@ -81,7 +81,7 @@ declare global {
interface ThreadPost {
no: number;
resto: number;
name: string;
name: string;
trip: string;
email: string;
sub: string;

View file

@ -64,7 +64,7 @@ function removeThreadFromMenu(threadID: number) {
function updateThreadInWatcherMenu(thread: WatchedThreadJSON) {
const currentPage = currentThread();
const $item = $watcherMenu.find(`div#thread${thread.op}`);
if($item.length === 0) return; // watched thread isn't in the menu
$item.find("span#reply-counter").remove();