chore(lint): modernize and unify linting configuration#6004
chore(lint): modernize and unify linting configuration#6004caseyisonit wants to merge 71 commits intomainfrom
Conversation
This reverts commit 6c95b04.
…om/adobe/spectrum-web-components into caseyisonit/typescript-exploration
- Add ESLint 9.x and related plugins to root package.json - Remove ESLint dependencies from 1st-gen/package.json - Remove ESLint dependencies from 2nd-gen/package.json - Remove ESLint dependencies from example-project-rollup - All linting dependencies now managed at root level
- Add eslint-plugin-mdx for linting .md and .mdx files - Remove CONTRIBUTOR-DOCS from ESLint ignore list - Disable code block linting (docs contain partial code snippets) - Update research doc with markdown/MDX linting recommendations - Align css-custom-vars-viewer with root typescript-eslint version
- Add eslint-plugin-lit@2.1.1 with 15 rules for Lit template validation - Add eslint-plugin-wc@3.0.1 with 9 rules for Web Component correctness - Add documented browser globals for DOM, events, observers, network APIs - Remove unused eslint-formatter-pretty dependency - Pin all ESLint dependencies to exact versions (no carets) - Update all packages to latest stable versions: - @eslint/js: 9.39.2 - @typescript-eslint/*: 8.54.0 - eslint: 9.39.2 - eslint-config-prettier: 10.1.8 - eslint-plugin-jsonc: 2.21.0 - eslint-plugin-lit-a11y: 4.1.4 - eslint-plugin-mdx: 3.6.2 - eslint-plugin-simple-import-sort: 12.1.1 - eslint-plugin-storybook: 10.2.1 - jsonc-eslint-parser: 2.4.2
- Add eslint-plugin-jsdoc@62.5.0 with minimal rule set - Configure custom tags for Custom Elements Manifest (CEM): @element, @slot, @csspart, @cssproperty, @fires, @attr, @Attribute, @internal - Add additional browser globals for HTML element types: HTMLSlotElement, HTMLInputElement, HTMLButtonElement, etc. - Rules focus on consistency, not requiring docs everywhere: - check-alignment (error): Consistent asterisk alignment - check-indentation (warn): Consistent description indentation - check-param-names (error): Param names match function signature - check-tag-names (error): Only valid JSDoc/CEM tags - check-types (warn): Prefer lowercase primitives - require-param-description (warn): Encourage param descriptions - require-returns-description (warn): Encourage return descriptions - valid-types (warn): Valid type expressions
There was a problem hiding this comment.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
stylelint
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "display" to come before "border-radius"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "grid-template-columns" to come before "gap"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "display" to come before "align-items"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "display" to come before "border-left"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "padding" to come before "overflow"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "container-type" to come before "border-radius"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "display" to come before "container-type"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "width" to come before "height"
🚫 [stylelint] <selector-pseudo-element-colon-notation> reported by reviewdog 🐶
Expected double colon pseudo-element notation
🚫 [stylelint] <selector-pseudo-element-colon-notation> reported by reviewdog 🐶
Expected double colon pseudo-element notation
🚫 [stylelint] <selector-pseudo-element-colon-notation> reported by reviewdog 🐶
Expected double colon pseudo-element notation
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "margin" to come before "font-style"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "font-family" to come before "color"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "line-height" to come before "letter-spacing"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "margin-block-end" to come before "line-height"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "margin-block-start" to come before "margin-block-end"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "color" to come before "background-color"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "font-family" to come before "color"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "margin" to come before "font-style"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "color" to come before "background-color"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "-webkit-tap-highlight-color" to come before "color"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected an empty line before property "-webkit-tap-highlight-color"
🚫 [stylelint] <order/properties-order> reported by reviewdog 🐶
Expected "font-family" to come before "background-color"
Description
Modernizes the repository's linting infrastructure by upgrading to ESLint 9 with flat config, centralizing all linting at the root, and adding unified commands for checking and fixing code across the entire codebase.
The RFC is stored temporarily in the style-guide in contributor docs: CONTRIBUTOR-DOCS/02_style-guide/temp_linting-RFC.md. It will be removed before merge and provides the context and reasoning for the changes. Start there for full background. This PR includes minor linting fixes in the Badge component across all systems as examples. A follow-up PR will apply linting to the entire repo (possibly phased in multiple PRs merged in sequence).
Motivation and context
The existing linting setup had several pain points:
.eslintrcformat (deprecated in ESLint 9)This PR addresses these by consolidating all linting at the root with a single configuration per tool (
eslint.config.js,stylelint.config.js,.prettierrc.yaml), so behavior is consistent wherever linting is run.Related issue(s)
Summary of changes
ESLint modernization
eslint.config.js)eslint-plugin-lit,eslint-plugin-wc,eslint-plugin-jsdoc,eslint-plugin-mdx,eslint-plugin-jsonc,eslint-plugin-notice@spectrum-web-components/eslint-pluginrules; header enforced viaeslint-plugin-noticewithlinters/HEADER.jsStylelint enhancements
stylelint.config.js(ES module) withstylelint-config-standard,stylelint-order, and custom@spectrum-web-components/stylelint-header-plugin(swc/header) for CSSorder/properties-orderandlinters/stylelint-property-order.js(recess-order style), enforced as errors (not alphabetical)stylelint-declaration-strict-valueas warning for design token enforcement1st-gen/**/*.cssUnified commands
yarn lintyarn formatyarn lint:eslintyarn lint:1st-genyarn lint:2nd-genyarn lint:stylesyarn lint:prettieryarn format:eslintyarn format:stylesyarn format:prettierPre-commit and CI
lint-staged.config.js): ESLint and Stylelint with--fix, Prettier;lit-analyzerfor staged 1st-gen package source; package.json version generation,yarn constraints --fix, lockfile refresh;.changeset/*.mdescape scriptDocumentation
Follow-up work
yarn formatacross the repo to fix pre-existing lint errors (separate PR, possibly phased)clickEventsAllowListineslint.config.jsforlit-a11yas neededAuthor's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Verify
yarn lintruns ESLint, Stylelint, and Prettieryarn lintfrom the repo rootVerify
yarn formatfixes issues across all toolsyarn formatfrom the repo rootVerify lint-staged runs on commit
.tsor.cssfile with a fixable issuegit commitVerify CI runs Prettier check
Device review