@putout/printer 7.3.0 → 7.4.0

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.
package/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2023.12.18, v7.4.0
2
+
3
+ feature:
4
+ - 48b8257 @putout/printer: encodeDoubleQuote: add
5
+
1
6
  2023.12.18, v7.3.0
2
7
 
3
8
  fix:
package/README.md CHANGED
@@ -102,6 +102,7 @@ print(ast, {
102
102
  maxPropertiesInOneLine: 2,
103
103
  trailingComma: true,
104
104
  encodeSingleQuote: true,
105
+ encodeDoubleQuote: false,
105
106
  },
106
107
  visitors: {
107
108
  AssignmentPattern(path, {print}) {
package/lib/json.js CHANGED
@@ -19,6 +19,7 @@ module.exports.maybeJSON = (ast, overrides) => {
19
19
  ...overrides?.semantics,
20
20
  trailingComma: false,
21
21
  encodeSingleQuote: false,
22
+ encodeDoubleQuote: true,
22
23
  },
23
24
  };
24
25
 
@@ -3,10 +3,13 @@
3
3
  const {TemplateLiteral} = require('./template-literal');
4
4
  const {Identifier} = require('./identifier');
5
5
 
6
- const maybeEncode = (value, {encodeSingleQuote}) => {
6
+ const maybeEncode = (value, {encodeDoubleQuote, encodeSingleQuote}) => {
7
7
  if (encodeSingleQuote && !value.includes('\\'))
8
8
  return value.replaceAll(`'`, `\\'`);
9
9
 
10
+ if (encodeDoubleQuote && !value.includes('\\"'))
11
+ return value.replaceAll(`"`, '\\"');
12
+
10
13
  return value;
11
14
  };
12
15
 
@@ -37,6 +37,7 @@ function initSemantics(semantics = {}) {
37
37
  maxVariablesInOneLine: 4,
38
38
  trailingComma: true,
39
39
  encodeSingleQuote: true,
40
+ encodeDoubleQuote: false,
40
41
  ...semantics,
41
42
  };
42
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "7.3.0",
3
+ "version": "7.4.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",