New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@markuplint/types

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markuplint/types - npm Package Compare versions

Comparing version 1.0.0-dev.20211213.0 to 1.0.0-dev.20211213.1

14

lib/check.spec.js

@@ -44,3 +44,3 @@ "use strict";

});
test('Srcset', () => {
test('IconSize', () => {
expect((0, check_1.check)('any', 'IconSize').matched).toBe(true);

@@ -59,1 +59,13 @@ expect((0, check_1.check)('Any', 'IconSize').matched).toBe(true);

});
test('Non-exist types', () => {
// @ts-ignore
expect((0, check_1.check)('abc', 'String').matched).toBe(true);
// @ts-ignore
expect((0, check_1.check)('abc', 'FooBar').matched).toBe(true);
// @ts-ignore
expect((0, check_1.check)('abc', ' ').matched).toBe(true);
// @ts-ignore
expect((0, check_1.check)('abc', '\n').matched).toBe(true);
// @ts-ignore
expect((0, check_1.check)('abc', '').matched).toBe(true);
});

@@ -17,2 +17,3 @@ "use strict";

function cssSyntaxMatch(value, type) {
(0, debug_1.log)('Search CSS Syntax: "%s"', type);
const origin = value;

@@ -127,2 +128,6 @@ let defName;

const matcher = isProp ? lexer.properties[name] : lexer.types[name];
if (!matcher) {
(0, debug_1.log)('"%s" CSS syntax not found', def);
throw new Error('MARKUPLINT_TYPE_NO_EXIST');
}
return {

@@ -129,0 +134,0 @@ isProp,

14

lib/defs.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tokenizers = exports.types = void 0;
const check_multi_types_1 = require("./check-multi-types");
const get_candicate_1 = require("./get-candicate");

@@ -331,9 +332,8 @@ const match_result_1 = require("./match-result");

is(value) {
if (!(0, is_abs_url_1.isAbsURL)()(value)) {
return (0, match_result_1.unmatched)(value, 'unexpected-token');
}
if (!(0, is_itemprop_name_1.isItempropName)()(value)) {
return (0, match_result_1.unmatched)(value, 'unexpected-token');
}
return (0, match_result_1.matched)();
const _matched = (0, match_result_1.matched)();
const _unmatched = (0, match_result_1.unmatched)(value, 'unexpected-token');
return (0, check_multi_types_1.checkMultiTypes)(value, [
value => ((0, is_abs_url_1.isAbsURL)()(value) ? _matched : _unmatched),
value => ((0, is_itemprop_name_1.isItempropName)()(value) ? _matched : _unmatched),
]);
},

@@ -340,0 +340,0 @@ },

@@ -8,2 +8,3 @@ "use strict";

const defs_1 = require("./defs");
const match_result_1 = require("./match-result");
const resultCache = new Map();

@@ -36,13 +37,23 @@ const CACHE_KEY_PREFIX = '@markuplint/types/checkKeywordType/cache:::';

if (!def) {
return (0, css_syntax_1.cssSyntaxMatch)(value, type);
(0, debug_1.log)('The "%s" type is not defined in custom type identifier markuplint specified', type);
try {
return (0, css_syntax_1.cssSyntaxMatch)(value, type);
}
catch (e) {
if (e instanceof Error && e.message === 'MARKUPLINT_TYPE_NO_EXIST') {
(0, debug_1.log)("Allow all of any value because the type doesn't exist");
return (0, match_result_1.matched)();
}
throw e;
}
}
const matched = (0, check_1.isCSSSyntax)(def) ? (0, css_syntax_1.cssSyntaxMatch)(value, def) : def.is(value);
if (!matched.matched) {
const matches = (0, check_1.isCSSSyntax)(def) ? (0, css_syntax_1.cssSyntaxMatch)(value, def) : def.is(value);
if (!matches.matched) {
return {
...matched,
ref: matched.ref || def.ref,
expects: matched.expects || def.expects,
...matches,
ref: matches.ref || def.ref,
expects: matches.expects || def.expects,
};
}
return matched;
return matches;
}
{
"name": "@markuplint/types",
"version": "1.0.0-dev.20211213.0",
"version": "1.0.0-dev.20211213.1",
"description": "Types of attributes and properties and more",

@@ -32,3 +32,3 @@ "repository": "git@github.com:markuplint/markuplint.git",

},
"gitHead": "8f4682ca3e0937082af8c39b999443afa4a1aef3"
"gitHead": "862b6312e54dc2cedc551ba86d10027adc25d3a5"
}

@@ -49,3 +49,3 @@ import { check } from './check';

test('Srcset', () => {
test('IconSize', () => {
expect(check('any', 'IconSize').matched).toBe(true);

@@ -64,1 +64,14 @@ expect(check('Any', 'IconSize').matched).toBe(true);

});
test('Non-exist types', () => {
// @ts-ignore
expect(check('abc', 'String').matched).toBe(true);
// @ts-ignore
expect(check('abc', 'FooBar').matched).toBe(true);
// @ts-ignore
expect(check('abc', ' ').matched).toBe(true);
// @ts-ignore
expect(check('abc', '\n').matched).toBe(true);
// @ts-ignore
expect(check('abc', '').matched).toBe(true);
});

@@ -35,2 +35,4 @@ import type { CustomCssSyntax, CssSyntaxTokenizer, CSSSyntaxToken, GetNextToken, Result, CssSyntax } from './types';

export function cssSyntaxMatch(value: string, type: CssSyntax | CustomCssSyntax): Result {
log('Search CSS Syntax: "%s"', type);
const origin = value;

@@ -160,2 +162,6 @@ let defName: `<${string}>`;

const matcher = isProp ? lexer.properties[name] : lexer.types[name];
if (!matcher) {
log('"%s" CSS syntax not found', def);
throw new Error('MARKUPLINT_TYPE_NO_EXIST');
}
return {

@@ -162,0 +168,0 @@ isProp,

import type { Defs, CssSyntaxTokenizer } from './types';
import { checkMultiTypes } from './check-multi-types';
import { getCandicate } from './get-candicate';

@@ -354,9 +355,8 @@ import { matched, matches, unmatched } from './match-result';

is(value) {
if (!isAbsURL()(value)) {
return unmatched(value, 'unexpected-token');
}
if (!isItempropName()(value)) {
return unmatched(value, 'unexpected-token');
}
return matched();
const _matched = matched();
const _unmatched = unmatched(value, 'unexpected-token');
return checkMultiTypes(value, [
value => (isAbsURL()(value) ? _matched : _unmatched),
value => (isItempropName()(value) ? _matched : _unmatched),
]);
},

@@ -363,0 +363,0 @@ },

@@ -8,2 +8,3 @@ import type { Result } from './types';

import { types } from './defs';
import { matched } from './match-result';

@@ -40,15 +41,24 @@ const resultCache = new Map<string, Result>();

if (!def) {
return cssSyntaxMatch(value, type as CssSyntax);
log('The "%s" type is not defined in custom type identifier markuplint specified', type);
try {
return cssSyntaxMatch(value, type as CssSyntax);
} catch (e) {
if (e instanceof Error && e.message === 'MARKUPLINT_TYPE_NO_EXIST') {
log("Allow all of any value because the type doesn't exist");
return matched();
}
throw e;
}
}
const matched = isCSSSyntax(def) ? cssSyntaxMatch(value, def) : def.is(value);
const matches = isCSSSyntax(def) ? cssSyntaxMatch(value, def) : def.is(value);
if (!matched.matched) {
if (!matches.matched) {
return {
...matched,
ref: matched.ref || def.ref,
expects: matched.expects || def.expects,
...matches,
ref: matches.ref || def.ref,
expects: matches.expects || def.expects,
};
}
return matched;
return matches;
}

Sorry, the diff of this file is not supported yet

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