Skip to content

Commit b6d1ad0

Browse files
committed
docs(lint): dashboard-filter-binding-unknown explanation names a globalFilters entry called dateRange as a declared filter
The explanation said a dateRange binding on a dashboard without dateRange is always reported. The rule reads every globalFilters entry's name as declared, so a globalFilters entry named dateRange makes the binding valid. Correct the sentence and the two docblocks, and pin the accepted case with a test. Claude-Session: https://claude.ai/code/session_01JQwxbaAMsVe1WU74CypjTZ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 94d3e25 commit b6d1ad0

4 files changed

Lines changed: 29 additions & 6 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/lint': patch
3+
---
4+
5+
docs(lint): the `dashboard-filter-binding-unknown` explanation no longer says a `dateRange` binding is always reported on a dashboard without `dateRange`
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`os explain dashboard-filter-binding-unknown` said a widget's `filterBindings.dateRange` key "on a dashboard that declares no `dateRange` is reported the same way". The rule never did that when the dashboard declares a `globalFilters` entry named `dateRange`: every `globalFilters` entry's name is a declared filter, so the key binds it and the rule accepts it, as the explanation's first paragraph already says. The sentence now reads that a `dateRange` key is reported only when the dashboard declares neither `dateRange` nor a `globalFilters` entry named `dateRange`. The rule's behaviour is unchanged; a new test pins the accepted case.

‎packages/lint/src/rule-explanations.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,9 @@ const DASHBOARD_FILTER_BINDING_UNKNOWN_EXPLANATION: RuleExplanation = {
405405
'way the widget counts different rows than the author wrote, with nothing on the page to say so, ' +
406406
'which is why the rule is an error and is not suppressible.',
407407
'To fix it, rename the key to a declared filter name (the finding names the nearest one), declare ' +
408-
'the filter on the dashboard, or delete the entry. A `dateRange` key on a dashboard that declares ' +
409-
'no `dateRange` is reported the same way: there is no date range for it to bind.',
408+
'the filter on the dashboard, or delete the entry. A `dateRange` key is reported the same way ' +
409+
'only when the dashboard declares neither `dateRange` nor a `globalFilters` entry named `dateRange`: ' +
410+
'either one is a declared filter under that name, and with neither there is nothing for it to bind.',
410411
],
411412
};
412413

‎packages/lint/src/validate-widget-bindings.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,14 @@ describe('dashboard-filter-binding-unknown (#27445)', () => {
948948
expect(findings[0].hint).toBe('Declare `dateRange` on the dashboard, or delete the `dateRange` entry.');
949949
});
950950

951+
it('a `globalFilters` entry named `dateRange` declares the name on a dashboard without `dateRange`', () => {
952+
const findings = only(validateWidgetBindings(stack(
953+
{ dateRange: undefined, globalFilters: [{ name: 'dateRange', field: 'signed_at', type: 'date' }] },
954+
{ filterBindings: { dateRange: false } },
955+
)));
956+
expect(findings).toEqual([]);
957+
});
958+
951959
it('a dashboard with no filters at all refuses every key and says so', () => {
952960
const findings = only(validateWidgetBindings(stack(
953961
{ dateRange: undefined, globalFilters: undefined },

‎packages/lint/src/validate-widget-bindings.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ import {
7979
* counts, which is why this is an error and not the warning tier
8080
* `chart-field-unknown` took for its ignored keys (#15463): those re-dress
8181
* the same numbers, this one changes them. The declared names are the ones
82-
* {@link dashboardFilterDefs} builds, so the reserved `dateRange` key is
83-
* valid only on a dashboard that declares `dateRange` — the runtime, this
84-
* file and `@objectstack/verify`'s window proof all build that def only then.
82+
* {@link dashboardFilterDefs} builds: every `globalFilters` entry's name,
83+
* and the reserved `dateRange` when the dashboard declares `dateRange` (the
84+
* runtime, this file and `@objectstack/verify`'s window proof all build that
85+
* built-in def only then). A `globalFilters` entry named `dateRange` is a
86+
* declared filter by that name too, so a `dateRange` key binds it on a
87+
* dashboard that declares no `dateRange`.
8588
*
8689
* Advisory rules — severity `warning`, build stays green:
8790
*
@@ -450,7 +453,8 @@ export const DASHBOARD_FILTER_FIELD_UNPROVISIONED = 'dashboard-filter-field-unpr
450453
export const DASHBOARD_FILTER_FIELD_NOT_INCLUDED = 'dashboard-filter-field-not-included';
451454
/**
452455
* [#27445] A widget `filterBindings` key that names no filter the dashboard
453-
* declares (`dateRange` counts only when the dashboard declares one).
456+
* declares (`dateRange` counts when the dashboard declares `dateRange` or a
457+
* `globalFilters` entry named `dateRange`).
454458
*/
455459
export const DASHBOARD_FILTER_BINDING_UNKNOWN = 'dashboard-filter-binding-unknown';
456460
/** [#14148] A key of the widget's OWN `filter` that resolves to no column. */

0 commit comments

Comments
 (0)