Skip to content

Adopt eslint-plugin-unicorn alongside the rest of the sitespeed.io stack#176

Merged
soulgalore merged 1 commit into
mainfrom
add-unicorn
May 17, 2026
Merged

Adopt eslint-plugin-unicorn alongside the rest of the sitespeed.io stack#176
soulgalore merged 1 commit into
mainfrom
add-unicorn

Conversation

@soulgalore
Copy link
Copy Markdown
Member

Brings coach-core onto eslint-plugin-unicorn 64 — the same major
sitespeed.io is on — and migrates the eslint config from .cjs to .js
(ESM), which is what the plugin requires and what coach-core's already
ESM package implies anyway. The unicorn rule set surfaced 354 findings,
276 of them auto-fixable: a sweep through the codebase toward modern
array methods (for…of over .forEach, flatMap over map().flat(),
some over findIndex truthy checks), node-native helpers
(Number.parseInt, String.fromCodePoint, structuredClone, String#slice,
String#replaceAll, String.raw, includes), and tidier conditionals
(explicit length checks, no nested ternaries, no useless undefined).

The remaining hand-fixes are small. The wappalyzer engine moves its
priority arrow out of resolve() into a module-level helper; an
exec()-as-truthy check becomes a .test(); lib/index.js hoists
getFolders to module scope and stops chaining off an awaited stat()
call. A single inline disable lives in lib/dom/bestpractice/charset.js
because the page's document.characterSet returns the literal 'UTF-8'
and the unicorn rule would rewrite it to 'utf8' and silently break
detection.

The config disables the same six unicorn rules sitespeed.io disables,
plus three more that don't fit coach-core's situation: no-null
(the vendored wappalyzer engine deliberately uses null to match the
upstream data format), import-style (destructured node:* imports are
clearer than forcing default imports), and prefer-module scoped to
lib/dom/** (those files are not modules — they are IIFE fragments
that get concatenated into dist/coach.min.js and evaluated in the
browser via WebDriver executeScript).

Co-authored-by: Claude noreply@anthropic.com

  Brings coach-core onto eslint-plugin-unicorn 64 — the same major
  sitespeed.io is on — and migrates the eslint config from .cjs to .js
  (ESM), which is what the plugin requires and what coach-core's already
  ESM package implies anyway. The unicorn rule set surfaced 354 findings,
  276 of them auto-fixable: a sweep through the codebase toward modern
  array methods (for…of over .forEach, flatMap over map().flat(),
  some over findIndex truthy checks), node-native helpers
  (Number.parseInt, String.fromCodePoint, structuredClone, String#slice,
  String#replaceAll, String.raw, includes), and tidier conditionals
  (explicit length checks, no nested ternaries, no useless undefined).

  The remaining hand-fixes are small. The wappalyzer engine moves its
  priority arrow out of resolve() into a module-level helper; an
  exec()-as-truthy check becomes a .test(); lib/index.js hoists
  getFolders to module scope and stops chaining off an awaited stat()
  call. A single inline disable lives in lib/dom/bestpractice/charset.js
  because the page's document.characterSet returns the literal 'UTF-8'
  and the unicorn rule would rewrite it to 'utf8' and silently break
  detection.

  The config disables the same six unicorn rules sitespeed.io disables,
  plus three more that don't fit coach-core's situation: no-null
  (the vendored wappalyzer engine deliberately uses null to match the
  upstream data format), import-style (destructured node:* imports are
  clearer than forcing default imports), and prefer-module scoped to
  lib/dom/** (those files are not modules — they are IIFE fragments
  that get concatenated into dist/coach.min.js and evaluated in the
  browser via WebDriver executeScript).

  Co-authored-by: Claude noreply@anthropic.com
@soulgalore soulgalore merged commit 78bcc3b into main May 17, 2026
3 checks passed
@soulgalore soulgalore deleted the add-unicorn branch May 17, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant