Skip to content

Commit dc546e2

Browse files
more lint rules (#302)
Co-authored-by: Matthew Lipski <[email protected]>
1 parent 5ea7b88 commit dc546e2

File tree

18 files changed

+64
-45
lines changed

18 files changed

+64
-45
lines changed

.eslintrc.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
module.exports = {
22
root: true,
3-
extends: ["react-app", "react-app/jest"],
4-
plugins: ["import"],
3+
extends: [
4+
"eslint:recommended",
5+
"plugin:@typescript-eslint/recommended",
6+
"react-app",
7+
"react-app/jest",
8+
],
9+
parser: "@typescript-eslint/parser",
10+
plugins: ["import", "@typescript-eslint"],
511
rules: {
612
curly: 1,
713
"import/no-extraneous-dependencies": [
@@ -13,5 +19,8 @@ module.exports = {
1319
bundledDependencies: false,
1420
},
1521
],
22+
// would be nice to enable these rules later, but they are too noisy right now
23+
"@typescript-eslint/no-non-null-assertion": "off",
24+
"@typescript-eslint/no-explicit-any": "off",
1625
},
1726
};

examples/vanilla/src/ui/addHyperlinkToolbar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export const addHyperlinkToolbar = (editor: BlockNoteEditor) => {
1212
element.style.padding = "10px";
1313
element.style.opacity = "0.8";
1414

15-
let url = hyperlinkToolbarState.url;
16-
let text = hyperlinkToolbarState.text;
15+
const url = hyperlinkToolbarState.url;
16+
const text = hyperlinkToolbarState.text;
1717

1818
const editBtn = createButton("edit", () => {
1919
const newUrl = prompt("new url") || url;

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"eslint-config-react-app": "^7.0.0",
1414
"lerna": "^5.4.0",
1515
"patch-package": "^6.4.7",
16-
"typescript": "^5.0.4"
16+
"typescript": "^5.0.4",
17+
"@typescript-eslint/parser": "^5.5.0",
18+
"@typescript-eslint/eslint-plugin": "^5.5.0"
1719
},
1820
"scripts": {
1921
"start": "lerna run --stream --scope @blocknote/example-editor dev",

packages/core/src/BlockNoteEditor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
353353
*/
354354
public forEachBlock(
355355
callback: (block: Block<BSchema>) => boolean,
356-
reverse: boolean = false
356+
reverse = false
357357
): void {
358358
const blocks = this.topLevelBlocks.slice();
359359

@@ -692,7 +692,7 @@ export class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
692692
return;
693693
}
694694

695-
let { from, to } = this._tiptapEditor.state.selection;
695+
const { from, to } = this._tiptapEditor.state.selection;
696696

697697
if (!text) {
698698
text = this._tiptapEditor.state.doc.textBetween(from, to);

packages/core/src/api/blockManipulation/blockManipulation.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let insert: (
2424
) => Block<DefaultBlockSchema>[];
2525

2626
beforeEach(() => {
27-
(window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS = {};
27+
(window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS = {};
2828

2929
editor = new BlockNoteEditor();
3030

@@ -80,7 +80,7 @@ afterEach(() => {
8080
editor._tiptapEditor.destroy();
8181
editor = undefined as any;
8282

83-
delete (window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS;
83+
delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS;
8484
});
8585

8686
describe("Inserting Blocks with Different Placements", () => {

packages/core/src/api/blockManipulation/blockManipulation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function removeBlocks(
107107
});
108108

109109
if (idsOfBlocksToRemove.size > 0) {
110-
let notFoundIds = [...idsOfBlocksToRemove].join("\n");
110+
const notFoundIds = [...idsOfBlocksToRemove].join("\n");
111111

112112
throw Error(
113113
"Blocks with the following IDs could not be found in the editor: " +

packages/core/src/api/formatConversions/formatConversions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ function removeInlineContentClass(html: string) {
579579
}
580580

581581
beforeEach(() => {
582-
(window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS = {};
582+
(window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS = {};
583583

584584
editor = new BlockNoteEditor();
585585
});
@@ -588,7 +588,7 @@ afterEach(() => {
588588
editor._tiptapEditor.destroy();
589589
editor = undefined as any;
590590

591-
delete (window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS;
591+
delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS;
592592
});
593593

594594
describe("Non-Nested Block/HTML/Markdown Conversions", () => {

packages/core/src/api/nodeConversions/nodeConversions.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { Editor } from "@tiptap/core";
22
import { afterEach, beforeEach, describe, expect, it } from "vitest";
33
import { BlockNoteEditor, PartialBlock } from "../..";
4-
import UniqueID from "../../extensions/UniqueID/UniqueID";
5-
import { blockToNode, nodeToBlock } from "./nodeConversions";
6-
import { partialBlockToBlockForTesting } from "./testUtil";
74
import {
8-
defaultBlockSchema,
95
DefaultBlockSchema,
6+
defaultBlockSchema,
107
} from "../../extensions/Blocks/api/defaultBlocks";
8+
import UniqueID from "../../extensions/UniqueID/UniqueID";
9+
import { blockToNode, nodeToBlock } from "./nodeConversions";
10+
import { partialBlockToBlockForTesting } from "./testUtil";
1111

1212
let editor: BlockNoteEditor;
1313
let tt: Editor;
1414

1515
beforeEach(() => {
16-
(window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS = {};
16+
(window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS = {};
1717

1818
editor = new BlockNoteEditor();
1919
tt = editor._tiptapEditor;
@@ -24,7 +24,7 @@ afterEach(() => {
2424
editor = undefined as any;
2525
tt = undefined as any;
2626

27-
delete (window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS;
27+
delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS;
2828
});
2929

3030
describe("Simple ProseMirror Node Conversions", () => {

packages/core/src/api/nodeConversions/nodeConversions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function styledTextArrayToNodes(
9191
content: string | StyledText[],
9292
schema: Schema
9393
): Node[] {
94-
let nodes: Node[] = [];
94+
const nodes: Node[] = [];
9595

9696
if (typeof content === "string") {
9797
nodes.push(
@@ -113,7 +113,7 @@ export function inlineContentToNodes(
113113
blockContent: PartialInlineContent[],
114114
schema: Schema
115115
): Node[] {
116-
let nodes: Node[] = [];
116+
const nodes: Node[] = [];
117117

118118
for (const content of blockContent) {
119119
if (content.type === "link") {

0 commit comments

Comments
 (0)