diff --git a/build/update-emoji.js b/build/update-emoji.js index dd965cf66..b2631ec6e 100644 --- a/build/update-emoji.js +++ b/build/update-emoji.js @@ -3,7 +3,7 @@ import emojis from '@kazvmoe-infra/unicode-emoji-json/data-by-group.json' with { type: 'json', } -Object.keys(emojis).map((k) => { +Object.keys(emojis).forEach((k) => { emojis[k].forEach((e) => { delete e.unicode_version delete e.emoji_version diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js index 60f0fd16b..7e0cf859c 100644 --- a/src/components/registration/registration.js +++ b/src/components/registration/registration.js @@ -154,7 +154,7 @@ const registration = { }) }, replaceNewlines(str) { - return str.replace(/\s*\n\s*/g, ' \n') + return str.replaceAll('\s*\n\s*', ' \n') }, }, } diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx index 646df5bab..89a61be89 100644 --- a/src/components/rich_content/rich_content.jsx +++ b/src/components/rich_content/rich_content.jsx @@ -181,7 +181,7 @@ export default { } // Processor to use with html_tree_converter - const processItem = (item, index, array, what) => { + const processItem = (item, index, array) => { // Handle text nodes - just add emoji if (typeof item === 'string') { const emptyText = item.trim() === '' @@ -281,7 +281,7 @@ export default { // Processor for back direction (for finding "last" stuff, just easier this way) let encounteredTextReverse = false - const processItemReverse = (item, index, array, what) => { + const processItemReverse = (item, index, array) => { // Handle text nodes - just add emoji if (typeof item === 'string') { const emptyText = item.trim() === '' @@ -479,7 +479,7 @@ export default { > {this.collapse ? pass2.map((x) => { - if (typeof x === 'string') return x.replace(/\n/g, ' ') + if (typeof x === 'string') return x.replaceAll('\n', ' ') if (!Array.isArray(x)) return x return x.map((y) => (y.type === 'br' ? ' ' : y)) }) @@ -547,8 +547,8 @@ export const preProcessPerLine = (html, greentext) => { (string.includes('>') || string.includes('<')) ) { const cleanedString = string - .replace(/<[^>]+?>/gi, '') // remove all tags - .replace(/@\w+/gi, '') // remove mentions (even failed ones) + .replaceAll(/<[^>]+?>/gi, '') // remove all tags + .replaceAll(/@\w+/gi, '') // remove mentions (even failed ones) .trim() if (cleanedString.startsWith('>')) { return `${string}` diff --git a/src/components/settings_modal/admin_tabs/emoji_tab.js b/src/components/settings_modal/admin_tabs/emoji_tab.js index 56361587d..7dc9e91bf 100644 --- a/src/components/settings_modal/admin_tabs/emoji_tab.js +++ b/src/components/settings_modal/admin_tabs/emoji_tab.js @@ -300,7 +300,7 @@ const EmojiTab = { sortPackFiles(nameOfPack) { // Sort by key const sorted = Object.keys(this.knownPacks[nameOfPack].files) - .sort() + .sort((a, b) => a.localeCompare(b)) .reduce((acc, key) => { if (key.length === 0) return acc acc[key] = this.knownPacks[nameOfPack].files[key] diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js index c2f5279f6..a2d33deff 100644 --- a/src/components/settings_modal/helpers/setting.js +++ b/src/components/settings_modal/helpers/setting.js @@ -179,7 +179,7 @@ export default { [ 'admin_dash', 'temp_overrides', - ...this.canonPath.map((p) => p.replace(/\./g, '_DOT_')), + ...this.canonPath.map((p) => p.replaceAll('\.', '_DOT_')), 'label', ].join('.'), ) @@ -198,7 +198,7 @@ export default { [ 'admin_dash', 'temp_overrides', - ...this.canonPath.map((p) => p.replace(/\./g, '_DOT_')), + ...this.canonPath.map((p) => p.replaceAll('\.', '_DOT_')), 'description', ].join('.'), ) diff --git a/src/components/settings_modal/tabs/appearance_tab.js b/src/components/settings_modal/tabs/appearance_tab.js index 518345d9e..d93758f9a 100644 --- a/src/components/settings_modal/tabs/appearance_tab.js +++ b/src/components/settings_modal/tabs/appearance_tab.js @@ -257,7 +257,7 @@ const AppearanceTab = { const result = { name: `${meta.directives.name || this.$t('settings.style.themes3.palette.imported')}: ${variant}`, - key: `style.${variant.toLowerCase().replace(/ /g, '_')}`, + key: `style.${variant.toLowerCase().replaceAll(' ', '_')}`, bg, fg, text, diff --git a/src/components/settings_modal/tabs/old_theme_tab/old_theme_tab.js b/src/components/settings_modal/tabs/old_theme_tab/old_theme_tab.js index 13bcc3ae6..7a2673621 100644 --- a/src/components/settings_modal/tabs/old_theme_tab/old_theme_tab.js +++ b/src/components/settings_modal/tabs/old_theme_tab/old_theme_tab.js @@ -319,7 +319,7 @@ export default { return useInterfaceStore().themeDataUsed }, shadowsAvailable() { - return Object.keys(DEFAULT_SHADOWS).sort() + return Object.keys(DEFAULT_SHADOWS).sort((a, b) => a.localeCompare(b)) }, currentShadowOverriden: { get() { diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js index c76e04b9c..5e94e6fa4 100644 --- a/src/components/status_body/status_body.js +++ b/src/components/status_body/status_body.js @@ -147,7 +147,7 @@ const StatusBody = { return this.status.attachments.map((file) => file.type) }, collapsedStatus() { - return this.status.raw_html.replace(/(\n|)/g, ' ') + return this.status.raw_html.replaceAll('(\n|)', ' ') }, ...mapState(useMergedConfigStore, ['mergedConfig']), }, @@ -168,7 +168,7 @@ const StatusBody = { .filter((mention) => !mention.notifying) .forEach((mention) => { const { content, url } = mention - const cleanedString = content.replace(/<[^>]+?>/gi, '') // remove all tags + const cleanedString = content.replaceAll(/<[^>]+?>/gi, '') // remove all tags if (!cleanedString.startsWith('@')) return const handle = cleanedString.slice(1) const host = url.replace(/^https?:\/\//, '').replace(/\/.+?$/, '') diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index 9f6488b34..b6e720c6f 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -196,7 +196,7 @@ export default { }, computed: { escapedNewBio() { - return ldEscape(this.newBio).replace(/\n/g, '
') + return ldEscape(this.newBio).replaceAll('\n', '
') }, somethingToSave() { if (this.newName !== this.user.name_unescaped) return true diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index d2df5e869..9a5a642fd 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -62,8 +62,8 @@ export const parseUser = (data) => { }) output.fields_text = data.fields.map((field) => { return { - name: unescape(field.name.replace(/<[^>]*>/g, '')), - value: unescape(field.value.replace(/<[^>]*>/g, '')), + name: unescape(field.name.replaceAll('<[^>]*>', '')), + value: unescape(field.value.replaceAll('<[^>]*>', '')), } }) diff --git a/src/services/errors/errors.js b/src/services/errors/errors.js index 5fbb8da11..0742de3f4 100644 --- a/src/services/errors/errors.js +++ b/src/services/errors/errors.js @@ -3,7 +3,7 @@ import { capitalize } from 'lodash' function humanizeErrors(errors) { return Object.entries(errors).reduce((errs, [k, val]) => { const message = val.reduce((acc, message) => { - const key = capitalize(k.replace(/_/g, ' ')) + const key = capitalize(k.replaceAll('_', ' ')) return acc + [key, message].join(' ') + '. ' }, '') return [...errs, message] diff --git a/src/services/style_setter/style_setter.js b/src/services/style_setter/style_setter.js index cb445d2c1..0cab385a3 100644 --- a/src/services/style_setter/style_setter.js +++ b/src/services/style_setter/style_setter.js @@ -29,7 +29,7 @@ export const createStyleSheet = (id, priority = 1000) => { addRule(rule) { let newRule = rule if (!CSS.supports?.('backdrop-filter', 'blur()')) { - newRule = newRule.replace(/backdrop-filter:[^;]+;/g, '') // Remove backdrop-filter + newRule = newRule.replaceAll('backdrop-filter:[^;]+;', '') // Remove backdrop-filter } if (newRule.startsWith('::-webkit')) { @@ -44,7 +44,7 @@ export const createStyleSheet = (id, priority = 1000) => { } this.rules.push( - newRule.replace(/var\(--shadowFilter\)[^;]*;/g, ''), // Remove shadowFilter references + newRule.replaceAll('var\(--shadowFilter\)[^;]*;', ''), // Remove shadowFilter references ) }, } diff --git a/src/services/sw/sw.js b/src/services/sw/sw.js index b45409b28..b114cb0de 100644 --- a/src/services/sw/sw.js +++ b/src/services/sw/sw.js @@ -1,7 +1,7 @@ /* global process */ function urlBase64ToUint8Array(base64String) { const padding = '='.repeat((4 - (base64String.length % 4)) % 4) - const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/') + const base64 = (base64String + padding).replaceAll('-', '+').replace(/_/g, '/') const rawData = window.atob(base64) return Uint8Array.from([...rawData].map((char) => char.codePointAt(0))) diff --git a/src/services/theme_data/theme_data.service.js b/src/services/theme_data/theme_data.service.js index cdce2cf57..4747c22c3 100644 --- a/src/services/theme_data/theme_data.service.js +++ b/src/services/theme_data/theme_data.service.js @@ -460,7 +460,7 @@ export const generatePreset = (input) => { return composePreset( colors, generateRadii(input), - generateShadows(input, colors.theme.colors, colors.mod), + generateShadows(input, colors.theme.colors), generateFonts(input), ) } diff --git a/src/services/user_highlighter/user_highlighter.js b/src/services/user_highlighter/user_highlighter.js index 697496c91..9724595c0 100644 --- a/src/services/user_highlighter/user_highlighter.js +++ b/src/services/user_highlighter/user_highlighter.js @@ -47,7 +47,7 @@ const highlightStyle = (prefs) => { const highlightClass = (user) => { return ( - 'USER____' + user.screen_name?.replace(/\./g, '_').replace(/@/g, '_AT_') + 'USER____' + user.screen_name?.replaceAll('\.', '_').replace(/@/g, '_AT_') ) } diff --git a/src/stores/emoji.js b/src/stores/emoji.js index 3316f8328..aea8e5985 100644 --- a/src/stores/emoji.js +++ b/src/stores/emoji.js @@ -231,7 +231,7 @@ export const useEmojiStore = defineStore('emoji', { .then((allPacks) => { // Sort by key return Object.keys(allPacks) - .sort() + .sort((a, b) => a.localeCompare(b)) .reduce((acc, key) => { if (key.length === 0) return acc acc[key] = allPacks[key] diff --git a/src/stores/interface.js b/src/stores/interface.js index 87ef65865..dc92d6067 100644 --- a/src/stores/interface.js +++ b/src/stores/interface.js @@ -578,7 +578,7 @@ export const useInterfaceStore = defineStore('interface', { return { name: x.variant, ...cleanDirectives } }) .forEach((palette) => { - const key = 'style.' + palette.name.toLowerCase().replace(/ /g, '_') + const key = 'style.' + palette.name.toLowerCase().replaceAll(' ', '_') if (!firstStylePaletteName) firstStylePaletteName = key palettesIndex[key] = () => Promise.resolve(palette) }) diff --git a/test/unit/specs/components/rich_content.spec.js b/test/unit/specs/components/rich_content.spec.js index fdf6c7f8f..48cd5eb91 100644 --- a/test/unit/specs/components/rich_content.spec.js +++ b/test/unit/specs/components/rich_content.spec.js @@ -50,7 +50,7 @@ describe('RichContent', () => { }, }) - expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(html)) + expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html)) }) it('unescapes everything as needed', () => { @@ -67,7 +67,7 @@ describe('RichContent', () => { }, }) - expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) + expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected)) }) it('replaces mention with mentionsline', () => { @@ -83,7 +83,7 @@ describe('RichContent', () => { }, }) - expect(wrapper.html().replace(/\n/g, '')).to.eql( + expect(wrapper.html().replaceAll('\n', '')).to.eql( compwrap(p(mentionsLine(1), ' how are you doing today?')), ) }) @@ -116,7 +116,7 @@ describe('RichContent', () => { }, }) - expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) + expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected)) }) it('Does not touch links if link handling is disabled', () => { @@ -211,7 +211,7 @@ describe('RichContent', () => { }, }) - expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) + expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected)) }) it("Doesn't add nonexistent emoji to post", () => { @@ -228,7 +228,7 @@ describe('RichContent', () => { }, }) - expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(html)) + expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html)) }) it('Greentext + last mentions', () => { @@ -279,7 +279,7 @@ describe('RichContent', () => { }, }) - expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) + expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected)) }) it('buggy example/hashtags', () => { @@ -315,7 +315,7 @@ describe('RichContent', () => { }, }) - expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) + expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected)) }) it('rich contents of a mention are handled properly', () => { @@ -365,8 +365,8 @@ describe('RichContent', () => { expect( wrapper .html() - .replace(/\n/g, '') - .replace(//g, ''), + .replaceAll('\n', '') + .replaceAll('', ''), ).to.eql(compwrap(expected)) }) @@ -438,8 +438,8 @@ describe('RichContent', () => { expect( wrapper .html() - .replace(/\n/g, '') - .replace(//g, ''), + .replaceAll('\n', '') + .replaceAll('', ''), ).to.eql(compwrap(expected)) }) @@ -484,7 +484,7 @@ describe('RichContent', () => { }, }) - expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected)) + expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected)) }) it.skip('[INFORMATIVE] Performance testing, 10 000 simple posts', () => { diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js index 1315724da..cd43496a9 100644 --- a/test/unit/specs/modules/statuses.spec.js +++ b/test/unit/specs/modules/statuses.spec.js @@ -107,7 +107,7 @@ describe('Statuses module', () => { showImmediately: true, timeline: 'public', }) - expect(state.timelines.public.maxId).to.eql('1') + expect(state.timelines.public.maxId).to.equal('1') mutations.addNewStatuses(state, { statuses: [secondStatus], @@ -120,7 +120,7 @@ describe('Statuses module', () => { secondStatus, status, ]) - expect(state.timelines.public.maxId).to.eql('1') + expect(state.timelines.public.maxId).to.equal('1') }) it('keeps a descending by id order in timeline.visibleStatuses and timeline.statuses', () => { @@ -340,7 +340,7 @@ describe('Statuses module', () => { expect(state.allStatusesObject['1'].emoji_reactions[0].me).to.eql(true) expect( state.allStatusesObject['1'].emoji_reactions[0].accounts[0].id, - ).to.eql('me') + ).to.equal('me') }) it('adds a new reaction', () => { @@ -362,7 +362,7 @@ describe('Statuses module', () => { expect(state.allStatusesObject['1'].emoji_reactions[0].me).to.eql(true) expect( state.allStatusesObject['1'].emoji_reactions[0].accounts[0].id, - ).to.eql('me') + ).to.equal('me') }) it('decreases count in existing reaction', () => { @@ -429,8 +429,8 @@ describe('Statuses module', () => { mutations.showNewStatuses(state, { timeline: 'public' }) expect(state.timelines.public.visibleStatuses.length).to.eql(2) - expect(state.timelines.public.minVisibleId).to.eql('10') - expect(state.timelines.public.minId).to.eql('10') + expect(state.timelines.public.minVisibleId).to.equal('10') + expect(state.timelines.public.minId).to.equal('10') }) }) diff --git a/tools/emoji_merger.js b/tools/emoji_merger.js index b49ead471..1e37134a7 100644 --- a/tools/emoji_merger.js +++ b/tools/emoji_merger.js @@ -54,7 +54,7 @@ const run = () => { // Sort by key const sorted = Object.keys(emojisObject) - .sort() + .sort((a, b) => a.localeCompare(b)) .reduce((acc, key) => { if (key.length === 0) return acc acc[key] = emojisObject[key]