@putout/printer 6.0.1 → 6.1.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,13 @@
1
+ 2023.11.02, v6.1.0
2
+
3
+ feature:
4
+ - 138a4ac @putout/printer: RegExpLiteral: use pattern when no raw
5
+
6
+ 2023.10.28, v6.0.2
7
+
8
+ fix:
9
+ - d1a013d @putout/printer: json: mutate object
10
+
1
11
  2023.10.28, v6.0.1
2
12
 
3
13
  fix:
package/lib/json.js CHANGED
@@ -6,18 +6,21 @@ const {
6
6
  } = require('@putout/babel').types;
7
7
 
8
8
  const {isJSON} = require('@putout/processor-json/is-json');
9
- const {assign} = Object;
10
9
 
11
10
  module.exports.maybeJSON = (ast, overrides) => {
12
- if (isASTJSON(ast))
13
- assign(overrides, {
11
+ if (isASTJSON(ast)) {
12
+ return {
13
+ ...overrides,
14
14
  format: {
15
15
  quote: `"`,
16
16
  },
17
17
  semantics: {
18
18
  trailingComma: false,
19
19
  },
20
- });
20
+ };
21
+ }
22
+
23
+ return overrides;
21
24
  };
22
25
 
23
26
  function isASTJSON(ast) {
package/lib/printer.js CHANGED
@@ -5,8 +5,8 @@ const {printTokens} = require('./print-tokens');
5
5
  const {maybeJSON} = require('./json');
6
6
 
7
7
  module.exports.print = (ast, overrides = {}) => {
8
- maybeJSON(ast, overrides);
9
- const tokens = tokenize(ast, overrides);
8
+ const options = maybeJSON(ast, overrides);
9
+ const tokens = tokenize(ast, options);
10
10
 
11
11
  return printTokens(tokens);
12
12
  };
@@ -58,7 +58,8 @@ module.exports = {
58
58
  write.quote();
59
59
  },
60
60
  RegExpLiteral(path, {print}) {
61
- print(path.node.raw);
61
+ const {raw, pattern} = path.node;
62
+ print(raw || `/${pattern}/`);
62
63
  },
63
64
  NullLiteral(path, {write}) {
64
65
  write('null');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "6.0.1",
3
+ "version": "6.1.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",