Socket
Socket
Sign inDemoInstall

prettier

Package Overview
Dependencies
9
Maintainers
2
Versions
162
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.8 to 0.0.9

9

bin/prettier.js
#!/usr/bin/env node
"use strict";

@@ -15,3 +16,4 @@ const fs = require("fs");

"single-quote",
"trailing-comma"
"trailing-comma",
"version"
],

@@ -21,2 +23,7 @@ default: { "bracket-spacing": true }

if (argv["version"]) {
console.log(jscodefmt.version);
process.exit(0);
}
const filenames = argv["_"];

@@ -23,0 +30,0 @@ const write = argv["write"];

@@ -0,1 +1,31 @@

# 0.0.9
[link](https://github.com/jlongster/prettier/compare/0192d58...a7405257)
* Workaround flow bug parsing astral unicode characters (#277)
* Allow specifying the major mode that `defun-before-save` will use. (#276
* Fix space missing before `,` on export with bracket spacing off (#278)
* Fix space missing before `,` on import with bracket spacing off (#279)
* Add newline after shebang if necessary. (#215)
* Remove +1 from newline detection (#261)
* Fix path when printing member chains so parens work properly (fixes #243
* Ensure parens on NewExpression with function callee (#282)
* Fix missing semi when default exporting CallExpression (#287)
* Workaround flow parser bug with spread in arrays (#285)
* Update flow-parser to 0.38 (#290)
* Allow customizing args sent to prettier-command (#289)
* Do not output trailing commas with rest arguments (#283)
* Use exact versions in package.json (#291)
* Use js native String.repeat() (#293)
* Handle additional export default parens cases (#298)
* Fix parens around anonymous functions (#297)
* Introduce second argument to ifBreak (#302)
* Fix bracketSpacing typo in tests (#299)
* Remove unused variable (#304)
* Fix trailing whitespace (#300)
* add version flag (#294)
* Add --run-in-band to travis (#306)
* [JSX] Split elements on newlines and preserve whitespace (w/@yamafaktory) (#234)
* Print binary and logical expressions in a nicer format (#262)
# 0.0.8

@@ -2,0 +32,0 @@

13

index.js

@@ -6,2 +6,3 @@ "use strict";

const comments = require("./src/comments");
const version = require('./package.json').version;

@@ -38,4 +39,4 @@ var babylonOptions = {

if (ast.errors.length > 0) {
let msg = ast.errors[(0)].message + " on line " +
ast.errors[(0)].loc.start.line;
let msg = ast.errors[0].message + " on line " +
ast.errors[0].loc.start.line;
if (opts.filename) {

@@ -70,3 +71,6 @@ msg += " in file " + opts.filename;

const programText = text.slice(index + 1);
return shebang + format(programText, opts);
const nextChar = text.charAt(index + 1);
const addNewline = nextChar == "\n" || nextChar == "\r";
return shebang + (addNewline ? "\n" : "") + format(programText, opts);
}

@@ -77,3 +81,4 @@

return formatWithShebang(text, opts);
}
},
version: version
};
{
"name": "prettier",
"version": "0.0.8",
"version": "0.0.9",
"bin": {

@@ -19,17 +19,17 @@ "prettier": "./bin/prettier.js"

"ast-types": "git+https://github.com/jlongster/ast-types.git",
"babylon": "^6.15.0",
"esutils": "^2.0.2",
"flow-parser": "^0.37.0",
"get-stdin": "^5.0.1",
"jsesc": "^2.4.0",
"minimist": "^1.2.0",
"private": "^0.1.6"
"babylon": "6.15.0",
"esutils": "2.0.2",
"flow-parser": "0.38.0",
"get-stdin": "5.0.1",
"jsesc": "2.4.0",
"minimist": "1.2.0",
"private": "0.1.6"
},
"devDependencies": {
"jest": "^18.0.0",
"rollup": "^0.41.1",
"rollup-plugin-commonjs": "^7.0.0",
"rollup-plugin-node-builtins": "^2.0.0",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-real-babili": "^1.0.0-alpha3"
"jest": "18.0.0",
"rollup": "0.41.1",
"rollup-plugin-commonjs": "7.0.0",
"rollup-plugin-node-builtins": "2.0.0",
"rollup-plugin-node-resolve": "2.0.0",
"rollup-plugin-real-babili": "1.0.0-alpha3"
},

@@ -36,0 +36,0 @@ "scripts": {

var assert = require("assert");
var types = require("ast-types");
var util = require("./util");
var n = types.namedTypes;

@@ -265,5 +266,5 @@ var Node = n.Node;

var po = parent.operator;
var pp = PRECEDENCE[po];
var pp = util.getPrecedence(po);
var no = node.operator;
var np = PRECEDENCE[no];
var np = util.getPrecedence(no);

@@ -377,2 +378,3 @@ if (pp > np) {

switch (parent.type) {
case "ExpressionStatement":
case "MemberExpression":

@@ -383,2 +385,5 @@ case "TaggedTemplateExpression":

case "NewExpression":
return name === "callee";
default:

@@ -426,20 +431,2 @@ return isBinary(parent);

var PRECEDENCE = {};
[
[ "||" ],
[ "&&" ],
[ "|" ],
[ "^" ],
[ "&" ],
[ "==", "===", "!=", "!==" ],
[ "<", ">", "<=", ">=", "in", "instanceof" ],
[ ">>", "<<", ">>>" ],
[ "+", "-" ],
[ "*", "/", "%", "**" ]
].forEach(function(tier, i) {
tier.forEach(function(op) {
PRECEDENCE[op] = i;
});
});
function containsCallExpression(node) {

@@ -446,0 +433,0 @@ if (n.CallExpression.check(node)) {

@@ -54,4 +54,11 @@ "use strict";

function ifBreak(contents) {
return { type: "if-break", contents };
function ifBreak(breakContents, flatContents) {
if (breakContents) {
assertDoc(breakContents);
}
if (flatContents) {
assertDoc(flatContents);
}
return { type: "if-break", breakContents, flatContents };
}

@@ -82,2 +89,9 @@

}
} else if (doc.type === "if-break") {
if (doc.breakContents) {
docs.push(doc.breakContents);
}
if (doc.flatContents) {
docs.push(doc.flatContents);
}
} else if (doc.type !== "line") {

@@ -136,12 +150,2 @@ docs.push(doc.contents);

function _makeIndent(n) {
var s = "";
for (var i = 0; i < n; i++) {
s += " ";
}
return s;
}
const MODE_BREAK = 1;

@@ -191,4 +195,11 @@ const MODE_FLAT = 2;

if (mode === MODE_BREAK) {
cmds.push([ ind, mode, doc.contents ]);
if (doc.breakContents) {
cmds.push([ ind, mode, doc.breakContents ]);
}
}
if (mode === MODE_FLAT) {
if (doc.flatContents) {
cmds.push([ ind, mode, doc.flatContents ]);
}
}

@@ -314,4 +325,11 @@ break;

if (mode === MODE_BREAK) {
cmds.push([ ind, MODE_BREAK, doc.contents ]);
if (doc.breakContents) {
cmds.push([ ind, mode, doc.breakContents ]);
}
}
if (mode === MODE_FLAT) {
if (doc.flatContents) {
cmds.push([ ind, mode, doc.flatContents ]);
}
}

@@ -342,10 +360,2 @@ break;

case MODE_BREAK:
if (out.length > 0) {
const lastString = out[out.length - 1];
if (lastString.match(/^\s*\n\s*$/)) {
out[out.length - 1] = "\n";
}
}
if (doc.literal) {

@@ -356,4 +366,10 @@ out.push("\n");

} else {
out.push("\n" + _makeIndent(ind));
if (out.length > 0) {
// Trim whitespace at the end of line
out[out.length - 1] = out[out.length - 1]
.replace(/[^\S\n]*$/, '');
}
out.push("\n" + " ".repeat(ind));
pos = ind;

@@ -360,0 +376,0 @@ }

@@ -122,10 +122,16 @@ "use strict";

function skipNewLineForward(text, index) {
if (text.charAt(index) === "\n") {
return index + 1;
// What the "end" location points to is not consistent in parsers.
// For some statement/expressions, it's the character immediately
// afterward. For others, it's the last character in it. We need to
// scan until we hit a newline in order to skip it.
while(index < text.length) {
if (text.charAt(index) === "\n") {
return index + 1;
}
if (text.charAt(index) === "\r" && text.charAt(index + 1) === "\n") {
return index + 2;
}
index++;
}
if (text.charAt(index) === "\r" && text.charAt(index + 1) === "\n") {
return index + 2;
}
// Note: this is incorrect, but makes the current tests pass for now.
return index + 1;
return index;
}

@@ -220,1 +226,23 @@

util.htmlEscapeInsideDoubleQuote = htmlEscapeInsideDoubleQuote;
var PRECEDENCE = {};
[
[ "||" ],
[ "&&" ],
[ "|" ],
[ "^" ],
[ "&" ],
[ "==", "===", "!=", "!==" ],
[ "<", ">", "<=", ">=", "in", "instanceof" ],
[ ">>", "<<", ">>>" ],
[ "+", "-" ],
[ "*", "/", "%", "**" ]
].forEach(function(tier, i) {
tier.forEach(function(op) {
PRECEDENCE[op] = i;
});
});
util.getPrecedence = function(op) {
return PRECEDENCE[op];
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc