mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-11-23 21:02:09 +00:00
Streamline lint configuration
- Add lint using local installation of the Nu HTML Validator and some jq-based filtering of false positives - Move linter configs to directory, to de-clutter the repo
This commit is contained in:
parent
b5bf54ff45
commit
7a3aee1539
10 changed files with 36 additions and 80 deletions
|
@ -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
|
|
|
@ -1,4 +0,0 @@
|
||||||
public/
|
|
||||||
public_*/
|
|
||||||
hint-report/
|
|
||||||
themes/etch-custom/exampleSite
|
|
16
Makefile
16
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"
|
# compression gets slow for extreme levels like the old "70109"
|
||||||
ECT_LEVEL=9
|
ECT_LEVEL=9
|
||||||
|
|
||||||
|
VNU ?= vnu
|
||||||
|
|
||||||
.PHONY: hugo
|
.PHONY: hugo
|
||||||
hugo: clean
|
hugo: clean
|
||||||
hugo -b $(HUGO_BASEURL) $(HUGO_FLAGS)
|
hugo -b $(HUGO_BASEURL) $(HUGO_FLAGS)
|
||||||
|
@ -25,10 +27,10 @@ hugo: clean
|
||||||
# .hintrc-local for linting local files
|
# .hintrc-local for linting local files
|
||||||
# same as regular .hintrc but with a different connector.
|
# same as regular .hintrc but with a different connector.
|
||||||
.hintrc-local: .hintrc
|
.hintrc-local: .hintrc
|
||||||
jq --tab '.connector .name = "local" | del(.connector .options)' <.hintrc >.hintrc-local
|
jq --tab '.connector .name = "local" | del(.connector .options)' <linter-configs/hintrc >.hintrc-local
|
||||||
|
|
||||||
.hintrc-devserver: .hintrc
|
.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"' <linter-configs/hintrc >.hintrc-devserver
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
@ -36,8 +38,12 @@ clean:
|
||||||
|
|
||||||
.PHONY: lint-css
|
.PHONY: lint-css
|
||||||
lint-css:
|
lint-css:
|
||||||
pnpx stylelint --di --rd --rdd $(CSS_DIR)/main.css $(CSS_DIR)/dark.css $(CSS_DIR)/print.css
|
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)
|
@#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
|
.PHONY: hint
|
||||||
hint: hugo .hintrc-local
|
hint: hugo .hintrc-local
|
||||||
|
@ -45,7 +51,7 @@ hint: hugo .hintrc-local
|
||||||
rm .hintrc-local
|
rm .hintrc-local
|
||||||
|
|
||||||
.PHONY: lint-local
|
.PHONY: lint-local
|
||||||
lint-local: lint-css hint
|
lint-local: lint-css lint-html
|
||||||
|
|
||||||
# dev server
|
# dev server
|
||||||
.PHONY: serve
|
.PHONY: serve
|
||||||
|
|
|
@ -6,14 +6,14 @@ SCHEME=https://
|
||||||
URL = $(SCHEME)$(DOMAIN)$(PAGE_PATH)
|
URL = $(SCHEME)$(DOMAIN)$(PAGE_PATH)
|
||||||
# latest bleeding-edge chromium snapshot
|
# latest bleeding-edge chromium snapshot
|
||||||
CHROME_PATH = /home/rkumar/Downloads/chromium/thorium/latest/chrome
|
CHROME_PATH = /home/rkumar/Downloads/chromium/thorium/latest/chrome
|
||||||
CHROME_PROFILE = /tmp/chrome-lighthouse
|
CHROME_PROFILE ?= /tmp/chrome-lighthouse
|
||||||
JS_FLAGS=''
|
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
|
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.9
|
CPU_SLOWDOWN=2.8
|
||||||
LIGHTHOUSE_ARGS += --budget-path budget.json --output html --output json --output-file lighthouse-results --throttling.cpuSlowdownMultiplier=$(CPU_SLOWDOWN) --chrome-flags="$(CHROME_FLAGS)"
|
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:
|
hint-online:
|
||||||
pnpx hint --config .hintrc -f codeframe $(URL)
|
hint --config linter-configs/hintrc -f codeframe $(URL)
|
||||||
lighthouse:
|
lighthouse:
|
||||||
mkdir -p $(CHROME_PROFILE)
|
mkdir -p $(CHROME_PROFILE)
|
||||||
CHROME_PATH=$(CHROME_PATH) CHROME_PROFILE=$(CHROME_PROFILE) JS_FLAGS='' lighthouse $(URL) $(LIGHTHOUSE_ARGS)
|
CHROME_PATH=$(CHROME_PATH) CHROME_PROFILE=$(CHROME_PROFILE) JS_FLAGS='' lighthouse $(URL) $(LIGHTHOUSE_ARGS)
|
||||||
|
|
19
linter-configs/vnu_filter.jq
Normal file
19
linter-configs/vnu_filter.jq
Normal file
|
@ -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
|
||||||
|
)
|
||||||
|
)
|
Loading…
Reference in a new issue