-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial bit of prettier, with recommended .prettierrc #3876
Conversation
✅ Deploy Preview for prismjs-com ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
89af935
to
c4af7bc
Compare
It seems like this file is broken. For example, on line 166, there is not enough code. Here is what is supposed to be there: prism/components/prism-bash.js Lines 154 to 161 in 76dde18
And everything starting from line 243 should be deleted: it's a fragment of the code above. With these two changes, the file will be read and parsed correctly. |
5284f42
to
dfe4c02
Compare
Yes now it's working. I think the v0.0.5 |
dfe4c02
to
0f6a1f0
Compare
I ran prettier on all files (besides /website) and it worked without error. I didn't commit anything because I didn't want to make the PR unreadable. |
I wouldn't have expected it to be so severe. 😱 My test didn't show that, but I can't deny I might have missed something. |
0f6a1f0
to
343aa88
Compare
Ok I have added a PR that actually runs Prettier on everything: It ran into an issue where it was mangling script/build.ts. Note it's based off the branch of current PR |
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.
Finally found some time to review this, thanks everyone for your patience!
Some small tweaks and we're ready to go. I’ve left some comments on the diff.
Some additional comments:
- If we're using Prettier, we should remove any rules from ESLint that are covered by Prettier, or ditch it entirely. I'm fine with either of these options, but currently we have rules in
eslintrc
that are covered by Prettier (e.g.curly
)
Not strictly related with this PR, just some things I noticed when going through the diff:
- I think we should ditch babel & minification in v2. If folks want to transpile or minify they can do their own transformations (which for minification is AFAIK the currently recommended way, as minifying twice is a recipe for bugs)
- I wonder if we could switch the language definitions back to JS. Their use of types is minimal, and TS imposes barriers to contributions, and these are the most frequently contributed files.
tests/helper/util.ts
Outdated
@@ -101,7 +101,7 @@ export function getTrailingSpaces(string: string): string { | |||
} | |||
|
|||
export function formatHtml(html: string): string { | |||
return Prettier.format(html, { | |||
return synchronizedPrettier.format(html, { | |||
printWidth: 100, | |||
tabWidth: 4, | |||
useTabs: true, |
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.
Non-blocking, but it would be nice if we could import our Prettier config here (and remove the plugins via JS since they don't work with sync prettier), instead of duplicating it.
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.
I think the plugins still work with sync prettier, I just ran it with tests and it seems totally fine.
343aa88
to
58c53e5
Compare
Ok, most recent update - to make things less confusing, I removed any formatting of Everything is now up to date and working! thanks so much for the feedback.
Done! |
e7b2abd
to
0071f98
Compare
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.
LGTM! Thanks for your patience everyone.
Non-blocking: We may want to add a .vscode/settings.json
with:
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.enable": true,
}
That way, folks that don't have Prettier enabled by default, can still use it.
Note that prettier sync is being imported in order to enable us to format test code during tests. It should not be used anywhere else Updated eslint rules to work with prettier, including removing redundant rules.
0071f98
to
f390aec
Compare
Note: I only ran prettier on
src/core
. The reason for this is that this prettier config will mangle some code.It is not the fault of a single prettier plugin, or the prettier version. Instead, it is when 3 plugins are used together that this issue happens.
It is kind of difficult to describe - you can see the error on the bash language definition. I just ran this:
npx prettier src/languages/prism-bash.ts --write
Additionally, I did not want to work super hard on forming eslint to the prettier config until we committed to this approach. I would love feedback.