Skip to content

Commit 0078ac0

Browse files
authored
Order tagged features properly and not with fix linter (#25761)
1 parent 817aceb commit 0078ac0

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@
115115
"traverse": "tsx scripts/traverse.ts",
116116
"update-browser-releases": "tsx scripts/update-browser-releases/index.ts",
117117
"bcd": "tsx scripts/bulk-editor/index.ts",
118-
"tag-web-features": "tsx scripts/tag-web-features.ts && npm run fix"
118+
"tag-web-features": "tsx scripts/tag-web-features.ts"
119119
}
120120
}

scripts/tag-web-features.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import esMain from 'es-main';
99
import { fdir } from 'fdir';
1010
import { features } from 'web-features';
1111

12+
import stringifyAndOrderProperties from '../scripts/lib/stringify-and-order-properties.js';
13+
1214
const dirname = fileURLToPath(new URL('.', import.meta.url));
1315

1416
// Map from api.CoolThing.something to cool-thing
@@ -29,6 +31,9 @@ for (const [feature, { compat_features }] of Object.entries(features)) {
2931

3032
// FixMe: The idea of scripts/bulk-editor is to have utilities for bulk updating BCD files programmatically. It also features an implementation to update tags which is not used here as the bulk-editor scripts aren't used and/or maintained properly at the moment.
3133

34+
/**
35+
* Add web-feature tags to BCD keys
36+
*/
3237
const main = async () => {
3338
const bcdJsons = new fdir()
3439
.withBasePath()
@@ -42,6 +47,12 @@ const main = async () => {
4247
.crawl(path.resolve(dirname, '..'))
4348
.sync();
4449

50+
/**
51+
* Lookup data at a specified key
52+
* @param root JSON object
53+
* @param key BCD key
54+
* @returns BCD data at the specified key
55+
*/
4556
const lookup = (root, key) => {
4657
const parts = key.split('.');
4758
let node = root;
@@ -99,8 +110,9 @@ const main = async () => {
99110
updated = true;
100111
}
101112
if (updated) {
102-
const src = JSON.stringify(data, null, ' ') + '\n';
103-
await fs.writeFile(fp, src, { encoding: 'utf-8' });
113+
await fs.writeFile(fp, stringifyAndOrderProperties(data) + '\n', {
114+
encoding: 'utf-8',
115+
});
104116
}
105117
}
106118

0 commit comments

Comments
 (0)