From b7f7c3b13766f06ecce9fd2e440924c654694b27 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 20 Aug 2024 03:16:31 -0700 Subject: [PATCH 1/7] Remove nonreal values from the schema --- lint/linter/test-versions.ts | 38 +------------------------ schemas/compat-data-schema.md | 50 +++++---------------------------- schemas/compat-data.schema.json | 25 ++++------------- 3 files changed, 13 insertions(+), 100 deletions(-) diff --git a/lint/linter/test-versions.ts b/lint/linter/test-versions.ts index 275ffe7b092601..c14da5781d04eb 100644 --- a/lint/linter/test-versions.ts +++ b/lint/linter/test-versions.ts @@ -26,33 +26,6 @@ const browserTips: Record = { 'Blink editions of Opera Android and Opera desktop were the Chrome version number minus 13, up until Opera Android 43 when they began skipping Chrome versions. Please double-check browsers/opera_android.json to make sure you are using the correct versions.', }; -const realValuesTargetBrowsers = [ - 'chrome', - 'chrome_android', - 'edge', - 'firefox', - 'firefox_android', - 'opera', - 'opera_android', - 'safari', - 'safari_ios', - 'samsunginternet_android', - 'webview_android', -]; - -const realValuesRequired: Record = { - api: realValuesTargetBrowsers, - css: realValuesTargetBrowsers, - html: realValuesTargetBrowsers, - http: realValuesTargetBrowsers, - svg: realValuesTargetBrowsers, - javascript: [...realValuesTargetBrowsers, 'nodejs', 'deno'], - mathml: realValuesTargetBrowsers, - webassembly: realValuesTargetBrowsers, - webdriver: realValuesTargetBrowsers, - webextensions: [], -}; - /** * Test to see if the browser allows for the specified version * @param browser The browser to check @@ -70,11 +43,6 @@ const isValidVersion = ( return !!browsers[browser].preview_name; } return Object.hasOwn(browsers[browser].releases, version.replace('≤', '')); - } else if ( - realValuesRequired[category].includes(browser) && - version !== false - ) { - return false; } return true; }; @@ -140,10 +108,6 @@ const checkVersions = ( supportData[browser]; if (!supportStatement) { - if (realValuesRequired[category].includes(browser)) { - logger.error(chalk`{red {bold ${browser}} must be defined}`); - } - continue; } @@ -170,7 +134,7 @@ const checkVersions = ( logger.error( chalk`{bold ${property}: "${version}"} is {bold NOT} a valid version number for {bold ${browser}}\n Valid {bold ${browser}} versions are: ${Object.keys( browsers[browser].releases, - ).join(', ')}`, + ).join(', ')}, false`, { tip: browserTips[browser] }, ); } diff --git a/schemas/compat-data-schema.md b/schemas/compat-data-schema.md index d36cfc19013431..c933069dc39499 100644 --- a/schemas/compat-data-schema.md +++ b/schemas/compat-data-schema.md @@ -100,7 +100,7 @@ Here is an example of a `__compat` statement, with all of the properties and the // Supported since Chrome 57 on "version_added": "57", }, - "chrome_android": "mirror", // Mirrors from Chrome Desktop, so "57" + "chrome_android": "mirror", // Mirrors from the upstream browser -- in this case, it is Chrome Desktop, so the data becomes "57" "edge": { // Supported since Edge 12, with a note about a difference in behavior "version_added": "12", @@ -112,8 +112,8 @@ Here is an example of a `__compat` statement, with all of the properties and the "version_removed": "80", }, "firefox_android": { - // Supported in Firefox Android, we just don't know what version it was added in - "version_added": true, + // Support is known to be in at least Firefox Android 50, but it could have been added earlier + "version_added": "≤50", }, "ie": { // Supported since IE 10, but has a caveat that impacts compatibility @@ -126,10 +126,7 @@ Here is an example of a `__compat` statement, with all of the properties and the // Not supported at all in Opera "version_added": false, }, - "opera_android": { - // We don't know if Opera Android supports this or not - "version_added": null, - }, + "opera_android": "mirror", "safari": [ // A support statement can be an array of multiple statements to better describe the compatibility story { @@ -148,6 +145,7 @@ Here is an example of a `__compat` statement, with all of the properties and the "safari_ios": "mirror", "samsunginternet_android": "mirror", "webview_android": "mirror", + // If a browser is not defined, it means we don't have support information for that browser (or for web extensions, the browser has no support at all) }, "status": { // Standards track, deprecation and experimental status @@ -294,14 +292,6 @@ This is the only mandatory property and it contains a string with the version nu } ``` -- Supported, but version unknown: - -```json -{ - "version_added": true -} -``` - - No support: ```json @@ -310,25 +300,10 @@ This is the only mandatory property and it contains a string with the version nu } ``` -- Support unknown (default value, if browser omitted): - -```json -{ - "version_added": null -} -``` - -Note: many data categories no longer allow for `version_added` to be set to `true` or `null`, as we are working to [improve the quality of the compatibility data](https://github.com/mdn/browser-compat-data/issues/3555). - #### `version_removed` Contains a string with the version number the sub-feature was removed in. It may also be `true`, meaning that it is unknown in which version support was removed. If the feature has not been removed from the browser, this property is omitted, rather than being set to `false`. -Default values: - -- If `version_added` is set to `true`, `false`, or a string, `version_removed` defaults to `false`. -- If `version_added` is set to `null`, the default value of `version_removed` is also `null`. - Examples: - Removed in version 10 (added in 4 and supported up until 9): @@ -340,17 +315,6 @@ Examples: } ``` -- Removed in some version after 4: - -```json -{ - "version_added": "4", - "version_removed": true -} -``` - -Note: many data categories no longer allow for `version_removed` to be set to `true`, as we are working to [improve the quality of the compatibility data](https://github.com/mdn/browser-compat-data/issues/3555). - #### `version_last` > [!NOTE] @@ -435,7 +399,7 @@ Example for one flag required: ```json { - "version_added": true, + "version_added": "40", "flags": [ { "type": "preference", @@ -450,7 +414,7 @@ Example for two flags required: ```json { - "version_added": true, + "version_added": "40", "flags": [ { "type": "preference", diff --git a/schemas/compat-data.schema.json b/schemas/compat-data.schema.json index 0bb5dc336c94a4..a7ff1c1a9ddde8 100644 --- a/schemas/compat-data.schema.json +++ b/schemas/compat-data.schema.json @@ -13,36 +13,21 @@ "pattern": "^(≤?(\\d+)(\\.\\d+)*|preview)$" }, { - "type": "boolean", - "nullable": true + "const": false } ], "tsType": "VersionValue" }, "version_removed": { "description": "A string, indicating which browser version removed this feature, or the value true, indicating that the feature was removed in an unknown version.", - "anyOf": [ - { - "type": "string", - "pattern": "^(≤?(\\d+)(\\.\\d+)*|preview)$" - }, - { - "const": true - } - ], + "type": "string", + "pattern": "^(≤?(\\d+)(\\.\\d+)*|preview)$", "tsType": "VersionValue" }, "version_last": { "description": "A string, indicating the last browser version that supported this feature, or the value true, indicating that the feature was removed in an unknown version. This is automatically generated.", - "anyOf": [ - { - "type": "string", - "pattern": "^(≤?(\\d+)(\\.\\d+)*|preview)$" - }, - { - "const": true - } - ], + "type": "string", + "pattern": "^(≤?(\\d+)(\\.\\d+)*|preview)$", "tsType": "VersionValue" }, "prefix": { From e769695f20775b9d8e6788d41e1addc9c46c3f4e Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 29 Aug 2024 00:13:29 -0700 Subject: [PATCH 2/7] Update statistics script --- scripts/statistics.ts | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/scripts/statistics.ts b/scripts/statistics.ts index aa0f214d01d6c5..b8df878de18269 100644 --- a/scripts/statistics.ts +++ b/scripts/statistics.ts @@ -18,8 +18,6 @@ import { getRefDate } from './release/utils.js'; interface VersionStatsEntry { all: number; - true: number; - null: number; range: number; real: number; } @@ -80,16 +78,7 @@ const processData = ( browsers.forEach((browser) => { stats[browser].all++; stats.total.all++; - if (!data.support[browser]) { - stats[browser].null++; - stats.total.null++; - } else if (checkSupport(data.support[browser], null)) { - stats[browser].null++; - stats.total.null++; - } else if (checkSupport(data.support[browser], true)) { - stats[browser].true++; - stats.total.true++; - } else if (checkSupport(data.support[browser], '≤')) { + if (checkSupport(data.support[browser], '≤')) { stats[browser].range++; stats.total.range++; } else { @@ -148,10 +137,10 @@ const getStats = ( ] as BrowserName[]); const stats: VersionStats = { - total: { all: 0, true: 0, null: 0, range: 0, real: 0 }, + total: { all: 0, range: 0, real: 0 }, }; browsers.forEach((browser) => { - stats[browser] = { all: 0, true: 0, null: 0, range: 0, real: 0 }; + stats[browser] = { all: 0, range: 0, real: 0 }; }); if (folder) { @@ -225,17 +214,15 @@ const printStats = ( }}: \n`, ); - let table = `| browser | real values | ranged values | \`true\` values | \`null\` values | -| --- | --- | --- | --- | --- | + let table = `| browser | real values | ranged values | +| --- | --- | --- | `; Object.keys(stats).forEach((entry) => { table += `| ${entry.replace('_', ' ')} | `; table += `${getStat(stats[entry], 'real', counts)} | `; table += `${getStat(stats[entry], 'range', counts)} | `; - table += `${getStat(stats[entry], 'true', counts)} | `; - table += `${getStat(stats[entry], 'null', counts)} | -`; + table += '\n'; }); console.log(table); From 1b9bf4cb36086b163a643bbe5034ac98aa0ded6a Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 29 Aug 2024 00:19:22 -0700 Subject: [PATCH 3/7] Update feature traversal script --- scripts/traverse.ts | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/scripts/traverse.ts b/scripts/traverse.ts index b01cb4f8e67f6b..33391f1ad9fce7 100644 --- a/scripts/traverse.ts +++ b/scripts/traverse.ts @@ -148,7 +148,7 @@ const main = ( browsers: BrowserName[] = Object.keys(bcd.browsers).filter( (b) => bcd.browsers[b].type !== 'server', ) as BrowserName[], - values = ['null', 'true'], + values = [], depth = 100, tag = '', ): string[] => { @@ -207,13 +207,6 @@ if (esMain(import.meta)) { nargs: 1, default: '', }) - .option('non-real', { - alias: 'n', - describe: - 'Filter to features with non-real values. Alias for "-f true -f null"', - type: 'boolean', - nargs: 0, - }) .option('depth', { alias: 'd', describe: @@ -229,12 +222,8 @@ if (esMain(import.meta)) { default: process.stdout.isTTY, }) .example( - 'npm run traverse -- --browser=safari -n', - 'Find all features containing non-real Safari entries', - ) - .example( - 'npm run traverse -- -b webview_android -f true', - 'Find all features marked as true for WebView', + 'npm run traverse -- -b webview_android -f ≤37', + 'Find all features marked as ≤37 for WebView', ) .example( 'npm run traverse -- -b firefox -f 10', @@ -251,12 +240,10 @@ if (esMain(import.meta)) { }, ); - const filter = [...argv.filter, ...(argv.nonReal ? ['true', 'null'] : [])]; - const features = main( argv.folder, argv.browser, - filter, + argv.filter, argv.depth, argv.tag, ); From 8fe105e4bd2c616a93955a6aa305bfb97040dc99 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 28 Nov 2024 03:23:21 -0800 Subject: [PATCH 4/7] Remove unittest for a removed error This error was removed as it is now redundant. --- lint/linter/test-versions.test.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lint/linter/test-versions.test.ts b/lint/linter/test-versions.test.ts index 6130fa69853f58..53b8909a999b5b 100644 --- a/lint/linter/test-versions.test.ts +++ b/lint/linter/test-versions.test.ts @@ -51,16 +51,6 @@ describe('test-versions', () => { }; }); - it('should log error when a required browser is not defined', () => { - support.chrome = undefined; - test.check(logger, { - data: { support }, - path: { category: 'api' }, - }); - assert.equal(logger.messages.length, 1); - assert.ok(logger.messages[0].message.includes('must be defined')); - }); - it('should log error when a browser is set to mirror but does not have an upstream browser', () => { support.chrome = 'mirror'; test.check(logger, { From 7915f67ded3cf62c3bf6462208e5aae8cc93d255 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 28 Nov 2024 03:27:46 -0800 Subject: [PATCH 5/7] Fix unittests for stats script --- scripts/statistics.test.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/statistics.test.ts b/scripts/statistics.test.ts index cdf792306669ab..dc21e78b68e3df 100644 --- a/scripts/statistics.test.ts +++ b/scripts/statistics.test.ts @@ -20,8 +20,8 @@ describe('getStats', () => { __compat: { support: { chrome: { version_added: '≤1' }, - firefox: { version_added: '1' }, - safari: { version_added: null }, + firefox: { version_added: '4' }, + safari: { version_added: '10' }, }, }, }, @@ -31,7 +31,7 @@ describe('getStats', () => { __compat: { support: { chrome: { version_added: '1' }, - firefox: { version_added: null }, + firefox: { version_added: '≤30' }, safari: { version_added: '1' }, }, }, @@ -43,24 +43,24 @@ describe('getStats', () => { it('should return stats for all browsers when allBrowsers is true', () => { const stats = getStats('api', true, bcd); assert.deepEqual(stats, { - total: { all: 3, true: 0, null: 1, range: 0, real: 2 }, - chrome: { all: 1, true: 0, null: 0, range: 0, real: 1 }, - firefox: { all: 1, true: 0, null: 1, range: 0, real: 0 }, - safari: { all: 1, true: 0, null: 0, range: 0, real: 1 }, + total: { all: 3, range: 1, real: 2 }, + chrome: { all: 1, range: 0, real: 1 }, + firefox: { all: 1, range: 1, real: 0 }, + safari: { all: 1, range: 0, real: 1 }, }); }); it('should return stats for webextensions browsers when folder is "webextensions"', () => { const stats = getStats('webextensions', false, bcd); assert.deepEqual(stats, { - total: { all: 7, true: 0, null: 5, range: 1, real: 1 }, - chrome: { all: 1, true: 0, null: 0, range: 1, real: 0 }, - edge: { all: 1, true: 0, null: 1, range: 0, real: 0 }, - firefox: { all: 1, true: 0, null: 0, range: 0, real: 1 }, - opera: { all: 1, true: 0, null: 1, range: 0, real: 0 }, - safari: { all: 1, true: 0, null: 1, range: 0, real: 0 }, - firefox_android: { all: 1, true: 0, null: 1, range: 0, real: 0 }, - safari_ios: { all: 1, true: 0, null: 1, range: 0, real: 0 }, + total: { all: 7, range: 1, real: 6 }, + chrome: { all: 1, range: 1, real: 0 }, + edge: { all: 1, range: 0, real: 1 }, + firefox: { all: 1, range: 0, real: 1 }, + opera: { all: 1, range: 0, real: 1 }, + safari: { all: 1, range: 0, real: 1 }, + firefox_android: { all: 1, range: 0, real: 1 }, + safari_ios: { all: 1, range: 0, real: 1 }, }); }); From c3298569dba982616689423e0a61e675d9d0a189 Mon Sep 17 00:00:00 2001 From: Florian Scholz Date: Tue, 25 Mar 2025 14:07:20 +0100 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Claas Augner <495429+caugner@users.noreply.github.com> --- schemas/compat-data.schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schemas/compat-data.schema.json b/schemas/compat-data.schema.json index fb9738a91daa60..a188fdacb106e5 100644 --- a/schemas/compat-data.schema.json +++ b/schemas/compat-data.schema.json @@ -19,13 +19,13 @@ "tsType": "VersionValue" }, "version_removed": { - "description": "A string, indicating which browser version removed this feature, or the value true, indicating that the feature was removed in an unknown version.", + "description": "A string, indicating which browser version removed this feature.", "type": "string", "pattern": "^(≤?(\\d+)(\\.\\d+)*|preview)$", "tsType": "VersionValue" }, "version_last": { - "description": "A string, indicating the last browser version that supported this feature, or the value true, indicating that the feature was removed in an unknown version. This is automatically generated.", + "description": "A string, indicating the last browser version that supported this feature. This is automatically generated.", "type": "string", "pattern": "^(≤?(\\d+)(\\.\\d+)*|preview)$", "tsType": "VersionValue" From a8c705677940d9aad05b182754b1e8f62a7649f8 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Tue, 25 Mar 2025 14:33:51 +0100 Subject: [PATCH 7/7] fixup! Apply suggestions from code review --- schemas/compat-data.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemas/compat-data.schema.json b/schemas/compat-data.schema.json index a188fdacb106e5..e8e8c73169f35e 100644 --- a/schemas/compat-data.schema.json +++ b/schemas/compat-data.schema.json @@ -6,7 +6,7 @@ "type": "object", "properties": { "version_added": { - "description": "A string (indicating which browser version added this feature), the value true (indicating support added in an unknown version), the value false (indicating the feature is not supported), or the value null (indicating support is unknown).", + "description": "A string (indicating which browser version added this feature), or the value false (indicating the feature is not supported).", "anyOf": [ { "type": "string",