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

How to set options in package.json ? #2929

Open
TriMoon opened this issue May 21, 2016 · 12 comments
Open

How to set options in package.json ? #2929

TriMoon opened this issue May 21, 2016 · 12 comments

Comments

@TriMoon
Copy link

TriMoon commented May 21, 2016

The documentation mentions this possibility using jshintConfig, but no example or explanations.

@jugglinmike
Copy link
Member

Here's an example of setting expr: true in a package.json file:

{
  "jshintConfig": {
    "expr": true
  }
}

Please let us know if that does not work for you--it may be a bug in JSHint.

As for documentation, I believe the current explanation is fairly descriptive
(see below), but there's always room for improvements.

There are three main ways to configure your copy of JSHint: you can either
specify the configuration file manually via the --config flag, use a
special file .jshintrc or put your config into your projects package.json
file under the jshintConfig property.

@originalfoo
Copy link

originalfoo commented Jun 4, 2016

@jugglinmike IMO it would be good to show examples of each of those options, and in addition the inline config (eg. // jshint asl: true format configs you can put direct in source code). As a new user to jshint, I also found the documentation stated in your comment above somewhat confusing - it makes perfect sense once you know what it means, but for newbies some examples would be very helpful.

Is there a way to contribute to documentation? If so I'll add some examples and send a pull request. Or is it pulled from this page in wiki?

@jugglinmike
Copy link
Member

Hi @aubergine10. The docs are maintained here: https://github.com/jshint/jshint.github.io

@originalfoo
Copy link

Ok, will send a pull request early next week.

@originalfoo
Copy link

originalfoo commented Jun 5, 2016

@jugglinmike What are the proper locations for the .jshintrc and package.json files?

EDIT: Worked it out, ignore me lol.

@TriMoon
Copy link
Author

TriMoon commented Jun 5, 2016

@jugglinmike

Please let us know if that does not work for you--it may be a bug in JSHint.

I'm sorry to inform you that i have switched to eslint+jscsin meantime, so i'm unable to give proper feedback.
But i'm sure it will help others who also just start with jshint while using package.json

originalfoo pushed a commit to originalfoo/jshint.github.io that referenced this issue Jun 5, 2016
PR inspired by jshint/jshint#2929

Added distinct sections for different ways to apply settings (inline,
settings files, CLI), ensuring clear example for each.

Removed some excess verbiage so that readers get to details quicker.

Applied some formatting for easier reading.

Wasn't sure about order of precedence so guessed - lmk if it's wrong.
@pabloleone
Copy link

the way you mentioned doesn't work for me. I tried the comments which I though would be the easiest, but nop. Then I tried the hidden file and also the package.json.

How can I configure this JSHint plugin?

@adityarar
Copy link

Its 2018 and I still could not get this working.

@toraxmalu
Copy link

toraxmalu commented Nov 4, 2018

It does work. But it is really a shame for such an important VSCode extension not to include a proper example in the documentation…

Long story short: You've to place the configuration block alongside the other settings in package.json. Here my version to set the directive for "esversion". The first few lines are set by VSCode at project start. The 2nd section ("jshintConfig") is the block of interest.

{
  "name": "webcontent",
  "version": "1.0.0",
  "description": "",
  "main": "conv.html",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  
  "jshintConfig" : {
    "esversion" : "6"
  }
}

@Wilker-uwu
Copy link

@toraxmalu should the numbers and booleans also be strings?

@toraxmalu
Copy link

toraxmalu commented Nov 22, 2018

Sorry, no clue. JShint worked as whished with the quoted config. And for me it was a hack without really knowing, what I do. ;)

But have a look into JSON-standard. There you should find the answer

@Wilker-uwu
Copy link

i tried it lol

no need for strings, booleans and numbers are fine ^-^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants