@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
+ });
@@ -1,22 +1,9 @@
1
- import type {
2
- FormattedPrimitiveTypeCheck,
3
- MatchedResult,
4
- UnmatchedResult,
5
- UnmatchedResultOptions,
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
- value: string,
18
- reason?: UnmatchedResultReason,
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
- Omit<List, 'token'> & {
8
- specificSeparator: string | string[];
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
- static fromPatterns(
14
- value: Readonly<Token> | string,
15
- patterns: readonly Readonly<RegExp>[],
16
- typeOptions?: ReadonlyDeep<
17
- Omit<TokenCollectionOptions, 'specificSeparator'> & {
18
- repeat?: boolean;
19
- }
20
- >,
21
- ): TokenCollection;
22
- static get [Symbol.species](): ArrayConstructor;
23
- readonly allowEmpty: NonNullable<List['allowEmpty']>;
24
- readonly caseInsensitive: NonNullable<List['caseInsensitive']>;
25
- readonly disallowToSurroundBySpaces: NonNullable<List['disallowToSurroundBySpaces']>;
26
- readonly number: List['number'];
27
- readonly ordered: NonNullable<List['ordered']>;
28
- readonly separator: NonNullable<List['separator']>;
29
- readonly unique: NonNullable<List['unique']>;
30
- constructor(value?: string, typeOptions?: ReadonlyDeep<TokenCollectionOptions>);
31
- constructor(value?: number);
32
- get value(): string;
33
- check(options?: {
34
- expects?: Expect[];
35
- ref?: string;
36
- cache?: boolean;
37
- }): import('..').MatchedResult | UnmatchedResult;
38
- chunk(split: number): TokenCollection[];
39
- compareTokens(
40
- callback: (prev: Readonly<Token>, current: Readonly<Token>) => Readonly<Token> | null | void,
41
- ): Readonly<Token> | null | undefined;
42
- divide(position: number): readonly [TokenCollection, TokenCollection];
43
- eachCheck(...callbacks: readonly TokenEachCheck[]): Result;
44
- filter(callback: Parameters<Array<Token>['filter']>[0]): TokenCollection;
45
- getConsecutiveToken(tokenType: number): Readonly<Token> | null;
46
- getDuplicated(): Token | null;
47
- getIdentTokens(): TokenCollection;
48
- /**
49
- *
50
- * @param value The token value or the token type or its list
51
- */
52
- has(value: TokenValue): boolean;
53
- headAndTail(): {
54
- head: Token | null;
55
- tail: TokenCollection;
56
- };
57
- /**
58
- *
59
- * @param value The token value or the token type or its list
60
- */
61
- search(value: TokenValue): Token | null;
62
- takeTurns(
63
- tokenNumbers: ReadonlyArray<number>,
64
- lastTokenNumber?: number,
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 {};
@@ -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
- * @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[]): 1 | 13 | 18;
24
- static shiftLocation(
25
- token: Readonly<Token>,
26
- offset: number,
27
- ): {
28
- offset: number;
29
- line: number;
30
- column: number;
31
- };
32
- readonly offset: number;
33
- readonly originalValue: string;
34
- readonly type: number;
35
- readonly value: string;
36
- constructor(value: string, offset: number, originalValue: string, separators?: readonly string[]);
37
- get length(): number;
38
- clone(): Token;
39
- /**
40
- *
41
- * @param value The token value or the token type or its list
42
- */
43
- includes(value: TokenValue, caseInsensitive?: boolean): boolean;
44
- /**
45
- *
46
- * @param value The token value or the token type or its list
47
- */
48
- match(value: TokenValue, caseInsensitive?: boolean): boolean;
49
- toJSON(): {
50
- type: number;
51
- value: string;
52
- offset: number;
53
- };
54
- toNumber(): number;
55
- unmatched(
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.0",
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": "715dd53d3b1064a9bcf616c1533921cad9e3b187"
36
+ "gitHead": "3cdf5a088b2da03773d5d4461d0e65ec32290a00"
37
37
  }