Conversation
Codecov Report
@@ Coverage Diff @@
## master #390 +/- ##
==========================================
+ Coverage 98.14% 98.21% +0.07%
==========================================
Files 22 22
Lines 3663 3988 +325
Branches 1024 1219 +195
==========================================
+ Hits 3595 3917 +322
- Misses 25 28 +3
Partials 43 43
Continue to review full report at Codecov.
|
|
We'll probably want a eslint-config-babel that contains no styling rules (or also extend https://github.com/prettier/eslint-config-prettier)? |
|
This is super exciting! Do not hesitate to open up issues on the prettier repo if you see anything that isn't printed in a way that you would have written code. I want to know about it :) |
src/tokenizer/state.js
Outdated
| this.inType = | ||
| this.noAnonFunctionType = | ||
| false; | ||
| this.inMethod = this.inFunction = this.inGenerator = this.inAsync = this.inPropertyName = this.inType = this.noAnonFunctionType = false; |
There was a problem hiding this comment.
I had no idea people would chain this kind of calls! We could support it in prettier but that would add quite a bit of complexity. Since you are already writing them each on their own line, I think that it would be better to just rewrite is as
this.inMethod = false;
this.inFunction = false;
// ...There was a problem hiding this comment.
It's probably specific to the parser/acorn, not common, we could probably just ignore for certain sections that aren't going to change much
There was a problem hiding this comment.
@vjeux Yes I mentioned that in the description above too. It is probably more readable if we rewrite it.
There was a problem hiding this comment.
feel free to add // @prettier-ignore just before if you want to keep formatting for some special cases.
There was a problem hiding this comment.
One case I know of is Babel actually outputs code like this in the case of exports at the moment. See https://babeljs.io/repl/#?babili=false&evaluate=false&lineWrap=false&presets=es2015&targets=&browsers=&builtIns=false&code=import%20thing%20from%20'bar'%3B%0A%0Aexport%20var%20a%2C%20b%2C%20c%2C%20d%2C%20e%2C%20f%2C%20g%2C%20h%2C%20i%2C%20j%2C%20k%2C%20l%2C%20m%2C%20n%20%2Co%2C%20p%2C%20q%2C%20r%2C%20s%2C%20t%2C%20u%2C%20v%2C%20x%2C%20y%2C%20z%3B&experimental=true&loose=false&spec=false&playground=true&stage=0
includes
exports.z = exports.y = exports.x = exports.v = exports.u = exports.t = exports.s = exports.r = exports.q = exports.p = exports.o = exports.n = exports.m = exports.l = exports.k = exports.j = exports.i = exports.h = exports.g = exports.f = exports.e = exports.d = exports.c = exports.b = exports.a = undefined;
There was a problem hiding this comment.
That's just output though so it's fine?
| // offset to the next range, and then a size of the range. They were | ||
| // generated by `bin/generate-identifier-regex.js`. | ||
| // eslint-disable-next-line comma-spacing | ||
| const astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,10591,541]; |
There was a problem hiding this comment.
fyi, you can use // @prettier-ignore in order to print it as is and not have every argument expanded in a single line.
src/tokenizer/index.js
Outdated
| if (isIdentifierStart(code) || code === 92 /* '\' */) { | ||
| return this.readWord(); | ||
| if (isIdentifierStart(code) || code === 92) { | ||
| /* '\' */ return this.readWord(); |
There was a problem hiding this comment.
This is not intended, I just created an issue for it: prettier/prettier#867
src/plugins/jsx/index.js
Outdated
|
|
||
| if (!openingElement.selfClosing) { | ||
| contents: for (;;) { | ||
| contents: |
There was a problem hiding this comment.
This will be fixed in the next release: prettier/prettier#860
|
Can we just target 7.0 for this? We can cherry pick other prs if necessary |
src/parser/statement.js
Outdated
| case tt._import: | ||
| if (this.hasPlugin("dynamicImport") && this.lookahead().type === tt.parenL) break; | ||
| if ( | ||
| this.hasPlugin("dynamicImport") && this.lookahead().type === tt.parenL |
There was a problem hiding this comment.
I opened prettier/prettier#868 as it looks a bit weird
src/plugins/jsx/fromCodePoint.js
Outdated
| // Astral code point; split in surrogate halves | ||
| // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae | ||
| codePoint -= 0x10000; | ||
| highSurrogate = (codePoint >> 10) + 0xD800; |
There was a problem hiding this comment.
It's always so interesting how little things trigger knee-jerk reactions. I always prefer capitalized hex haha.
|
We moved the previous 7.0 branch to be |
|
I just rerun prettier 1.2.2 on the source and all the mentioned things are fixed now. :) |
|
Okay rebased and change everything to work. Ready for review. |
| const startData = generate(start); | ||
| const contData = generate(cont); | ||
|
|
||
| console.log("let nonASCIIidentifierStartChars = \"" + startData.nonASCII + "\";"); |
There was a problem hiding this comment.
We can just use template strings here, don't have to change in this pr
|
|
||
| this.finishNode(node, (op === tt.logicalOR || op === tt.logicalAND) ? "LogicalExpression" : "BinaryExpression"); | ||
| return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn); | ||
| node.right = this.parseExprOp( |
|
Just going to be annoying for @Andy-MS ts pr |
|
@hzoo after this lands he can just run prettier on his pr, presumably! |
|
That's the idea! I guess you would run beforehand and then rebase 7.0 and it would be ok? |
|
Moving to #600 |

The changes are very minimal, only in state.js prettier created a super long line, but we could also optimize this by hand and instead initialize every property individual.
Thoughts?