Add linting

This commit is contained in:
hedy 2024-04-13 14:44:22 +08:00
parent 3ea69c95c8
commit 1bb4339364
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
8 changed files with 5540 additions and 1 deletions

18
.config/htmlvalidate.json Normal file
View File

@ -0,0 +1,18 @@
{
"extends": ["html-validate:recommended"],
"rules": {
"doctype-style": ["off"],
"void-style": ["error", { "style": "selfclosing" }],
"valid-id": ["warn", { "relaxed": true}],
"no-autoplay": ["warn"],
"no-inline-style": ["warn", { "allowedProperties": [
"display",
"font-size",
"font-family",
"margin-bottom",
"margin-top",
"margin-left",
"margin-right"
] }]
}
}

1
.config/prettier.toml Normal file
View File

@ -0,0 +1 @@
bracketSameLine = false

6
.config/stylelint.json Normal file
View File

@ -0,0 +1,6 @@
{
"extends": "stylelint-config-recommended",
"rules": {
"no-descending-specificity": null
}
}

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
public/
resources/
.hugo_build.lock
tmp
node_modules
hint-report

View File

@ -21,6 +21,17 @@ DEPLOY_GEMINI_DIST=gemini.tar.gz
.DEFAULT_GOAL := all
lint-css:
pnpm exec stylelint --config .config/stylelint.json --rd --rdd assets/main.css
lint-html-validate:
pnpm exec html-validate --config .config/htmlvalidate.json $(HTML_DEST)
lint-html-proofer:
htmlproofer $(HTML_DEST) --checks Links,Images,Scripts,Favicon,OpenGraph --no-allow-missing-href --no-ignore-empty-alt
lint: lint-css lint-html-validate lint-html-proofer
deploy-html:
tar -C $(HTML_DEST) -cvz . > $(DEPLOY_HTML_DIST)
$(HUT) pages publish --protocol HTTPS -d $(DEPLOY_DOMAIN) $(DEPLOY_HTML_DIST)
@ -58,7 +69,7 @@ html:
$(RSYNC) $(RSYNC_FLAGS) public/ --exclude '*.gmi' --exclude gemini $(HTML_DEST)
@# Manually include gemini tag (because it was excluded above)
$(RSYNC) $(RSYNC_FLAGS) public/tags/gemini $(HTML_DEST)/tags/
$(PRETTIER) --write $(HTML_DEST)"/**/*.html"
$(PRETTIER) --config .config/prettier.toml --write $(HTML_DEST)"/**/*.html"
finish-clean:
rm -rf $(GEMINI_DEST)-back $(HTML_DEST)-back

View File

@ -45,6 +45,10 @@ css](https://simplecss.org) and sometimes [seirdy's site](https://seirdy.one).
### deploy
- **hut** - publishes HTML/gemini files to srht.site
### lint
- `pnpm` - install dev dependencies in `package.json`
- `ruby >= 2.7` - for `htmlproofer`
## hardcoded values
### resources

10
package.json Normal file
View File

@ -0,0 +1,10 @@
{
"devDependencies": {
"@hint/hint-doctype": "^3.3.20",
"hint": "^7.1.0",
"html-validate": "^8.18.1",
"stylelint": "^14.8.1",
"stylelint-config-recommended": "^7.0.0",
"stylelint-config-standard": "^25.0.0"
}
}

5486
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff