prettier 1.6.1 → 2.0.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +316 -293
- data/CONTRIBUTING.md +6 -9
- data/LICENSE +1 -1
- data/README.md +11 -12
- data/dist/haml/embed.js +53 -0
- data/dist/haml/parser.js +31 -0
- data/{src → dist}/haml/parser.rb +0 -0
- data/dist/haml/printer.js +336 -0
- data/dist/parser/getInfo.js +17 -0
- data/{src → dist}/parser/netcat.js +1 -0
- data/dist/parser/parseSync.js +128 -0
- data/dist/parser/server.rb +140 -0
- data/dist/plugin.js +143 -0
- data/dist/prettier.js +15 -0
- data/dist/rbs/parser.js +34 -0
- data/{src → dist}/rbs/parser.rb +0 -0
- data/dist/rbs/printer.js +517 -0
- data/dist/ruby/embed.js +110 -0
- data/dist/ruby/nodes/alias.js +59 -0
- data/{src → dist}/ruby/nodes/aref.js +26 -35
- data/dist/ruby/nodes/args.js +165 -0
- data/dist/ruby/nodes/arrays.js +126 -0
- data/dist/ruby/nodes/assign.js +41 -0
- data/dist/ruby/nodes/blocks.js +68 -0
- data/dist/ruby/nodes/calls.js +220 -0
- data/dist/ruby/nodes/case.js +50 -0
- data/dist/ruby/nodes/class.js +54 -0
- data/dist/ruby/nodes/commands.js +124 -0
- data/dist/ruby/nodes/conditionals.js +242 -0
- data/dist/ruby/nodes/constants.js +38 -0
- data/dist/ruby/nodes/flow.js +66 -0
- data/dist/ruby/nodes/hashes.js +130 -0
- data/dist/ruby/nodes/heredocs.js +30 -0
- data/dist/ruby/nodes/hooks.js +35 -0
- data/dist/ruby/nodes/ints.js +27 -0
- data/dist/ruby/nodes/lambdas.js +69 -0
- data/dist/ruby/nodes/loops.js +73 -0
- data/dist/ruby/nodes/massign.js +73 -0
- data/dist/ruby/nodes/methods.js +70 -0
- data/dist/ruby/nodes/operators.js +70 -0
- data/dist/ruby/nodes/params.js +89 -0
- data/dist/ruby/nodes/patterns.js +109 -0
- data/dist/ruby/nodes/regexp.js +45 -0
- data/dist/ruby/nodes/rescue.js +82 -0
- data/dist/ruby/nodes/return.js +75 -0
- data/dist/ruby/nodes/statements.js +111 -0
- data/dist/ruby/nodes/strings.js +218 -0
- data/dist/ruby/nodes/super.js +30 -0
- data/dist/ruby/nodes/undef.js +26 -0
- data/dist/ruby/nodes.js +151 -0
- data/dist/ruby/parser.js +34 -0
- data/{src → dist}/ruby/parser.rb +1215 -252
- data/dist/ruby/printer.js +125 -0
- data/dist/ruby/toProc.js +93 -0
- data/dist/types/haml.js +4 -0
- data/dist/types/plugin.js +3 -0
- data/dist/types/rbs.js +4 -0
- data/dist/types/ruby.js +4 -0
- data/dist/types/utils.js +2 -0
- data/dist/types.js +30 -0
- data/dist/utils/containsAssignment.js +15 -0
- data/dist/utils/getTrailingComma.js +6 -0
- data/dist/utils/hasAncestor.js +15 -0
- data/{src → dist}/utils/inlineEnsureParens.js +16 -17
- data/dist/utils/isEmptyBodyStmt.js +10 -0
- data/dist/utils/isEmptyStmts.js +10 -0
- data/dist/utils/literal.js +8 -0
- data/dist/utils/literallineWithoutBreakParent.js +8 -0
- data/dist/utils/makeCall.js +13 -0
- data/dist/utils/noIndent.js +11 -0
- data/dist/utils/printEmptyCollection.js +44 -0
- data/dist/utils/skipAssignIndent.js +15 -0
- data/dist/utils.js +30 -0
- data/node_modules/prettier/bin-prettier.js +313 -190
- data/node_modules/prettier/doc.js +191 -323
- data/node_modules/prettier/index.js +2753 -3677
- data/node_modules/prettier/package.json +1 -1
- data/node_modules/prettier/parser-angular.js +13 -14
- data/node_modules/prettier/parser-babel.js +7 -7
- data/node_modules/prettier/parser-espree.js +7 -7
- data/node_modules/prettier/parser-flow.js +7 -7
- data/node_modules/prettier/parser-glimmer.js +1 -1
- data/node_modules/prettier/parser-graphql.js +1 -1
- data/node_modules/prettier/parser-html.js +17 -17
- data/node_modules/prettier/parser-markdown.js +9 -9
- data/node_modules/prettier/parser-meriyah.js +7 -7
- data/node_modules/prettier/parser-postcss.js +2 -2
- data/node_modules/prettier/parser-typescript.js +7 -7
- data/node_modules/prettier/parser-yaml.js +2 -2
- data/node_modules/prettier/third-party.js +143 -78
- data/package.json +26 -18
- metadata +74 -67
- data/src/haml/embed.js +0 -87
- data/src/haml/parser.js +0 -23
- data/src/haml/printer.js +0 -438
- data/src/parser/parseSync.js +0 -172
- data/src/parser/server.rb +0 -66
- data/src/plugin.js +0 -148
- data/src/prettier.js +0 -16
- data/src/rbs/parser.js +0 -37
- data/src/rbs/printer.js +0 -643
- data/src/ruby/embed.js +0 -142
- data/src/ruby/nodes/alias.js +0 -73
- data/src/ruby/nodes/args.js +0 -222
- data/src/ruby/nodes/arrays.js +0 -162
- data/src/ruby/nodes/assign.js +0 -47
- data/src/ruby/nodes/blocks.js +0 -90
- data/src/ruby/nodes/calls.js +0 -246
- data/src/ruby/nodes/case.js +0 -65
- data/src/ruby/nodes/class.js +0 -64
- data/src/ruby/nodes/commands.js +0 -131
- data/src/ruby/nodes/conditionals.js +0 -282
- data/src/ruby/nodes/constants.js +0 -43
- data/src/ruby/nodes/flow.js +0 -74
- data/src/ruby/nodes/hashes.js +0 -155
- data/src/ruby/nodes/heredocs.js +0 -36
- data/src/ruby/nodes/hooks.js +0 -34
- data/src/ruby/nodes/ints.js +0 -31
- data/src/ruby/nodes/lambdas.js +0 -76
- data/src/ruby/nodes/loops.js +0 -98
- data/src/ruby/nodes/massign.js +0 -98
- data/src/ruby/nodes/methods.js +0 -74
- data/src/ruby/nodes/operators.js +0 -83
- data/src/ruby/nodes/params.js +0 -106
- data/src/ruby/nodes/patterns.js +0 -157
- data/src/ruby/nodes/regexp.js +0 -56
- data/src/ruby/nodes/rescue.js +0 -101
- data/src/ruby/nodes/return.js +0 -94
- data/src/ruby/nodes/statements.js +0 -142
- data/src/ruby/nodes/strings.js +0 -272
- data/src/ruby/nodes/super.js +0 -35
- data/src/ruby/nodes/undef.js +0 -42
- data/src/ruby/nodes.js +0 -34
- data/src/ruby/parser.js +0 -37
- data/src/ruby/printer.js +0 -147
- data/src/ruby/toProc.js +0 -105
- data/src/utils/containsAssignment.js +0 -11
- data/src/utils/getTrailingComma.js +0 -5
- data/src/utils/hasAncestor.js +0 -17
- data/src/utils/isEmptyBodyStmt.js +0 -7
- data/src/utils/isEmptyStmts.js +0 -11
- data/src/utils/literal.js +0 -7
- data/src/utils/literallineWithoutBreakParent.js +0 -7
- data/src/utils/makeCall.js +0 -14
- data/src/utils/noIndent.js +0 -10
- data/src/utils/printEmptyCollection.js +0 -49
- data/src/utils/skipAssignIndent.js +0 -17
- data/src/utils.js +0 -13
data/src/plugin.js
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
const rubyPrinter = require("./ruby/printer");
|
2
|
-
const rubyParser = require("./ruby/parser");
|
3
|
-
|
4
|
-
const rbsPrinter = require("./rbs/printer");
|
5
|
-
const rbsParser = require("./rbs/parser");
|
6
|
-
|
7
|
-
const hamlPrinter = require("./haml/printer");
|
8
|
-
const hamlParser = require("./haml/parser");
|
9
|
-
|
10
|
-
/*
|
11
|
-
* metadata mostly pulled from linguist and rubocop:
|
12
|
-
* https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
|
13
|
-
* https://github.com/rubocop/rubocop/blob/master/spec/rubocop/target_finder_spec.rb
|
14
|
-
*/
|
15
|
-
|
16
|
-
module.exports = {
|
17
|
-
languages: [
|
18
|
-
{
|
19
|
-
name: "Ruby",
|
20
|
-
parsers: ["ruby"],
|
21
|
-
extensions: [
|
22
|
-
".arb",
|
23
|
-
".axlsx",
|
24
|
-
".builder",
|
25
|
-
".eye",
|
26
|
-
".fcgi",
|
27
|
-
".gemfile",
|
28
|
-
".gemspec",
|
29
|
-
".god",
|
30
|
-
".jb",
|
31
|
-
".jbuilder",
|
32
|
-
".mspec",
|
33
|
-
".opal",
|
34
|
-
".pluginspec",
|
35
|
-
".podspec",
|
36
|
-
".rabl",
|
37
|
-
".rake",
|
38
|
-
".rb",
|
39
|
-
".rbi",
|
40
|
-
".rbuild",
|
41
|
-
".rbw",
|
42
|
-
".rbx",
|
43
|
-
".ru",
|
44
|
-
".ruby",
|
45
|
-
".thor",
|
46
|
-
".watchr"
|
47
|
-
],
|
48
|
-
filenames: [
|
49
|
-
".irbrc",
|
50
|
-
".pryrc",
|
51
|
-
".simplecov",
|
52
|
-
"Appraisals",
|
53
|
-
"Berksfile",
|
54
|
-
"Brewfile",
|
55
|
-
"Buildfile",
|
56
|
-
"Capfile",
|
57
|
-
"Cheffile",
|
58
|
-
"Dangerfile",
|
59
|
-
"Deliverfile",
|
60
|
-
"Fastfile",
|
61
|
-
"Gemfile",
|
62
|
-
"Guardfile",
|
63
|
-
"Jarfile",
|
64
|
-
"Mavenfile",
|
65
|
-
"Podfile",
|
66
|
-
"Puppetfile",
|
67
|
-
"Rakefile",
|
68
|
-
"Snapfile",
|
69
|
-
"Thorfile",
|
70
|
-
"Vagabondfile",
|
71
|
-
"Vagrantfile",
|
72
|
-
"buildfile"
|
73
|
-
],
|
74
|
-
interpreters: ["jruby", "macruby", "rake", "rbx", "ruby"],
|
75
|
-
linguistLanguageId: 326,
|
76
|
-
vscodeLanguageIds: ["ruby"]
|
77
|
-
},
|
78
|
-
{
|
79
|
-
name: "RBS",
|
80
|
-
parsers: ["rbs"],
|
81
|
-
extensions: [".rbs"]
|
82
|
-
},
|
83
|
-
{
|
84
|
-
name: "HAML",
|
85
|
-
parsers: ["haml"],
|
86
|
-
extensions: [".haml"],
|
87
|
-
vscodeLanguageIds: ["haml"]
|
88
|
-
}
|
89
|
-
],
|
90
|
-
parsers: {
|
91
|
-
ruby: rubyParser,
|
92
|
-
rbs: rbsParser,
|
93
|
-
haml: hamlParser
|
94
|
-
},
|
95
|
-
printers: {
|
96
|
-
ruby: rubyPrinter,
|
97
|
-
rbs: rbsPrinter,
|
98
|
-
haml: hamlPrinter
|
99
|
-
},
|
100
|
-
options: {
|
101
|
-
rubyArrayLiteral: {
|
102
|
-
type: "boolean",
|
103
|
-
category: "Ruby",
|
104
|
-
default: true,
|
105
|
-
description:
|
106
|
-
"When possible, favor the use of string and symbol array literals."
|
107
|
-
},
|
108
|
-
rubyHashLabel: {
|
109
|
-
type: "boolean",
|
110
|
-
category: "Ruby",
|
111
|
-
default: true,
|
112
|
-
description:
|
113
|
-
"When possible, uses the shortened hash key syntax, as opposed to hash rockets."
|
114
|
-
},
|
115
|
-
rubyModifier: {
|
116
|
-
type: "boolean",
|
117
|
-
category: "Ruby",
|
118
|
-
default: true,
|
119
|
-
description:
|
120
|
-
"When it fits on one line, allows if, unless, while, and until statements to use the modifier form."
|
121
|
-
},
|
122
|
-
rubyNetcatCommand: {
|
123
|
-
type: "string",
|
124
|
-
category: "Ruby",
|
125
|
-
description:
|
126
|
-
'The prefix of the command to execute to communicate between the node.js process and the Ruby process. (For example, "nc -U" or "telnet -u") Normally you should not set this option.'
|
127
|
-
},
|
128
|
-
rubySingleQuote: {
|
129
|
-
type: "boolean",
|
130
|
-
category: "Ruby",
|
131
|
-
default: true,
|
132
|
-
description:
|
133
|
-
"When double quotes are not necessary for interpolation, prefers the use of single quotes for string literals."
|
134
|
-
},
|
135
|
-
rubyToProc: {
|
136
|
-
type: "boolean",
|
137
|
-
category: "Ruby",
|
138
|
-
default: false,
|
139
|
-
description:
|
140
|
-
"When possible, convert blocks to the more concise Symbol#to_proc syntax."
|
141
|
-
}
|
142
|
-
},
|
143
|
-
defaultOptions: {
|
144
|
-
printWidth: 80,
|
145
|
-
tabWidth: 2,
|
146
|
-
trailingComma: "none"
|
147
|
-
}
|
148
|
-
};
|
data/src/prettier.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
// If `RBPRETTIER` is set, then this is being run from the `Prettier::run` ruby
|
2
|
-
// method. In that case, we need to pull `prettier` from the node_modules
|
3
|
-
// directly, as it's been shipped with the gem.
|
4
|
-
/* istanbul ignore next */
|
5
|
-
const source = process.env.RBPRETTIER ? "../node_modules/prettier" : "prettier";
|
6
|
-
|
7
|
-
const prettier = require(source);
|
8
|
-
|
9
|
-
// Just combine all the things into one big object so that we can import
|
10
|
-
// whatever we need from prettier without having to dive too deeply.
|
11
|
-
module.exports = Object.assign(
|
12
|
-
{},
|
13
|
-
prettier.doc.builders,
|
14
|
-
prettier.doc.utils,
|
15
|
-
prettier.util
|
16
|
-
);
|
data/src/rbs/parser.js
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
const parseSync = require("../parser/parseSync");
|
2
|
-
|
3
|
-
// This function is responsible for taking an input string of text and returning
|
4
|
-
// to prettier a JavaScript object that is the equivalent AST that represents
|
5
|
-
// the code stored in that string. We accomplish this by spawning a new Ruby
|
6
|
-
// process of parser.rb and reading JSON off STDOUT.
|
7
|
-
function parse(text, _parsers, opts) {
|
8
|
-
return parseSync("rbs", text, opts);
|
9
|
-
}
|
10
|
-
|
11
|
-
// This function handles checking whether or not the source string has the
|
12
|
-
// pragma for prettier. This is an optional workflow for incremental adoption.
|
13
|
-
function hasPragma(text) {
|
14
|
-
return /^\s*#[^\S\n]*@(format|prettier)\s*(\n|$)/.test(text);
|
15
|
-
}
|
16
|
-
|
17
|
-
// This function is critical for comments and cursor support, and is responsible
|
18
|
-
// for returning the index of the character within the source string that is the
|
19
|
-
// beginning of the given node.
|
20
|
-
function locStart(node) {
|
21
|
-
return (node.location || node.type.location).start_pos;
|
22
|
-
}
|
23
|
-
|
24
|
-
// This function is critical for comments and cursor support, and is responsible
|
25
|
-
// for returning the index of the character within the source string that is the
|
26
|
-
// ending of the given node.
|
27
|
-
function locEnd(node) {
|
28
|
-
return (node.location || node.type.location).end_pos;
|
29
|
-
}
|
30
|
-
|
31
|
-
module.exports = {
|
32
|
-
parse,
|
33
|
-
astFormat: "rbs",
|
34
|
-
hasPragma,
|
35
|
-
locStart,
|
36
|
-
locEnd
|
37
|
-
};
|