From 4b7ec75caad9d9f8ede023f361afecfbbea6b375 Mon Sep 17 00:00:00 2001 From: Matthias Kestenholz Date: Thu, 12 Sep 2024 14:33:16 +0200 Subject: [PATCH] Back to biome, now with an actually good configuration --- .pre-commit-config.yaml | 21 +++----- biome.json | 57 +++++++++++++++++++++ eslint.config.mjs | 17 ------ feincms3/inline_ckeditor.py | 3 -- feincms3/static/feincms3/inline-ckeditor.js | 9 ++-- package.json | 8 --- 6 files changed, 68 insertions(+), 47 deletions(-) create mode 100644 biome.json delete mode 100644 eslint.config.mjs delete mode 100644 package.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5d20e0d..94c6bcd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,6 +24,12 @@ repos: - id: ruff args: [--unsafe-fixes] - id: ruff-format + - repo: https://github.com/biomejs/pre-commit + rev: "v0.4.0" + hooks: + - id: biome-check + additional_dependencies: ["@biomejs/biome@1.8.3"] + args: [--unsafe] - repo: https://github.com/tox-dev/pyproject-fmt rev: 2.2.3 hooks: @@ -32,18 +38,3 @@ repos: rev: v0.19 hooks: - id: validate-pyproject - - repo: local - hooks: - - id: prettier - name: prettier - entry: npx prettier@3.3.3 --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 diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..03bf2a0 --- /dev/null +++ b/biome.json @@ -0,0 +1,57 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + "organizeImports": { + "enabled": false + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 2 + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "a11y": { + "noSvgWithoutTitle": "off" + }, + "correctness": { + "noUndeclaredVariables": "error", + "noUnusedImports": "error", + "noUnusedVariables": "error", + "useArrayLiterals": "error", + "useHookAtTopLevel": "error" + }, + "security": { + "noDangerouslySetInnerHtml": "warn" + }, + "style": { + "noParameterAssign": "off", + "useForOf": "warn" + }, + "suspicious": { + "noArrayIndexKey": "warn", + "noAssignInExpressions": "off" + } + } + }, + "javascript": { + "formatter": { + "semicolons": "asNeeded" + }, + "globals": ["django", "CKEDITOR"] + }, + "css": { + "formatter": { + "enabled": true + }, + "linter": { + "enabled": true + } + }, + "json": { + "formatter": { + "enabled": false + } + } +} diff --git a/eslint.config.mjs b/eslint.config.mjs deleted file mode 100644 index 5b0c2b8..0000000 --- a/eslint.config.mjs +++ /dev/null @@ -1,17 +0,0 @@ -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: "^_"} - ] - }, - }, -]; diff --git a/feincms3/inline_ckeditor.py b/feincms3/inline_ckeditor.py index 4eccd82..691bd1f 100644 --- a/feincms3/inline_ckeditor.py +++ b/feincms3/inline_ckeditor.py @@ -1,6 +1,5 @@ import json -import django from django import forms from django.conf import settings from django.core.checks import Warning @@ -160,8 +159,6 @@ def __init__(self, *args, **kwargs): attrs = kwargs.setdefault("attrs", {}) attrs["data-inline-cke"] = id(self.config) - if django.VERSION < (4, 2): - attrs["data-inline-cke-dj41"] = True super().__init__(*args, **kwargs) @property diff --git a/feincms3/static/feincms3/inline-ckeditor.js b/feincms3/static/feincms3/inline-ckeditor.js index 0f035e7..d1c9e90 100644 --- a/feincms3/static/feincms3/inline-ckeditor.js +++ b/feincms3/static/feincms3/inline-ckeditor.js @@ -15,14 +15,15 @@ onReady(() => { const configs = {} const scripts = document.querySelectorAll("[data-inline-cke-config]") - scripts.forEach(function parseConfig(script) { + for (const script of scripts) { configs[script.dataset.inlineCkeId] = JSON.parse( script.dataset.inlineCkeConfig, ) - }) + } function initializeInlineCKE() { - document.querySelectorAll("textarea[data-inline-cke]").forEach((el) => { + const textareas = document.querySelectorAll("textarea[data-inline-cke]") + for (const el of textareas) { if ( el.dataset.inlineCke !== "active" && !el.id.includes("__prefix__") @@ -30,7 +31,7 @@ CKEDITOR.replace(el, configs[el.dataset.inlineCke]) el.dataset.inlineCke = "active" } - }) + } } function addFormsetAddedHandler() { diff --git a/package.json b/package.json deleted file mode 100644 index fbe1113..0000000 --- a/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type": "module", - "devDependencies": { - "@eslint/js": "^9.10.0", - "eslint": "^9.10.0", - "globals": "^15.9.0" - } -}