Skip to content

Commit

Permalink
Back to biome
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Sep 13, 2024
1 parent c49cc19 commit 6afb254
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 59 deletions.
22 changes: 7 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ repos:
rev: "v0.6.4"
hooks:
- 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/[email protected]"]
args: [--unsafe]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.2.3
hooks:
Expand All @@ -31,18 +38,3 @@ repos:
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 content_editor
language: system
types_or: [javascript]
require_serial: true
verbose: true
57 changes: 57 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -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", "ContentEditor"]
},
"css": {
"formatter": {
"enabled": true
},
"linter": {
"enabled": true
}
},
"json": {
"formatter": {
"enabled": false
}
}
}
8 changes: 2 additions & 6 deletions content_editor/static/content_editor/content_editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ html {
border: 1px solid var(--hairline-color, #e8e8e8);
border-bottom: none;
user-select: none;
transition:
0.15s background,
0.15s color;
transition: 0.15s background, 0.15s color;
}

.tabs > .active {
Expand Down Expand Up @@ -97,9 +95,7 @@ html {
padding: 7px;
margin: 0;
background-color: var(--darkened-bg, #f8f8f8);
transition:
0.15s background,
0.15s color;
transition: 0.15s background, 0.15s color;

white-space: nowrap;
overflow: hidden;
Expand Down
28 changes: 15 additions & 13 deletions content_editor/static/content_editor/content_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
regionsByKey: Object.fromEntries(
ContentEditor.regions.map((region) => [region.key, region]),
),
hasSections: ContentEditor.plugins.some(
(plugin) => plugin.sections,
),
hasSections: ContentEditor.plugins.some((plugin) => plugin.sections),
})
}

Expand Down Expand Up @@ -248,7 +246,7 @@
inline.addEventListener("drop", (e) => {
if (window.__fs_dragging) {
e.preventDefault()
for (let inline of qsa(".order-machine .inline-related.selected")) {
for (const inline of qsa(".order-machine .inline-related.selected")) {
selectSection(inline)
}

Expand Down Expand Up @@ -319,7 +317,10 @@
div.style.right = "5px"
div.style.height = `${until.top - from.top + until.height + 10}px`

div.classList.toggle("content-editor-hide", fromInline.classList.contains("collapsed"))
div.classList.toggle(
"content-editor-hide",
fromInline.classList.contains("collapsed"),
)
}

for (const inline of inlines) {
Expand Down Expand Up @@ -719,7 +720,7 @@
}
})

$(document).on("formset:removed", (event, $row, formsetName) => {
$(document).on("formset:removed", (event, _$row, formsetName) => {
if (event.detail?.formsetName) {
// Django >= 4.1
handleFormsetRemoved(event.detail.formsetName)
Expand All @@ -738,9 +739,9 @@
}

function hideSection(inline, hide = true) {
const children = childrenMap && childrenMap.get(inline)
const children = childrenMap?.get(inline)
if (children) {
for (let child of children) {
for (const child of children) {
child.classList.toggle("content-editor-hide", hide)
if (hide || !child.classList.contains("collapsed")) {
/* Hiding is recursive, showing uncollapsed child sections too */
Expand All @@ -751,15 +752,14 @@
}

function selectSection(inline) {
const children = childrenMap && childrenMap.get(inline)
const children = childrenMap?.get(inline)
if (children) {
for (let child of children) {
for (const child of children) {
child.classList.add("selected")
selectSection(child)
}
}
}

// Initialize tabs and currentRegion.
;(() => {
const tabContainer = $(".tabs.regions")
Expand Down Expand Up @@ -790,7 +790,9 @@
function initializeCollapseAll() {
const collapseAllInput = $(".collapse-items input")
collapseAllInput.on("change", function () {
for (const inline of qsa(".order-machine .inline-related:not(.empty-form)")) {
for (const inline of qsa(
".order-machine .inline-related:not(.empty-form)",
)) {
collapseInline(inline, this.checked)
}
LS.set("collapseAll", this.checked)
Expand Down Expand Up @@ -891,7 +893,7 @@
scrollY: window.scrollY,
collapsed: qsa(
".order-machine .inline-related.collapsed:not(.empty-form) .field-ordering input",
).map((input) => input.value)
).map((input) => input.value),
})
}

Expand Down
17 changes: 0 additions & 17 deletions eslint.config.mjs

This file was deleted.

8 changes: 0 additions & 8 deletions package.json

This file was deleted.

0 comments on commit 6afb254

Please sign in to comment.