Skip to content

Commit 87d074a

Browse files
authored
fix(lint/status): compute experimental status from core browser set (#28641)
1 parent c34e34b commit 87d074a

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

lint/linter/test-status.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,30 @@ describe('checkExperimental', () => {
6565

6666
assert.equal(checkExperimental(data), false);
6767
});
68+
69+
it('should ignore non-relevant browsers when determining experimental status', () => {
70+
const data: CompatStatement = {
71+
status: {
72+
experimental: true,
73+
standard_track: true,
74+
deprecated: false,
75+
},
76+
support: {
77+
// Bun and Deno are not part of the Core browser set.
78+
firefox: {
79+
version_added: '1',
80+
},
81+
bun: {
82+
version_added: '1.0',
83+
},
84+
deno: {
85+
version_added: '1.0',
86+
},
87+
},
88+
};
89+
90+
assert.equal(checkExperimental(data), true);
91+
});
6892
});
6993

7094
describe('checkStatus', () => {

lint/linter/test-status.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ import { BrowserName, CompatStatement } from '../../types/types.js';
88
import bcd from '../../index.js';
99
const { browsers } = bcd;
1010

11+
// See: https://github.com/web-platform-dx/web-features/blob/main/docs/baseline.md#core-browser-set
12+
const CORE_BROWSER_SET = new Set([
13+
'chrome',
14+
'chrome_android',
15+
'edge',
16+
'firefox',
17+
'firefox_android',
18+
'safari',
19+
'safari_ios',
20+
]);
21+
1122
/**
1223
* Check if experimental should be true or false
1324
* @param data The data to check
@@ -20,6 +31,9 @@ export const checkExperimental = (data: CompatStatement): boolean => {
2031
const browserSupport = new Set<BrowserName>();
2132

2233
for (const [browser, support] of Object.entries(data.support)) {
34+
if (!CORE_BROWSER_SET.has(browser)) {
35+
continue;
36+
}
2337
// Consider only the first part of an array statement.
2438
const statement = Array.isArray(support) ? support[0] : support;
2539
// Ignore anything behind flag, prefix or alternative name

0 commit comments

Comments
 (0)