|
1 | | -// The lintable issue this fixture exists for: the `null` literal below is |
2 | | -// reported by `local/no-null` (see `rslint.config.mjs`). Exactly one `null` |
3 | | -// literal — the smoke test asserts on the diagnostic count. |
| 1 | +// This fixture doubles as the F5 playground: open this file in the dev host |
| 2 | +// and every lint capability of the extension is observable directly below. |
| 3 | +// Constraint: the smoke test asserts on `local/no-null` — keep exactly one |
| 4 | +// `null` literal in this file. |
| 5 | + |
| 6 | +// #region Diagnostics — clickable rule docs in the Problems panel |
| 7 | +// Every rslint diagnostic in the Problems panel (Cmd+Shift+M) shows its rule |
| 8 | +// id as a clickable link, and the message carries no `[rule-id]` prefix — the |
| 9 | +// extension lifts the id into the diagnostic's code. |
| 10 | + |
| 11 | +// `local/no-null` is this fixture's own plugin rule (see local-plugin.mjs). |
| 12 | +// Its derived docs link is a deliberate 404: a user-local rule has no page on |
| 13 | +// rslint.rs. This is the diagnostic the smoke test asserts on. |
4 | 14 | export function getValue() { |
5 | 15 | return null; |
6 | 16 | } |
| 17 | + |
| 18 | +// Native rules link to real pages: `no-console` → /rules/eslint/no-console, |
| 19 | +// `@typescript-eslint/no-explicit-any` → /rules/typescript-eslint/no-explicit-any. |
| 20 | +export function debugValue(value: any) { |
| 21 | + console.log(value); |
| 22 | +} |
| 23 | +// #endregion |
| 24 | + |
| 25 | +// #region Inline directives — hover, underline, Ctrl+click |
| 26 | +// Rule ids inside a disable comment are underlined. Hovering one shows |
| 27 | +// `Rslint(rule-id)` with the id linking to its docs page; Ctrl+click |
| 28 | +// (Cmd+click on macOS) opens the page directly. The directive keyword itself |
| 29 | +// has no hover — only the rule ids do. |
| 30 | + |
| 31 | +// rslint-disable-next-line no-console |
| 32 | +console.log('suppressed — hover the underlined rule id above'); |
| 33 | + |
| 34 | +// Comma-separated ids are each their own hover target; the ` -- ` trailer is |
| 35 | +// free-form description and is not parsed. |
| 36 | +// rslint-disable-next-line no-console, @typescript-eslint/no-explicit-any -- demo: two rule ids and a trailer |
| 37 | +export const logAny = (value: any) => console.log(value); |
| 38 | +// #endregion |
| 39 | + |
| 40 | +// #region Directive forms — disable-line, eslint- prefix, wildcard |
| 41 | +// `rslint-disable-line` suppresses its own line, and works from a trailing |
| 42 | +// comment too. |
| 43 | +console.log('suppressed inline'); // rslint-disable-line no-console |
| 44 | + |
| 45 | +// The `eslint-` prefix is an exact equivalent of `rslint-`. |
| 46 | +// eslint-disable-next-line no-console |
| 47 | +console.log('suppressed via the eslint- prefix'); |
| 48 | + |
| 49 | +// A bare directive suppresses every rule; with no rule id there is nothing to |
| 50 | +// hover. |
| 51 | +// rslint-disable-next-line |
| 52 | +console.log('suppressed by the wildcard directive'); |
| 53 | +// #endregion |
| 54 | + |
| 55 | +// #region Pitfall — a mistyped rule id |
| 56 | +// A mistyped id suppresses nothing: the squiggle below survives, which is the |
| 57 | +// signal the directive missed. Its hover link still derives (and 404s) — the |
| 58 | +// extension deliberately validates nothing against a rule list (ADR 0004). |
| 59 | +// rslint-disable-next-line no-consle |
| 60 | +console.log('NOT suppressed — the rule id above is mistyped'); |
| 61 | +// #endregion |
0 commit comments