Tighten up eslint rule to catch unused const {_} = useLingui() (#9122)

* tighten eslint config to catch unused `useLingui`s

* fix now-invalid uses of _

* remove unused function that produces a ton of eslint warnings

* upgrade react compiler plugin
This commit is contained in:
Samuel Newman
2025-10-02 19:59:05 +03:00
committed by GitHub
parent 02b189a40e
commit 77bf49f212
19 changed files with 29 additions and 64 deletions
+11 -11
View File
@@ -105,7 +105,7 @@ export function parseEmbedPlayerFromUrl(
urlp.hostname === 'm.youtube.com' ||
urlp.hostname === 'music.youtube.com'
) {
const [_, page, shortOrLiveVideoId] = urlp.pathname.split('/')
const [__, page, shortOrLiveVideoId] = urlp.pathname.split('/')
const isShorts = page === 'shorts'
const isLive = page === 'live'
@@ -137,7 +137,7 @@ export function parseEmbedPlayerFromUrl(
window.location.hostname
: 'localhost'
const [_, channelOrVideo, clipOrId, id] = urlp.pathname.split('/')
const [__, channelOrVideo, clipOrId, id] = urlp.pathname.split('/')
if (channelOrVideo === 'videos') {
return {
@@ -162,7 +162,7 @@ export function parseEmbedPlayerFromUrl(
// spotify
if (urlp.hostname === 'open.spotify.com') {
const [_, typeOrLocale, idOrType, id] = urlp.pathname.split('/')
const [__, typeOrLocale, idOrType, id] = urlp.pathname.split('/')
if (idOrType) {
if (typeOrLocale === 'playlist' || idOrType === 'playlist') {
@@ -210,7 +210,7 @@ export function parseEmbedPlayerFromUrl(
urlp.hostname === 'soundcloud.com' ||
urlp.hostname === 'www.soundcloud.com'
) {
const [_, user, trackOrSets, set] = urlp.pathname.split('/')
const [__, user, trackOrSets, set] = urlp.pathname.split('/')
if (user && trackOrSets) {
if (trackOrSets === 'sets' && set) {
@@ -270,7 +270,7 @@ export function parseEmbedPlayerFromUrl(
}
if (urlp.hostname === 'vimeo.com' || urlp.hostname === 'www.vimeo.com') {
const [_, videoId] = urlp.pathname.split('/')
const [__, videoId] = urlp.pathname.split('/')
if (videoId) {
return {
type: 'vimeo_video',
@@ -281,7 +281,7 @@ export function parseEmbedPlayerFromUrl(
}
if (urlp.hostname === 'giphy.com' || urlp.hostname === 'www.giphy.com') {
const [_, gifs, nameAndId] = urlp.pathname.split('/')
const [__, gifs, nameAndId] = urlp.pathname.split('/')
/*
* nameAndId is a string that consists of the name (dash separated) and the id of the gif (the last part of the name)
@@ -309,7 +309,7 @@ export function parseEmbedPlayerFromUrl(
// These can include (presumably) a tracking id in the path name, so we have to check for that as well
if (giphyRegex.test(urlp.hostname)) {
// We can link directly to the gif, if its a proper link
const [_, media, trackingOrId, idOrFilename, filename] =
const [__, media, trackingOrId, idOrFilename, filename] =
urlp.pathname.split('/')
if (media === 'media') {
@@ -338,7 +338,7 @@ export function parseEmbedPlayerFromUrl(
// Finally, we should see if it is a link to i.giphy.com. These links don't necessarily end in .gif but can also
// be .webp
if (urlp.hostname === 'i.giphy.com' || urlp.hostname === 'www.i.giphy.com') {
const [_, mediaOrFilename, filename] = urlp.pathname.split('/')
const [__, mediaOrFilename, filename] = urlp.pathname.split('/')
if (mediaOrFilename === 'media' && filename) {
const gifId = filename.split('.')[0]
@@ -389,7 +389,7 @@ export function parseEmbedPlayerFromUrl(
const path_components = urlp.pathname.slice(1, i + 1).split('/')
if (path_components.length === 4) {
// discard username - it's not relevant
const [photos, _, albums, id] = path_components
const [photos, __, albums, id] = path_components
if (photos === 'photos' && albums === 'albums') {
// this at least has the shape of a valid photo-album URL!
return {
@@ -417,7 +417,7 @@ export function parseEmbedPlayerFromUrl(
// link shortened flickr path
if (urlp.hostname === 'flic.kr') {
const b58alph = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
let [_, type, idBase58Enc] = urlp.pathname.split('/')
let [__, type, idBase58Enc] = urlp.pathname.split('/')
let id = 0n
for (const char of idBase58Enc) {
const nextIdx = b58alph.indexOf(char)
@@ -528,7 +528,7 @@ export function parseTenorGif(urlp: URL):
return {success: false}
}
let [_, id, filename] = urlp.pathname.split('/')
let [__, id, filename] = urlp.pathname.split('/')
if (!id || !filename) {
return {success: false}
-17
View File
@@ -62,23 +62,6 @@ export function useWarnMaxGraphemeCount({
}, [splitter, maxCount, text])
}
// https://stackoverflow.com/a/52171480
export function toHashCode(str: string, seed = 0): number {
let h1 = 0xdeadbeef ^ seed,
h2 = 0x41c6ce57 ^ seed
for (let i = 0, ch; i < str.length; i++) {
ch = str.charCodeAt(i)
h1 = Math.imul(h1 ^ ch, 2654435761)
h2 = Math.imul(h2 ^ ch, 1597334677)
}
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507)
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909)
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507)
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909)
return 4294967296 * (2097151 & h2) + (h1 >>> 0)
}
export function countLines(str: string | undefined): number {
if (!str) return 0
return str.match(/\n/g)?.length ?? 0
+1 -1
View File
@@ -46,7 +46,7 @@ export function parseStarterPackUri(uri?: string): {
} else {
const url = new URL(uri)
const parts = url.pathname.split('/')
const [_, path, name, rkey] = parts
const [__, path, name, rkey] = parts
if (parts.length !== 4) return null
if (path !== 'starter-pack' && path !== 'start') return null