yaml 2.3.1 → 2.3.2

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.
@@ -4,6 +4,8 @@ function debug(logLevel, ...messages) {
4
4
  }
5
5
  function warn(logLevel, warning) {
6
6
  if (logLevel === 'debug' || logLevel === 'warn') {
7
+ // https://github.com/typescript-eslint/typescript-eslint/issues/7478
8
+ // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
7
9
  if (typeof process !== 'undefined' && process.emitWarning)
8
10
  process.emitWarning(warning);
9
11
  else
@@ -81,7 +81,7 @@ function stringifyKey(key, jsKey, ctx) {
81
81
  return '';
82
82
  if (typeof jsKey !== 'object')
83
83
  return String(jsKey);
84
- if (isNode(key) && ctx && ctx.doc) {
84
+ if (isNode(key) && ctx?.doc) {
85
85
  const strCtx = createStringifyContext(ctx.doc, {});
86
86
  strCtx.anchors = new Set();
87
87
  for (const node of ctx.anchors.keys())
@@ -56,8 +56,9 @@ function createPairs(schema, iterable, ctx) {
56
56
  key = keys[0];
57
57
  value = it[key];
58
58
  }
59
- else
60
- throw new TypeError(`Expected { key: value } tuple: ${it}`);
59
+ else {
60
+ throw new TypeError(`Expected tuple with one key, not ${keys.length} keys`);
61
+ }
61
62
  }
62
63
  else {
63
64
  key = it;
@@ -96,7 +96,7 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
96
96
  if (iv.commentBefore)
97
97
  reqNewline = true;
98
98
  }
99
- else if (item.value == null && ik && ik.comment) {
99
+ else if (item.value == null && ik?.comment) {
100
100
  comment = ik.comment;
101
101
  }
102
102
  }
@@ -240,7 +240,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
240
240
  function plainString(item, ctx, onComment, onChompKeep) {
241
241
  const { type, value } = item;
242
242
  const { actualString, implicitKey, indent, indentStep, inFlow } = ctx;
243
- if ((implicitKey && /[\n[\]{},]/.test(value)) ||
243
+ if ((implicitKey && value.includes('\n')) ||
244
244
  (inFlow && /[[\]{},]/.test(value))) {
245
245
  return quotedString(value, ctx);
246
246
  }
package/dist/log.js CHANGED
@@ -6,6 +6,8 @@ function debug(logLevel, ...messages) {
6
6
  }
7
7
  function warn(logLevel, warning) {
8
8
  if (logLevel === 'debug' || logLevel === 'warn') {
9
+ // https://github.com/typescript-eslint/typescript-eslint/issues/7478
10
+ // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
9
11
  if (typeof process !== 'undefined' && process.emitWarning)
10
12
  process.emitWarning(warning);
11
13
  else
@@ -83,7 +83,7 @@ function stringifyKey(key, jsKey, ctx) {
83
83
  return '';
84
84
  if (typeof jsKey !== 'object')
85
85
  return String(jsKey);
86
- if (identity.isNode(key) && ctx && ctx.doc) {
86
+ if (identity.isNode(key) && ctx?.doc) {
87
87
  const strCtx = stringify.createStringifyContext(ctx.doc, {});
88
88
  strCtx.anchors = new Set();
89
89
  for (const node of ctx.anchors.keys())
@@ -58,8 +58,9 @@ function createPairs(schema, iterable, ctx) {
58
58
  key = keys[0];
59
59
  value = it[key];
60
60
  }
61
- else
62
- throw new TypeError(`Expected { key: value } tuple: ${it}`);
61
+ else {
62
+ throw new TypeError(`Expected tuple with one key, not ${keys.length} keys`);
63
+ }
63
64
  }
64
65
  else {
65
66
  key = it;
@@ -98,7 +98,7 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
98
98
  if (iv.commentBefore)
99
99
  reqNewline = true;
100
100
  }
101
- else if (item.value == null && ik && ik.comment) {
101
+ else if (item.value == null && ik?.comment) {
102
102
  comment = ik.comment;
103
103
  }
104
104
  }
@@ -242,7 +242,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
242
242
  function plainString(item, ctx, onComment, onChompKeep) {
243
243
  const { type, value } = item;
244
244
  const { actualString, implicitKey, indent, indentStep, inFlow } = ctx;
245
- if ((implicitKey && /[\n[\]{},]/.test(value)) ||
245
+ if ((implicitKey && value.includes('\n')) ||
246
246
  (inFlow && /[[\]{},]/.test(value))) {
247
247
  return quotedString(value, ctx);
248
248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaml",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "license": "ISC",
5
5
  "author": "Eemeli Aro <eemeli@gmail.com>",
6
6
  "repository": "github:eemeli/yaml",
@@ -75,16 +75,16 @@
75
75
  "@rollup/plugin-typescript": "^11.0.0",
76
76
  "@types/jest": "^29.2.4",
77
77
  "@types/node": "^14.18.35",
78
- "@typescript-eslint/eslint-plugin": "^5.3.1",
79
- "@typescript-eslint/parser": "^5.3.1",
78
+ "@typescript-eslint/eslint-plugin": "^6.4.1",
79
+ "@typescript-eslint/parser": "^6.4.1",
80
80
  "babel-jest": "^29.0.1",
81
81
  "cross-env": "^7.0.3",
82
82
  "eslint": "^8.2.0",
83
- "eslint-config-prettier": "^8.1.0",
83
+ "eslint-config-prettier": "^9.0.0",
84
84
  "fast-check": "^2.12.0",
85
85
  "jest": "^29.0.1",
86
86
  "jest-ts-webcompat-resolver": "^1.0.0",
87
- "prettier": "^2.2.1",
87
+ "prettier": "^3.0.2",
88
88
  "rollup": "^3.7.5",
89
89
  "tslib": "^2.1.0",
90
90
  "typescript": "^5.0.3"