Skip to content

Commit 660922b

Browse files
caugnerLeoMcA
andauthored
feat(lint): require spec_url if standard_track is true (#28810)
Introduces a linter that requires `spec_url` if `standard_track` is true for new features. Existing violations are tracked in an exceptions list, and get removed automatically when resolved. --------- Co-authored-by: Leo McArdle <leo@mozilla.com>
1 parent 5c7ba12 commit 660922b

File tree

8 files changed

+2280
-7
lines changed

8 files changed

+2280
-7
lines changed

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default [
5757

5858
languageOptions: {
5959
globals: {
60-
...globals.jest,
60+
...globals.mocha,
6161
...globals.node,
6262
Atomics: 'readonly',
6363
SharedArrayBuffer: 'readonly',
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { readFile, writeFile } from 'node:fs/promises';
2+
import { dirname, join } from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = dirname(__filename);
7+
8+
export const exceptionListPath = join(
9+
__dirname,
10+
'./standard-track-exceptions.txt',
11+
);
12+
13+
/**
14+
* @returns {Promise<string[]>}
15+
*/
16+
export const getStandardTrackExceptions = async () =>
17+
(await readFile(exceptionListPath, 'utf-8'))
18+
.split('\n')
19+
.map((line) => line.trim())
20+
.filter((line) => line.length > 0 && !line.startsWith('#'));
21+
22+
/**
23+
*
24+
* @param {Iterable<string>} features
25+
*/
26+
export const setStandardTrackExceptions = async (features) => {
27+
const lines = (await readFile(exceptionListPath, 'utf-8'))
28+
.split('\n')
29+
.map((line) => line.trim());
30+
const headerLines = lines.filter((line) => line.startsWith('#'));
31+
const result = [...headerLines, ...[...features].sort()].join('\n');
32+
await writeFile(exceptionListPath, result + '\n', 'utf-8');
33+
};

0 commit comments

Comments
 (0)