mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: update tooling (#11388)
This commit is contained in:
parent
aeae19192a
commit
52263f7241
@ -15,12 +15,12 @@
|
||||
"doctest": "wireit",
|
||||
"format": "run-s format:*",
|
||||
"format:eslint": "eslint --ext js --ext ts --fix .",
|
||||
"format:expectations": "node tools/sort-test-expectations.js",
|
||||
"format:expectations": "node tools/sort-test-expectations.mjs",
|
||||
"format:prettier": "prettier --write .",
|
||||
"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",
|
||||
"lint:expectations": "node tools/sort-test-expectations.mjs --lint",
|
||||
"postinstall": "npm run postinstall --workspaces --if-present",
|
||||
"prepare": "npm run prepare --workspaces --if-present",
|
||||
"test": "wireit",
|
||||
|
@ -15,17 +15,20 @@
|
||||
*/
|
||||
|
||||
// TODO: this could be an eslint rule probably.
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import url from 'url';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const prettier = require('@prettier/sync');
|
||||
import prettier from 'prettier';
|
||||
|
||||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
||||
const source = 'test/TestExpectations.json';
|
||||
|
||||
const testExpectations = JSON.parse(fs.readFileSync(source, 'utf-8'));
|
||||
const committedExpectations = structuredClone(testExpectations);
|
||||
|
||||
const commitedExpectations = structuredClone(testExpectations);
|
||||
const prettierConfig = await import(
|
||||
path.join(__dirname, '..', '.prettierrc.cjs')
|
||||
);
|
||||
|
||||
function getSpecificity(item) {
|
||||
return (
|
||||
@ -54,7 +57,7 @@ testExpectations.forEach(item => {
|
||||
|
||||
if (process.argv.includes('--lint')) {
|
||||
if (
|
||||
JSON.stringify(commitedExpectations) !== JSON.stringify(testExpectations)
|
||||
JSON.stringify(committedExpectations) !== JSON.stringify(testExpectations)
|
||||
) {
|
||||
console.error(
|
||||
`${source} is not formatted properly. Run 'npm run format:expectations'.`
|
||||
@ -64,8 +67,8 @@ if (process.argv.includes('--lint')) {
|
||||
} else {
|
||||
fs.writeFileSync(
|
||||
source,
|
||||
prettier.format(JSON.stringify(testExpectations), {
|
||||
...require(path.join(__dirname, '..', '.prettierrc.cjs')),
|
||||
await prettier.format(JSON.stringify(testExpectations), {
|
||||
...prettierConfig,
|
||||
parser: 'json',
|
||||
})
|
||||
);
|
Loading…
Reference in New Issue
Block a user