Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linter to make sure statuses have consistent inheritance #7351

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f79d586
Add linter to make sure deprecated statuses are consistent
saschanaz Nov 12, 2020
0968d49
rename to flag consistency
saschanaz Nov 12, 2020
92f1d88
rename as test-status
saschanaz Nov 13, 2020
05848f8
Merge branch 'main' into lint-deprecated
saschanaz Oct 2, 2021
4c6b198
Deprecate members of SVGGlyphRefElement
saschanaz Oct 2, 2021
73b0387
Merge branch 'main' into lint-deprecated
saschanaz Apr 20, 2022
d78125d
Merge remote-tracking branch 'upstream/main' into lint-deprecated
saschanaz Apr 21, 2022
2a5e2d8
Include `experimental` status check
saschanaz Apr 21, 2022
1ede23a
Revert data change
saschanaz Apr 21, 2022
fc8fa1e
Merge remote-tracking branch 'upstream/main' into lint-deprecated
saschanaz May 8, 2022
4a679c5
Merge remote-tracking branch 'upstream/main' into lint-deprecated
saschanaz May 16, 2022
c17c33e
Fix lint issue
saschanaz May 16, 2022
cb12d19
Merge remote-tracking branch 'upstream/main' into lint-deprecated
saschanaz May 21, 2022
b0cf7ef
Add standard_track support
saschanaz May 22, 2022
2fa5ad8
let deprecated win over experimental
saschanaz May 22, 2022
fb3de4e
Merge remote-tracking branch 'upstream/main' into lint-deprecated
saschanaz May 22, 2022
75f942f
Merge branch 'main' into lint-deprecated
saschanaz May 23, 2022
252e2ad
Merge remote-tracking branch 'upstream/main' into lint-deprecated
saschanaz May 23, 2022
b4d33f8
Merge branch 'main' into lint-deprecated
queengooborg May 25, 2022
58c018a
reformat
saschanaz May 25, 2022
2be7218
Merge branch 'main' into lint-deprecated
saschanaz Nov 24, 2022
b5ed287
Fix incorrect logic
saschanaz Nov 24, 2022
34301c9
Merge branch 'main' into lint-deprecated
saschanaz Nov 24, 2022
ec39eb2
Fix the only remaining failure
saschanaz Nov 24, 2022
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/CanvasRenderingContext2D.json
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@
}
},
"status": {
"experimental": true,
"experimental": false,
"standard_track": false,
"deprecated": true
}
Expand Down Expand Up @@ -1220,9 +1220,9 @@
}
},
"status": {
"experimental": true,
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/UIEvent.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"status": {
"experimental": false,
"standard_track": false,
"deprecated": true
"deprecated": false
saschanaz marked this conversation as resolved.
Show resolved Hide resolved
}
},
"implemented_on_event": {
Expand Down
2 changes: 1 addition & 1 deletion api/WorkerGlobalScope.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"status": {
"experimental": false,
"standard_track": false,
"deprecated": true
"deprecated": false
saschanaz marked this conversation as resolved.
Show resolved Hide resolved
}
},
"close_moved": {
Expand Down
2 changes: 1 addition & 1 deletion html/elements/script.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": true
"deprecated": false
saschanaz marked this conversation as resolved.
Show resolved Hide resolved
}
},
"module": {
Expand Down
6 changes: 3 additions & 3 deletions svg/elements/cursor.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
},
Expand Down Expand Up @@ -138,7 +138,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
},
Expand Down Expand Up @@ -233,7 +233,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions svg/elements/missing-glyph.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
},
Expand Down Expand Up @@ -138,7 +138,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
},
Expand Down Expand Up @@ -185,7 +185,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
},
Expand Down Expand Up @@ -232,7 +232,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
},
Expand Down Expand Up @@ -279,7 +279,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions svg/elements/vkern.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
},
Expand Down Expand Up @@ -138,7 +138,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
},
Expand Down Expand Up @@ -185,7 +185,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
},
Expand Down Expand Up @@ -232,7 +232,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
},
Expand Down Expand Up @@ -279,7 +279,7 @@
"status": {
"experimental": false,
"standard_track": true,
"deprecated": false
"deprecated": true
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion test/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const {
testVersions,
testConsistency,
testDescriptions,
testDeprecated,
} = require('./linter/index.js');
const { IS_CI } = require('./utils.js');
const testCompareFeatures = require('./test-compare-features');
Expand Down Expand Up @@ -63,7 +64,8 @@ function load(...files) {
hasConsistencyErrors = false,
hasRealValueErrors = false,
hasPrefixErrors = false,
hasDescriptionsErrors = false;
hasDescriptionsErrors = false,
hasDeprecatedErrors = false;
const relativeFilePath = path.relative(process.cwd(), file);

const spinner = ora({
Expand Down Expand Up @@ -103,6 +105,7 @@ function load(...files) {
hasRealValueErrors = testRealValues(file);
hasPrefixErrors = testPrefix(file);
hasDescriptionsErrors = testDescriptions(file);
hasDeprecatedErrors = testDeprecated(file);
}
} catch (e) {
hasSyntaxErrors = true;
Expand All @@ -120,6 +123,7 @@ function load(...files) {
hasRealValueErrors,
hasPrefixErrors,
hasDescriptionsErrors,
hasDeprecatedErrors,
].some(x => !!x);

if (fileHasErrors) {
Expand Down
2 changes: 2 additions & 0 deletions test/linter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const testStyle = require('./test-style.js');
const testVersions = require('./test-versions.js');
const testConsistency = require('./test-consistency.js');
const testDescriptions = require('./test-descriptions.js');
const testDeprecated = require('./test-deprecated.js');

module.exports = {
testBrowsers,
Expand All @@ -19,4 +20,5 @@ module.exports = {
testVersions,
testConsistency,
testDescriptions,
testDeprecated,
};
48 changes: 48 additions & 0 deletions test/linter/test-deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const chalk = require('chalk');
const { Logger } = require('./utils.js');

/**
* @typedef {import('../../types').Identifier} Identifier
*/

/**
* @param {Identifier} data
* @param {Logger} logger
* @param {boolean} isParentDeprecated,
* @param {string[]} path
*/
function checkStatus(data, logger, isParentDeprecated, path = []) {
const status = data.__compat && data.__compat.status;
const deprecated = status && status.deprecated;
if (!deprecated && isParentDeprecated) {
logger.error(
chalk`{red → Unexpected non-deprecated status while the parent is deprecated, in ${path.join(
'.',
)}}`,
);
}
for (const member in data) {
if (member === '__compat') {
continue;
}
checkStatus(data[member], logger, deprecated, [...path, member]);
}
}

/**
* @param {string} filename
* @returns {boolean} If the file contains errors
*/
function testDeprecated(filename) {
/** @type {Identifier} */
const data = require(filename);

const logger = new Logger('Deprecated');

checkStatus(data, logger, false);

logger.emit();
return logger.hasErrors();
}

module.exports = testDeprecated;