mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
ci: add lint for expectations (#11365)
This commit is contained in:
parent
915eb7ff4e
commit
02d62be58e
@ -20,6 +20,7 @@
|
||||
"lint": "run-s lint:*",
|
||||
"lint:eslint": "([ \"$CI\" = true ] && eslint --ext js --ext ts --quiet . || eslint --ext js --ext ts .)",
|
||||
"lint:prettier": "prettier --check .",
|
||||
"lint:expectations": "node tools/sort-test-expectations.js --lint",
|
||||
"postinstall": "npm run postinstall --workspaces --if-present",
|
||||
"prepare": "npm run prepare --workspaces --if-present",
|
||||
"test": "wireit",
|
||||
|
@ -25,6 +25,8 @@ const source = 'test/TestExpectations.json';
|
||||
|
||||
const testExpectations = JSON.parse(fs.readFileSync(source, 'utf-8'));
|
||||
|
||||
const commitedExpectations = structuredClone(testExpectations);
|
||||
|
||||
function getSpecificity(item) {
|
||||
return (
|
||||
item.parameters.length +
|
||||
@ -50,6 +52,16 @@ testExpectations.forEach(item => {
|
||||
item.platforms.sort();
|
||||
});
|
||||
|
||||
if (process.argv.includes('--lint')) {
|
||||
if (
|
||||
JSON.stringify(commitedExpectations) !== JSON.stringify(testExpectations)
|
||||
) {
|
||||
console.error(
|
||||
`${source} is not formatted properly. Run 'npm run format:expectations'.`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
fs.writeFileSync(
|
||||
source,
|
||||
prettier.format(JSON.stringify(testExpectations), {
|
||||
@ -57,3 +69,4 @@ fs.writeFileSync(
|
||||
parser: 'json',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user