Add prettier to format frontend

This commit is contained in:
Jake Howard 2022-06-12 19:35:06 +01:00
parent 27c0d64122
commit b521163007
Signed by: jake
GPG Key ID: 57AFB45680EDD477
6 changed files with 61 additions and 18 deletions

View File

@ -1,5 +1,3 @@
image: python:3.10-slim
stages: stages:
- build - build
- test - test
@ -41,6 +39,7 @@ pip:
expire_in: 30 mins expire_in: 30 mins
.python_test_template: &python_test_template .python_test_template: &python_test_template
image: python:3.10-slim
stage: test stage: test
dependencies: dependencies:
- pip - pip
@ -50,6 +49,12 @@ pip:
variables: variables:
SECRET_KEY: super-secret SECRET_KEY: super-secret
.node_test_template: &node_test_template
image: node:alpine
stage: test
dependencies:
- static
test_python: test_python:
<<: *python_test_template <<: *python_test_template
script: script:
@ -81,3 +86,8 @@ mypy:
<<: *python_test_template <<: *python_test_template
script: script:
- mypy website - mypy website
prettier:
<<: *node_test_template
script:
- npm run lint

View File

@ -30,9 +30,15 @@ test *ARGS:
format: format:
black website black website
isort website isort website
npm run format
lint: lint: lint_python lint_node
lint_python:
black --check website black --check website
isort --check website isort --check website
flake8 website flake8 website
mypy website mypy website
@lint_node:
npm run lint

22
package-lock.json generated
View File

@ -15,6 +15,7 @@
"devDependencies": { "devDependencies": {
"esbuild": "^0.14.43", "esbuild": "^0.14.43",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "2.6.2",
"sass": "^1.52.3" "sass": "^1.52.3"
} }
}, },
@ -1256,6 +1257,21 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/prettier": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.2.tgz",
"integrity": "sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/read-pkg": { "node_modules/read-pkg": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz",
@ -2377,6 +2393,12 @@
"integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==", "integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==",
"dev": true "dev": true
}, },
"prettier": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.6.2.tgz",
"integrity": "sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==",
"dev": true
},
"read-pkg": { "read-pkg": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz",

View File

@ -8,12 +8,15 @@
"build:js": "esbuild static/src/js/*.js --bundle --outdir=static/build/js --minify --sourcemap", "build:js": "esbuild static/src/js/*.js --bundle --outdir=static/build/js --minify --sourcemap",
"build:css": "sass --style=compressed --load-path=$PWD/node_modules static/src/scss:static/build/css", "build:css": "sass --style=compressed --load-path=$PWD/node_modules static/src/scss:static/build/css",
"build:contrib": "./scripts/copy-npm-contrib.sh", "build:contrib": "./scripts/copy-npm-contrib.sh",
"build": "npm-run-all build:*" "build": "npm-run-all build:*",
"lint": "prettier --check static/src",
"format": "prettier --write static/src"
}, },
"author": "Jake Howard", "author": "Jake Howard",
"devDependencies": { "devDependencies": {
"esbuild": "^0.14.43", "esbuild": "^0.14.43",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "2.6.2",
"sass": "^1.52.3" "sass": "^1.52.3"
}, },
"dependencies": { "dependencies": {

View File

@ -4,7 +4,7 @@ document.addEventListener("DOMContentLoaded", () => {
navbarBurger.addEventListener("click", () => { navbarBurger.addEventListener("click", () => {
console.log("click"); console.log("click");
navbarBurger.classList.toggle('is-active'); navbarBurger.classList.toggle("is-active");
navbar.classList.toggle('is-active'); navbar.classList.toggle("is-active");
}) });
}); });

View File

@ -1,11 +1,11 @@
import Darkmode from 'darkmode-js'; import Darkmode from "darkmode-js";
const DARKMODE_OPTIONS = { const DARKMODE_OPTIONS = {
left: '32px', left: "32px",
right: 'unset', right: "unset",
time: '0.7s', time: "0.7s",
saveInCookies: false, saveInCookies: false,
label: '🌓', label: "🌓",
}; };
window.addEventListener("load", () => { window.addEventListener("load", () => {
@ -15,9 +15,11 @@ window.addEventListener("load", () => {
}); });
// Also listen to native theme changes // Also listen to native theme changes
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", e => { window
if (e.matches !== window.darkmodejs.isActivated()) { .matchMedia("(prefers-color-scheme: dark)")
// HACK: .toggle doesn't work quite right .addEventListener("change", (e) => {
window.darkmodejs.button.click(); if (e.matches !== window.darkmodejs.isActivated()) {
} // HACK: .toggle doesn't work quite right
}); window.darkmodejs.button.click();
}
});