prettier 2.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -6
- data/README.md +16 -16
- data/exe/rbprettier +2 -2
- data/lib/prettier/rake/task.rb +5 -5
- data/lib/prettier.rb +11 -11
- data/package.json +9 -23
- data/rubocop.yml +6 -6
- data/{dist/parser → src}/getInfo.js +0 -1
- data/{dist/parser → src}/netcat.js +0 -1
- data/src/parseSync.js +212 -0
- data/src/plugin.js +161 -0
- data/{dist/parser → src}/server.rb +45 -31
- metadata +94 -78
- data/bin/console +0 -7
- data/dist/haml/embed.js +0 -53
- data/dist/haml/parser.js +0 -31
- data/dist/haml/parser.rb +0 -149
- data/dist/haml/printer.js +0 -336
- data/dist/parser/parseSync.js +0 -179
- data/dist/plugin.js +0 -143
- data/dist/prettier.js +0 -15
- data/dist/rbs/parser.js +0 -34
- data/dist/rbs/parser.rb +0 -155
- data/dist/rbs/printer.js +0 -525
- data/dist/ruby/embed.js +0 -115
- data/dist/ruby/location.js +0 -19
- data/dist/ruby/nodes/alias.js +0 -60
- data/dist/ruby/nodes/aref.js +0 -51
- data/dist/ruby/nodes/args.js +0 -138
- data/dist/ruby/nodes/arrays.js +0 -122
- data/dist/ruby/nodes/assign.js +0 -37
- data/dist/ruby/nodes/blocks.js +0 -90
- data/dist/ruby/nodes/calls.js +0 -263
- data/dist/ruby/nodes/case.js +0 -50
- data/dist/ruby/nodes/class.js +0 -54
- data/dist/ruby/nodes/commands.js +0 -138
- data/dist/ruby/nodes/conditionals.js +0 -246
- data/dist/ruby/nodes/constants.js +0 -35
- data/dist/ruby/nodes/flow.js +0 -59
- data/dist/ruby/nodes/hashes.js +0 -126
- data/dist/ruby/nodes/heredocs.js +0 -30
- data/dist/ruby/nodes/hooks.js +0 -35
- data/dist/ruby/nodes/ints.js +0 -27
- data/dist/ruby/nodes/lambdas.js +0 -70
- data/dist/ruby/nodes/loops.js +0 -75
- data/dist/ruby/nodes/massign.js +0 -60
- data/dist/ruby/nodes/methods.js +0 -50
- data/dist/ruby/nodes/operators.js +0 -68
- data/dist/ruby/nodes/params.js +0 -95
- data/dist/ruby/nodes/patterns.js +0 -119
- data/dist/ruby/nodes/regexp.js +0 -45
- data/dist/ruby/nodes/rescue.js +0 -86
- data/dist/ruby/nodes/return.js +0 -100
- data/dist/ruby/nodes/statements.js +0 -110
- data/dist/ruby/nodes/strings.js +0 -220
- data/dist/ruby/nodes/super.js +0 -26
- data/dist/ruby/nodes/undef.js +0 -31
- data/dist/ruby/nodes.js +0 -177
- data/dist/ruby/parser.js +0 -35
- data/dist/ruby/parser.rb +0 -9134
- data/dist/ruby/printer.js +0 -67
- data/dist/ruby/toProc.js +0 -91
- data/dist/types/haml.js +0 -4
- data/dist/types/plugin.js +0 -3
- data/dist/types/rbs.js +0 -4
- data/dist/types/ruby.js +0 -4
- data/dist/types/utils.js +0 -2
- data/dist/types.js +0 -34
- data/dist/utils/containsAssignment.js +0 -18
- data/dist/utils/getChildNodes.js +0 -305
- data/dist/utils/getTrailingComma.js +0 -6
- data/dist/utils/hasAncestor.js +0 -15
- data/dist/utils/inlineEnsureParens.js +0 -49
- data/dist/utils/isEmptyBodyStmt.js +0 -10
- data/dist/utils/isEmptyParams.js +0 -12
- data/dist/utils/isEmptyStmts.js +0 -10
- data/dist/utils/literal.js +0 -8
- data/dist/utils/literallineWithoutBreakParent.js +0 -8
- data/dist/utils/makeCall.js +0 -14
- data/dist/utils/noIndent.js +0 -11
- data/dist/utils/printEmptyCollection.js +0 -46
- data/dist/utils/skipAssignIndent.js +0 -19
- data/dist/utils.js +0 -32
data/src/plugin.js
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
const { parseSync } = require("./parseSync");
|
2
|
+
|
3
|
+
/*
|
4
|
+
* metadata mostly pulled from linguist and rubocop:
|
5
|
+
* https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
|
6
|
+
* https://github.com/rubocop/rubocop/blob/master/spec/rubocop/target_finder_spec.rb
|
7
|
+
*/
|
8
|
+
const plugin = {
|
9
|
+
languages: [
|
10
|
+
{
|
11
|
+
name: "Ruby",
|
12
|
+
parsers: ["ruby"],
|
13
|
+
extensions: [
|
14
|
+
".arb",
|
15
|
+
".axlsx",
|
16
|
+
".builder",
|
17
|
+
".eye",
|
18
|
+
".fcgi",
|
19
|
+
".gemfile",
|
20
|
+
".gemspec",
|
21
|
+
".god",
|
22
|
+
".jb",
|
23
|
+
".jbuilder",
|
24
|
+
".mspec",
|
25
|
+
".opal",
|
26
|
+
".pluginspec",
|
27
|
+
".podspec",
|
28
|
+
".rabl",
|
29
|
+
".rake",
|
30
|
+
".rb",
|
31
|
+
".rbi",
|
32
|
+
".rbuild",
|
33
|
+
".rbw",
|
34
|
+
".rbx",
|
35
|
+
".ru",
|
36
|
+
".ruby",
|
37
|
+
".thor",
|
38
|
+
".watchr"
|
39
|
+
],
|
40
|
+
filenames: [
|
41
|
+
".irbrc",
|
42
|
+
".pryrc",
|
43
|
+
".simplecov",
|
44
|
+
"Appraisals",
|
45
|
+
"Berksfile",
|
46
|
+
"Brewfile",
|
47
|
+
"Buildfile",
|
48
|
+
"Capfile",
|
49
|
+
"Cheffile",
|
50
|
+
"Dangerfile",
|
51
|
+
"Deliverfile",
|
52
|
+
"Fastfile",
|
53
|
+
"Gemfile",
|
54
|
+
"Guardfile",
|
55
|
+
"Jarfile",
|
56
|
+
"Mavenfile",
|
57
|
+
"Podfile",
|
58
|
+
"Puppetfile",
|
59
|
+
"Rakefile",
|
60
|
+
"Snapfile",
|
61
|
+
"Thorfile",
|
62
|
+
"Vagabondfile",
|
63
|
+
"Vagrantfile",
|
64
|
+
"buildfile"
|
65
|
+
],
|
66
|
+
interpreters: ["jruby", "macruby", "rake", "rbx", "ruby"],
|
67
|
+
linguistLanguageId: 326,
|
68
|
+
vscodeLanguageIds: ["ruby"]
|
69
|
+
},
|
70
|
+
{
|
71
|
+
name: "RBS",
|
72
|
+
parsers: ["rbs"],
|
73
|
+
extensions: [".rbs"]
|
74
|
+
},
|
75
|
+
{
|
76
|
+
name: "HAML",
|
77
|
+
parsers: ["haml"],
|
78
|
+
extensions: [".haml"],
|
79
|
+
vscodeLanguageIds: ["haml"]
|
80
|
+
}
|
81
|
+
],
|
82
|
+
parsers: {
|
83
|
+
ruby: {
|
84
|
+
parse(text) {
|
85
|
+
return parseSync("ruby", text);
|
86
|
+
},
|
87
|
+
astFormat: "ruby",
|
88
|
+
hasPragma(text) {
|
89
|
+
return /^\s*#[^\S\n]*@(?:prettier|format)\s*?(?:\n|$)/m.test(text);
|
90
|
+
},
|
91
|
+
locStart() {
|
92
|
+
return 0;
|
93
|
+
},
|
94
|
+
locEnd() {
|
95
|
+
return 0;
|
96
|
+
}
|
97
|
+
},
|
98
|
+
rbs: {
|
99
|
+
parse(text) {
|
100
|
+
return parseSync("rbs", text);
|
101
|
+
},
|
102
|
+
astFormat: "rbs",
|
103
|
+
hasPragma(text) {
|
104
|
+
return /^\s*#[^\S\n]*@(prettier|format)\s*(\n|$)/.test(text);
|
105
|
+
},
|
106
|
+
locStart() {
|
107
|
+
return 0;
|
108
|
+
},
|
109
|
+
locEnd() {
|
110
|
+
return 0;
|
111
|
+
}
|
112
|
+
},
|
113
|
+
haml: {
|
114
|
+
parse(text) {
|
115
|
+
return parseSync("haml", text);
|
116
|
+
},
|
117
|
+
astFormat: "haml",
|
118
|
+
hasPragma(text) {
|
119
|
+
return /^\s*-#\s*@(prettier|format)/.test(text);
|
120
|
+
},
|
121
|
+
locStart() {
|
122
|
+
return 0;
|
123
|
+
},
|
124
|
+
locEnd() {
|
125
|
+
return 0;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
},
|
129
|
+
printers: {
|
130
|
+
ruby: {
|
131
|
+
print(path) {
|
132
|
+
return path.getValue();
|
133
|
+
},
|
134
|
+
insertPragma(text) {
|
135
|
+
return `# @format${text.startsWith("#") ? "\n" : "\n\n"}${text}`;
|
136
|
+
}
|
137
|
+
},
|
138
|
+
rbs: {
|
139
|
+
print(path) {
|
140
|
+
return path.getValue();
|
141
|
+
},
|
142
|
+
insertPragma(text) {
|
143
|
+
return `# @format${text.startsWith("#") ? "\n" : "\n\n"}${text}`;
|
144
|
+
}
|
145
|
+
},
|
146
|
+
haml: {
|
147
|
+
print(path) {
|
148
|
+
return path.getValue();
|
149
|
+
},
|
150
|
+
insertPragma(text) {
|
151
|
+
return `-# @format${text.startsWith("-#") ? "\n" : "\n\n"}${text}`;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
},
|
155
|
+
defaultOptions: {
|
156
|
+
printWidth: 80,
|
157
|
+
tabWidth: 2
|
158
|
+
}
|
159
|
+
};
|
160
|
+
|
161
|
+
module.exports = plugin;
|
@@ -1,29 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
|
9
|
-
# Ensure the parent module is defined before requiring the parsers.
|
10
|
-
module Prettier
|
11
|
-
end
|
3
|
+
require "bundler/setup"
|
4
|
+
require "socket"
|
5
|
+
require "json"
|
6
|
+
require "fileutils"
|
7
|
+
require "open3"
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
require "syntax_tree"
|
10
|
+
require "syntax_tree/haml"
|
11
|
+
require "syntax_tree/rbs"
|
16
12
|
|
17
13
|
# Make sure we trap these signals to be sure we get the quit command coming from
|
18
14
|
# the parent node process
|
19
15
|
quit = false
|
20
16
|
trap(:INT) { quit = true }
|
21
17
|
trap(:TERM) { quit = true }
|
22
|
-
|
18
|
+
|
19
|
+
if Signal.list.key?("QUIT") && RUBY_ENGINE != "jruby"
|
20
|
+
trap(:QUIT) { quit = true }
|
21
|
+
end
|
23
22
|
|
24
23
|
# The information variable stores the actual connection information, which will
|
25
24
|
# either be an IP address and port or a path to a unix socket file.
|
26
|
-
information =
|
25
|
+
information = ""
|
27
26
|
|
28
27
|
# The candidates array is a list of potential programs that could be used to
|
29
28
|
# connect to our server. We'll run through them after the server starts to find
|
@@ -33,7 +32,7 @@ candidates = []
|
|
33
32
|
if Gem.win_platform?
|
34
33
|
# If we're on windows, we're going to start up a TCP server. The 0 here means
|
35
34
|
# to bind to some available port.
|
36
|
-
server = TCPServer.new(
|
35
|
+
server = TCPServer.new("127.0.0.1", 0)
|
37
36
|
address = server.local_address
|
38
37
|
|
39
38
|
# Ensure that we close the server when this process exits.
|
@@ -55,7 +54,7 @@ else
|
|
55
54
|
end
|
56
55
|
|
57
56
|
information = server.local_address.unix_path
|
58
|
-
candidates = [
|
57
|
+
candidates = ["nc -w 3 -U", "ncat -w 3 -U"]
|
59
58
|
end
|
60
59
|
|
61
60
|
# This is the actual listening thread that will be acting as our server. We have
|
@@ -69,26 +68,41 @@ listener =
|
|
69
68
|
|
70
69
|
# Start up a new thread that will handle each successive connection.
|
71
70
|
Thread.new(server.accept_nonblock) do |socket|
|
72
|
-
parser, source = socket.read.force_encoding(
|
71
|
+
parser, source = socket.read.force_encoding("UTF-8").split("|", 2)
|
72
|
+
|
73
|
+
source.each_line do |line|
|
74
|
+
case line
|
75
|
+
when /^\s*#.+?coding/
|
76
|
+
# If we've found an encoding comment, then we're going to take that
|
77
|
+
# into account and reclassify the encoding for the source.
|
78
|
+
encoding = Ripper.new(line).tap(&:parse).encoding
|
79
|
+
source = source.force_encoding(encoding)
|
80
|
+
break
|
81
|
+
when /^\s*#/
|
82
|
+
# continue
|
83
|
+
else
|
84
|
+
break
|
85
|
+
end
|
86
|
+
end
|
73
87
|
|
74
88
|
response =
|
75
89
|
case parser
|
76
|
-
when
|
77
|
-
|
78
|
-
when
|
79
|
-
SyntaxTree.
|
80
|
-
when
|
81
|
-
|
82
|
-
when
|
83
|
-
|
90
|
+
when "ping"
|
91
|
+
"pong"
|
92
|
+
when "ruby"
|
93
|
+
SyntaxTree.format(source)
|
94
|
+
when "rbs"
|
95
|
+
SyntaxTree::RBS.format(source)
|
96
|
+
when "haml"
|
97
|
+
SyntaxTree::Haml.format(source)
|
84
98
|
end
|
85
99
|
|
86
100
|
if response
|
87
|
-
socket.write(JSON.fast_generate(response))
|
101
|
+
socket.write(JSON.fast_generate(response.force_encoding("UTF-8")))
|
88
102
|
else
|
89
|
-
socket.write(
|
103
|
+
socket.write("{ \"error\": true }")
|
90
104
|
end
|
91
|
-
rescue SyntaxTree::ParseError => error
|
105
|
+
rescue SyntaxTree::Parser::ParseError => error
|
92
106
|
loc = { start: { line: error.lineno, column: error.column } }
|
93
107
|
socket.write(JSON.fast_generate(error: error.message, loc: loc))
|
94
108
|
rescue StandardError => error
|
@@ -118,9 +132,9 @@ candidates.map! do |candidate|
|
|
118
132
|
|
119
133
|
# We do not care about stderr here, so throw it away
|
120
134
|
stdout, _stderr, status =
|
121
|
-
Open3.capture3("#{candidate} #{information}", stdin_data:
|
135
|
+
Open3.capture3("#{candidate} #{information}", stdin_data: "ping")
|
122
136
|
|
123
|
-
candidate if JSON.parse(stdout) ==
|
137
|
+
candidate if JSON.parse(stdout) == "pong" && status.exitstatus == 0
|
124
138
|
rescue StandardError
|
125
139
|
# We don't actually care if this fails, because we'll just skip that
|
126
140
|
# connection option.
|
@@ -136,7 +150,7 @@ prefix =
|
|
136
150
|
|
137
151
|
# Default to running the netcat.js script that we ship with the plugin. It's a
|
138
152
|
# good fallback as it will always work, but it is slower than the other options.
|
139
|
-
prefix ||= "node #{File.expand_path(
|
153
|
+
prefix ||= "node #{File.expand_path("netcat.js", __dir__)}"
|
140
154
|
|
141
155
|
# Write out our connection information to the file given as the first argument
|
142
156
|
# to this script.
|
metadata
CHANGED
@@ -1,15 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prettier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
12
|
-
dependencies:
|
11
|
+
date: 2022-05-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: syntax_tree
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.3.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.3.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: syntax_tree-haml
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: syntax_tree-rbs
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.2.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.2.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
13
97
|
description:
|
14
98
|
email:
|
15
99
|
executables:
|
@@ -22,79 +106,6 @@ files:
|
|
22
106
|
- CONTRIBUTING.md
|
23
107
|
- LICENSE
|
24
108
|
- README.md
|
25
|
-
- bin/console
|
26
|
-
- dist/haml/embed.js
|
27
|
-
- dist/haml/parser.js
|
28
|
-
- dist/haml/parser.rb
|
29
|
-
- dist/haml/printer.js
|
30
|
-
- dist/parser/getInfo.js
|
31
|
-
- dist/parser/netcat.js
|
32
|
-
- dist/parser/parseSync.js
|
33
|
-
- dist/parser/server.rb
|
34
|
-
- dist/plugin.js
|
35
|
-
- dist/prettier.js
|
36
|
-
- dist/rbs/parser.js
|
37
|
-
- dist/rbs/parser.rb
|
38
|
-
- dist/rbs/printer.js
|
39
|
-
- dist/ruby/embed.js
|
40
|
-
- dist/ruby/location.js
|
41
|
-
- dist/ruby/nodes.js
|
42
|
-
- dist/ruby/nodes/alias.js
|
43
|
-
- dist/ruby/nodes/aref.js
|
44
|
-
- dist/ruby/nodes/args.js
|
45
|
-
- dist/ruby/nodes/arrays.js
|
46
|
-
- dist/ruby/nodes/assign.js
|
47
|
-
- dist/ruby/nodes/blocks.js
|
48
|
-
- dist/ruby/nodes/calls.js
|
49
|
-
- dist/ruby/nodes/case.js
|
50
|
-
- dist/ruby/nodes/class.js
|
51
|
-
- dist/ruby/nodes/commands.js
|
52
|
-
- dist/ruby/nodes/conditionals.js
|
53
|
-
- dist/ruby/nodes/constants.js
|
54
|
-
- dist/ruby/nodes/flow.js
|
55
|
-
- dist/ruby/nodes/hashes.js
|
56
|
-
- dist/ruby/nodes/heredocs.js
|
57
|
-
- dist/ruby/nodes/hooks.js
|
58
|
-
- dist/ruby/nodes/ints.js
|
59
|
-
- dist/ruby/nodes/lambdas.js
|
60
|
-
- dist/ruby/nodes/loops.js
|
61
|
-
- dist/ruby/nodes/massign.js
|
62
|
-
- dist/ruby/nodes/methods.js
|
63
|
-
- dist/ruby/nodes/operators.js
|
64
|
-
- dist/ruby/nodes/params.js
|
65
|
-
- dist/ruby/nodes/patterns.js
|
66
|
-
- dist/ruby/nodes/regexp.js
|
67
|
-
- dist/ruby/nodes/rescue.js
|
68
|
-
- dist/ruby/nodes/return.js
|
69
|
-
- dist/ruby/nodes/statements.js
|
70
|
-
- dist/ruby/nodes/strings.js
|
71
|
-
- dist/ruby/nodes/super.js
|
72
|
-
- dist/ruby/nodes/undef.js
|
73
|
-
- dist/ruby/parser.js
|
74
|
-
- dist/ruby/parser.rb
|
75
|
-
- dist/ruby/printer.js
|
76
|
-
- dist/ruby/toProc.js
|
77
|
-
- dist/types.js
|
78
|
-
- dist/types/haml.js
|
79
|
-
- dist/types/plugin.js
|
80
|
-
- dist/types/rbs.js
|
81
|
-
- dist/types/ruby.js
|
82
|
-
- dist/types/utils.js
|
83
|
-
- dist/utils.js
|
84
|
-
- dist/utils/containsAssignment.js
|
85
|
-
- dist/utils/getChildNodes.js
|
86
|
-
- dist/utils/getTrailingComma.js
|
87
|
-
- dist/utils/hasAncestor.js
|
88
|
-
- dist/utils/inlineEnsureParens.js
|
89
|
-
- dist/utils/isEmptyBodyStmt.js
|
90
|
-
- dist/utils/isEmptyParams.js
|
91
|
-
- dist/utils/isEmptyStmts.js
|
92
|
-
- dist/utils/literal.js
|
93
|
-
- dist/utils/literallineWithoutBreakParent.js
|
94
|
-
- dist/utils/makeCall.js
|
95
|
-
- dist/utils/noIndent.js
|
96
|
-
- dist/utils/printEmptyCollection.js
|
97
|
-
- dist/utils/skipAssignIndent.js
|
98
109
|
- exe/rbprettier
|
99
110
|
- lib/prettier.rb
|
100
111
|
- lib/prettier/rake/task.rb
|
@@ -118,6 +129,11 @@ files:
|
|
118
129
|
- node_modules/prettier/third-party.js
|
119
130
|
- package.json
|
120
131
|
- rubocop.yml
|
132
|
+
- src/getInfo.js
|
133
|
+
- src/netcat.js
|
134
|
+
- src/parseSync.js
|
135
|
+
- src/plugin.js
|
136
|
+
- src/server.rb
|
121
137
|
homepage: https://github.com/prettier/plugin-ruby#readme
|
122
138
|
licenses:
|
123
139
|
- MIT
|
@@ -130,14 +146,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
146
|
requirements:
|
131
147
|
- - ">="
|
132
148
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
149
|
+
version: 2.7.3
|
134
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
151
|
requirements:
|
136
152
|
- - ">="
|
137
153
|
- !ruby/object:Gem::Version
|
138
154
|
version: '0'
|
139
155
|
requirements: []
|
140
|
-
rubygems_version: 3.
|
156
|
+
rubygems_version: 3.4.0.dev
|
141
157
|
signing_key:
|
142
158
|
specification_version: 4
|
143
159
|
summary: prettier plugin for the Ruby programming language
|
data/bin/console
DELETED
data/dist/haml/embed.js
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const prettier_1 = __importDefault(require("../prettier"));
|
7
|
-
const { hardline, indent, literalline, markAsRoot, mapDoc, stripTrailingHardline } = prettier_1.default;
|
8
|
-
// This function is in here because it handles embedded parser values. I don't
|
9
|
-
// have a test that exercises it because I'm not sure for which parser it is
|
10
|
-
// necessary, but since it's in prettier core I'm keeping it here.
|
11
|
-
/* istanbul ignore next */
|
12
|
-
function replaceNewlines(doc) {
|
13
|
-
return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" && currentDoc.includes("\n")
|
14
|
-
? currentDoc.split(/(\n)/g).map((v, i) => (i % 2 === 0 ? v : literalline))
|
15
|
-
: currentDoc);
|
16
|
-
}
|
17
|
-
const embed = (path, _print, textToDoc, opts) => {
|
18
|
-
const node = path.getValue();
|
19
|
-
// We're only going to embed other languages on filter nodes.
|
20
|
-
if (node.type !== "filter") {
|
21
|
-
return null;
|
22
|
-
}
|
23
|
-
let parser = node.value.name;
|
24
|
-
// We don't want to deal with some weird recursive parser situation, so we
|
25
|
-
// need to explicitly call out the HAML parser here and just return null.
|
26
|
-
if (parser === "haml") {
|
27
|
-
return null;
|
28
|
-
}
|
29
|
-
// In HAML the name of the JS filter is :javascript, whereas in prettier the
|
30
|
-
// name of the JS parser is babel. Here we explicitly handle that conversion.
|
31
|
-
if (parser === "javascript") {
|
32
|
-
parser = "babel";
|
33
|
-
}
|
34
|
-
// If there aren't any plugins that look like the name of the filter, then we
|
35
|
-
// will just exit early.
|
36
|
-
if (!opts.plugins.some((plugin) => typeof plugin !== "string" &&
|
37
|
-
plugin.parsers &&
|
38
|
-
Object.prototype.hasOwnProperty.call(plugin.parsers, parser))) {
|
39
|
-
return null;
|
40
|
-
}
|
41
|
-
// If there is a plugin that has a parser that matches the name of this
|
42
|
-
// filter, then we're going to assume that's correct for embedding and go
|
43
|
-
// ahead and switch to that parser.
|
44
|
-
return markAsRoot([
|
45
|
-
":",
|
46
|
-
node.value.name,
|
47
|
-
indent([
|
48
|
-
hardline,
|
49
|
-
replaceNewlines(stripTrailingHardline(textToDoc(node.value.text, { parser })))
|
50
|
-
])
|
51
|
-
]);
|
52
|
-
};
|
53
|
-
exports.default = embed;
|
data/dist/haml/parser.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const parseSync_1 = __importDefault(require("../parser/parseSync"));
|
7
|
-
const parser = {
|
8
|
-
// This function is responsible for taking an input string of text and
|
9
|
-
// returning to prettier a JavaScript object that is the equivalent AST that
|
10
|
-
// represents the code stored in that string. We accomplish this by spawning a
|
11
|
-
// new process and reading JSON off STDOUT.
|
12
|
-
parse(text) {
|
13
|
-
return (0, parseSync_1.default)("haml", text);
|
14
|
-
},
|
15
|
-
astFormat: "haml",
|
16
|
-
// This function handles checking whether or not the source string has the
|
17
|
-
// pragma for prettier. This is an optional workflow for incremental adoption.
|
18
|
-
hasPragma(text) {
|
19
|
-
return /^\s*-#\s*@(prettier|format)/.test(text);
|
20
|
-
},
|
21
|
-
// These functions are just placeholders until we can actually perform this
|
22
|
-
// properly. The functions are necessary otherwise the format with cursor
|
23
|
-
// functions break.
|
24
|
-
locStart() {
|
25
|
-
return 0;
|
26
|
-
},
|
27
|
-
locEnd() {
|
28
|
-
return 0;
|
29
|
-
}
|
30
|
-
};
|
31
|
-
exports.default = parser;
|