prettier 0.22.0 → 1.0.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,8 +40,10 @@ function canAttachComment(node) {
40
40
  // where it needs to attach the comments.
41
41
  function getCommentChildNodes(node) {
42
42
  switch (node.type) {
43
+ case "heredoc":
44
+ return [node.beging];
43
45
  case "rescue":
44
- return node.body[0].concat(node.body.slice(1));
46
+ return [].concat(node.body[0]).concat(node.body.slice(1));
45
47
  case "aryptn":
46
48
  return [node.body[0]]
47
49
  .concat(node.body[1])
@@ -76,42 +76,28 @@ module.exports = {
76
76
  ruby: printer
77
77
  },
78
78
  options: {
79
- addTrailingCommas: {
80
- type: "boolean",
81
- category: "Global",
82
- default: false,
83
- description:
84
- "Adds a trailing comma to array literals, hash literals, and method calls."
85
- },
86
- inlineConditionals: {
87
- type: "boolean",
88
- category: "Global",
89
- default: true,
90
- description:
91
- "When it fits on one line, allows if and unless statements to use the modifier form."
92
- },
93
- inlineLoops: {
79
+ rubyHashLabel: {
94
80
  type: "boolean",
95
81
  category: "Global",
96
82
  default: true,
97
83
  description:
98
- "When it fits on one line, allows while and until statements to use the modifier form."
84
+ "When possible, uses the shortened hash key syntax, as opposed to hash rockets."
99
85
  },
100
- preferHashLabels: {
86
+ rubyModifier: {
101
87
  type: "boolean",
102
88
  category: "Global",
103
89
  default: true,
104
90
  description:
105
- "When possible, uses the shortened hash key syntax, as opposed to hash rockets."
91
+ "When it fits on one line, allows if, unless, while, and until statements to use the modifier form."
106
92
  },
107
- preferSingleQuotes: {
93
+ rubySingleQuote: {
108
94
  type: "boolean",
109
95
  category: "Global",
110
96
  default: true,
111
97
  description:
112
98
  "When double quotes are not necessary for interpolation, prefers the use of single quotes for string literals."
113
99
  },
114
- toProcTransform: {
100
+ rubyToProc: {
115
101
  type: "boolean",
116
102
  category: "Global",
117
103
  default: false,
@@ -121,6 +107,7 @@ module.exports = {
121
107
  },
122
108
  defaultOptions: {
123
109
  printWidth: 80,
124
- tabWidth: 2
110
+ tabWidth: 2,
111
+ trailingComma: "none"
125
112
  }
126
113
  };
@@ -12,7 +12,7 @@ const isCall = (node) => ["::", "."].includes(node) || node.type === "@period";
12
12
  //
13
13
  // This works with `do` blocks as well.
14
14
  const toProc = (path, opts, node) => {
15
- if (!node || !opts.toProcTransform) {
15
+ if (!node || !opts.rubyToProc) {
16
16
  return null;
17
17
  }
18
18
 
@@ -31,6 +31,8 @@ const empty = () => "";
31
31
 
32
32
  const first = (path, opts, print) => path.call(print, "body", 0);
33
33
 
34
+ const getTrailingComma = (opts) => ["all", "es5"].includes(opts.trailingComma);
35
+
34
36
  const hasAncestor = (path, types) => {
35
37
  let parent = 0;
36
38
  let parentNode = path.getParentNode();
@@ -59,6 +61,15 @@ const makeCall = (path, opts, print) => {
59
61
  return operation === "::" ? "." : path.call(print, "body", 1);
60
62
  };
61
63
 
64
+ const noIndent = [
65
+ "array",
66
+ "hash",
67
+ "heredoc",
68
+ "if",
69
+ "method_add_block",
70
+ "xstring_literal"
71
+ ];
72
+
62
73
  const prefix = (value) => (path, opts, print) =>
63
74
  concat([value, path.call(print, "body", 0)]);
64
75
 
@@ -73,11 +84,13 @@ module.exports = {
73
84
  docLength,
74
85
  empty,
75
86
  first,
87
+ getTrailingComma,
76
88
  hasAncestor,
77
89
  isEmptyStmts,
78
90
  literal,
79
91
  literalLineNoBreak,
80
92
  makeCall,
93
+ noIndent,
81
94
  prefix,
82
95
  skipAssignIndent
83
96
  };
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prettier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 1.0.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Deisz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-08 00:00:00.000000000 Z
11
+ date: 2020-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,9 +130,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  requirements:
133
- - - ">="
133
+ - - ">"
134
134
  - !ruby/object:Gem::Version
135
- version: '0'
135
+ version: 1.3.1
136
136
  requirements: []
137
137
  rubygems_version: 3.0.3
138
138
  signing_key: