Skip to content

Commit a3d8487

Browse files
ddbeckfoolipcaptainbrossetLeoMcARumyra
authored
Embellish discouraged data with more detail (#3193)
Co-authored-by: Philip Jägenstedt <philip@foolip.org> Co-authored-by: captainbrosset <1152698+captainbrosset@users.noreply.github.com> Co-authored-by: LeoMcA <755354+LeoMcA@users.noreply.github.com> Co-authored-by: Rumyra <302715+Rumyra@users.noreply.github.com>
1 parent 6cd54e4 commit a3d8487

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+138
-24
lines changed

assertions.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { isOrdinaryFeatureData } from "./type-guards";
2+
import { FeatureData } from "./types";
23
import { WebFeaturesData } from "./types.quicktype";
34

45
/**
@@ -26,4 +27,35 @@ export function assertValidFeatureReference(
2627
}
2728
}
2829

30+
/**
31+
* Assert that a discouraged feature with no supporting browsers has a
32+
* `removal_date`.
33+
*
34+
* @export
35+
* @param {string} id The ID of the feature to be checked
36+
* @param {FeatureData} feature The ordinary feature data to be checked
37+
*/
38+
export function assertRequiredRemovalDateSet(
39+
id: string,
40+
feature: FeatureData,
41+
): void {
42+
if (!feature.discouraged) {
43+
return;
44+
}
45+
if (feature.discouraged.removal_date) {
46+
return;
47+
}
48+
if (Object.keys(feature.status.support).length > 0) {
49+
return;
50+
}
51+
if (
52+
feature.compat_features &&
53+
Object.keys(feature.status.by_compat_key).length > 0
54+
)
55+
return;
56+
throw new Error(
57+
`${id} is discouraged and has no reported support, so a removal date is required`,
58+
);
59+
}
60+
2961
// TODO: assertValidSnapshotReference

features/accessor-methods.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description: The `__defineGetter__()` and `__defineSetter__()` methods of object
33
spec: https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.prototype-legacy-accessor-methods
44
group: javascript
55
discouraged:
6+
reason: TC39 included accessor methods in Annex B of the ECMAScript specification, which covers JavaScript features with "one or more undesirable characteristics and in the absence of legacy usage would be removed."
67
according_to:
78
- https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-additional-ecmascript-features-for-web-browsers
89
# No `alternatives` because it would be `alternatives:

features/arguments-callee.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ discouraged:
66
# From note 4: "The definition of this property […] exists to ensure that it
77
# is not defined in any other manner by conforming ECMAScript
88
# implementations."
9+
reason: JavaScript strict mode prohibits accessing `arguments.callee`.
910
according_to:
1011
- https://tc39.es/ecma262/multipage/ordinary-and-exotic-objects-behaviours.html#sec-arguments-exotic-objects
1112
compat_features:

features/clip.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description: The `clip` CSS property sets the visible area of an absolutely posi
33
spec: https://drafts.fxtf.org/css-masking-1/#clip-property
44
group: clipping-shapes-masking
55
discouraged:
6+
reason: The CSS Masking specification deprecated the `clip` property.
67
according_to:
78
- https://drafts.fxtf.org/css-masking-1/#clip-property
89
alternatives:

features/color-adjust.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description: The `color-adjust` shorthand CSS property allows multiple performan
33
spec: https://drafts.csswg.org/css-color-adjust-1/#color-adjust
44
group: print
55
discouraged:
6+
reason: The CSS Color Adjustment specification described the `color-adjust` as deprecated, to prevent authors from accidentally resetting color adjustments in unexpected contexts.
67
according_to:
78
- https://drafts.csswg.org/css-color-adjust-1/#color-adjust
89
alternatives:

features/color-contrast.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ description: "The `color-contrast()` CSS function picks a color from a list that
33
spec: https://drafts.csswg.org/css-color-5/#contrast-color
44
group: color-types
55
discouraged:
6+
reason: The CSS Color specification renamed `color-contrast()` to `contrast-color()`.
67
# See these CSSWG discussions
78
# https://github.com/w3c/csswg-drafts/issues/7557
89
# https://github.com/w3c/csswg-drafts/issues/7359
10+
removal_date: 2022-10-19
911
according_to:
1012
- https://github.com/w3c/csswg-drafts/issues/7557
1113
- https://github.com/w3c/csswg-drafts/commit/36594e9e8496a5ca83f1f1ee2b4a83bcdf28753b

features/css-object-model-discouraged.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description: The DOM level 2 style specification defined interfaces to access an
33
spec: https://www.w3.org/TR/DOM-Level-2-Style/
44
group: cssom
55
discouraged:
6+
reason: The DOM level 2 CSS object model was excluded from the later CSS object model (CSSOM) specification.
67
according_to:
78
- https://www.w3.org/TR/DOM-Level-2-Style/#Overview-status
89
alternatives:

features/date-get-year-set-year.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description: The `getYear()` and `setYear()` methods of `Date` objects get and s
33
spec: https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-date.prototype.getyear
44
group: javascript
55
discouraged:
6+
reason: The `getYear()` and `setYear()` methods use a truncated number instead of the actual year number, known as a year 2000 problem.
67
according_to:
78
- https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-additional-ecmascript-features-for-web-browsers
89
# No `alternatives` because it would be `alternatives: [date]`. In the future

features/date-to-gmt-string.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ description: The `toGMTString()` method of `Date` objects is an alias to the `to
33
spec: https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-date.prototype.togmtstring
44
group: javascript
55
discouraged:
6+
reason: The method exists "principally for compatibility with old code."
67
according_to:
78
- https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-additional-ecmascript-features-for-web-browsers
9+
- https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-date.prototype.togmtstring
810
# No `alternatives` because it would be `alternatives: [date]`. In the future
911
# it'd be nice to have an internal reference to the `toUTCString()` method
1012
# instead.

features/device-queries.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description: The `device-aspect-ratio`, `device-height`, and `device-width` medi
33
spec: https://drafts.csswg.org/mediaqueries-5/#mf-deprecated
44
group: media-queries
55
discouraged:
6+
reason: Device media queries do not reflect available layout, only the physical size of the device.
67
according_to:
78
- https://drafts.csswg.org/mediaqueries-5/#mf-deprecated
89
alternatives:

0 commit comments

Comments
 (0)