mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-22 03:57:47 -04:00
lint: reenable json schema checks
This commit is contained in:
parent
323daf29b1
commit
6700c2c116
@ -83,25 +83,24 @@ export default withNuxt(
|
||||
},
|
||||
},
|
||||
eslintPluginJsonSchemaValidator.configs['flat/base'],
|
||||
// ! JSON Schema generation fails and causes ESLint to crash
|
||||
// {
|
||||
// name: 'pronouns-page/validation',
|
||||
// files: ['locale/**/*.suml'],
|
||||
// rules: {
|
||||
// 'json-schema-validator/no-invalid': ['error', {
|
||||
// schemas: [
|
||||
// {
|
||||
// fileMatch: ['locale/*/config.suml'],
|
||||
// schema: 'locale/config.schema.json',
|
||||
// },
|
||||
// {
|
||||
// fileMatch: ['locale/*/nouns/nounsData.suml'],
|
||||
// schema: 'locale/nounsData.schema.json',
|
||||
// },
|
||||
// ],
|
||||
// }],
|
||||
// },
|
||||
// },
|
||||
{
|
||||
name: 'pronouns-page/validation',
|
||||
files: ['locale/**/*.suml'],
|
||||
rules: {
|
||||
'json-schema-validator/no-invalid': ['error', {
|
||||
schemas: [
|
||||
{
|
||||
fileMatch: ['locale/*/config.suml'],
|
||||
schema: 'locale/config.schema.json',
|
||||
},
|
||||
{
|
||||
fileMatch: ['locale/*/nouns/nounsData.suml'],
|
||||
schema: 'locale/nounsData.schema.json',
|
||||
},
|
||||
],
|
||||
}],
|
||||
},
|
||||
},
|
||||
)
|
||||
.override('nuxt/javascript', {
|
||||
rules: {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import fs from 'fs/promises';
|
||||
|
||||
// import { createGenerator } from 'ts-json-schema-generator';
|
||||
import { createGenerator } from 'ts-json-schema-generator';
|
||||
|
||||
import type { Config } from '~~/locale/config.ts';
|
||||
import localeDescriptions from '~~/locale/locales.ts';
|
||||
@ -8,21 +8,20 @@ import { loadSuml } from '~~/server/loader.ts';
|
||||
|
||||
const __dirname = new URL('.', import.meta.url).pathname;
|
||||
|
||||
// const generateJsonSchema = async (path: string, typeName: string) => {
|
||||
// const schema = createGenerator({
|
||||
// path,
|
||||
// tsconfig: `${__dirname}/../.nuxt/tsconfig.node.json`,
|
||||
// strictTuples: true,
|
||||
// markdownDescription: true,
|
||||
// // speed up schema generation; type checking happens separately
|
||||
// skipTypeCheck: true,
|
||||
// }).createSchema(typeName);
|
||||
|
||||
// await fs.writeFile(
|
||||
// `${__dirname}/${typeName[0].toLowerCase()}${typeName.substring(1)}.schema.json`,
|
||||
// `${JSON.stringify(schema, null, 4)}\n`,
|
||||
// );
|
||||
// };
|
||||
const generateJsonSchema = async (path: string, typeName: string) => {
|
||||
const schema = createGenerator({
|
||||
path,
|
||||
tsconfig: `${__dirname}/../.nuxt/tsconfig.node.json`,
|
||||
strictTuples: true,
|
||||
markdownDescription: true,
|
||||
// speed up schema generation; type checking happens separately
|
||||
skipTypeCheck: true,
|
||||
}).createSchema(typeName);
|
||||
await fs.writeFile(
|
||||
`${__dirname}/${typeName[0].toLowerCase()}${typeName.substring(1)}.schema.json`,
|
||||
`${JSON.stringify(schema, null, 4)}\n`,
|
||||
);
|
||||
};
|
||||
|
||||
const generateFontsModule = async () => {
|
||||
const configByLocale = Object.fromEntries(await Promise.all(localeDescriptions.map(async (locale) => {
|
||||
@ -39,8 +38,7 @@ const generateFontsModule = async () => {
|
||||
};
|
||||
|
||||
await Promise.all([
|
||||
// ! throws errors
|
||||
// generateJsonSchema(`${__dirname}/config.ts`, 'Config'),
|
||||
// generateJsonSchema(`${__dirname}/../src/nouns.ts`, 'NounsData'),
|
||||
generateJsonSchema(`${__dirname}/config.ts`, 'Config'),
|
||||
generateJsonSchema(`${__dirname}/../src/nouns.ts`, 'NounsData'),
|
||||
generateFontsModule(),
|
||||
]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user