forked from prettier/plugin-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ruby.js
134 lines (130 loc) · 2.99 KB
/
ruby.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
const parse = require("./parse");
const print = require("./print");
const pragmaPattern = /#\s*@(prettier|format)/;
const hasPragma = text => pragmaPattern.test(text);
// This is a placeholder until we have been node location reporting coming from
// the ripper parser.
const locStart = node => 0;
const locEnd = node => 0;
/*
* metadata mostly pulled from linguist and rubocop:
* https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
* https://github.com/rubocop-hq/rubocop/blob/master/spec/rubocop/target_finder_spec.rb
*/
module.exports = {
languages: [
{
name: "Ruby",
parsers: ["ruby"],
extensions: [
".arb",
".axlsx",
".builder",
".eye",
".fcgi",
".gemfile",
".gemspec",
".god",
".jb",
".jbuilder",
".mspec",
".opal",
".pluginspec",
".podspec",
".rabl",
".rake",
".rb",
".rbuild",
".rbw",
".rbx",
".ru",
".ruby",
".thor",
".watchr"
],
filenames: [
".irbrc",
".pryrc",
"Appraisals",
"Berksfile",
"Brewfile",
"Buildfile",
"Capfile",
"Cheffile",
"Dangerfile",
"Deliverfile",
"Fastfile",
"Gemfile",
"Guardfile",
"Jarfile",
"Mavenfile",
"Podfile",
"Puppetfile",
"Rakefile",
"Snapfile",
"Thorfile",
"Vagabondfile",
"Vagrantfile",
"buildfile"
],
interpreters: ["jruby", "macruby", "rake", "rbx", "ruby"],
linguistLanguageId: 326,
vscodeLanguageIds: ["ruby"]
}
],
parsers: {
ruby: {
parse,
astFormat: "ruby",
hasPragma,
locStart,
locEnd
}
},
printers: {
ruby: {
print
}
},
options: {
addTrailingCommas: {
type: "boolean",
category: "Global",
default: false,
description:
"Adds a trailing comma to array literals, hash literals, and method calls."
},
inlineConditionals: {
type: "boolean",
category: "Global",
default: true,
description:
"When it fits on one line, allows if and unless statements to use the modifier form."
},
inlineLoops: {
type: "boolean",
category: "Global",
default: true,
description:
"When it fits on one line, allows while and until statements to use the modifier form."
},
preferHashLabels: {
type: "boolean",
category: "Global",
default: true,
description:
"When possible, uses the shortened hash key syntax, as opposed to hash rockets."
},
preferSingleQuotes: {
type: "boolean",
category: "Global",
default: true,
description:
"When double quotes are not necessary for interpolation, prefers the use of single quotes for string literals."
}
},
defaultOptions: {
printWidth: 80,
tabWidth: 2
}
};