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.json delegates to plugin:drupal-contrib/recommended (extends Airbnb base + Prettier + import rules) and adds eslint-plugin-jsdoc for JSDoc quality enforcement. The non-standard filename (not .eslintrc.json) is intentional: the upstream gitlab_templates ESLint binary resolves plugins from core/node_modules/, which cannot reach the project's eslint-plugin-drupal-contrib. Auto-discovery of a project config would cause plugin resolution failures in CI. The eslint CI job is overridden to allow_failure: false (the upstream gitlab_templates default is allow_failure: true).
  • Prettier — .prettierrc.json with print-width 80, single quotes, trailing commas. Scope defined via .prettierignore.
  • markdownlint — .markdownlintrc.cjs with standard rules. Scope defined via .markdownlintignore.
  • cspell — .cspell.json with project dictionary .cspell-project-words.txt (Drupal ecosystem terms). Pinned in devDependencies for deterministic local runs. Ignore paths in .cspell.json match _CSPELL_IGNORE_PATHS in .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 --fix and prettier --write applied across JS, CSS, Markdown, and JSON files.
  • Remaining ESLint violations in patternkit_media_library JS resolved manually.
  • One eslint-disable-next-line added in js/postcss/drupalize/index.js for a jsdoc/require-returns-check false positive (nested @return tags 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 root yarn.lock is 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_example module JS modernization — Gulpfile.js has dead dependencies; atom index.js files use invalid JS patterns and deprecated browser APIs. Tracked separately.

Test plan

  • ddev eslint exits 0 (CI parity — uses Drupal core config)
  • ddev exec yarn eslint exits 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 --gitignore exits 0
  • GitLab CI pipeline passes on the branch (eslint, cspell, phpcs, phpstan, phpunit)
Edited by Stephen Lucero

Merge request reports

Loading
Loading