Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@markuplint/html-spec

Package Overview
Dependencies
Maintainers
1
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markuplint/html-spec - npm Package Compare versions

Comparing version 2.7.0 to 3.0.0-alpha.66

src/spec-common.attributes.json

12

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc