diff --git a/.eslintrc-no-types.json b/.eslintrc-no-types.json index 1f2442c6c6..126b961549 100644 --- a/.eslintrc-no-types.json +++ b/.eslintrc-no-types.json @@ -217,7 +217,7 @@ "max-len": ["warn", { "code": 120, "tabWidth": 0, // see bottom of file for source - "ignorePattern": "^\\s*(?:\\/\\/ \\s*)?(?:(?:export )?(?:let |const )?[a-zA-Z0-9_$.]+(?: \\+?=>? )|[a-zA-Z0-9$]+: \\[?|(?:return |throw )?(?:new )?(?:[a-zA-Z0-9$.]+\\()?)?(?:Utils\\.html|(?:this\\.)?(?:room\\.)?tr|\\$\\()?['\"`/]" + "ignorePattern": "^\\s*(?:\\/\\/ \\s*)?(?:(?:export )?(?:let |const |readonly )?[a-zA-Z0-9_$.]+(?: \\+?=>? )|[a-zA-Z0-9$]+: \\[?|(?:return |throw )?(?:new )?(?:[a-zA-Z0-9$.]+\\()?)?(?:Utils\\.html|(?:this\\.)?(?:room\\.)?tr|\\$\\()?['\"`/]" }], "prefer-const": ["warn", {"destructuring": "all"}], // typescript-eslint/recommended forces this so we need to re-override @@ -329,7 +329,7 @@ REGEXFREE SOURCE FOR IGNOREPATTERN: https://zarel.github.io/regexfree/ ( # define a variable, append to a variable, or define a single-arg arrow function - (export\ )? (let\ |const\ )? [a-zA-Z0-9_$.]+ (\ \+?=>?\ ) + (export\ )? (let\ |const\ |readonly\ )? [a-zA-Z0-9_$.]+ (\ \+?=>?\ ) | # define a property (oversize arrays are only allowed in properties) [a-zA-Z0-9$]+:\ \[? diff --git a/server/chat-formatter.ts b/server/chat-formatter.ts index 16c47a0bb7..a540b40521 100644 --- a/server/chat-formatter.ts +++ b/server/chat-formatter.ts @@ -112,8 +112,7 @@ class TextFormatter { this.replaceLinebreaks = this.isTrusted || replaceLinebreaks; this.offset = 0; } - // eslint-disable-next-line max-len - // debugAt(i=0, j=i+1) { console.log(this.slice(0, i) + '[' + this.slice(i, j) + ']' + this.slice(j, this.str.length)); } + // debugAt(i=0, j=i+1) { console.log(`${this.slice(0, i)}[${this.slice(i, j)}]${this.slice(j, this.str.length)}`); } slice(start: number, end: number) { return this.str.slice(start, end); diff --git a/server/chat-plugins/chat-monitor.ts b/server/chat-plugins/chat-monitor.ts index f92c242684..beeed42ad9 100644 --- a/server/chat-plugins/chat-monitor.ts +++ b/server/chat-plugins/chat-monitor.ts @@ -6,7 +6,6 @@ const WRITE_THROTTLE_TIME = 5 * 60 * 1000; // Substitution dictionary adapted from https://github.com/ThreeLetters/NoSwearingPlease/blob/master/index.js // Licensed under MIT. -/* eslint-disable max-len */ const EVASION_DETECTION_SUBSTITUTIONS: {[k: string]: string[]} = { a: ["a", "4", "@", "á", "â", "ã", "à", "ᗩ", "A", "ⓐ", "Ⓐ", "α", "͏", "₳", "ä", "Ä", "Ꮧ", "λ", "Δ", "Ḁ", "Ꭺ", "ǟ", "̾", "a", "A", "ᴀ", "ɐ", "🅐", "𝐚", "𝐀", "𝘢", "𝘈", "𝙖", "𝘼", "𝒶", "𝓪", "𝓐", "𝕒", "𝔸", "𝔞", "𝔄", "𝖆", "𝕬", "🄰", "🅰", "𝒜", "𝚊", "𝙰", "ꍏ", "а"], b: ["b", "8", "ᗷ", "B", "ⓑ", "Ⓑ", "в", "฿", "ḅ", "Ḅ", "Ᏸ", "ϐ", "Ɓ", "ḃ", "Ḃ", "ɮ", "b", "B", "ʙ", "🅑", "𝐛", "𝐁", "𝘣", "𝘉", "𝙗", "𝘽", "𝒷", "𝓫", "𝓑", "𝕓", "𝔹", "𝔟", "𝔅", "𝖇", "𝕭", "🄱", "🅱", "𝐵", "Ⴆ", "𝚋", "𝙱", "♭", "b"], @@ -43,7 +42,6 @@ const EVASION_DETECTION_SUBSTITUTIONS: {[k: string]: string[]} = { ], z: ["z", "ᘔ", "Z", "ⓩ", "Ⓩ", "Ⱬ", "ẓ", "Ẓ", "ፚ", "Ꮓ", "ʐ", "z", "Z", "ᴢ", "🅩", "𝐳", "𝐙", "𝘻", "𝘡", "𝙯", "𝙕", "𝓏", "𝔃", "𝓩", "𝕫", "𝕋", "𝔷", "𝔙", "𝖟", "𝖅", "🅉", "🆉", "𝒵", "ȥ", "𝚣", "𝚉", "☡", "z"], }; -/* eslint-enable max-len */ const EVASION_DETECTION_SUB_STRINGS: {[k: string]: string} = {}; @@ -499,7 +497,6 @@ export const statusfilter: Chat.StatusFilter = (status, user) => { lcStatus = lcStatus.replace('herapist', '').replace('grape', '').replace('scrape', ''); // Check for blatant staff impersonation attempts. Ideally this could be completely generated from Config.grouplist // for better support for side servers, but not all ranks are staff ranks or should necessarily be filted. - // eslint-disable-next-line max-len const impersonationRegex = /\b(?:global|room|upper|senior)?\s*(?:staff|admin|administrator|leader|owner|founder|mod|moderator|driver|voice|operator|sysop|creator)\b/gi; if (!user.can('lock') && impersonationRegex.test(lcStatus)) return ''; diff --git a/server/chat.ts b/server/chat.ts index 56520ea3a1..5c9f9a1013 100644 --- a/server/chat.ts +++ b/server/chat.ts @@ -1125,8 +1125,10 @@ export class CommandContext extends MessageContext { } // remove zalgo - // eslint-disable-next-line max-len - message = message.replace(/[\u0300-\u036f\u0483-\u0489\u0610-\u0615\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06ED\u0E31\u0E34-\u0E3A\u0E47-\u0E4E]{3,}/g, ''); + message = message.replace( + /[\u0300-\u036f\u0483-\u0489\u0610-\u0615\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06ED\u0E31\u0E34-\u0E3A\u0E47-\u0E4E]{3,}/g, + '' + ); if (/[\u115f\u1160\u239b-\u23b9]/.test(message)) { throw new Chat.ErrorMessage(this.tr`Your message contains banned characters.`); } @@ -1481,8 +1483,11 @@ export const Chat = new class { // \u2E80-\u32FF CJK symbols // \u3400-\u9FFF CJK // \uF900-\uFAFF\uFE00-\uFE6F CJK extended - // eslint-disable-next-line no-misleading-character-class, max-len - name = name.replace(/[^a-zA-Z0-9 /\\.~()<>^*%&=+$#_'?!"\u00A1-\u00BF\u00D7\u00F7\u02B9-\u0362\u2012-\u2027\u2030-\u205E\u2050-\u205F\u2190-\u23FA\u2500-\u2BD1\u2E80-\u32FF\u3400-\u9FFF\uF900-\uFAFF\uFE00-\uFE6F-]+/g, ''); + name = name.replace( + // eslint-disable-next-line no-misleading-character-class + /[^a-zA-Z0-9 /\\.~()<>^*%&=+$#_'?!"\u00A1-\u00BF\u00D7\u00F7\u02B9-\u0362\u2012-\u2027\u2030-\u205E\u2050-\u205F\u2190-\u23FA\u2500-\u2BD1\u2E80-\u32FF\u3400-\u9FFF\uF900-\uFAFF\uFE00-\uFE6F-]+/g, + '' + ); // blacklist // \u00a1 upside-down exclamation mark (i) @@ -1500,11 +1505,21 @@ export const Chat = new class { // Limit the amount of symbols allowed in usernames to 4 maximum, and // disallow (R) and (C) from being used in the middle of names. - // eslint-disable-next-line max-len - const nameSymbols = name.replace(/[^\u00A1-\u00BF\u00D7\u00F7\u02B9-\u0362\u2012-\u2027\u2030-\u205E\u2050-\u205F\u2090-\u23FA\u2500-\u2BD1]+/g, ''); + const nameSymbols = name.replace( + /[^\u00A1-\u00BF\u00D7\u00F7\u02B9-\u0362\u2012-\u2027\u2030-\u205E\u2050-\u205F\u2090-\u23FA\u2500-\u2BD1]+/g, + '' + ); // \u00ae\u00a9 (R) (C) - // eslint-disable-next-line no-misleading-character-class, max-len - if (nameSymbols.length > 4 || /[^a-z0-9][a-z0-9][^a-z0-9]/.test(name.toLowerCase() + ' ') || /[\u00ae\u00a9].*[a-zA-Z0-9]/.test(name)) name = name.replace(/[\u00A1-\u00BF\u00D7\u00F7\u02B9-\u0362\u2012-\u2027\u2030-\u205E\u2050-\u205F\u2190-\u23FA\u2500-\u2BD1\u2E80-\u32FF\u3400-\u9FFF\uF900-\uFAFF\uFE00-\uFE6F]+/g, '').replace(/[^A-Za-z0-9]{2,}/g, ' ').trim(); + if ( + nameSymbols.length > 4 || + /[^a-z0-9][a-z0-9][^a-z0-9]/.test(name.toLowerCase() + ' ') || /[\u00ae\u00a9].*[a-zA-Z0-9]/.test(name) + ) { + name = name.replace( + // eslint-disable-next-line no-misleading-character-class + /[\u00A1-\u00BF\u00D7\u00F7\u02B9-\u0362\u2012-\u2027\u2030-\u205E\u2050-\u205F\u2190-\u23FA\u2500-\u2BD1\u2E80-\u32FF\u3400-\u9FFF\uF900-\uFAFF\uFE00-\uFE6F]+/g, + '' + ).replace(/[^A-Za-z0-9]{2,}/g, ' ').trim(); + } } name = name.replace(/^[^A-Za-z0-9]+/, ""); // remove symbols from start name = name.replace(/@/g, ""); // Remove @ as this is used to indicate status messages diff --git a/server/ip-tools.ts b/server/ip-tools.ts index 98c867024f..3c7932777f 100644 --- a/server/ip-tools.ts +++ b/server/ip-tools.ts @@ -44,9 +44,7 @@ export const IPTools = new class { readonly connectionTestCache = new Map(); - // eslint-disable-next-line max-len readonly ipRegex = /^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/; - // eslint-disable-next-line max-len readonly ipRangeRegex = /^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]|\*)){0,2}\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]|\*)$/; readonly hostRegex = /^.+\..{2,}$/; diff --git a/sim/dex.ts b/sim/dex.ts index b9e1deda03..2dc06961d8 100644 --- a/sim/dex.ts +++ b/sim/dex.ts @@ -213,7 +213,6 @@ export class ModdedDex { // remove zalgo name = name.replace( - // eslint-disable-next-line max-len /[\u0300-\u036f\u0483-\u0489\u0610-\u0615\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06ED\u0E31\u0E34-\u0E3A\u0E47-\u0E4E]{3,}/g, '' );