@markuplint/types 3.4.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.
@@ -285,7 +285,7 @@ const checkAutoComplete = () => value => {
285
285
  const [prefix, namedGroupStr] = head.value.split('-');
286
286
  const candidatePrefix = (0, get_candidate_1.getCandidate)(prefix, 'section');
287
287
  if (candidatePrefix) {
288
- candidate = `${candidatePrefix}-${namedGroupStr || ''}`;
288
+ candidate = `${candidatePrefix}-${namedGroupStr !== null && namedGroupStr !== void 0 ? namedGroupStr : ''}`;
289
289
  }
290
290
  }
291
291
  else if (!hasPartOfAddress) {
@@ -305,7 +305,7 @@ const checkAutoComplete = () => value => {
305
305
  })));
306
306
  candidate = (0, get_candidate_1.getCandidate)(head.value, autofillFieldNames, contactingTokens, contactableFieldNames);
307
307
  }
308
- candidate = candidate || (0, get_candidate_1.getCandidate)(head.value, autofillFieldNames);
308
+ candidate = candidate !== null && candidate !== void 0 ? candidate : (0, get_candidate_1.getCandidate)(head.value, autofillFieldNames);
309
309
  if (candidate) {
310
310
  acLog('[Unmatched ("%s")] Unexpected token: "%s", Do you mean "%s"? ', value, head.value, candidate);
311
311
  }
@@ -1,3 +1,23 @@
1
1
  import type { TokenEachCheck } from '../../token/token-collection';
2
- export declare const datetimeTokenCheck: Record<'year' | 'month' | 'date' | 'hour' | 'minute' | 'second' | 'secondFractionalPart' | 'week' | 'hyphen' | 'colon' | 'extra' | 'colonOrEnd' | 'decimalPointOrEnd' | 'localDateTimeSeparator' | 'normalizedlocalDateTimeSeparator' | 'plusOrMinusSign' | 'weekSign', TokenEachCheck> & Record<'_year' | '_month', number | null>;
2
+ export declare const datetimeTokenCheck: Record<
3
+ | 'year'
4
+ | 'month'
5
+ | 'date'
6
+ | 'hour'
7
+ | 'minute'
8
+ | 'second'
9
+ | 'secondFractionalPart'
10
+ | 'week'
11
+ | 'hyphen'
12
+ | 'colon'
13
+ | 'extra'
14
+ | 'colonOrEnd'
15
+ | 'decimalPointOrEnd'
16
+ | 'localDateTimeSeparator'
17
+ | 'normalizedlocalDateTimeSeparator'
18
+ | 'plusOrMinusSign'
19
+ | 'weekSign',
20
+ TokenEachCheck
21
+ > &
22
+ Record<'_year' | '_month', number | null>;
3
23
  export declare function getMaxWeekNum(year: number): number;
@@ -95,7 +95,7 @@ exports.datetimeTokenCheck = {
95
95
  * > then the day can be 29, as if the year was a leap year.
96
96
  */
97
97
  date(date) {
98
- var _a;
98
+ var _a, _b, _c;
99
99
  (0, debug_1.log)('Parsing Datetime Date: "%s"', date === null || date === void 0 ? void 0 : date.value);
100
100
  if (!date || !date.value) {
101
101
  return (0, match_result_1.unmatched)('', 'missing-token', {
@@ -118,10 +118,10 @@ exports.datetimeTokenCheck = {
118
118
  });
119
119
  }
120
120
  // Set the leap year if _year is null
121
- const year = this._year || 2000;
121
+ const year = (_a = this._year) !== null && _a !== void 0 ? _a : 2000;
122
122
  const isLeap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
123
- const month = this._month || 1;
124
- const dayOfMonth = ((_a = daysOfMonth[month]) !== null && _a !== void 0 ? _a : 0) + (month === 2 && isLeap ? 1 : 0);
123
+ const month = (_b = this._month) !== null && _b !== void 0 ? _b : 1;
124
+ const dayOfMonth = ((_c = daysOfMonth[month]) !== null && _c !== void 0 ? _c : 0) + (month === 2 && isLeap ? 1 : 0);
125
125
  const _date = date.toNumber();
126
126
  (0, debug_1.log)('Temporary Year and Month: %s, %s', this._year, this._month);
127
127
  (0, debug_1.log)('Computed Year, Month, and Day of Month: %s, %s, %s', year, month, dayOfMonth);
@@ -265,6 +265,7 @@ exports.datetimeTokenCheck = {
265
265
  * > Two ASCII digits, representing the week week, in the range 1 ≤ week ≤ maxweek, where maxweek is the week number of the last day of week-year year
266
266
  */
267
267
  week(week) {
268
+ var _a;
268
269
  (0, debug_1.log)('Parsing Datetime Week: "%s"', week === null || week === void 0 ? void 0 : week.value);
269
270
  if (!week || !week.value) {
270
271
  return (0, match_result_1.unmatched)('', 'missing-token', {
@@ -286,7 +287,7 @@ exports.datetimeTokenCheck = {
286
287
  partName: 'week',
287
288
  });
288
289
  }
289
- const maxweek = getMaxWeekNum(this._year || 0);
290
+ const maxweek = getMaxWeekNum((_a = this._year) !== null && _a !== void 0 ? _a : 0);
290
291
  const _week = week.toNumber();
291
292
  if (!(1 <= _week && _week <= maxweek)) {
292
293
  return week.unmatched({
@@ -495,9 +496,10 @@ const daysOfMonth = [
495
496
  ];
496
497
  function getMaxWeekNum(year) {
497
498
  let date = 31;
498
- while (date) {
499
+ while (date > 0) {
499
500
  const d = new Date(Date.UTC(year, 11, date, 0, 0, 0, 0));
500
- d.setDate(d.getDate() + 4 - (d.getDay() || 7));
501
+ const day = d.getDay();
502
+ d.setDate(d.getDate() + 4 - (day > 0 ? day : 7));
501
503
  const yearStart = new Date(d.getFullYear(), 0, 1);
502
504
  const weekNo = Math.ceil(((d.valueOf() - yearStart.valueOf()) / 86400000 + 1) / 7);
503
505
  if (weekNo !== 1) {
@@ -84,6 +84,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
84
84
  });
85
85
  }
86
86
  }, time => {
87
+ var _a, _b, _c;
87
88
  if (!time) {
88
89
  return (0, match_result_1.unmatched)('', 'missing-token', {
89
90
  expects: [
@@ -104,7 +105,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
104
105
  ]);
105
106
  (0, debug_1.log)('Time part: "%s" => %O', timeTokens.value, timeTokens);
106
107
  const [h, m, s] = timeTokens;
107
- if (((h === null || h === void 0 ? void 0 : h.value) || '') + ((m === null || m === void 0 ? void 0 : m.value) || '') + ((s === null || s === void 0 ? void 0 : s.value) || '') === '') {
108
+ if (((_a = h === null || h === void 0 ? void 0 : h.value) !== null && _a !== void 0 ? _a : '') + ((_b = m === null || m === void 0 ? void 0 : m.value) !== null && _b !== void 0 ? _b : '') + ((_c = s === null || s === void 0 ? void 0 : s.value) !== null && _c !== void 0 ? _c : '') === '') {
108
109
  return (0, match_result_1.unmatched)('', 'missing-token', {
109
110
  expects: [
110
111
  { type: 'common', value: 'hour' },
@@ -115,7 +116,7 @@ const checkDurationISO8601LikeString = () => function checkDurationISO8601LikeSt
115
116
  }
116
117
  const specified = new Set();
117
118
  for (const t of timeTokens) {
118
- if (!t || !t.value) {
119
+ if (!t.value) {
119
120
  continue;
120
121
  }
121
122
  if (specified.has('S')) {
@@ -95,8 +95,8 @@ const checkNormalizedLocalDateAndTimeString = () => function checkNormalizedLoca
95
95
  (0, debug_1.log)('Failed: %O', res);
96
96
  return res;
97
97
  }
98
- const _second = second.toNumber() || 0;
99
- const _fp = fp.toNumber() || 0;
98
+ const _second = second.toNumber();
99
+ const _fp = fp.toNumber();
100
100
  (0, debug_1.log)('Omitting the seconds component: "%s.%s" => %d, %d', second === null || second === void 0 ? void 0 : second.value, fp === null || fp === void 0 ? void 0 : fp.value, _second, _fp);
101
101
  if (second.value && _second === 0 && (!fp.value || (fp.value && _fp === 0))) {
102
102
  const res = second.unmatched({
@@ -4,4 +4,4 @@ import type { CustomSyntaxChecker } from '../../types';
4
4
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#time-zones
5
5
  */
6
6
  export declare const checkTimeZoneOffsetString: CustomSyntaxChecker;
7
- export declare function parseTimeZone(zone: string | Readonly<Token>): import("../../types").Result;
7
+ export declare function parseTimeZone(zone: string | Readonly<Token>): import('../../types').Result;
@@ -4,8 +4,8 @@ import type { CustomSyntaxChecker } from '../types';
4
4
  * @see https://mimesniff.spec.whatwg.org/#valid-mime-type
5
5
  */
6
6
  export declare const checkMIMEType: CustomSyntaxChecker<{
7
- /**
8
- * @see https://mimesniff.spec.whatwg.org/#valid-mime-type-with-no-parameters
9
- */
10
- withoutParameters?: boolean;
7
+ /**
8
+ * @see https://mimesniff.spec.whatwg.org/#valid-mime-type-with-no-parameters
9
+ */
10
+ withoutParameters?: boolean;
11
11
  }>;
@@ -27,7 +27,7 @@ const checkMIMEType = options => value => {
27
27
  if (value.toLowerCase() === mimeType.essence) {
28
28
  return (0, match_result_1.matched)();
29
29
  }
30
- if (!withoutParameters && mimeType.parameters.size) {
30
+ if (!withoutParameters && mimeType.parameters.size > 0) {
31
31
  return (0, match_result_1.matched)();
32
32
  }
33
33
  const extraToken = value.slice(mimeType.essence.length);
@@ -13,7 +13,7 @@ exports.isItempropName = void 0;
13
13
  */
14
14
  const isItempropName = () => {
15
15
  return value => {
16
- return value.indexOf(':') === -1 && value.indexOf('.') === -1 && value.indexOf(' ') === -1;
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.4.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": "0c47b2c2722f6823a17f36edbab98486275f8ab4"
36
+ "gitHead": "3cdf5a088b2da03773d5d4461d0e65ec32290a00"
37
37
  }