Add biome for js lint and formatting.

This commit is contained in:
Fredrik Jonsson 2024-12-20 14:53:04 +01:00
commit 089a0de6e0
3 changed files with 46 additions and 2 deletions

View file

@ -3,6 +3,7 @@
* A JavaScript file for analytic tracking.
*/
import * as params from '@params';
const cookiebanner = params.cookieConsent;
@ -12,6 +13,8 @@ const matomoTrackingApiUrl = 'https://' + params.piwikTrackerUrl + '/matomo.php'
const googleAnalytics = params.GoogleAnalytics;
if (idSite) {
// biome-ignore lint/style/useConst: Google code.
// biome-ignore lint/suspicious/noAssignInExpressions: Google code.
let _paq = window._paq = window._paq || [];
if (cookiebanner) {

41
biome.json Normal file
View file

@ -0,0 +1,41 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "main"
},
"files": {
"ignoreUnknown": true,
"include": ["assets/**/*.js"],
"ignore": ["**/*.min.js", "assets/libs/**/*.js"]
},
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noForEach": "off",
"useArrowFunction": "off"
},
"style": {
"useTemplate": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single"
},
"globals": ["define", "htmx", "jQuery", "Alpine"]
}
}

View file

@ -4,9 +4,9 @@
"description": "The node.js requirements to lint this project.",
"scripts": {
"lint-theme:css": "stylelint \"assets/sass/**/*.scss\"",
"lint-theme:js": "",
"lint-theme:js": "biome check",
"lint-project:css": "stylelint \"../../assets/sass/**/*.scss\"",
"lint-project:js": "",
"lint-project:js": "biome check \"../../assets/js/**/*.js\"",
"lint-theme": "npm run lint-theme:css && npm run lint-theme:js",
"lint-project": "npm run lint-project:css && npm run lint-project:js",
"lint:css": "npm run lint-theme:css && npm run lint-project:css",