feat: Add linting toolchain (ESLint, Prettier, markdownlint, cspell) with CI enforcement
Summary
Establishes a complete, enforced linting baseline for JavaScript, Markdown, spelling, and general formatting across the Patternkit codebase.
What's added
- ESLint —
.eslintrc.contrib.jsondelegates toplugin:drupal-contrib/recommended(extends Airbnb base + Prettier + import rules) and addseslint-plugin-jsdocfor JSDoc quality enforcement. The non-standard filename (not.eslintrc.json) is intentional: the upstreamgitlab_templatesESLint binary resolves plugins fromcore/node_modules/, which cannot reach the project'seslint-plugin-drupal-contrib. Auto-discovery of a project config would cause plugin resolution failures in CI. TheeslintCI job is overridden toallow_failure: false(the upstreamgitlab_templatesdefault isallow_failure: true). - Prettier —
.prettierrc.jsonwith print-width 80, single quotes, trailing commas. Scope defined via.prettierignore. - markdownlint —
.markdownlintrc.cjswith standard rules. Scope defined via.markdownlintignore. - cspell —
.cspell.jsonwith project dictionary.cspell-project-words.txt(Drupal ecosystem terms). Pinned indevDependenciesfor deterministic local runs. Ignore paths in.cspell.jsonmatch_CSPELL_IGNORE_PATHSin.gitlab-ci.yml(vendored assets, lock files, compiled CSS).
Package management
Migrates from npm / npm-shrinkwrap.json to Yarn 4 as the authoritative
package manager. yarn.lock is now the canonical lockfile. CI uses
yarn install --frozen-lockfile (correct for the gitlab_templates CI image,
which runs Yarn 1 Classic — Corepack is not enabled there).
markdownlint-cli was missing from devDependencies despite being referenced
in package scripts; added as part of this work.
A yarn install --immutable post-start hook was added to .ddev/config.yaml
so JS dependencies are available automatically after every ddev start.
Baseline fixes
All existing files brought to passing state:
- Automated
eslint --fixandprettier --writeapplied across JS, CSS, Markdown, and JSON files. - Remaining ESLint violations in
patternkit_media_libraryJS resolved manually. - One
eslint-disable-next-lineadded injs/postcss/drupalize/index.jsfor ajsdoc/require-returns-checkfalse positive (nested@returntags documenting object shape, not multiple return paths). modules/patternkit_example/lib/patternkit/excluded from ESLint scope pending a future modernization of that module's JS toolchain.
Cleanup
Removed stale toolchain artifacts:
tslint.json— TSLint reached end-of-life in 2019; superseded by ESLint.modules/patternkit_media_library/npm-shrinkwrap.json— npm toolchain unused post-Yarn migration; the rootyarn.lockis now the single lockfile.
Submodule devDependencies and scripts consolidated to the root package.json.
Compliance
js/jsoneditor.js.LICENSE.txt added to version control. jsoneditor.min.js
contains a webpack banner that explicitly references this file for license
attribution of bundled MIT dependencies (JSON Editor 2.15.2, regenerator-runtime).
Distributing the minified asset without the license file would violate both
licenses.
Excluded from this MR
patternkit_examplemodule JS modernization — Gulpfile.js has dead dependencies; atomindex.jsfiles use invalid JS patterns and deprecated browser APIs. Tracked separately.
Test plan
-
ddev eslintexits 0 (CI parity — uses Drupal core config) -
ddev exec yarn eslintexits 0 (project config — stricter, editor parity) -
ddev exec yarn prettier --check .exits 0 -
ddev exec yarn markdownlint .exits 0 -
ddev exec yarn cspell '**' --no-progress --gitignoreexits 0 - GitLab CI pipeline passes on the branch (eslint, cspell, phpcs, phpstan, phpunit)