tasks: switch dashboard-pie-chart spec to inline eslint-disable-line for charts CSS import#36
Conversation
…for charts CSS import The CSS import itself is required — build comparison verified (PR #30 / PR #35 dogfood): without it the `.a8ccharts-* svg{display:block}` chart-layout rule is missing from the bundle, exposing the resize-loop class of bug the rule guards against. Keep the import. But the `eslint-disable-next-line` form (comment on the line above) doesn't survive this repo's tooling: * Prettier inserts a blank line between import groups → separates the comment from the import * Local ESLint auto-fix sees the comment as unused (charts package built locally → dist/index.css exists) → removes it * CI's lint job runs without the charts package built → import is unresolved AND the disable comment is gone → fail Switch to inline `eslint-disable-line` at the end of the import line. Prettier doesn't move trailing comments and ESLint won't auto-remove a comment that actually disables an active rule (the rule fires in CI where the file is unresolved). Adds a "Why the disable comment must be inline" section so future contributors understand why the cleaner-looking next-line form was rejected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@copilot review |
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
There was a problem hiding this comment.
Pull request overview
Updates the premium-analytics “dashboard-pie-chart” task spec to use an inline ESLint disable comment for the @automattic/charts/style.css import so it survives the repo’s prettier + ESLint auto-fix workflow, and documents why this is required.
Changes:
- Switch the spec’s CSS import example from
eslint-disable-next-lineto inlineeslint-disable-line. - Update and expand documentation explaining why the CSS import is required and why the disable comment must be inline.
- Add an internal tooling-only changelog entry for the spec update.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| projects/packages/premium-analytics/tasks/dashboard-pie-chart.md | Updates the import example and adds rationale for using inline eslint-disable-line. |
| projects/packages/premium-analytics/changelog/update-pie-chart-task-inline-eslint-disable | Internal changelog entry documenting the spec/tooling adjustment. |
| * Locally the charts package is usually built, so `dist/index.css` exists and ESLint's auto-fix sees the disable comment as "unused" and removes it. | ||
| * CI's lint job runs without the charts package built, so the import is unresolved — but the disable comment was already deleted locally and committed away, so CI fails. | ||
|
|
||
| The inline `disable-line` form has none of these failure modes: prettier doesn't move trailing comments, and ESLint won't auto-remove it because the rule it disables actually fires (in the CI environment where the file is unresolved). |
There was a problem hiding this comment.
Good catch — fixed in 0b867cb. The trailing paragraph now uses the full eslint-disable-line directive, matching every other reference in the spec.
Addresses Copilot review on PR #36: the trailing rationale paragraph used the shortened `disable-line`; everywhere else uses the full `eslint-disable-line`. Use the full directive name for consistency. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| Use `eslint-disable-line` on the same line as the import — **not** `eslint-disable-next-line` on the line above. The next-line form looks cleaner but doesn't survive this repo's lint/format toolchain end-to-end: | ||
|
|
||
| * Prettier (run by the pre-commit hook) inserts a blank line between import groups, which separates the next-line comment from the import it was annotating. | ||
| * Locally the charts package is usually built, so `dist/index.css` exists and ESLint's auto-fix sees the disable comment as "unused" and removes it. | ||
| * CI's lint job runs without the charts package built, so the import is unresolved — but the disable comment was already deleted locally and committed away, so CI fails. | ||
|
|
||
| The inline `eslint-disable-line` form has none of these failure modes: prettier doesn't move trailing comments, and ESLint won't auto-remove it because the rule it disables actually fires (in the CI environment where the file is unresolved). |
There was a problem hiding this comment.
Good catch — you're right, the Prettier attribution was wrong. Confirmed locally: .prettierrc.js only loads prettier-plugin-svelte (tools/js-tools/prettier-plugins.js), no import-organizing plugin. The real driver is ESLint import/order per tools/js-tools/eslintrc/base.mjs:318-325 enforcing 'newlines-between': 'never' + alphabetic ordering — that reorder detaches the next-line disable comment, then --fix removes the detached comment as unused (locally dist/index.css exists so the rule doesn't fire).
Rewrote the failure-chain bullets in 734fcf6 to describe the actual mechanism (ESLint reorders → comment detaches → --fix removes it → CI fails) instead of misattributing the cause to Prettier. The practical takeaway (use inline eslint-disable-line) is unchanged.
…ust be inline" Addresses Copilot review on PR #36: the prior wording blamed Prettier for inserting blank lines between import groups, but the repo's Prettier config only loads `prettier-plugin-svelte` — no import-organizing plugin. The real driver is ESLint's `import/order` rule (`tools/js-tools/eslintrc/base.mjs:318-325`) which enforces `'newlines-between': 'never'` and alphabetic ordering; that reordering plus `--fix` removing the now-detached "unused" disable comment is what produces the observed failure mode. Rewrite the failure-chain bullets to describe the actual mechanism (lint reorders → comment detaches → --fix removes it → CI fails) rather than misattributing the cause to Prettier. Practical recommendation (inline `eslint-disable-line`) is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| `import { __ } from '@wordpress/i18n';` line unchanged — do not re-add it. The | ||
| `eslint-disable-next-line` comment is required — see "Why the CSS import" below. | ||
| inline `eslint-disable-line` comment on the CSS import line is required — see | ||
| "Why the CSS import" below for the rationale, and "Why the disable comment must |
There was a problem hiding this comment.
Fixed in 01a9d88 — the Imports section now references the full heading "Why the CSS import is required" verbatim, matching the actual section title.
Addresses Copilot review on PR #36: the Imports section pointed to "Why the CSS import" but the actual heading later in the doc is "Why the CSS import is required". Match the full heading text so readers find the referenced section without ambiguity and future edits don't silently drift. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| * Once the comment is no longer immediately above the unresolved import, ESLint's `--fix` sees the comment as "unused" — locally the `@automattic/charts/dist/index.css` file exists (charts package is built), so the `import/no-unresolved` rule doesn't fire there, and the disable comment gets removed. | ||
| * On CI the lint job runs without the charts package built. The import is unresolved, but the disable comment was already deleted locally in the previous step and committed away — so CI lint fails. | ||
|
|
||
| The inline `eslint-disable-line` form has none of these failure modes: trailing comments don't move during import reordering, and ESLint won't auto-remove a comment whose target rule actually fires (in CI where the file is genuinely unresolved). |
There was a problem hiding this comment.
You're right, my second iteration still encoded an unverified mechanism. Confirmed: pnpm run lint-file is just eslint --flag v10_config_lookup_from_file with no --report-unused-disable-directives, and reportUnusedDisableDirectives doesn't appear in the ESLint configs.
Fixed in 7788e43. The failure-chain bullets now describe the observed outcome (pre-commit reorders imports → disable comment ends up missing from the committed file → CI lint fails on import/no-unresolved) and explicitly note we haven't reverse-engineered which rule/interaction drops the comment. The practical fix (inline eslint-disable-line) and the reason it works are unchanged; the spec just no longer makes claims about internal lint behavior it can't substantiate.
Good discipline catch — the spec is doc-as-source-of-truth for future agent runs, encoding a wrong mechanism would propagate.
…ionale Addresses Copilot review on PR #36: prior wording asserted ESLint --fix removes the detached disable comment as "unused", but `pnpm run lint-file --fix` doesn't set `--report-unused-disable-directives` and no `reportUnusedDisableDirectives` setting is present in the repo's ESLint configs. The exact rule interaction that drops the comment isn't pinned down by available config evidence. Rewrite the failure-chain to describe the observed outcome ("pre-commit reorders imports → disable comment ends up missing from the committed file → CI lint fails") and explicitly note we haven't reverse-engineered the mechanism. The recommendation (inline `eslint-disable-line`) and its justification are unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fixes RSM-3355
Proposed changes
Switch the
dashboard-pie-charttask spec's ESLint disable-comment form for the@automattic/charts/style.cssimport fromeslint-disable-next-line(comment on the line above) to inlineeslint-disable-line(comment at end of import line). Keep the CSS import itself — it's load-bearing.Evidence the CSS import is needed (vs my earlier suspicion that it was redundant)
Built the package twice on host and grepped
routes/dashboard/content.min.js:svg ?\{.*display.*blockimport '@automattic/charts/style.css'.a8ccharts-... svg{display:block}and one is inside a runtimestyle.appendChild(document.createTextNode('...'))injectionThe CSS rule is genuinely missing without the import. The task spec's existing "Why the CSS import is required" rationale is correct and stays.
What was actually failing
Both PR #30 and PR #35 sandbox runs of
/premium-analytics-implement-taskhit the same recurring friction at commit time:// eslint-disable-next-line ...above the import per spec.@automattic/chartsand@wordpress/i18nimport groups — separating the disable comment from the import it was annotating.dist/index.cssexists) → auto-removes the comment.import/no-unresolvedfires → comment is gone → CI fail.Each run the agent burned 2–3 commit attempts fighting prettier + ESLint before either removing the import (wrong fix; loses the CSS rule) or switching to the inline form (right fix). Fixing the spec saves every future run that same cycle.
Why inline works where next-line doesn't
Does this pull request change what data or activity we track or use?
No — task spec / docs only, no code or behavior change.
Testing instructions
Docs-only change to a task spec. Read through
projects/packages/premium-analytics/tasks/dashboard-pie-chart.mdand confirm:// eslint-disable-line ...at the end of the CSS import line.Related