chore: update tooling (#11388)

This commit is contained in:
Nikolay Vitkov 2023-11-14 13:07:24 +01:00 committed by GitHub
parent aeae19192a
commit 52263f7241
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View File

@ -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",

View File

@ -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',
})
);