Skip to content

refactor(lint): clear the directory scanner's CSS warnings - #728

Merged
Quorafind merged 5 commits into
masterfrom
refactor/scanner-css-warnings
Nov 29, 2026
Merged

Quorafind merged 5 commits into
masterfrom
refactor/scanner-css-warnings

Conversation

@Quorafind

Copy link
Copy Markdown
Member

Clears most of the CSS warnings the community directory scanner reports. Counts are from the scanner's Stylelint rules:

Rule Before After
!important 120 9
:has 41 4
Duplicate declarations (padding, display, align-items, margin-bottom, margin, gap, width) 14 0
display: contents / multicolumn 2 0

Why styles.css changes

The scanner lints the tracked styles.css at the repo root, not the release asset. Its line numbers match that file exactly. The committed file was a dev build from December 2025 (5610bc41), so CSS fixes in src/styles never reached the scan.

  • New node esbuild.config.mjs styles (npm run build:styles) writes only the root styles.css, unminified and without a source map, so findings point at readable lines. It leaves main.js alone.
  • release-it runs it after the production build, so the committed file matches every release.
  • This PR regenerates the root styles.css from the current sources, which accounts for the large diff on that file.

Approach

  • !important is replaced by enough specificity, e.g. scoping under the plugin's containers or chaining the element's own classes.
  • :has(...) is replaced by a class that the TS code sets where it renders the element, e.g. has-task-checkbox, has-pie-dot, is-left-column-visible and is-cycle-disabled.
  • Duplicates: the declaration that actually applied is kept.
  • Year view: the mini-month weekday header uses a subgrid instead of display: contents.

Kept on purpose

  • !important (9):
    • calendar event backgrounds (3): the calendar library sets them inline.
    • mobile table row-number width/min-width (4): TableRenderer sets them inline.
    • SortableJS ghost/chosen backgrounds (2): shared by 6 lists, each with its own item background.
  • :has (4):
    • three in Obsidian's own menu DOM, where the plugin only fills the title and a sibling selector can't reach the icon;
    • one timeline row hover that reacts to hovering a child.

Verification

  • Build passes.
  • jest: 187 suites, 2005 tests pass.
  • The scanner's Stylelint rules run on the regenerated styles.css show the counts above. 33 color-named remain; the directory doesn't report that rule.

Please check visually

Specificity changes can lose to a theme's more specific rule. These are the areas worth a look in Obsidian:

  • Phone: the overlay when the left column opens in Forecast, Projects, Tags, Review and Properties.
  • Year view: weekday alignment, including with weekends hidden.
  • Calendar: month drag-select preview in light and dark themes, and event checkboxes.
  • Table view: inputs, the resize cursor, and the mobile row-number column.
  • Editing: bulk-selection hover, and the inline editor and inline project pill.
  • Settings: settings search highlight, and the status-cycle cards (disabled, drag handle).
  • Elsewhere:
    • onboarding showcase steps
    • capture button in split tab headers
    • quick capture with a single save mode
    • hidden progress bars (.no-progress-bar)

One intended difference: in the views settings list, the item hovered while dragging now shows the drag colour instead of the hover colour.

…eatures

Remove the earlier copy of each property that a later declaration in the
same rule overrides, so the computed styles stay the same.

Replace `display: contents` on the year view's mini weekday header with a
subgrid that spans the first row, and write the project properties grid's
`column-gap` as `gap: 0 10px`. The scanner flags both features as only
partially supported.
Obsidian's review scanner warns about :has because of its broad selector
invalidation. Each element now gets a class from the code that renders
it or changes its state, and the stylesheet keys off that class:

- phone sidebars (forecast, projects, tags, review, task properties):
  is-left-column-visible / is-forecast-left-column-visible
- calendar events and Task Genius calendar events with a checkbox,
  table cells with an expand button, habit heatmap cells with a pie dot
- inline metadata editors built on a text input, and the project pill
  being edited
- quick capture title bar without tabs, disabled status cycle cards,
  the tab header status container that holds the capture button
- onboarding view and showcase layout flags

Other rules use what the DOM already provides: the existing
details-visible class, a sibling combinator for the forecast header and
the Fluent top navigation, the right detail leaf's data-type, and
`.is-phone` alone where the close button only exists on phones.

Three rules for the removed legacy settings layout never matched and are
deleted.
Obsidian's review scanner warns about !important. Each rule now wins
through specificity against the rule it was overriding instead:

- Obsidian input and button rules (table inline inputs, table control
  buttons, settings search input and clear button): scoped to their
  container and element, with explicit :hover/:focus/:active variants
  where Obsidian styles those states
- Obsidian .setting-item and .markdown-rendered p, CodeMirror's
  .cm-focused outline, the calendar library's header and positioning:
  scoped under the plugin's own classes
- the plugin's own later or more specific rules (task selection, month
  cell range preview, mobile table tree cells, status rows, the onboarding
  view grid, the no-progress-bar toggle): scoped, chained or excluded
  with :not() so the cascade result stays the same

Declarations that nothing competes with just lose the flag. The
!important steps inside two @Keyframes never applied (browsers ignore
them), so those steps were removed rather than made effective.

Kept on purpose: the event background colours that override the
calendar library's inline colour, the table row-number width and
min-width that override inline widths, and SortableJS's shared
.sortable-ghost/.sortable-chosen state classes.
The community directory scanner lints the styles.css committed at the repo root, not the release asset. That file was a dev build from December 2025, so CSS fixes in src/styles never reached the scan. Add `node esbuild.config.mjs styles` (npm run build:styles): it writes only the root styles.css, unminified and without a source map so findings point at readable lines, and leaves main.js alone. release-it now runs it after the production build, so the committed file matches each release.
@Quorafind
Quorafind merged commit b742531 into master Nov 29, 2026
3 checks passed
@Quorafind
Quorafind deleted the refactor/scanner-css-warnings branch November 29, 2026 03:58
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant