From d44cee02ac28277045100e9dbf830e838973a29c Mon Sep 17 00:00:00 2001 From: yousefed Date: Sun, 2 Jun 2024 20:58:22 +0200 Subject: [PATCH] fix console log + add lint rule --- .eslintrc.js | 1 + packages/core/src/editor/BlockNoteEditor.ts | 2 ++ packages/core/src/editor/BlockNoteTipTapEditor.ts | 1 + packages/dev-scripts/examples/gen.ts | 2 ++ .../FormattingToolbar/FormattingToolbarController.tsx | 4 ++-- .../src/components/SuggestionMenu/SuggestionMenu.test.tsx | 2 ++ packages/react/src/schema/@util/ReactRenderUtil.ts | 1 + playground/src/main.tsx | 1 - tests/src/utils/components/Editor.tsx | 6 ++---- tests/src/utils/customblocks/Alert.tsx | 1 + tests/src/utils/customblocks/ReactAlert.tsx | 1 + 11 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index dee0b4c119..c0a4c78b89 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -26,6 +26,7 @@ module.exports = { }, ignorePatterns: ["**/ui/*"], rules: { + "no-console": "error", curly: 1, "import/no-extraneous-dependencies": [ "error", diff --git a/packages/core/src/editor/BlockNoteEditor.ts b/packages/core/src/editor/BlockNoteEditor.ts index 53ec4d9f83..650a3ff026 100644 --- a/packages/core/src/editor/BlockNoteEditor.ts +++ b/packages/core/src/editor/BlockNoteEditor.ts @@ -307,6 +307,7 @@ export class BlockNoteEditor< this.resolveFileUrl = newOptions.resolveFileUrl || (async (url) => url); if (newOptions.collaboration && newOptions.initialContent) { + // eslint-disable-next-line no-console console.warn( "When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider" ); @@ -777,6 +778,7 @@ export class BlockNoteEditor< for (const mark of marks) { const config = this.schema.styleSchema[mark.type.name]; if (!config) { + // eslint-disable-next-line no-console console.warn("mark not found in styleschema", mark.type.name); continue; } diff --git a/packages/core/src/editor/BlockNoteTipTapEditor.ts b/packages/core/src/editor/BlockNoteTipTapEditor.ts index 6857c6f0e7..dc4644af3c 100644 --- a/packages/core/src/editor/BlockNoteTipTapEditor.ts +++ b/packages/core/src/editor/BlockNoteTipTapEditor.ts @@ -87,6 +87,7 @@ export class BlockNoteTipTapEditor extends TiptapEditor { this.options.parseOptions ); } catch (e) { + // eslint-disable-next-line no-console console.error( "Error creating document from blocks passed as `initialContent`. Caused by exception: ", e diff --git a/packages/dev-scripts/examples/gen.ts b/packages/dev-scripts/examples/gen.ts index da789ca102..b3f3576a7c 100644 --- a/packages/dev-scripts/examples/gen.ts +++ b/packages/dev-scripts/examples/gen.ts @@ -51,6 +51,7 @@ async function writeTemplate(project: Project, templateFile: string) { // try { // // fs.unlinkSync(targetFilePath); // } catch (e) {} + // eslint-disable-next-line no-console console.log("written", targetFilePath); } @@ -79,6 +80,7 @@ async function generateExamplesData(projects: Project[]) { const projects = getExampleProjects(); for (const project of projects) { + // eslint-disable-next-line no-console console.log("generating code for example", project); await generateCodeForExample(project); } diff --git a/packages/react/src/components/FormattingToolbar/FormattingToolbarController.tsx b/packages/react/src/components/FormattingToolbar/FormattingToolbarController.tsx index 61dba65c14..fe44ff1142 100644 --- a/packages/react/src/components/FormattingToolbar/FormattingToolbarController.tsx +++ b/packages/react/src/components/FormattingToolbar/FormattingToolbarController.tsx @@ -80,8 +80,8 @@ export const FormattingToolbarController = (props: { { placement, middleware: [offset(10), flip()], - onOpenChange: (open, event) => { - console.log("change", event); + onOpenChange: (open, _event) => { + // console.log("change", event); if (!open) { editor.formattingToolbar.closeMenu(); editor.focus(); diff --git a/packages/react/src/components/SuggestionMenu/SuggestionMenu.test.tsx b/packages/react/src/components/SuggestionMenu/SuggestionMenu.test.tsx index f580b5697a..a161d17c60 100644 --- a/packages/react/src/components/SuggestionMenu/SuggestionMenu.test.tsx +++ b/packages/react/src/components/SuggestionMenu/SuggestionMenu.test.tsx @@ -33,6 +33,7 @@ it("has good typing", () => { suggestionMenuComponent={undefined as any} getItems={async () => [{ hello: "hello" }]} onItemClick={(item) => { + // eslint-disable-next-line no-console console.log(item.hello); }} triggerCharacter="/" @@ -40,5 +41,6 @@ it("has good typing", () => { ); // prevent typescript unused error + // eslint-disable-next-line no-console console.log("menu", menu); }); diff --git a/packages/react/src/schema/@util/ReactRenderUtil.ts b/packages/react/src/schema/@util/ReactRenderUtil.ts index d88cd8637a..f70fb07ea1 100644 --- a/packages/react/src/schema/@util/ReactRenderUtil.ts +++ b/packages/react/src/schema/@util/ReactRenderUtil.ts @@ -28,6 +28,7 @@ export function renderToDOMSpec( if (!div.childElementCount) { // TODO + // eslint-disable-next-line no-console console.warn("ReactInlineContentSpec: renderHTML() failed"); return { dom: document.createElement("span"), diff --git a/playground/src/main.tsx b/playground/src/main.tsx index ec2f7fc2b2..292d0fc70c 100644 --- a/playground/src/main.tsx +++ b/playground/src/main.tsx @@ -96,7 +96,6 @@ const App = (props: { project: (typeof examples.basic)["projects"][0] }) => { React.useEffect(() => { (async () => { // load app async - console.log("../../" + props.project.pathFromRoot + "/App.tsx"); const c: any = await modules[ "../../" + props.project.pathFromRoot + "/App.tsx" ](); diff --git a/tests/src/utils/components/Editor.tsx b/tests/src/utils/components/Editor.tsx index dba0b4b96d..112ea8becd 100644 --- a/tests/src/utils/components/Editor.tsx +++ b/tests/src/utils/components/Editor.tsx @@ -1,13 +1,13 @@ import { BlockNoteSchema, filterSuggestionItems } from "@blocknote/core"; import "@blocknote/core/style.css"; +import { BlockNoteView } from "@blocknote/mantine"; +import "@blocknote/mantine/style.css"; import { BlockNoteDefaultUI, SuggestionMenuController, getDefaultReactSlashMenuItems, useCreateBlockNote, } from "@blocknote/react"; -import { BlockNoteView } from "@blocknote/mantine"; -import "@blocknote/mantine/style.css"; import { Alert, insertAlert } from "../customblocks/Alert"; import { Button } from "../customblocks/Button"; @@ -24,8 +24,6 @@ const schema = BlockNoteSchema.create({ export default function Editor() { const editor = useCreateBlockNote({ schema }); - console.log(editor); - // Give tests a way to get prosemirror instance (window as WindowWithProseMirror).ProseMirror = editor?._tiptapEditor; // editor.insertBlocks([{ diff --git a/tests/src/utils/customblocks/Alert.tsx b/tests/src/utils/customblocks/Alert.tsx index fa2e98f34f..ad64f90c97 100644 --- a/tests/src/utils/customblocks/Alert.tsx +++ b/tests/src/utils/customblocks/Alert.tsx @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import { BlockNoteEditor, BlockSchemaWithBlock, diff --git a/tests/src/utils/customblocks/ReactAlert.tsx b/tests/src/utils/customblocks/ReactAlert.tsx index 5a8752c2f9..29cc053000 100644 --- a/tests/src/utils/customblocks/ReactAlert.tsx +++ b/tests/src/utils/customblocks/ReactAlert.tsx @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import { BlockNoteEditor, defaultProps } from "@blocknote/core"; import { createReactBlockSpec } from "@blocknote/react"; import { useEffect, useState } from "react";