web/eslint: add import sorting

This commit is contained in:
Tulir Asokan 2024-10-07 01:26:13 +03:00
parent 40b66f3057
commit 0cb2fb88cb
8 changed files with 1364 additions and 6 deletions

View file

@ -2,6 +2,7 @@ import js from "@eslint/js"
import globals from "globals" import globals from "globals"
import reactHooks from "eslint-plugin-react-hooks" import reactHooks from "eslint-plugin-react-hooks"
import reactRefresh from "eslint-plugin-react-refresh" import reactRefresh from "eslint-plugin-react-refresh"
import pluginImport from "eslint-plugin-import"
import tseslint from "typescript-eslint" import tseslint from "typescript-eslint"
export default tseslint.config( export default tseslint.config(
@ -16,6 +17,7 @@ export default tseslint.config(
plugins: { plugins: {
"react-hooks": reactHooks, "react-hooks": reactHooks,
"react-refresh": reactRefresh, "react-refresh": reactRefresh,
"import": pluginImport,
}, },
rules: { rules: {
...reactHooks.configs.recommended.rules, ...reactHooks.configs.recommended.rules,
@ -23,6 +25,7 @@ export default tseslint.config(
"warn", "warn",
{allowConstantExport: true}, {allowConstantExport: true},
], ],
"import/order": "error",
"indent": ["error", "tab", { "indent": ["error", "tab", {
"FunctionDeclaration": {"parameters": "first"}, "FunctionDeclaration": {"parameters": "first"},
"FunctionExpression": {"parameters": "first"}, "FunctionExpression": {"parameters": "first"},

1354
web/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -21,6 +21,7 @@
"@eslint/js": "^9.11.1", "@eslint/js": "^9.11.1",
"@vitejs/plugin-react-swc": "^3.5.0", "@vitejs/plugin-react-swc": "^3.5.0",
"eslint": "^9.11.1", "eslint": "^9.11.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0", "eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.12", "eslint-plugin-react-refresh": "^0.4.12",
"globals": "^15.9.0", "globals": "^15.9.0",

View file

@ -14,12 +14,12 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
import { useEffect, useMemo, useState } from "react" import { useEffect, useMemo, useState } from "react"
import { ScaleLoader } from "react-spinners"
import Client from "./api/client.ts" import Client from "./api/client.ts"
import WSClient from "./api/wsclient.ts" import WSClient from "./api/wsclient.ts"
import { ClientState } from "./api/types/hievents.ts" import { ClientState } from "./api/types/hievents.ts"
import { ConnectionEvent } from "./api/rpc.ts" import { ConnectionEvent } from "./api/rpc.ts"
import { LoginScreen, VerificationScreen } from "./ui/login" import { LoginScreen, VerificationScreen } from "./ui/login"
import { ScaleLoader } from "react-spinners"
import MainScreen from "./ui/MainScreen.tsx" import MainScreen from "./ui/MainScreen.tsx"
function App() { function App() {

View file

@ -13,12 +13,12 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
import { CachedEventDispatcher } from "../util/eventdispatcher.ts"
import type { import type {
ClientWellKnown, DBEvent, EventID, EventRowID, EventType, RoomID, TimelineRowID, UserID, ClientWellKnown, DBEvent, EventID, EventRowID, EventType, RoomID, TimelineRowID, UserID,
} from "./types/hitypes.ts" } from "./types/hitypes.ts"
import { ClientState, RPCEvent } from "./types/hievents.ts" import { ClientState, RPCEvent } from "./types/hievents.ts"
import { RPCClient } from "./rpc.ts" import { RPCClient } from "./rpc.ts"
import { CachedEventDispatcher } from "../util/eventdispatcher.ts"
import { StateStore } from "./statestore.ts" import { StateStore } from "./statestore.ts"
export default class Client { export default class Client {

View file

@ -13,9 +13,9 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
import { RPCEvent } from "./types/hievents.ts"
import { EventDispatcher } from "../util/eventdispatcher.ts" import { EventDispatcher } from "../util/eventdispatcher.ts"
import { CancellablePromise } from "../util/promise.ts" import { CancellablePromise } from "../util/promise.ts"
import { RPCEvent } from "./types/hievents.ts"
export interface RPCClient { export interface RPCClient {
connect: EventDispatcher<ConnectionEvent> connect: EventDispatcher<ConnectionEvent>

View file

@ -13,6 +13,7 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
import { NonNullCachedEventDispatcher } from "../util/eventdispatcher.ts"
import type { import type {
ContentURI, ContentURI,
DBEvent, DBEvent,
@ -24,7 +25,6 @@ import type {
TimelineRowTuple, TimelineRowTuple,
} from "./types/hitypes.ts" } from "./types/hitypes.ts"
import type { EventsDecryptedData, SyncCompleteData, SyncRoom } from "./types/hievents.ts" import type { EventsDecryptedData, SyncCompleteData, SyncRoom } from "./types/hievents.ts"
import { NonNullCachedEventDispatcher } from "../util/eventdispatcher.ts"
function arraysAreEqual<T>(arr1?: T[], arr2?: T[]): boolean { function arraysAreEqual<T>(arr1?: T[], arr2?: T[]): boolean {
if (!arr1 || !arr2) { if (!arr1 || !arr2) {

View file

@ -13,10 +13,10 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
import { RPCCommand, RPCEvent } from "./types/hievents.ts"
import { CachedEventDispatcher, EventDispatcher } from "../util/eventdispatcher.ts" import { CachedEventDispatcher, EventDispatcher } from "../util/eventdispatcher.ts"
import { ConnectionEvent, RPCClient } from "./rpc.ts"
import { CancellablePromise } from "../util/promise.ts" import { CancellablePromise } from "../util/promise.ts"
import { RPCCommand, RPCEvent } from "./types/hievents.ts"
import { ConnectionEvent, RPCClient } from "./rpc.ts"
export class ErrorResponse extends Error { export class ErrorResponse extends Error {
constructor(public data: unknown) { constructor(public data: unknown) {