-
-
Notifications
You must be signed in to change notification settings - Fork 40
Upgrade Prettier version, fix comment discovery #25
Conversation
Oh nice! I like a lot of the Python stuff done in that diff! It seems like the overlap with this (using the |
Yeah, that sounds totally reasonable. I haven't had much time to think about much of this – just wanted to point you at another attempt to handle some of the same issues. |
Looks like CI might have had a flake. Closing and re-opening to try to force Travis to rebuild. (Is there a better way to do that?) |
@@ -1,5 +1,6 @@ | |||
"use strict"; | |||
|
|||
const utilShared = require("prettier").util; | |||
const util = require("./_util-from-prettier"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we delete this file now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, good call! It's gone!
src/index.js
Outdated
@@ -47,7 +133,6 @@ function clean(ast, newObj) { | |||
const printers = { | |||
python: { | |||
print, | |||
hasPrettierIgnore: util.hasIgnoreComment, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this wasn't actually being passed in, as far as I can tell (the value was undefined
, even on master).
@FuegoFro what's the state of this? |
Bump the dependency on the main Prettier repo to the latest commit. This allows us to specify additional options (such as `pythonVersion`). Note that the version is defaulting to Python3, which I believe matches the behavior from before. The plugin API in the newer version requires plugins to provide a `locStart` and `locEnd` function. From what I've seen, this is to allow customization, which is something we want and will help with things like better comment rendering. However, I'm not totally sure what customizations we want/need in these functions, so for now this just copies in the old versions of those functions. This shouldn't actually be a functional change from before the upgrade, and still allows us to modify/customize that functionality in the future as needed. I also noticed a bug in how comments are detected within Python. There was a check that hard-coded the `COMMENT` token type as `57`, but it's actually different on different versions of Python. This fixes that check to use the proper value for the given version of Python and updates a test that mistakenly did not have comments in the expected output.
f365ae9
to
a83b4d8
Compare
Just rebased and fixed up conflicts and failing tests! |
Bump the dependency on the main Prettier repo to the latest commit. This allows us to specify additional options (such as
pythonVersion
). Note that the Python version defaults to Python3, which I believe matches the behavior from before.The plugin API in the newer version requires plugins to provide a
locStart
andlocEnd
function. From what I've seen, this is to allow customization, which is something we want and will help with things like better comment rendering. However, I'm not totally sure what customizations we want/need in these functions, so for now this just copies in the old versions of those functions. This shouldn't actually be a functional change from before the upgrade, and still allows us to modify/customize that functionality in the future as needed.I also noticed a bug in how comments are detected within Python. There was a check that hard-coded the
COMMENT
token type as57
, but it's actually different in different versions of Python. This fixes that check to use the proper value for the given version of Python and updates a test that mistakenly did not have comments in the expected output.