@markuplint/types 3.5.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import type { CustomSyntaxCheck, UnmatchedResult } from './types';
|
|
2
|
-
export declare function checkMultiTypes(
|
|
3
|
-
value: string,
|
|
4
|
-
checks: readonly CustomSyntaxCheck[],
|
|
5
|
-
): import('./types').MatchedResult | UnmatchedResult;
|
|
2
|
+
export declare function checkMultiTypes(value: string, checks: readonly CustomSyntaxCheck[]): UnmatchedResult | import("./types").MatchedResult;
|
package/lib/check.spec.js
CHANGED
|
@@ -75,3 +75,8 @@ test('Non-exist types', () => {
|
|
|
75
75
|
// @ts-ignore
|
|
76
76
|
expect((0, check_1.check)('abc', '').matched).toBe(true);
|
|
77
77
|
});
|
|
78
|
+
test('ItemProp', () => {
|
|
79
|
+
expect((0, check_1.check)('itemListElement', 'ItemProp').matched).toBe(true);
|
|
80
|
+
expect((0, check_1.check)('item', 'ItemProp').matched).toBe(true);
|
|
81
|
+
expect((0, check_1.check)('position', 'ItemProp').matched).toBe(true);
|
|
82
|
+
});
|
package/lib/match-result.d.ts
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
UnmatchedResultReason,
|
|
7
|
-
} from './types';
|
|
8
|
-
export declare function matches(
|
|
9
|
-
checker: FormattedPrimitiveTypeCheck,
|
|
10
|
-
options?: UnmatchedResultOptions & {
|
|
11
|
-
readonly ref?: string;
|
|
12
|
-
readonly reason?: UnmatchedResultReason;
|
|
13
|
-
},
|
|
14
|
-
): (value: string) => MatchedResult | UnmatchedResult;
|
|
1
|
+
import type { FormattedPrimitiveTypeCheck, MatchedResult, UnmatchedResult, UnmatchedResultOptions, UnmatchedResultReason } from './types';
|
|
2
|
+
export declare function matches(checker: FormattedPrimitiveTypeCheck, options?: UnmatchedResultOptions & {
|
|
3
|
+
readonly ref?: string;
|
|
4
|
+
readonly reason?: UnmatchedResultReason;
|
|
5
|
+
}): (value: string) => UnmatchedResult | MatchedResult;
|
|
15
6
|
export declare function matched(): MatchedResult;
|
|
16
|
-
export declare function unmatched(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
options?: UnmatchedResultOptions & {
|
|
20
|
-
readonly ref?: string;
|
|
21
|
-
},
|
|
22
|
-
): UnmatchedResult;
|
|
7
|
+
export declare function unmatched(value: string, reason?: UnmatchedResultReason, options?: UnmatchedResultOptions & {
|
|
8
|
+
readonly ref?: string;
|
|
9
|
+
}): UnmatchedResult;
|
|
@@ -3,75 +3,62 @@ import type { UnmatchedResult } from '..';
|
|
|
3
3
|
import type { Expect, Result, List } from '../types';
|
|
4
4
|
import type { ReadonlyDeep } from 'type-fest';
|
|
5
5
|
import { Token } from './token';
|
|
6
|
-
type TokenCollectionOptions = Partial<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
>;
|
|
6
|
+
type TokenCollectionOptions = Partial<Omit<List, 'token'> & {
|
|
7
|
+
specificSeparator: string | string[];
|
|
8
|
+
}>;
|
|
11
9
|
export type TokenEachCheck = (head: Readonly<Token> | null, tail: ReadonlyDeep<TokenCollection>) => Result | void;
|
|
12
10
|
export declare class TokenCollection extends Array<Token> {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
): {
|
|
66
|
-
unexpectedLastToken: boolean;
|
|
67
|
-
expectedTokenNumber: number | undefined;
|
|
68
|
-
token: Token;
|
|
69
|
-
} | null;
|
|
70
|
-
toJSON(): {
|
|
71
|
-
type: number;
|
|
72
|
-
value: string;
|
|
73
|
-
offset: number;
|
|
74
|
-
}[];
|
|
75
|
-
private static _new;
|
|
11
|
+
static fromPatterns(value: Readonly<Token> | string, patterns: readonly Readonly<RegExp>[], typeOptions?: ReadonlyDeep<Omit<TokenCollectionOptions, 'specificSeparator'> & {
|
|
12
|
+
repeat?: boolean;
|
|
13
|
+
}>): TokenCollection;
|
|
14
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
15
|
+
readonly allowEmpty: NonNullable<List['allowEmpty']>;
|
|
16
|
+
readonly caseInsensitive: NonNullable<List['caseInsensitive']>;
|
|
17
|
+
readonly disallowToSurroundBySpaces: NonNullable<List['disallowToSurroundBySpaces']>;
|
|
18
|
+
readonly number: List['number'];
|
|
19
|
+
readonly ordered: NonNullable<List['ordered']>;
|
|
20
|
+
readonly separator: NonNullable<List['separator']>;
|
|
21
|
+
readonly unique: NonNullable<List['unique']>;
|
|
22
|
+
constructor(value?: string, typeOptions?: ReadonlyDeep<TokenCollectionOptions>);
|
|
23
|
+
constructor(value?: number);
|
|
24
|
+
get value(): string;
|
|
25
|
+
check(options?: {
|
|
26
|
+
expects?: Expect[];
|
|
27
|
+
ref?: string;
|
|
28
|
+
cache?: boolean;
|
|
29
|
+
}): UnmatchedResult | import("..").MatchedResult;
|
|
30
|
+
chunk(split: number): TokenCollection[];
|
|
31
|
+
compareTokens(callback: (prev: Readonly<Token>, current: Readonly<Token>) => Readonly<Token> | null | void): Readonly<Token> | null | undefined;
|
|
32
|
+
divide(position: number): readonly [TokenCollection, TokenCollection];
|
|
33
|
+
eachCheck(...callbacks: readonly TokenEachCheck[]): Result;
|
|
34
|
+
filter(callback: Parameters<Array<Token>['filter']>[0]): TokenCollection;
|
|
35
|
+
getConsecutiveToken(tokenType: number): Readonly<Token> | null;
|
|
36
|
+
getDuplicated(): Token | null;
|
|
37
|
+
getIdentTokens(): TokenCollection;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param value The token value or the token type or its list
|
|
41
|
+
*/
|
|
42
|
+
has(value: TokenValue): boolean;
|
|
43
|
+
headAndTail(): {
|
|
44
|
+
head: Token | null;
|
|
45
|
+
tail: TokenCollection;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param value The token value or the token type or its list
|
|
50
|
+
*/
|
|
51
|
+
search(value: TokenValue): Token | null;
|
|
52
|
+
takeTurns(tokenNumbers: ReadonlyArray<number>, lastTokenNumber?: number): {
|
|
53
|
+
unexpectedLastToken: boolean;
|
|
54
|
+
expectedTokenNumber: number | undefined;
|
|
55
|
+
token: Token;
|
|
56
|
+
} | null;
|
|
57
|
+
toJSON(): {
|
|
58
|
+
type: number;
|
|
59
|
+
value: string;
|
|
60
|
+
offset: number;
|
|
61
|
+
}[];
|
|
62
|
+
private static _new;
|
|
76
63
|
}
|
|
77
64
|
export {};
|
package/lib/token/token.d.ts
CHANGED
|
@@ -1,61 +1,56 @@
|
|
|
1
1
|
import type { TokenValue } from './types';
|
|
2
2
|
import type { UnmatchedResult, UnmatchedResultOptions, UnmatchedResultReason } from '../types';
|
|
3
3
|
export declare class Token {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
options?: UnmatchedResultOptions & {
|
|
57
|
-
readonly ref?: string;
|
|
58
|
-
readonly reason?: UnmatchedResultReason;
|
|
59
|
-
},
|
|
60
|
-
): UnmatchedResult;
|
|
4
|
+
/**
|
|
5
|
+
* @see https://github.com/csstree/csstree/blob/master/lib/tokenizer/types.js
|
|
6
|
+
*/
|
|
7
|
+
static readonly Comma = 18;
|
|
8
|
+
static readonly Ident = 1;
|
|
9
|
+
static readonly WhiteSpace = 13;
|
|
10
|
+
/**
|
|
11
|
+
* ASCII whitespace is
|
|
12
|
+
* - U+0009 TAB
|
|
13
|
+
* - U+000A LF
|
|
14
|
+
* - U+000C FF
|
|
15
|
+
* - U+000D CR
|
|
16
|
+
* - U+0020 SPACE.
|
|
17
|
+
*
|
|
18
|
+
* @see https://infra.spec.whatwg.org/#ascii-whitespace
|
|
19
|
+
*/
|
|
20
|
+
static readonly whitespace: ReadonlyArray<string>;
|
|
21
|
+
static getCol(value: string, offset: number): number;
|
|
22
|
+
static getLine(value: string, offset: number): number;
|
|
23
|
+
static getType(value: string, separators?: readonly string[]): 18 | 1 | 13;
|
|
24
|
+
static shiftLocation(token: Readonly<Token>, offset: number): {
|
|
25
|
+
offset: number;
|
|
26
|
+
line: number;
|
|
27
|
+
column: number;
|
|
28
|
+
};
|
|
29
|
+
readonly offset: number;
|
|
30
|
+
readonly originalValue: string;
|
|
31
|
+
readonly type: number;
|
|
32
|
+
readonly value: string;
|
|
33
|
+
constructor(value: string, offset: number, originalValue: string, separators?: readonly string[]);
|
|
34
|
+
get length(): number;
|
|
35
|
+
clone(): Token;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param value The token value or the token type or its list
|
|
39
|
+
*/
|
|
40
|
+
includes(value: TokenValue, caseInsensitive?: boolean): boolean;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param value The token value or the token type or its list
|
|
44
|
+
*/
|
|
45
|
+
match(value: TokenValue, caseInsensitive?: boolean): boolean;
|
|
46
|
+
toJSON(): {
|
|
47
|
+
type: number;
|
|
48
|
+
value: string;
|
|
49
|
+
offset: number;
|
|
50
|
+
};
|
|
51
|
+
toNumber(): number;
|
|
52
|
+
unmatched(options?: UnmatchedResultOptions & {
|
|
53
|
+
readonly ref?: string;
|
|
54
|
+
readonly reason?: UnmatchedResultReason;
|
|
55
|
+
}): UnmatchedResult;
|
|
61
56
|
}
|
|
@@ -13,7 +13,7 @@ exports.isItempropName = void 0;
|
|
|
13
13
|
*/
|
|
14
14
|
const isItempropName = () => {
|
|
15
15
|
return value => {
|
|
16
|
-
return value.includes(':') && value.includes('.') && value.includes(' ');
|
|
16
|
+
return !value.includes(':') && !value.includes('.') && !value.includes(' ');
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
exports.isItempropName = isItempropName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/types",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "Type declaration and value checker",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"@types/whatwg-mimetype": "2",
|
|
34
34
|
"type-fest": "^3.6.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "3cdf5a088b2da03773d5d4461d0e65ec32290a00"
|
|
37
37
|
}
|