Skip to content

Commit

Permalink
Make biome slightly happier
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Sep 23, 2024
1 parent 6afb254 commit 319a49f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ repos:
- id: django-upgrade
args: [--target-version, "3.2"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.4"
rev: "v0.6.7"
hooks:
- id: ruff
args: [--unsafe-fixes]
- id: ruff-format
- repo: https://github.com/biomejs/pre-commit
rev: "v0.4.0"
rev: "v0.5.0"
hooks:
- id: biome-check
additional_dependencies: ["@biomejs/biome@1.8.3"]
additional_dependencies: ["@biomejs/biome@1.9.2"]
args: [--unsafe]
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.2.3
rev: 2.2.4
hooks:
- id: pyproject-fmt
- repo: https://github.com/abravalheri/validate-pyproject
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"organizeImports": {
"enabled": false
},
Expand Down
39 changes: 18 additions & 21 deletions content_editor/static/content_editor/content_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,16 @@
const select = document.createElement("select")
let idx = 0

if (title) select.options[idx++] = new Option(title, "", true)
if (title) {
select.options[idx++] = new Option(title, "", true)
}

for (let i = 0; i < contents.length; i++) {
for (const content of contents) {
// Option _values_ may either be the prefix (for plugins) or keys (for
// regions)
select.options[idx++] = new Option(
contents[i].title,
contents[i].prefix || contents[i].key,
content.title,
content.prefix || content.key,
)
}
return select
Expand Down Expand Up @@ -489,17 +491,14 @@
// Filter allowed regions
const inlineType = getInlineType($inline)
const regions = []
for (let i = 0; i < ContentEditor.regions.length; i++) {
for (const region of ContentEditor.regions) {
if (
(!inlineType ||
!pluginRegions[inlineType] ||
$.inArray(
ContentEditor.regions[i].key,
pluginRegions[inlineType],
) >= 0) &&
!/^_unknown_/.test(ContentEditor.regions[i].key)
$.inArray(region.key, pluginRegions[inlineType]) >= 0) &&
!/^_unknown_/.test(region.key)
) {
regions.push(ContentEditor.regions[i])
regions.push(region)
}
}

Expand Down Expand Up @@ -611,13 +610,11 @@
)
}

const pluginInlineGroups = (function selectPluginInlineGroups() {
const selector = []
for (let i = 0; i < ContentEditor.plugins.length; i++) {
selector.push(`#${ContentEditor.plugins[i].prefix}-group`)
}
return $(selector.join(", "))
})()
const pluginInlineGroups = $(
ContentEditor.plugins
.map((plugin) => `#${plugin.prefix}-group`)
.join(", "),
)

reorderInlines(pluginInlineGroups)
pluginInlineGroups.hide()
Expand Down Expand Up @@ -763,11 +760,11 @@
// Initialize tabs and currentRegion.
;(() => {
const tabContainer = $(".tabs.regions")
for (let i = 0; i < ContentEditor.regions.length; i++) {
for (const region of ContentEditor.regions) {
const t = document.createElement("h2")
t.className = "tab"
t.textContent = ContentEditor.regions[i].title
t.setAttribute("data-region", ContentEditor.regions[i].key)
t.textContent = region.title
t.setAttribute("data-region", region.key)
tabContainer.append(t)
}

Expand Down

0 comments on commit 319a49f

Please sign in to comment.