mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-21 17:25:10 -05:00
Fix max-len for long regexes
We use eslint-disable for max-len in a lot of places where we don't actually need it. This fixes that.
This commit is contained in:
parent
d8f492d209
commit
d555f6fe0d
|
|
@ -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$]+:\ \[?
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 '';
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -44,9 +44,7 @@ export const IPTools = new class {
|
|||
|
||||
readonly connectionTestCache = new Map<string, boolean>();
|
||||
|
||||
// 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,}$/;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
''
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user