Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/uv-pre-commit
rev: "0.11.7"
rev: "0.12.16"
hooks:
- id: uv-export
name: uv-export requirements/prod.txt
Expand Down Expand Up @@ -46,7 +46,7 @@ repos:
- id: django-upgrade

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.15.11"
rev: "v0.16.8"
hooks:
# Run the linter.
- id: ruff-check
Expand All @@ -72,10 +72,9 @@ repos:
types_or: [html, css]

- repo: https://github.com/biomejs/pre-commit
rev: "v2.4.12"
rev: "v2.5.13"
hooks:
- id: biome-check
additional_dependencies: ["@biomejs/biome@1.9.4"]

- repo: https://github.com/awebdeveloper/pre-commit-stylelint
rev: "0.0.2"
Expand All @@ -93,6 +92,6 @@ repos:
- id: gitleaks

- repo: https://github.com/crate-ci/typos
rev: v1.45.1
rev: v1.50.2
hooks:
- id: typos
90 changes: 21 additions & 69 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"$schema": "https://biomejs.dev/schemas/2.5.13/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
Expand All @@ -8,91 +8,43 @@
},
"files": {
"ignoreUnknown": true,
"ignore": [
"**/*.min.js",
"**/javascript/esm/**",
"**/javascript/vendor/**",
"public/**",
"site.webmanifest",
"**/settings.local.json"
"includes": [
"**",
"!**/*.min.js",
"!**/*.html",
"!**/static_src/images",
"!**/static_src/tailwind",
"!**/javascript/esm",
"!**/javascript/vendor",
"!**/public",
"!**/site.webmanifest",
"!**/settings.local.json"
]
},
"formatter": {
"enabled": true,
"useEditorconfig": true,
"indentStyle": "space"
},
"organizeImports": { "enabled": true },
"assist": { "actions": { "source": { "organizeImports": "on" } } },
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"preset": "recommended",
"complexity": {
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noUselessLoneBlockStatements": "error",
"noUselessUndefinedInitialization": "error",
"noWith": "error"
"noImportantStyles": "off",
"useArrowFunction": "off",
"useOptionalChain": "off"
},
"correctness": {
"noConstAssign": "error",
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInvalidBuiltinInstantiation": "error",
"noInvalidConstructorSuper": "error",
"noNonoctalDecimalEscape": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedLabels": "error",
"noUnusedPrivateClassMembers": "error",
"useArrayLiterals": "error",
"useIsNan": "error",
"useValidForDirection": "error",
"useYield": "error"
"noInnerDeclarations": "off"
},
"security": { "noGlobalEval": "error" },
"style": {
"noCommaOperator": "error",
"noYodaExpression": "error",
"useBlockStatements": "off",
"useConsistentBuiltinInstantiation": "error",
"useSingleVarDeclarator": "error"
"useTemplate": "off",
"useConst": "off"
},
"suspicious": {
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCompareNegZero": "error",
"noControlCharactersInRegex": "error",
"noDebugger": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noLabelVar": "error",
"noMisleadingCharacterClass": "error",
"noPrototypeBuiltins": "error",
"noRedeclare": "error",
"noShadowRestrictedNames": "error",
"noSparseArray": "error",
"noUnsafeNegation": "error",
"useGetterReturn": "error",
"useValidTypeof": "error"
"useIterableCallbackReturn": "off"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions docs/references/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def make_email_object(self, to: str | List[str], context, **kwargs):
if not isinstance(to, (list, tuple)):
to = [to]

lang = context.get('lang', None) or settings.LANGUAGE_CODE
lang = context.get("lang", None) or settings.LANGUAGE_CODE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you manually add this or should we manually exclude *.md\docs? could get messy if it's trying to lint markdown/python/bash in the docs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excluding the docs sounds like a good approach. As you say, this could get messy.


with language(lang):
rendered_template = self._render_template(context)
Expand All @@ -58,7 +58,7 @@ def make_email_object(self, to: str | List[str], context, **kwargs):

email = EmailMultiAlternatives(**kwargs)
email.body = body_txt
email.attach_alternative(body_html, 'text/html')
email.attach_alternative(body_html, "text/html")

email.to = to

Expand Down
2 changes: 0 additions & 2 deletions hypha/addressfield/static/addressfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* Licensed under the MIT license.
*/
(() => {
"use strict";

// WeakMap for per-element value storage during select↔input conversion.
const savedValues = new WeakMap();

Expand Down
4 changes: 1 addition & 3 deletions hypha/static_src/javascript/batch-actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
(function () {
"use strict";

const checkboxes = document.querySelectorAll(".js-batch-select");
const allCheckboxInputs = document.querySelectorAll(".js-batch-select-all");
const batchButtons = document.querySelectorAll("[data-js-batch-actions]");
Expand Down Expand Up @@ -93,7 +91,7 @@
let newActions;
try {
newActions = JSON.parse(actionsEl.dataset.actions);
} catch (e) {
} catch (_e) {
newActions = [];
}
if (!actions) {
Expand Down
2 changes: 1 addition & 1 deletion hypha/static_src/javascript/behaviours/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// Read the max height from the data-js-collapse attribute
// If the attribute is not set, use the default value
const content_max_height =
parseInt(el.getAttribute("data-js-collapse-height")) || 320;
parseInt(el.getAttribute("data-js-collapse-height"), 10) || 320;

// If the content height is less than or equal to the max height, do nothing
if (content_height <= content_max_height) {
Expand Down
4 changes: 2 additions & 2 deletions hypha/static_src/javascript/behaviours/review-score.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ document.addEventListener("alpine:init", () => {
*/
calculateScore() {
const validValues = [...this.selectors]
.map((selector) => parseInt(selector.value))
.filter((value) => !isNaN(value) && value !== 99);
.map((selector) => parseInt(selector.value, 10))
.filter((value) => !Number.isNaN(value) && value !== 99);

this.totalScore = validValues.reduce((sum, value) => sum + value, 0);
},
Expand Down
6 changes: 3 additions & 3 deletions hypha/static_src/javascript/determination-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

let DeterminationCopy = class {
static selector() {
return "#id_" + field_blocks_ids["determination"];
return "#id_" + field_blocks_ids.determination;
}

constructor(node) {
Expand Down Expand Up @@ -55,7 +55,7 @@

updateTextArea(text) {
this.message_box = document.querySelector(
"#id_" + field_blocks_ids["message"] + "_ifr"
"#id_" + field_blocks_ids.message + "_ifr"
);
this.message_box.contentDocument.getElementsByTagName(
"body"
Expand All @@ -66,7 +66,7 @@
document.querySelectorAll(DeterminationCopy.selector()).forEach((el) => {
new DeterminationCopy(el);
});
window.addEventListener("load", function (event) {
window.addEventListener("load", function () {
const proposal_form_field = document.querySelector("#id_proposal_form");
if (proposal_form_field && !proposal_form_field.value) {
proposal_form_field.disabled = true;
Expand Down
2 changes: 0 additions & 2 deletions hypha/static_src/javascript/form-group-toggle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
(function () {
"use strict";

/**
* Wrap all elements matching a selector into a single wrapper div.
* Similar to jQuery's wrapAll.
Expand Down
3 changes: 2 additions & 1 deletion hypha/static_src/javascript/multi-input-fields-alpine.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ document.addEventListener("alpine:init", () => {
});
});

// biome-ignore lint/correctness/noUnusedVariables: used in html attribute
function multiInputField(fieldId, fieldName, maxIndex) {
return {
fieldId: fieldId,
fieldIndex: parseInt(fieldName.split("_").pop()),
fieldIndex: parseInt(fieldName.split("_").pop(), 10),
maxIndex: maxIndex,

initField() {
Expand Down
2 changes: 0 additions & 2 deletions hypha/static_src/javascript/submission-form-copy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
(function () {
"use strict";

/**
* Strip HTML tags from a string and return plain text.
* @param {string} html
Expand Down
1 change: 0 additions & 1 deletion hypha/templates/includes/_toast-placeholder.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<!-- Toast layer -->
<script>
function toastHandler() {
"use strict";
const AUTO_HIDE_TIMEOUT = 3000;
return {
toasts: [],
Expand Down
Loading
Loading