diff --git a/.lighthouserc.yml b/.lighthouserc.yml deleted file mode 100644 index 3fbaa4b..0000000 --- a/.lighthouserc.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -ci: - assert: - preset: lighthouse:recommended - assertions: - performance-budget: "error" - render-blocking-resources: - - warn - # the CSS file. - # My site doesn't use JS so it doesn't use the recommended async hack - - maxLength: 1 - timing-budget: "off" # buggy; manually use the below assertions instead - # https://seirdy.one/2020/11/23/website-best-practices.html#about-lazy-loading - speed-index: - - warn - - maxNumericValue: 2000 - largest-contentful-paint: - - warn - - maxNumericValue: 2000 - first-contentful-paint: - - warn - - maxNumericValue: 2000 - first-meaningful-paint: - - warn - - maxNumericValue: 2000 - total-blocking-time: - - warn - - maxNumericValue: 0 - cumulative-layout-shift: - - warn - - maxNumericValue: 0 - canonical: "off" # staging site has no rel=canonical - service-worker: "off" # not a PWA - works-offline: "off" # not a PWA - installable-manifest: "off" # not a PWA - splash-screen: "off" # not a PWA - themed-omnibox: "off" # not a PWA - offline-start-url: "off" # not a pwa - offscreen-images: "off" # antipattern: see my article on best practices for textual websites - collect: - method: node - settings: - budgetPath: budget.json - chromeFlags: "--disable-gpu --no-sandbox --disable-extensions --no-first-run --headless" - skipAudits: - - canonical - - service-worker - - works-offline - - installable-manifest - - splash-screen - - themed-omnibox - - offline-start-url - - offscreen-images - throttling: - cpuSlowdownMultiplier: 1 - throttlingMethod: devtools - url: - - https://seirdy.one/ - - https://seirdy.one/about.html - - https://seirdy.one/2020/11/23/website-best-practices.html - numberOfRuns: 3 - upload: - outputDir: lighthouse-reports - reportFilenamePattern: lighthouse-report-%%PATHNAME%%.%%EXTENSION%% - target: filesystem diff --git a/.stylelintignore b/.stylelintignore deleted file mode 100644 index 4792b07..0000000 --- a/.stylelintignore +++ /dev/null @@ -1,4 +0,0 @@ -public/ -public_*/ -hint-report/ -themes/etch-custom/exampleSite diff --git a/Makefile b/Makefile index bb9a590..cc0ebed 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,8 @@ RSYNCFLAGS += --skip-compress=gz/br/zst/png/webp/jpg/avif/jxl/mp4/mkv/webm/opus/ # compression gets slow for extreme levels like the old "70109" ECT_LEVEL=9 +VNU ?= vnu + .PHONY: hugo hugo: clean hugo -b $(HUGO_BASEURL) $(HUGO_FLAGS) @@ -25,10 +27,10 @@ hugo: clean # .hintrc-local for linting local files # same as regular .hintrc but with a different connector. .hintrc-local: .hintrc - jq --tab '.connector .name = "local" | del(.connector .options)' <.hintrc >.hintrc-local + jq --tab '.connector .name = "local" | del(.connector .options)' .hintrc-local .hintrc-devserver: .hintrc - jq --tab '.extends = ["development"] | .hints["http-compression","https-only","ssllabs","sri"] = "off"' <.hintrc >.hintrc-devserver + jq --tab '.extends = ["development"] | .hints["http-compression","https-only","ssllabs","sri"] = "off"' .hintrc-devserver .PHONY: clean clean: @@ -36,8 +38,12 @@ clean: .PHONY: lint-css lint-css: - pnpx stylelint --di --rd --rdd $(CSS_DIR)/main.css $(CSS_DIR)/dark.css $(CSS_DIR)/print.css - csslint --quiet $(CSS_DIR) + pnpm -s dlx stylelint --config linter-configs/stylelintrc.json --di --rd --rdd $(CSS_DIR)/main.css $(CSS_DIR)/dark.css $(CSS_DIR)/print.css + @#csslint --quiet $(CSS_DIR) + +.PHONY: lint-html +lint-html: hugo + $(VNU) --stdout --format json --skip-non-html --also-check-svg public | jq --from-file linter-configs/vnu_filter.jq .PHONY: hint hint: hugo .hintrc-local @@ -45,7 +51,7 @@ hint: hugo .hintrc-local rm .hintrc-local .PHONY: lint-local -lint-local: lint-css hint +lint-local: lint-css lint-html # dev server .PHONY: serve @@ -79,7 +85,7 @@ endif mentions.json: hugo # gather old version of the site # rsync $(RSYNCFLAGS) --exclude '*.gz' --exclude '*.br' --exclude '*.png' --exclude-from .rsyncignore $(WWW_RSYNC_DEST)/ old - static-webmentions -f mentions.json.unfiltered find + static-webmentions -f mentions.json.unfiltered find # filter the webmentions a bit; jq offers more flexibility than config.toml jq '[ .[] | select(.Dest|test("https://(git.sr.ht/~seirdy/seirdy.one/log/master|seirdy.one|web.archive.org|archive.is|en.wikipedia.org|matrix.to|([a-z]*.)?reddit.com|github.com)") | not) ]' mentions.json rm mentions.json.unfiltered diff --git a/Makefile.online b/Makefile.online index acea491..74444e3 100644 --- a/Makefile.online +++ b/Makefile.online @@ -6,14 +6,14 @@ SCHEME=https:// URL = $(SCHEME)$(DOMAIN)$(PAGE_PATH) # latest bleeding-edge chromium snapshot CHROME_PATH = /home/rkumar/Downloads/chromium/thorium/latest/chrome -CHROME_PROFILE = /tmp/chrome-lighthouse +CHROME_PROFILE ?= /tmp/chrome-lighthouse JS_FLAGS='' -CHROME_FLAGS += --disable-extensions --no-default-browser-check --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-device-discovery-notifications --disable-domain-reliability --disable-background-timer-throttling --disable-breakpad --enable-blink-features=LayoutInstabilityAPI --no-first-run --disable-component-update --disable-background-networking --user-data-dir=$(CHROME_PROFILE) --enable-quic --origin-to-force-quic-on=seirdy.one:443 -CPU_SLOWDOWN=2.9 -LIGHTHOUSE_ARGS += --budget-path budget.json --output html --output json --output-file lighthouse-results --throttling.cpuSlowdownMultiplier=$(CPU_SLOWDOWN) --chrome-flags="$(CHROME_FLAGS)" +CHROME_FLAGS += --disable-extensions --no-default-browser-check --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-device-discovery-notifications --disable-domain-reliability --disable-background-timer-throttling --disable-breakpad --enable-blink-features=LayoutInstabilityAPI --no-first-run --disable-component-update --disable-background-networking --user-data-dir=$(CHROME_PROFILE) --enable-quic --origin-to-force-quic-on=$(DOMAIN):443 +CPU_SLOWDOWN=2.8 +LIGHTHOUSE_ARGS += --budget-path linter-configs/budget.json --output html --output json --output-file lighthouse-results --throttling.cpuSlowdownMultiplier=$(CPU_SLOWDOWN) --chrome-flags="$(CHROME_FLAGS)" hint-online: - pnpx hint --config .hintrc -f codeframe $(URL) + hint --config linter-configs/hintrc -f codeframe $(URL) lighthouse: mkdir -p $(CHROME_PROFILE) CHROME_PATH=$(CHROME_PATH) CHROME_PROFILE=$(CHROME_PROFILE) JS_FLAGS='' lighthouse $(URL) $(LIGHTHOUSE_ARGS) diff --git a/.browserslistrc b/linter-configs/browserslistrc similarity index 100% rename from .browserslistrc rename to linter-configs/browserslistrc diff --git a/budget.json b/linter-configs/budget.json similarity index 100% rename from budget.json rename to linter-configs/budget.json diff --git a/.hintrc b/linter-configs/hintrc similarity index 100% rename from .hintrc rename to linter-configs/hintrc diff --git a/lychee.toml b/linter-configs/lychee.toml similarity index 100% rename from lychee.toml rename to linter-configs/lychee.toml diff --git a/.stylelintrc.json b/linter-configs/stylelintrc.json similarity index 100% rename from .stylelintrc.json rename to linter-configs/stylelintrc.json diff --git a/linter-configs/vnu_filter.jq b/linter-configs/vnu_filter.jq new file mode 100644 index 0000000..f2defa2 --- /dev/null +++ b/linter-configs/vnu_filter.jq @@ -0,0 +1,19 @@ +# Filter false positives from the .messages entry of Nu Validator output +.messages |= map( + . | select( + .type == "error" and + ( + ( # See https://github.com/w3c/css-validator/issues/361 + .message == "CSS: Parse Error." + and .extract == "){outline:none}}:focus-visible" + and .hiliteLength == 1 + ) + or + ( # See https://github.com/validator/validator/issues/1166 + .message == "Attribute “media” not allowed on element “meta” at this point." + and .firstColumn == 1 + and (.extract | test(" name=\"theme-color\"")) + ) + ) | not + ) +)