prettier 1.5.2 → 1.6.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +58 -1
- data/CONTRIBUTING.md +2 -2
- data/README.md +41 -12
- data/node_modules/prettier/bin-prettier.js +13848 -11589
- data/node_modules/prettier/doc.js +4961 -0
- data/node_modules/prettier/index.js +19466 -16783
- data/node_modules/prettier/package.json +23 -0
- data/node_modules/prettier/parser-angular.js +67 -0
- data/node_modules/prettier/parser-babel.js +22 -0
- data/node_modules/prettier/parser-espree.js +22 -0
- data/node_modules/prettier/parser-flow.js +22 -0
- data/node_modules/prettier/parser-glimmer.js +1 -0
- data/node_modules/prettier/parser-graphql.js +1 -0
- data/node_modules/prettier/parser-html.js +132 -0
- data/node_modules/prettier/parser-markdown.js +34 -0
- data/node_modules/prettier/parser-meriyah.js +22 -0
- data/node_modules/prettier/parser-postcss.js +22 -0
- data/node_modules/prettier/parser-typescript.js +22 -0
- data/node_modules/prettier/parser-yaml.js +15 -0
- data/node_modules/prettier/third-party.js +1671 -864
- data/package.json +5 -5
- data/rubocop.yml +12 -0
- data/src/haml/parser.js +6 -5
- data/src/haml/parser.rb +8 -3
- data/src/haml/printer.js +428 -18
- data/src/parser/netcat.js +0 -2
- data/src/parser/parseSync.js +153 -14
- data/src/parser/server.rb +5 -0
- data/src/plugin.js +7 -1
- data/src/rbs/parser.js +3 -5
- data/src/rbs/parser.rb +7 -3
- data/src/rbs/printer.js +46 -8
- data/src/ruby/nodes/args.js +111 -19
- data/src/ruby/nodes/calls.js +50 -3
- data/src/ruby/nodes/conditionals.js +47 -45
- data/src/ruby/nodes/hashes.js +5 -14
- data/src/ruby/nodes/params.js +2 -9
- data/src/ruby/nodes/strings.js +97 -2
- data/src/ruby/parser.js +3 -5
- data/src/ruby/parser.rb +76 -31
- data/src/ruby/printer.js +10 -1
- data/src/utils/inlineEnsureParens.js +1 -0
- data/src/utils/noIndent.js +0 -1
- data/src/utils/skipAssignIndent.js +8 -1
- metadata +16 -14
- data/src/haml/nodes/comment.js +0 -27
- data/src/haml/nodes/doctype.js +0 -34
- data/src/haml/nodes/filter.js +0 -16
- data/src/haml/nodes/hamlComment.js +0 -21
- data/src/haml/nodes/plain.js +0 -6
- data/src/haml/nodes/root.js +0 -8
- data/src/haml/nodes/script.js +0 -33
- data/src/haml/nodes/silentScript.js +0 -59
- data/src/haml/nodes/tag.js +0 -193
- data/src/parser/getLang.js +0 -32
- data/src/parser/getNetcat.js +0 -50
- data/src/parser/requestParse.js +0 -74
data/src/parser/getLang.js
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
// In order to properly parse ruby code, we need to tell the ruby process to
|
2
|
-
// parse using UTF-8. Unfortunately, the way that you accomplish this looks
|
3
|
-
// differently depending on your platform.
|
4
|
-
/* istanbul ignore next */
|
5
|
-
function getLang() {
|
6
|
-
const { env, platform } = process;
|
7
|
-
const envValue = env.LC_ALL || env.LC_CTYPE || env.LANG;
|
8
|
-
|
9
|
-
// If an env var is set for the locale that already includes UTF-8 in the
|
10
|
-
// name, then assume we can go with that.
|
11
|
-
if (envValue && envValue.includes("UTF-8")) {
|
12
|
-
return envValue;
|
13
|
-
}
|
14
|
-
|
15
|
-
// Otherwise, we're going to guess which encoding to use based on the system.
|
16
|
-
// This is probably not the best approach in the world, as you could be on
|
17
|
-
// linux and not have C.UTF-8, but in that case you're probably passing an env
|
18
|
-
// var for it. This object below represents all of the possible values of
|
19
|
-
// process.platform per:
|
20
|
-
// https://nodejs.org/api/process.html#process_process_platform
|
21
|
-
return {
|
22
|
-
aix: "C.UTF-8",
|
23
|
-
darwin: "en_US.UTF-8",
|
24
|
-
freebsd: "C.UTF-8",
|
25
|
-
linux: "C.UTF-8",
|
26
|
-
openbsd: "C.UTF-8",
|
27
|
-
sunos: "C.UTF-8",
|
28
|
-
win32: ".UTF-8"
|
29
|
-
}[platform];
|
30
|
-
}
|
31
|
-
|
32
|
-
module.exports = getLang;
|
data/src/parser/getNetcat.js
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
const { spawnSync } = require("child_process");
|
2
|
-
const os = require("os");
|
3
|
-
|
4
|
-
// Checks to see if an executable is available.
|
5
|
-
function hasCommand(name) {
|
6
|
-
let result;
|
7
|
-
|
8
|
-
if (os.type() === "Windows_NT") {
|
9
|
-
result = spawnSync("where", [name]);
|
10
|
-
} else {
|
11
|
-
result = spawnSync("command", ["-v", name]);
|
12
|
-
}
|
13
|
-
|
14
|
-
return result.status === 0;
|
15
|
-
}
|
16
|
-
|
17
|
-
// Finds an netcat-like adapter to use for sending data to a socket. We order
|
18
|
-
// these by likelihood of being found so we can avoid some shell-outs.
|
19
|
-
function getCommandAndArg() {
|
20
|
-
if (hasCommand("nc")) {
|
21
|
-
return ["nc", "-U"];
|
22
|
-
}
|
23
|
-
|
24
|
-
if (hasCommand("telnet")) {
|
25
|
-
return ["telnet", "-u"];
|
26
|
-
}
|
27
|
-
|
28
|
-
if (hasCommand("ncat")) {
|
29
|
-
return ["ncat", "-U"];
|
30
|
-
}
|
31
|
-
|
32
|
-
if (hasCommand("socat")) {
|
33
|
-
return ["socat", "-"];
|
34
|
-
}
|
35
|
-
|
36
|
-
return ["node", require.resolve("./netcat.js")];
|
37
|
-
}
|
38
|
-
|
39
|
-
let command;
|
40
|
-
let arg;
|
41
|
-
|
42
|
-
function getNetcat() {
|
43
|
-
if (!command) {
|
44
|
-
[command, arg] = getCommandAndArg();
|
45
|
-
}
|
46
|
-
|
47
|
-
return { command, arg };
|
48
|
-
}
|
49
|
-
|
50
|
-
module.exports = getNetcat;
|
data/src/parser/requestParse.js
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
const { spawn, spawnSync, execSync } = require("child_process");
|
2
|
-
const path = require("path");
|
3
|
-
const { existsSync, mkdtempSync } = require("fs");
|
4
|
-
const process = require("process");
|
5
|
-
const os = require("os");
|
6
|
-
|
7
|
-
const getNetcat = require("./getNetcat");
|
8
|
-
const getLang = require("./getLang");
|
9
|
-
|
10
|
-
let sockfile = process.env.PRETTIER_RUBY_HOST;
|
11
|
-
|
12
|
-
// Spawn the parser.rb subprocess. We do this since booting Ruby is slow, and we
|
13
|
-
// can re-use the parser process multiple times since it is statelesss.
|
14
|
-
function spawnParseServer() {
|
15
|
-
const server = spawn(
|
16
|
-
"ruby",
|
17
|
-
[path.join(__dirname, "./server.rb"), sockfile],
|
18
|
-
{
|
19
|
-
env: Object.assign({}, process.env, { LANG: getLang() }),
|
20
|
-
detached: true,
|
21
|
-
stdio: "inherit"
|
22
|
-
}
|
23
|
-
);
|
24
|
-
|
25
|
-
process.on("exit", () => {
|
26
|
-
try {
|
27
|
-
process.kill(-server.pid);
|
28
|
-
} catch (e) {
|
29
|
-
// ignore
|
30
|
-
}
|
31
|
-
});
|
32
|
-
|
33
|
-
server.unref();
|
34
|
-
const now = new Date();
|
35
|
-
|
36
|
-
// Wait for server to go live.
|
37
|
-
while (!existsSync(sockfile) && new Date() - now < 3000) {
|
38
|
-
execSync("sleep 0.1");
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
// Ensures that a parser server is currently running by checking against the
|
43
|
-
// sockfile variable. If it is not, create a temporary directory to house the
|
44
|
-
// sockfile and spawn the ruby process.
|
45
|
-
function ensureParseServer() {
|
46
|
-
if (sockfile) {
|
47
|
-
return;
|
48
|
-
}
|
49
|
-
|
50
|
-
const tmpDir = mkdtempSync(path.join(os.tmpdir(), "prettier-ruby"));
|
51
|
-
sockfile = path.join(tmpDir, `${process.pid}.sock`);
|
52
|
-
|
53
|
-
spawnParseServer();
|
54
|
-
}
|
55
|
-
|
56
|
-
// Sends a request to the parse server to parse the given content.
|
57
|
-
function requestParse(parser, source) {
|
58
|
-
ensureParseServer();
|
59
|
-
|
60
|
-
const { command, arg } = getNetcat();
|
61
|
-
const { stdout, stderr, status } = spawnSync(command, [arg, sockfile], {
|
62
|
-
input: `${parser}|${source}`,
|
63
|
-
maxBuffer: 15 * 1024 * 1024
|
64
|
-
});
|
65
|
-
|
66
|
-
return {
|
67
|
-
command,
|
68
|
-
stdout: stdout.toString(),
|
69
|
-
stderr: stderr.toString(),
|
70
|
-
status
|
71
|
-
};
|
72
|
-
}
|
73
|
-
|
74
|
-
module.exports = requestParse;
|