Skip to content

Commit 02c74a5

Browse files
committed
refactor(lint): extract spec urls exceptions
Exclude it in CODEOWNERS file.
1 parent 2fac7da commit 02c74a5

4 files changed

Lines changed: 68 additions & 48 deletions

File tree

.github/CODEOWNERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@
2020

2121
# Exclude some paths
2222
/.github/ISSUE_TEMPLATE/
23-
/.github/PULL_REQUESET_TEMPLATE.md
23+
/.github/PULL_REQUEST_TEMPLATE.md
24+
/lint/common/spec-urls-exceptions.txt
25+
/lint/common/standard-track-exceptions.txt
2426
/*.md
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { readFile } 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(__dirname, './spec-urls-exceptions.txt');
9+
10+
/**
11+
* @returns {Promise<string[]>}
12+
*/
13+
export const getSpecURLsExceptions = async () =>
14+
(await readFile(exceptionListPath, 'utf-8'))
15+
.split('\n')
16+
.map((line) => line.trim())
17+
.filter((line) => line.length > 0 && !line.startsWith('#'));
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This file lists spec URLs that are accepted by the spec_url linter
2+
# even though they are not in https://github.com/w3c/browser-specs.
3+
#
4+
# Before adding an exception, open an issue with https://github.com/w3c/browser-specs to
5+
# see if a spec should be added there instead.
6+
# When adding an exception here, provide a reason and indicate how the exception can be removed.
7+
8+
# Remove once https://github.com/whatwg/html/pull/6715 is resolved.
9+
https://wicg.github.io/controls-list/
10+
11+
# Unfortunately this doesn't produce a rendered spec, so it isn't in browser-specs.
12+
# Remove if it is in the main ECMA spec.
13+
https://github.com/tc39/proposal-regexp-legacy-features/
14+
15+
# See https://github.com/w3c/browser-specs/issues/305.
16+
# Features with this URL need to be checked after some time
17+
# if they have been integrated into a real spec.
18+
https://w3c.github.io/webrtc-extensions/
19+
20+
# This is being used to develop Error.captureStackTrace() standard.
21+
# Need to be checked after some time to see if integrated into a real spec.
22+
https://github.com/tc39/proposal-error-capturestacktrace
23+
24+
# Proposals for WebAssembly.
25+
https://github.com/WebAssembly/spec/blob/main/proposals
26+
https://github.com/WebAssembly/exception-handling/blob/main/proposals
27+
https://github.com/WebAssembly/extended-const/blob/main/proposals
28+
https://github.com/WebAssembly/tail-call/blob/main/proposals
29+
https://github.com/WebAssembly/threads/blob/main/proposal
30+
https://github.com/WebAssembly/relaxed-simd/blob/main/proposals
31+
https://github.com/WebAssembly/multi-memory/blob/main/proposals
32+
https://github.com/WebAssembly/memory64/blob/main/proposals/memory64/Overview.md
33+
https://github.com/WebAssembly/js-string-builtins/blob/main/proposals/js-string-builtins/Overview.md
34+
https://github.com/WebAssembly/function-references/blob/main/proposals/function-references/Overview.md
35+
https://github.com/WebAssembly/js-promise-integration
36+
https://github.com/WebAssembly/branch-hinting/blob/main/proposals/branch-hinting/Overview.md
37+
38+
# Media types.
39+
https://developers.google.com/speed/webp/docs/riff_container
40+
https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification
41+
https://jpeg.org/jpeg/
42+
https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
43+
https://www.iso.org/standard/89035.html
44+
https://www.rfc-editor.org/rfc/rfc7903
45+
https://www.w3.org/Graphics/GIF/spec-gif87.txt

lint/linter/test-spec-urls.js

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,12 @@ import { styleText } from 'node:util';
55

66
import specData from 'web-specs' with { type: 'json' };
77

8+
import { getSpecURLsExceptions } from '../common/spec-urls-exceptions.js';
9+
810
/** @import {Linter, LinterData} from '../types.js' */
911
/** @import {Logger} from '../utils.js' */
1012
/** @import {CompatStatement} from '../../types/types.js' */
1113

12-
/*
13-
* Before adding an exception, open an issue with https://github.com/w3c/browser-specs to
14-
* see if a spec should be added there instead.
15-
* When adding an exception here, provide a reason and indicate how the exception can be removed.
16-
*/
17-
const specsExceptions = [
18-
// Remove once https://github.com/whatwg/html/pull/6715 is resolved
19-
'https://wicg.github.io/controls-list/',
20-
21-
// Unfortunately this doesn't produce a rendered spec, so it isn't in browser-specs
22-
// Remove if it is in the main ECMA spec
23-
'https://github.com/tc39/proposal-regexp-legacy-features/',
24-
25-
// See https://github.com/w3c/browser-specs/issues/305
26-
// Features with this URL need to be checked after some time
27-
// if they have been integrated into a real spec
28-
'https://w3c.github.io/webrtc-extensions/',
29-
30-
// This is being used to develop Error.captureStackTrace() standard
31-
// Need to be checked after some time to see if integrated into a real spec
32-
'https://github.com/tc39/proposal-error-capturestacktrace',
33-
34-
// Proposals for WebAssembly
35-
'https://github.com/WebAssembly/spec/blob/main/proposals',
36-
'https://github.com/WebAssembly/exception-handling/blob/main/proposals',
37-
'https://github.com/WebAssembly/extended-const/blob/main/proposals',
38-
'https://github.com/WebAssembly/tail-call/blob/main/proposals',
39-
'https://github.com/WebAssembly/threads/blob/main/proposal',
40-
'https://github.com/WebAssembly/relaxed-simd/blob/main/proposals',
41-
'https://github.com/WebAssembly/multi-memory/blob/main/proposals',
42-
'https://github.com/WebAssembly/memory64/blob/main/proposals/memory64/Overview.md',
43-
'https://github.com/WebAssembly/js-string-builtins/blob/main/proposals/js-string-builtins/Overview.md',
44-
'https://github.com/WebAssembly/function-references/blob/main/proposals/function-references/Overview.md',
45-
'https://github.com/WebAssembly/js-promise-integration',
46-
'https://github.com/WebAssembly/branch-hinting/blob/main/proposals/branch-hinting/Overview.md',
47-
48-
// Media types
49-
'https://developers.google.com/speed/webp/docs/riff_container',
50-
'https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification',
51-
'https://jpeg.org/jpeg/',
52-
'https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/',
53-
'https://www.iso.org/standard/89035.html',
54-
'https://www.rfc-editor.org/rfc/rfc7903',
55-
'https://www.w3.org/Graphics/GIF/spec-gif87.txt',
56-
];
57-
5814
const allowedSpecURLs = [
5915
.../** @type {string[]} */ (
6016
specData
@@ -68,7 +24,7 @@ const allowedSpecURLs = [
6824
.flat()
6925
.filter((url) => !!url)
7026
),
71-
...specsExceptions,
27+
...(await getSpecURLsExceptions()),
7228
];
7329

7430
/**

0 commit comments

Comments
 (0)