@dsmith-dev/eslint-plugin
v0.5.0
Published
ESLint rules for dsmith: no hardcoded style values, prefer design-system components, no deprecated components
Maintainers
Readme
@dsmith-dev/eslint-plugin
ESLint rules for dsmith: no hardcoded style values, prefer design-system components, no deprecated components.
// eslint.config.js
import dsmith from "@dsmith-dev/eslint-plugin";
export default [dsmith.configs.recommended];dsmith guard init adds this block to your flat config for you.
Rules
configs.recommended turns on all three (flat config only; eslintrc is not supported):
| Rule | Level | Reports |
| --- | --- | --- |
| dsmith/no-hardcoded-style | warn | A hardcoded style value. Exact matches get an auto-fix to the token reference; close matches get a suggestion only. |
| dsmith/prefer-ds-component | warn | A non-DS component that has a design-system counterpart. |
| dsmith/no-deprecated-component | error | A component the design system marks as deprecated. |
They use the same rule engine (evaluateFile in @dsmith-dev/core) as dsmith migrate and dsmith guard --ci.
Scope and behavior
- JS/TS only. The rules run on
js, jsx, mjs, cjs, ts, tsx, mts, ctsfiles. CSS files are not linted by ESLint; they are checked bydsmith guard --ci. - Needs
.dsmith/guard.json. The rules read the snapshot written bydsmith guard init(found by walking up from the linted file, orsettings.dsmith.guardFile). If it is missing, the rules report nothing. If it is broken, the rules report nothing and Node prints one warning per process. In editors that warning goes to the ESLint server log, so checkdsmith guardif lint seems silent. - Stale snapshot. If a token file changed after
guard init, the first message in each file says so, andno-hardcoded-styleoffers its replacement as a suggestion instead of an auto-fix. Rundsmith guard initagain. - Aliased imports.
import { DialogContent as DC }andimport * as UI(<UI.DialogContent />) are matched by the imported name.
--cache
ESLint's cache key covers file content and config, not .dsmith/guard.json. configs.recommended is a getter that adds settings.dsmith.snapshotHash (sha256 of guard.json, or "none"), so the cache is invalidated when the snapshot changes. The file is looked up from process.cwd() when the config is evaluated, once per ESLint run. If you point settings.dsmith.guardFile at a different file, or do not use configs.recommended, rerun without --cache after guard init. Token file edits are not part of the hash.
Docs: https://github.com/project-hh-org/dsmith#readme
