Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions packages/liveblocks-server/.eslintrc.cjs

This file was deleted.

54 changes: 54 additions & 0 deletions packages/liveblocks-server/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { makeConfig } from "@liveblocks/eslint-config";
import licenseHeader from "eslint-plugin-license-header";

export default [
...makeConfig(),

{
plugins: {
"license-header": licenseHeader,
},
rules: {
"license-header/header": ["error", "./resources/license-header.txt"],

// -------------------------------
// Custom syntax we want to forbid
// -------------------------------
"no-restricted-syntax": [
"error",
// Protocol types should be imported from ~/protocol
{
selector:
"ImportDeclaration[source.value='@liveblocks/core'] > ImportSpecifier[imported.name=/Op$/]",
message: "Import Op types from `~/protocol`, not core.",
},
{
selector:
"ImportDeclaration[source.value='@liveblocks/core'] > ImportSpecifier[imported.name=/ClientMsg$/]",
message: "Import ClientMsg types from `~/protocol`, not core.",
},
{
selector:
"ImportDeclaration[source.value='@liveblocks/core'] > ImportSpecifier[imported.name=/ServerMsg$/]",
message: "Import ServerMsg types from `~/protocol`, not core.",
},
],
},
},

// Allow imports from @liveblocks/core in protocol files (they re-export)
{
files: ["src/protocol/**"],
rules: {
"no-restricted-syntax": "off",
},
},

// Special config for test files
{
files: ["test/**", "**/*.test.ts", "**/*.test.tsx"],
rules: {
"@typescript-eslint/explicit-module-boundary-types": "off",
},
},
];
10 changes: 4 additions & 6 deletions packages/liveblocks-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@
"@liveblocks/eslint-config": "workspace:*",
"@liveblocks/jest-config": "workspace:*",
"@types/node": "^24.12.2",
"@typescript-eslint/eslint-plugin": "^8.57.1",
"@typescript-eslint/parser": "^8.57.1",
"eslint": "^8.56.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-license-header": "^0.8.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint": "^9.39.4",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-license-header": "^0.9.0",
"eslint-plugin-simple-import-sort": "^13.0.0",
"fast-check": "^3.23.2",
"prettier": "^3.3.2",
"publint": "^0.3.17",
Expand Down
1 change: 0 additions & 1 deletion packages/liveblocks-server/src/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,6 @@ export class Room<RM, SM, CM extends JsonObject, C = undefined> {
* @internal
* Handles an incoming ping, by sending a pong back.
*/
// eslint-disable-next-line @typescript-eslint/require-await
private async handlePing(sessionKey: SessionKey, ctx?: C): Promise<void> {
const session = this.sessions.get(sessionKey);
if (session === undefined) {
Expand Down
4 changes: 1 addition & 3 deletions packages/liveblocks-server/src/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ export class Storage {

// No conflict, node got inserted as intended
return accept(op);
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
else if (intent === "set") {
} else if (intent === "set") {
// The intent here is to "set", not insert, into the list, replacing the
// existing item that

Expand Down
1 change: 0 additions & 1 deletion packages/liveblocks-server/src/lib/DefaultMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export class DefaultMap<K, V> extends Map<K, V> {
*/
getOrCreate(key: K, defaultFn?: (key: K) => V): V {
if (super.has(key)) {
// eslint-disable-next-line no-restricted-syntax
return super.get(key)!;
} else {
const fn =
Expand Down
2 changes: 0 additions & 2 deletions packages/liveblocks-server/src/lib/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,11 @@ export class Logger {
});

this.o = {
/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
debug: minLevel <= LogLevel.DEBUG ? makeLogFn(LogLevel.DEBUG) : undefined,
info: minLevel <= LogLevel.INFO ? makeLogFn(LogLevel.INFO) : undefined,
warn:
minLevel <= LogLevel.WARNING ? makeLogFn(LogLevel.WARNING) : undefined,
error: minLevel <= LogLevel.ERROR ? makeLogFn(LogLevel.ERROR) : undefined,
/* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */
};

this.debug = this.o.debug ?? noop;
Expand Down
26 changes: 5 additions & 21 deletions packages/liveblocks-server/test/plugins/_generateFullTestSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,8 @@ function expectToThrow(fn: () => Awaitable<unknown>, errorPattern: RegExp) {
}

// SYNC-SLOT: directives
/* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/await-thenable */
// SYNC-SLOT-END: directives

const KNOWN_DOC_KEYS = ["root", "0:do", "0:dl", "0:dm"];
Expand Down Expand Up @@ -208,12 +207,9 @@ export async function selfCheck(storage: Storage): Promise<void> {
for (const [id, node] of inMemoryNodes) {
if (id === "root") {
assert(node.parentId === undefined, "Root node must have no parent ID", id, node); // prettier-ignore

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
assert(node.parentKey === undefined, "Root node must have no parent key", id, node); // prettier-ignore
} else {
assert(node.parentId !== undefined, `Node ${quote(id)} is missing parent ID`); // prettier-ignore
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
assert(node.parentKey !== undefined, `Node ${quote(id)} is missing parent key`); // prettier-ignore

const parentId = nn(node.parentId);
Expand Down Expand Up @@ -356,7 +352,6 @@ function plainLsonTreeToNodeMap(
plainLson.data.forEach((child) => {
recurse(child, id, uniqPositions.next().value);
});
// eslint-disable-next-line
} else if (plainLson.liveblocksType === "LiveMap") {
result.push([id, { type: CrdtType.MAP, parentId, parentKey }]);

Expand Down Expand Up @@ -1071,7 +1066,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {
// Call next_actor 1000 times concurrently
const actors = new Set(
await Promise.all(
// eslint-disable-next-line @typescript-eslint/await-thenable -- Awaitable<T> is fine with Promise.all
Array.from({ length: 1000 }).map(() => driver.next_actor())
)
);
Expand Down Expand Up @@ -2157,8 +2151,9 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {

// Snapshot should return the same data as the driver
for (const [id] of entries) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
expect(snapshot.get_node(id)).toEqual(db.get_node(id) as any);
expect(snapshot.get_node(id)).toEqual(
db.get_node(id) as SerializedChild
);
}
}
)
Expand Down Expand Up @@ -2865,7 +2860,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {
async (entries) => {
// Write all the entries (can have dupes)
await Promise.all(
// eslint-disable-next-line @typescript-eslint/await-thenable -- Awaitable<T> is fine with Promise.all
Array.from(entries).map(([key, value]) =>
driver.put_meta(key, value)
)
Expand Down Expand Up @@ -3305,7 +3299,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {
async (entries) => {
// Put all sessions concurrently
await Promise.all(
// eslint-disable-next-line @typescript-eslint/await-thenable -- Awaitable<T> is fine with Promise.all
Array.from(entries).map(([sessionId, session]) => {
session.sessionId = sessionId;
return driver.put_leased_session(session);
Expand All @@ -3314,7 +3307,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {

// Verify all sessions exist
const results = await Promise.all(
// eslint-disable-next-line @typescript-eslint/await-thenable -- Awaitable<T> is fine with Promise.all
Array.from(entries.keys()).map((sessionId) =>
driver.get_leased_session(sessionId)
)
Expand All @@ -3328,7 +3320,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {

// Cleanup: delete all sessions added in this iteration
await Promise.all(
// eslint-disable-next-line @typescript-eslint/await-thenable -- Awaitable<T> is fine with Promise.all
Array.from(entries.keys()).map((sessionId) =>
driver.delete_leased_session(sessionId)
)
Expand Down Expand Up @@ -4582,7 +4573,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {
parentKey: SECOND_POSITION,
},
// NOTE: Fix ops are generated server-side and don't preserve the input opId
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
fix: expect.objectContaining({
type: OpCode.SET_PARENT_KEY,
id: "1:0",
Expand Down Expand Up @@ -4735,7 +4725,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {
parentKey: SECOND_POSITION,
},
// NOTE: Fix ops are generated server-side and don't preserve the input opId
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
fix: expect.objectContaining({
type: OpCode.SET_PARENT_KEY,
id: "1:0",
Expand Down Expand Up @@ -4821,7 +4810,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {
parentKey: THIRD_POSITION,
},
// NOTE: Fix ops are generated server-side and don't preserve the input opId
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
fix: expect.objectContaining({
type: OpCode.SET_PARENT_KEY,
id: "0:2",
Expand Down Expand Up @@ -4986,7 +4974,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {
parentKey: SECOND_POSITION,
},
// NOTE: Fix ops are generated server-side and don't preserve the input opId
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
fix: expect.objectContaining({
type: OpCode.SET_PARENT_KEY,
id: "1:0",
Expand Down Expand Up @@ -5078,7 +5065,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {
parentKey: expectedPosition,
},
// NOTE: Fix ops are generated server-side and don't preserve the input opId
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
fix: expect.objectContaining({
type: OpCode.SET_PARENT_KEY,
id: "1:0",
Expand Down Expand Up @@ -5269,7 +5255,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {
parentKey: SECOND_POSITION,
},
// NOTE: Fix ops are generated server-side and don't preserve the input opId
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
fix: expect.objectContaining({
type: OpCode.SET_PARENT_KEY,
id: "1:0",
Expand Down Expand Up @@ -5351,7 +5336,6 @@ export function generateFullTestSuite<TDriver extends IStorageDriver>(config: {
// make sure that it won't lead to two clients seeing different
// state.
//
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
fix: expect.objectContaining({
type: OpCode.DELETE_CRDT,
id: "0:2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import type { NodeStream, SerializedCrdt } from "@liveblocks/core";
import { assertNever, CrdtType, OpCode } from "@liveblocks/core";
import * as fc from "fast-check";
Expand Down
57 changes: 0 additions & 57 deletions tools/liveblocks-cli/.eslintrc.cjs

This file was deleted.

Loading
Loading