design_token_lints 0.4.0
design_token_lints: ^0.4.0 copied to clipboard
Enforce your Flutter design system: flag raw colors, magic spacing, inline text styles and off-system widgets, auto-fix to your own tokens, and measure design-system coverage.
0.4.0 #
Ecosystem: fit into the tools teams already use.
- New
design_token_lints check-tokenscommand anddesign_tokens:section: compares the Dart tokens with a design tokens file in the Design Tokens Format Module 2025.10 (as exported from Figma or Tokens Studio) and lists values that differ and tokens missing on either side. Exit code 1 on drift. - A JSON schema for
design_token_lints.yaml(doc/design_token_lints.schema.json): with a# yaml-language-serverline, editors complete keys and flag mistakes as you type. coverage --format sarifwrites a SARIF 2.1.0 log for GitHub code scanning, with paths relative to the git repository root and without baselined findings. The README has a workflow that uploads it.
0.3.0 #
Reach: more of a real design system.
ThemeExtensiontokens: a token source withinstance:reads the fields of astatic constinstance (static const light = AppPalette(brand: …)), with an optionalaccess:template (context.palette.{name}, by defaultTheme.of(context).extension<AppPalette>()!.{name}) andimport:. Fixes are offered only where the result compiles: with aBuildContext contextin scope and outside constants. Reads of the extension's fields count incoverage.- Coverage counts colors read from Flutter's
ColorSchemeand text styles read from itsTextTheme(Theme.of(context).colorScheme.primary,TextTheme.of(context).bodyMedium) as color and typography uses. Apps that use Material theming will see higher coverage than with 0.2.x. - New rules
avoid_raw_icon_sizeandavoid_raw_elevation, with theicon_sizeandelevationtoken categories,allow.icon_size,allow.elevation,matching.icon_size_toleranceandmatching.elevation_tolerance. Like every rule, they report nothing until their tokens are configured.fix,baselineandcoveragesupport them.
0.2.1 #
- Support apps that use the
material_uiandcupertino_uipackages (Flutter 3.47 and later, wherepackage:flutter/material.dartis deprecated). Those packages declare their ownColorsand widgets, whichavoid_raw_colorandprefer_design_system_componentdid not recognize, soColors.*and configured components went unreported. - The example app uses
material_ui.
0.2.0 #
Adoption: easier to switch on in an existing app.
- New
design_token_lints baselinecommand: records the current raw values indesign_token_lints.baseline.yaml, and the plugin then reports only new ones. Values are matched by file, rule and code, so moving or reformatting code keeps them accepted.coveragestill counts them, and reports how many are baselined (baselinedin the JSON report). - New
design_token_lints fixcommand: applies every exact-token fix in a project at once, with imports, honoring// ignore:comments. Nearest matches and values that match two tokens are listed, not changed.--dry-runexits with code 1 when there is something to fix;--rulelimits the rules. avoid_raw_color: a translucent color whose red, green and blue equal an opaque token now offers a fix toToken.withValues(alpha: …), for exampleColor(0x801E88E5)toAppColors.primary.withValues(alpha: 0.5). Not offered in constant contexts or default values, where a method call is not allowed.
0.1.2 #
- README: a shorter introduction, a table of contents, a getting-started section with requirements, a link to the example app, a comparison with related tools, and a grouped roadmap.
- Add a pub.dev screenshot of the quick fix.
0.1.1 #
- Fix the README on pub.dev: the demo GIF, the video links and the license links now use absolute URLs, so they render outside GitHub.
0.1.0 #
First release.
- Six analyzer rules, on by default once the matching tokens are configured:
avoid_raw_color,avoid_magic_spacing,avoid_raw_radius,avoid_inline_text_style,avoid_raw_shadowandprefer_design_system_component. - Quick fixes that replace raw values with your own tokens: exact matches, and "nearest" matches within the configured spacing, radius and CIEDE2000 tolerances. The component fix swaps the widget and adds the import.
- Configuration through a
design_token_lints:section inanalysis_options.yamlor a standalonedesign_token_lints.yaml, with workspace-root fallback. Token values are read from your existing token classes; no annotations, no code generation. - Automatic exemptions for design-system paths and packages, the token files themselves, and generated files.
design_token_lints coverage(console, JSON, Markdown,--fail-under) anddesign_token_lints check-config.- Works with
analysis_server_plugin0.3.15 to 0.3.26 (analyzer 13.0 to 14.7).
See the roadmap in the README for what comes next.
