@markuplint/html-spec
Advanced tools
Comparing version 2.7.0 to 3.0.0-alpha.66
{ | ||
"name": "@markuplint/html-spec", | ||
"version": "2.7.0", | ||
"version": "3.0.0-alpha.66+6cde1134", | ||
"description": "A specification of HTML Living Standard for markuplint", | ||
@@ -18,16 +18,16 @@ "repository": "git@github.com:markuplint/markuplint.git", | ||
"devDependencies": { | ||
"@apidevtools/json-schema-ref-parser": "^9.0.9", | ||
"@types/cheerio": "^0.22.31", | ||
"@types/cli-progress": "^3.9.2", | ||
"@types/node-fetch": "2", | ||
"ajv": "^8.11.0", | ||
"cheerio": "^1.0.0-rc.10", | ||
"cli-progress": "^3.10.0", | ||
"fast-xml-parser": "^4.0.7", | ||
"jsonschema": "^1.4.0", | ||
"node-fetch": "2" | ||
"node-fetch": "2", | ||
"strip-json-comments": "3" | ||
}, | ||
"dependencies": { | ||
"@markuplint/ml-spec": "2.1.0" | ||
"@markuplint/ml-spec": "3.0.0-alpha.82+6cde1134" | ||
}, | ||
"gitHead": "0c774ce046ebc8a9c494e9884a4bfcd72a66250d" | ||
"gitHead": "6cde113402758a8fdbd6a0fcf98e78efd2cdb778" | ||
} |
@@ -0,13 +1,43 @@ | ||
import { readFile } from 'fs/promises'; | ||
import path from 'path'; | ||
import $RefParser from '@apidevtools/json-schema-ref-parser'; | ||
import { getAttrSpecs } from '@markuplint/ml-spec'; | ||
import { resolveNamespace } from '@markuplint/ml-spec'; | ||
import { getAttrSpecs } from '@markuplint/ml-spec/lib/specs/get-attr-specs'; | ||
import Ajv, { type ValidateFunction } from 'ajv'; | ||
import { sync as glob } from 'glob'; | ||
import { Validator } from 'jsonschema'; | ||
import strip from 'strip-json-comments'; | ||
import htmlSpec, { specs } from '../index'; | ||
const schemas = { | ||
element: { | ||
$id: '@markuplint/ml-spec/schemas/element.schema.json', | ||
...require('../../ml-spec/schemas/element.schema.json'), | ||
}, | ||
aria: { | ||
$id: '@markuplint/ml-spec/schemas/aria.schema.json', | ||
...require('../../ml-spec/schemas/aria.schema.json'), | ||
}, | ||
contentModels: { | ||
$id: '@markuplint/ml-spec/schemas/content-models.schema.json', | ||
...require('../../ml-spec/schemas/content-models.schema.json'), | ||
}, | ||
globalAttributes: { | ||
$id: '@markuplint/ml-spec/schemas/global-attributes.schema.json', | ||
...require('../../ml-spec/schemas/global-attributes.schema.json'), | ||
}, | ||
attributes: { | ||
$id: '@markuplint/ml-spec/schemas/attributes.schema.json', | ||
...require('../../ml-spec/schemas/attributes.schema.json'), | ||
}, | ||
types: { | ||
$id: '@markuplint/types/types.schema.json', | ||
...require('../../types/types.schema.json'), | ||
}, | ||
}; | ||
test('structure', () => { | ||
specs.forEach(el => { | ||
getAttrSpecs(el.name, htmlSpec); | ||
const { localName, namespaceURI } = resolveNamespace(el.name); | ||
getAttrSpecs(localName, namespaceURI, htmlSpec); | ||
}); | ||
@@ -17,46 +47,36 @@ }); | ||
describe('schema', () => { | ||
const map = [ | ||
const map: [name: string, validator: ValidateFunction, targetFiles: string][] = [ | ||
[ | ||
'permitted-structures', | ||
path.resolve(__dirname, '../../ml-spec/schemas/permitted-structures.schema.json'), | ||
path.resolve(__dirname, 'permitted-structures'), | ||
'spec.*.json', | ||
new Ajv({ | ||
schemas: [ | ||
schemas.element, | ||
schemas.aria, | ||
schemas.contentModels, | ||
schemas.globalAttributes, | ||
schemas.attributes, | ||
schemas.types, | ||
], | ||
}).getSchema(schemas.element.$id)!, | ||
path.resolve(__dirname, 'spec.*.json'), | ||
], | ||
// [ | ||
// 'attributes', | ||
// path.resolve(__dirname, '../../ml-spec/schemas/attributes.schema.json'), | ||
// path.resolve(__dirname, 'attributes'), | ||
// ], | ||
[ | ||
'global-attributes', | ||
path.resolve(__dirname, '../../ml-spec/schemas/global-attributes.schema.json'), | ||
path.resolve(__dirname, 'global-attributes'), | ||
'spec-common.attributes.json', | ||
new Ajv({ | ||
schemas: [schemas.globalAttributes, schemas.attributes, schemas.types], | ||
}).getSchema(schemas.globalAttributes.$id)!, | ||
path.resolve(__dirname, 'spec-common.attributes.json'), | ||
], | ||
[ | ||
'aria-in-html', | ||
path.resolve(__dirname, '../../ml-spec/schemas/wai-aria.schema.json'), | ||
path.resolve(__dirname, 'aria-in-html'), | ||
], | ||
]; | ||
for (const [testName, schamaPath, targetDir] of map) { | ||
for (const [testName, validator, targetFiles] of map) { | ||
test(testName, async () => { | ||
const schema = await $RefParser.bundle(schamaPath); | ||
const validator = new Validator(); | ||
const attributes = glob(path.resolve(targetDir, '*.json')).map(attr => path.resolve(targetDir, attr)); | ||
attributes.forEach(jsonPath => { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const json = require(jsonPath); | ||
try { | ||
const res = validator.validate(json, schema as any); | ||
if (!res.valid) { | ||
// eslint-disable-next-line no-console | ||
console.warn(res); | ||
throw new SyntaxError(`Invalid JSON: ${jsonPath}`); | ||
} | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.log({ target: jsonPath, schema: schamaPath }); | ||
throw e; | ||
const files = glob(targetFiles); | ||
for (const jsonPath of files) { | ||
const json = JSON.parse(strip(await readFile(jsonPath, { encoding: 'utf-8' }))); | ||
const isValid = validator(json); | ||
if (!isValid) { | ||
throw new Error(`${path.basename(jsonPath)} is invalid (${validator.schemaEnv.baseId})`); | ||
} | ||
}); | ||
} | ||
expect(testName).toBe(testName); | ||
@@ -63,0 +83,0 @@ }); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1397905
50051
186
2
1
- Removed@markuplint/ml-spec@2.1.0(transitive)
- Removedtslib@2.8.1(transitive)