-
-
Notifications
You must be signed in to change notification settings - Fork 412
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
style: Use dedent for prettier multi-line template literals #242
style: Use dedent for prettier multi-line template literals #242
Conversation
Codecov Report
@@ Coverage Diff @@
## master #242 +/- ##
==========================================
+ Coverage 97.09% 97.15% +0.06%
==========================================
Files 10 10
Lines 172 176 +4
Branches 26 26
==========================================
+ Hits 167 171 +4
Misses 5 5
Continue to review full report at Codecov.
|
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.
👍
Do you mind waiting till I merge #141 and applying those changes again? I just spent an evening merging master into it and I think this PR will intro some conflicts again. 🙄 |
Sure, no problem. |
@okonet Thanks! |
@sudo-suhas it's a pleasure! 👍 Thanks for accepting. I don't mind more eyes and hands here :) |
@sudo-suhas do you need help with resolving conflicts in this one? |
Nah.. I'll just discard my changes and start over. |
@sudo-suhas do you use cmd or powershell on windows? I'm thinking about something to improve our cross-platform compatibility |
I actually use |
28121aa
to
6834691
Compare
I know this is less important but I figured since the PR was open and changes were simple, would be better to merge it in. |
Rebasing and fixing conflicts. |
6834691
to
22bb370
Compare
} | ||
|
||
will fix it and remove this message. | ||
Unknown option \\"*.js\\" with value ['eslint --fix', 'git add'] was found in the config root. |
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.
Is there a way to keep this indentation of 2 spaces?
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.
It is possible if we keep a header text:
const message = dedent`
WARNING
Unknown option ${chalk.bold(`"${option}"`)} with value ${chalk.bold(
format(config[option], { inlineCharacterLimit: Number.POSITIVE_INFINITY })
)} was found in the config root.
You are probably trying to mix simple and advanced config formats. Adding
${chalk.bold(`"linters": {
"${option}": ${JSON.stringify(config[option])}
}`)}
will fix it and remove this message.
`
Dedent uses the min of indentation to strip. So we need relative indentation. What do you suggest?
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 put 2 spaces on the first line:
const message = dedent` Unknown option ${chalk.bold(`"${option}"`)} with value ${chalk.bold(
format(config[option], { inlineCharacterLimit: Number.POSITIVE_INFINITY })
)} was found in the config root.
You are probably trying to mix simple and advanced config formats. Adding
${chalk.bold(`"linters": {
"${option}": ${JSON.stringify(config[option])}
}`)}
will fix it and remove this message.
`
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.
Although it doesn't look very nice either...
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.
How about
const message = dedent`
UNKNOWN OPTION
Option ${chalk.bold(`"${option}"`)} with value ${chalk.bold(
format(config[option], { inlineCharacterLimit: Number.POSITIVE_INFINITY })
)} was found in the config root.
You are probably trying to mix simple and advanced config formats. Adding
${chalk.bold(`"linters": {
"${option}": ${JSON.stringify(config[option])}
}`)}
will fix it and remove this message.
`
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.
All caps are bad for readability. Also, I don't see a reason to have 2 titles. If dedent doesn't support our case, we should either not use it or add support to dedent. I don't want to compromise the UX in favor of better indented codebase.
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.
Okay. That makes sense. I'll look into dedent
.
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.
@okonet Small update, I made a PR to dedent
which would allow us to specify default indent - dmnd/dedent#14.
Running lint-staged with the following config: | ||
{ | ||
LOG Running lint-staged with the following config: | ||
{ |
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.
That's an odd indentation here
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.
You're right, sorry I missed it. Can be fixed with this:
console.log(`Running lint-staged with the following config: \n${stringifyObject(config)}`)
Is this ok?
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.
Okay with me!
src/index.js
Outdated
Make sure you have created it. See https://github.com/okonet/lint-staged#readme. | ||
console.error(dedent` | ||
Could not parse lint-staged config. | ||
Make sure you have created it. See https://github.com/okonet/lint-staged#readme. |
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.
isn't it better if we set the link to https://github.com/okonet/lint-staged#configuration?
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.
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.
Configuration is better IMO. No need to search for it.
Can this one be finalized, please? |
I made a PR to dedent(dmnd/dedent#14) for our requirement but did not get a response yet. |
@okonet I am not getting any response for the PR I made to
What do you suggest? |
@sudo-suhas can we just skip it for https://github.com/okonet/lint-staged/pull/242/files#diff-3aafb296b115847cd397630c3d4960a7R65 and move along? |
Yes @okonet that's what I meant by
Will rebase and resolve conflicts. |
22bb370
to
af45ede
Compare
🍾 |
This PR uses
dedent
for beautifying multi-line template literals: