mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Switches all samples to use eslint 9 with flat configs. I've tried to migrate existing settings as much as possible. However our eslint configs were also inconsistent so I've tried to align these too
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
// @ts-check
|
|
const path = require('path');
|
|
|
|
const { samples, lspSamples } = require('./samples');
|
|
const fs = require('fs');
|
|
|
|
const root = path.join(__dirname, '..');
|
|
|
|
/**
|
|
* Validates that all samples are correctly listed in `.scripts/samples.js`.
|
|
*/
|
|
function validateSamplesAreListed() {
|
|
const allSamples = samples.concat(lspSamples);
|
|
|
|
const samplesByPath = new Map();
|
|
for (const sample of allSamples) {
|
|
samplesByPath.set(sample.path, sample);
|
|
}
|
|
|
|
for (const fileName of fs.readdirSync(root)) {
|
|
if (fileName === 'node_modules'
|
|
|| fileName.startsWith('.')
|
|
|| !fs.lstatSync(path.join(root, fileName)).isDirectory()
|
|
) {
|
|
continue;
|
|
}
|
|
|
|
const sampleEntry = samplesByPath.get(fileName);
|
|
if (!sampleEntry) {
|
|
throw new Error(`Sample '${fileName}' is not listed in samples.js`);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Validates that all samples are correctly listed in `.scripts/samples.js`.
|
|
*/
|
|
function validateReadmeUpdated() {
|
|
const { updateReadme } = require('./update-readme');
|
|
if (updateReadme(true)) {
|
|
throw new Error(`Readme not updated. Run 'node .scripts/update-readme.js' to update the readme.`);
|
|
}
|
|
}
|
|
|
|
validateSamplesAreListed();
|
|
validateReadmeUpdated(); |