Skip to content
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

Don't print Validation Warning for "//" comments in package.json #6027

Closed
melissachang opened this issue Apr 18, 2018 · 12 comments
Closed

Don't print Validation Warning for "//" comments in package.json #6027

melissachang opened this issue Apr 18, 2018 · 12 comments

Comments

@melissachang
Copy link

Do you want to request a feature or report a bug?

Feature

What is the current behavior?

package.json doesn't support comments. The official, npm-sanctioned way to add comments is to use "//" key:

{ "//": "this is the first line of a comment", 
  "//": "this is the second line of the comment" } 

Running https://repl.it/repls/ThornyHatefulVirus prints a Validation Warning:

● Validation Warning:

  Unknown option "//" with value "comment" was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://facebook.github.io/jest/docs/configuration.html

What is the expected behavior?

No warning should be printed for "//" keys.

@thymikee
Copy link
Collaborator

I don't know, is this a widely used practice? Honestly I see this for the first time, but maybe it's just me. We would probably need to add more if these special characters to the whitelist, which I'm not happy with.

@thymikee
Copy link
Collaborator

Is this actually documented somewhere outside of node mailing list? I'd be happy to accept a PR if this really exists

@melissachang
Copy link
Author

This does not appear to be documented at docs.npmjs.com, but the mailing list looks pretty official to me. It was written by the creator (and current CEO) of npm.

Unfortunately github doesn't allow searching on special characters, so I can't see how common this is.

FYI the SO post is the first Google hit for comments package.json

@SimenB
Copy link
Member

SimenB commented Apr 19, 2018

I remember seeing this as the response on the npm issue tracker, I think I actually submitted a PR at one point to npm supporting comments. Lemme see if I can dig it up!

EDIT: Yeah, see npm/npm#4482 (and my rejected PR, for posterity: npm/read-package-json#46)

@rickhanlonii
Copy link
Member

I've seen this used before and since node people are directing folks to do it I'm also +1 for supporting 👍It's not like we're ever going to use "//" as a config for anything

Labeling good first issue! @melissachang any interesting in taking it?

@melissachang
Copy link
Author

Sorry, not at the moment :/

@rickhanlonii
Copy link
Member

No sweat!

@andrew-pyle
Copy link
Contributor

@rickhanlonii First-time contributor here. I’d like to take a stab at implementing this feature. Can you point me at the validation logic for Jest configuration in package.json?

@SimenB
Copy link
Member

SimenB commented Oct 27, 2018

That's awesome @andrew-pyle!

It's here: https://github.com/facebook/jest/blob/c22d9f584627a1ae6c476d44f10c3c186b480722/packages/jest-validate/src/validate.js#L59-L63

What I would do (I think, haven't tested it) is add // to the default blacklist. Feel free to ask questions if you're stuck 🙂

@andrew-pyle
Copy link
Contributor

Pull request #7295 sent to implement @SimenB's suggestion of adding "//" to the default blacklist

@SimenB
Copy link
Member

SimenB commented Oct 30, 2018

Fixed in #7295

@SimenB SimenB closed this as completed Oct 30, 2018
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants