Skip to content

Commit 4e3af94

Browse files
authored
Release v0.2.2 - self-host JS lint + typecheck (#2)
* ci: self-host JS lint + typecheck The CI comment used to delegate ESLint + tsc to the consuming blog repo, which made sense when the blog vendored the theme as a submodule and could reach into assets/js/. Once consumers switch to Hugo Modules the theme's JS source no longer lives in their working tree, so the tooling has to live where the code lives. Brings eslint.config.mjs, a minimal package.json (eslint + typescript devDeps, lint/typecheck scripts), and a lint job that mirrors the blog workflow (setup-node, npm ci --ignore-scripts, eslint, tsc). * docs: add CHANGELOG entry for self-hosted JS lint * docs: stage v0.2.2 and strip guidance prose from [Unreleased] Introduces ## [0.2.2] under [Unreleased] with the self-hosted lint entry, so tagging v0.2.2 after merge publishes cleanly from the extracted section without a follow-up rename commit. Drops the contributor-facing instructional paragraph that was living inside [Unreleased]. Keep a Changelog doesn't put prose there; past released sections already demonstrate the ### Added / ### Changed shape, and changelog.yml emits its own failure message when a PR omits a required entry, so the guidance is over-documented for a repo this size. --------- Co-authored-by: Przemysław Szypowicz <2733699+pszypowicz@users.noreply.github.com>
1 parent 40bf977 commit 4e3af94

5 files changed

Lines changed: 1190 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ on:
99
permissions:
1010
contents: read
1111

12-
# The theme is consumed by the blog repo, which runs the full budget /
13-
# lint / typecheck matrix. This workflow is a lightweight sanity gate:
14-
# it confirms the theme still compiles against a representative site
15-
# (exampleSite/) so broken SCSS imports or template syntax errors are
16-
# caught before a blog-side submodule bump exposes them.
12+
# The theme owns its own lint + typecheck for the JS assets under
13+
# assets/js/, and builds exampleSite/ as a sanity gate so broken SCSS
14+
# imports or template syntax errors surface before downstream consumers
15+
# bump to a new version.
1716

1817
jobs:
1918
build:
@@ -38,3 +37,20 @@ jobs:
3837
- name: Build exampleSite
3938
working-directory: pager/exampleSite
4039
run: hugo --minify --gc --themesDir ../.. --destination public
40+
41+
lint:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
45+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
46+
with:
47+
node-version: '22'
48+
cache: npm
49+
- name: Install npm devDependencies
50+
# --ignore-scripts blocks postinstall hooks so a malicious
51+
# package-lock.json change cannot execute code during install.
52+
run: npm ci --include=dev --ignore-scripts
53+
- name: ESLint
54+
run: npm run lint
55+
- name: TypeScript check
56+
run: npm run typecheck

CHANGELOG.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
Add bullets here under `### Added`, `### Changed`, `### Fixed`, or `### Removed`
11-
when a PR modifies theme behavior. On release, rename this heading to the new
12-
version (dates are not tracked here; the git tag carries them), then push an
13-
annotated tag `vX.Y.Z`; `.github/workflows/release.yml` turns the extracted
14-
section into a GitHub Release body. Docs-only, CI-only, or meta-only PRs can
15-
bypass the PR-side check via the `skip-changelog` label or a `[skip changelog]`
16-
tag in the PR body; see `.github/workflows/changelog.yml`.
10+
## [0.2.2]
11+
12+
### Added
13+
14+
- Self-hosted ESLint and `tsc --checkJs` for `assets/js/`. The theme
15+
ships `package.json` (eslint + typescript devDeps, `lint` /
16+
`typecheck` scripts) and `eslint.config.mjs`, and `ci.yml` gains a
17+
`lint` job. Consumers on Hugo Modules (where the theme's JS source
18+
is not in the consumer tree) no longer need to re-host this tooling.
1719

1820
## [0.2.1]
1921

eslint.config.mjs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import js from "@eslint/js";
2+
3+
export default [
4+
{
5+
files: ["assets/js/**/*.js"],
6+
languageOptions: {
7+
ecmaVersion: 2020,
8+
sourceType: "module",
9+
globals: {
10+
// Browser globals used by debug scripts. Kept explicit instead
11+
// of pulling in eslint's `browser` env so additions to this list
12+
// stay visible in review.
13+
window: "readonly",
14+
document: "readonly",
15+
navigator: "readonly",
16+
location: "readonly",
17+
innerWidth: "readonly",
18+
innerHeight: "readonly",
19+
devicePixelRatio: "readonly",
20+
performance: "readonly",
21+
getComputedStyle: "readonly",
22+
console: "readonly",
23+
localStorage: "readonly",
24+
fetch: "readonly",
25+
setTimeout: "readonly",
26+
setInterval: "readonly",
27+
clearInterval: "readonly",
28+
addEventListener: "readonly",
29+
HTMLElement: "readonly",
30+
PerformanceNavigationTiming: "readonly",
31+
DOMParser: "readonly",
32+
},
33+
},
34+
rules: {
35+
...js.configs.recommended.rules,
36+
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
37+
"no-implicit-globals": "error",
38+
"no-var": "error",
39+
"prefer-const": "warn",
40+
eqeqeq: ["error", "smart"],
41+
},
42+
},
43+
];

0 commit comments

Comments
 (0)