Skip to content

Commit

Permalink
fix: fix some ESLint errors (#948)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robot-Inventor authored Aug 12, 2024
1 parent fe25260 commit f25cd9e
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/ts/browserAction/loadSettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// eslint-disable-next-line import-x/no-unassigned-import
import "../components/settingsItem";
// eslint-disable-next-line import-x/no-unassigned-import
import "../components/settingsSeparator";
import { DEFAULT_SETTINGS } from "../common/defaultSettings";
import { SETTINGS_ITEMS } from "./settingsItems";
Expand Down
2 changes: 1 addition & 1 deletion src/ts/browserAction/settingsItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface SettingsSeparator {
type: "separator";
}

type SettingsItems = (SettingsItem | SettingsSeparator)[];
type SettingsItems = Array<SettingsItem | SettingsSeparator>;

const SETTINGS_ITEMS = [
{
Expand Down
5 changes: 3 additions & 2 deletions src/ts/components/sbsMessage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import-x/no-unassigned-import
import "@material/web/button/filled-button";
import { LitElement, type PropertyValues, css, html } from "lit";
import { customElement, property } from "lit/decorators.js";
Expand Down Expand Up @@ -181,7 +182,7 @@ class SbsMessage extends LitElement {
</ul>`;
}

private getNotes(): "" | ReturnType<typeof html>[] {
private getNotes(): "" | Array<ReturnType<typeof html>> {
if (!this.notes.length) return "";

const notesClasses = classMap({
Expand Down Expand Up @@ -236,4 +237,4 @@ declare global {
}
}

export { SbsMessageDetails, SbsMessage };
export { type SbsMessageDetails, SbsMessage };
1 change: 1 addition & 0 deletions src/ts/components/settingsItem.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import-x/no-unassigned-import
import "@material/web/checkbox/checkbox.js";
import { LitElement, css, html } from "lit";
import { customElement, property, query } from "lit/decorators.js";
Expand Down
4 changes: 2 additions & 2 deletions src/ts/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Core {
const sbsMessageWrapper = new SbsMessageWrapper(messageData);

const bioOrUserName =
document.querySelector("[data-testid='UserDescription']") ||
document.querySelector("[data-testid='UserDescription']") ??
document.querySelector("[data-testid='UserName']");
if (!bioOrUserName) throw new Error("Failed to get user description of profile");

Expand All @@ -61,7 +61,7 @@ class Core {
const sbsMessageWrapper = new SbsMessageWrapper(messageData);

const landmarkElement =
tweet.element.querySelector<HTMLElement>("[data-testid='analyticsButton']")?.parentElement ||
tweet.element.querySelector<HTMLElement>("[data-testid='analyticsButton']")?.parentElement ??
tweet.element.querySelector<HTMLElement>("div[role='group'][id]");

if (!landmarkElement) throw new Error("Failed to get landmark element of tweet");
Expand Down
8 changes: 7 additions & 1 deletion src/ts/core/propsAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@ const analyzeTombstoneProps = (props: [CellInnerDivProps, TombstoneGrandchildPro
return tweetId;
};

export { ProfileAnalysisResult, TweetAnalysisResult, analyzeProfileProps, analyzeTweetProps, analyzeTombstoneProps };
export {
type ProfileAnalysisResult,
type TweetAnalysisResult,
analyzeProfileProps,
analyzeTweetProps,
analyzeTombstoneProps
};
3 changes: 2 additions & 1 deletion src/ts/core/sbsMessageWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import-x/no-unassigned-import
import "../components/sbsMessage";
import { SHADOW_TRANSLATION_ATTRIBUTE } from "../common/constants";
// eslint-disable-next-line no-duplicate-imports
Expand Down Expand Up @@ -94,4 +95,4 @@ class SbsMessageWrapper {
}
}

export { SbsMessageWrapperOptionsForTweets, SbsMessageWrapperOptionsForProfiles, SbsMessageWrapper };
export { type SbsMessageWrapperOptionsForTweets, type SbsMessageWrapperOptionsForProfiles, SbsMessageWrapper };
2 changes: 1 addition & 1 deletion src/ts/core/translationKeyProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const formatCountryList = (countries: string[]): string => {
});
const translator = new Intl.DisplayNames([userLanguage], { type: "region" });

const translatedCountries = countries.map((country) => translator.of(country) || "");
const translatedCountries = countries.map((country) => translator.of(country) ?? "");
const formattedText = listFormatter.format(translatedCountries);

return formattedText;
Expand Down
8 changes: 4 additions & 4 deletions src/ts/initialSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import type { Settings } from "../types/common/settings";
import { Translator } from "./common/translator";
import browser from "webextension-polyfill";

type InitialSetupItem = {
options: {
interface InitialSetupItem {
options: Array<{
default: boolean;
icon: string;
label: string;
value: boolean;
}[];
}>;
settingsKey: keyof Settings;
};
}

const INITIAL_SETUP_ITEMS = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/ts/ossLicenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const normalizeRepositoryLink = (repository: string): string => {
return repository.replace(/^git\+/u, "");
}

if (!repository.match(/^https?:\/\//u)) {
if (!/^https?:\/\//u.exec(repository)) {
return `https://github.com/${repository}`;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ts/userScript/en.user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createUserScript } from "./userScriptBase";
import translation from "../../../src/_locales/en/messages.json";
import translation from "../../_locales/en/messages.json";

createUserScript(translation);
2 changes: 1 addition & 1 deletion src/ts/userScript/ja.user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createUserScript } from "./userScriptBase";
import translation from "../../../src/_locales/ja/messages.json";
import translation from "../../_locales/ja/messages.json";

createUserScript(translation);
2 changes: 1 addition & 1 deletion src/ts/userScript/ko.user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createUserScript } from "./userScriptBase";
import translation from "../../../src/_locales/ko/messages.json";
import translation from "../../_locales/ko/messages.json";

createUserScript(translation);
1 change: 1 addition & 0 deletions src/ts/userScript/userScriptBase.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import-x/no-unassigned-import
import "../../css/style.css";
import { Core } from "../core/core";
import { DEFAULT_SETTINGS } from "../common/defaultSettings";
Expand Down
2 changes: 1 addition & 1 deletion src/ts/userScript/zh_TW.user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createUserScript } from "./userScriptBase";
import translation from "../../../src/_locales/zh_TW/messages.json";
import translation from "../../_locales/zh_TW/messages.json";

createUserScript(translation);
4 changes: 2 additions & 2 deletions src/types/common/translator.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type enTranslation from "../../../src/_locales/en/messages.json";
import type enTranslation from "../../_locales/en/messages.json";

type TranslationData = typeof enTranslation;
type TranslationKey = keyof TranslationData;
Expand All @@ -8,4 +8,4 @@ type TranslationFunction = (messageName: TranslationKey, substitutions?: string
// eslint-disable-next-line no-magic-numbers
type TranslationSubstitutions = Parameters<TranslationFunction>[1];

export { TranslationData, TranslationKey, TranslationFunction, TranslationSubstitutions };
export type { TranslationData, TranslationKey, TranslationFunction, TranslationSubstitutions };
6 changes: 4 additions & 2 deletions src/types/core/reactProps/reactProps.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @see {isCellInnerDivProps} ts-auto-guard:type-guard */
export interface CellInnerDivProps {
interface CellInnerDivProps {
children: {
_owner?: {
key: string;
Expand All @@ -11,7 +11,7 @@ export interface CellInnerDivProps {
* (tombstones' cell inner div) > div > div <- This element is the tombstone's grandchild and has detailed information.
* @see {isTombstoneGrandchildProps} ts-auto-guard:type-guard
*/
export interface TombstoneGrandchildProps {
interface TombstoneGrandchildProps {
children: [
{
props: {
Expand All @@ -29,3 +29,5 @@ export interface TombstoneGrandchildProps {
}
];
}

export type { CellInnerDivProps, TombstoneGrandchildProps };

0 comments on commit f25cd9e

Please sign in to comment.