Skip to content

Commit

Permalink
Back to ESLint and prettier, fix a few minor issues with the code
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Sep 12, 2024
1 parent 9a2adb0 commit b9e9ef4
Show file tree
Hide file tree
Showing 18 changed files with 666 additions and 71 deletions.
29 changes: 19 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,35 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.18.0
rev: 1.21.0
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.9"
rev: "v0.6.4"
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/biomejs/pre-commit
rev: "v0.4.0"
hooks:
- id: biome-check
additional_dependencies: ["@biomejs/[email protected]"]
args: [--unsafe]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.1.3
rev: 2.2.3
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.18
rev: v0.19
hooks:
- id: validate-pyproject
- repo: local
hooks:
- id: prettier
name: prettier
entry: npx [email protected] --no-semi --write
language: system
types_or: [css, scss]
require_serial: true
- id: eslint
name: eslint
entry: yarn eslint
language: system
types_or: [javascript]
require_serial: true
verbose: true
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Next version
~~~~~~~~~~~~

- Updated the ProseMirror dependencies.
- Switched back to ESLint and prettier. Somehow biome didn't warn when
variables were unused or undefined.


0.8 (2024-08-26)
Expand Down
41 changes: 0 additions & 41 deletions biome.json

This file was deleted.

2 changes: 1 addition & 1 deletion django_prose_editor/static/django_prose_editor/editor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion esbuild.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* globals process */
import * as esbuild from "esbuild"
import postcss from "esbuild-postcss"

const devMode = process.argv.includes("watch")
const ctx = await esbuild.context({
entryPoints: ["./src/overrides.css", "./src/editor.js"],
entryPoints: ["./src/overrides.css", "./src/editor.mjs"],
minify: true,
bundle: true,
target: "es6",
Expand Down
17 changes: 17 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import globals from "globals";
import pluginJs from "@eslint/js";


export default [
{files: ["**/*.js"], languageOptions: {sourceType: "script"}},
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
{
rules: {
"no-unused-vars": [
"error",
{argsIgnorePattern: "^_", varsIgnorePattern: "^_"}
]
},
},
];
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
"prosemirror-schema-list": "^1.4.1",
"prosemirror-state": "^1.4.3",
"prosemirror-transform": "^1.10.0",
"prosemirror-view": "^1.34.2"
"prosemirror-view": "^1.34.2",
"@eslint/js": "^9.10.0",
"eslint": "^9.10.0",
"globals": "^15.9.0"
},
"scripts": {
"dev": "node esbuild.mjs watch",
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/commands.js → src/commands.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getMarkRange } from "./extendMarkRange.js"
import { getHTML, parseHTML, trimmedRangeFromSelection } from "./utils.js"
import { getMarkRange } from "./extendMarkRange.mjs"
import { getHTML, parseHTML, trimmedRangeFromSelection } from "./utils.mjs"

const linkDialog = (attrs) => {
const { messages } = window.DjangoProseEditor
Expand Down
8 changes: 6 additions & 2 deletions src/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,14 @@ label:empty:has(+ .prose-editor) {

.prose-editor-nbsp {
background: var(--_t);
box-shadow: 0 2px 0 0 var(--_t), 0 -2px 0 0 var(--_t);
box-shadow:
0 2px 0 0 var(--_t),
0 -2px 0 0 var(--_t);
}

.prose-editor-shy {
background: var(--_t);
box-shadow: 0 2px 0 1px var(--_t), 0 -2px 0 1px var(--_t);
box-shadow:
0 2px 0 1px var(--_t),
0 -2px 0 1px var(--_t);
}
12 changes: 6 additions & 6 deletions src/editor.js → src/editor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { addListNodes } from "prosemirror-schema-list"
import { EditorState } from "prosemirror-state"
import { EditorView } from "prosemirror-view"

import { buildKeymap, applyMarksKeymap } from "./keymap.js"
import { buildKeymap, applyMarksKeymap } from "./keymap.mjs"
import {
menuPlugin,
blockTypeMenuItems,
Expand All @@ -22,10 +22,10 @@ import {
historyMenuItems,
markMenuItems,
htmlMenuItem,
} from "./menu.js"
import { noSpellCheck } from "./nospellcheck.js"
import { typographicPlugin } from "./typographic.js"
import { crel, createDebouncedBackWriter, parseHTML } from "./utils.js"
} from "./menu.mjs"
import { noSpellCheck } from "./nospellcheck.mjs"
import { typographicPlugin } from "./typographic.mjs"
import { crel, createDebouncedBackWriter, parseHTML } from "./utils.mjs"

const underlineDOM = ["u", 0]
const strikethroughDOM = ["s", 0]
Expand Down Expand Up @@ -146,7 +146,7 @@ export function createEditor(textarea, config) {
editor.before(textarea)
try {
editorViewInstance.destroy()
} catch (_err) {
} finally {
/* Intentionally left empty */
}
editor.remove()
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/keymap.js → src/keymap.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
sinkListItem,
} from "prosemirror-schema-list"

import { addLink } from "./commands.js"
import { addLink } from "./commands.mjs"

const mac =
typeof navigator !== "undefined"
Expand Down
4 changes: 2 additions & 2 deletions src/menu.js → src/menu.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
removeLink,
updateHTML,
insertHorizontalRule,
} from "./commands.js"
import { crel, markActive } from "./utils.js"
} from "./commands.mjs"
import { crel, markActive } from "./utils.mjs"

export function menuPlugin(items) {
return new Plugin({
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion src/typographic.js → src/typographic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const typographicDecorationsForNode = (node, position) => {
const decorations = []
if (node.text) {
for (const match of node.text.matchAll(/(\u00A0|\u00AD)/g)) {
const array = Array.from(match)
const from = position + (match.index || 0)
decorations.push(
Decoration.inline(from, from + 1, {
Expand Down
File renamed without changes.
Loading

0 comments on commit b9e9ef4

Please sign in to comment.