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

CLI not locating .hintrc in user's home directory #1142

Closed
jgarber623 opened this issue Jun 20, 2018 · 3 comments
Closed

CLI not locating .hintrc in user's home directory #1142

jgarber623 opened this issue Jun 20, 2018 · 3 comments
Labels

Comments

@jgarber623
Copy link

Hello!

There appears to be a small issue when running the sonarwhal CLI under the following conditions:

  • sonarwhal is installed globally (consistent with the official documentation),
  • There's a "global" .sonarwhalrc configuration file in the user's home directory (~/.sonarwhalrc),
  • The user is running sonarwhal [url] in a folder other than the user's home directory, and
  • The current working directory contains package.json, node_modules/, etc.

I would expect that, regardless of the presence or absence of package.json, node_modules/, etc. in the current working directory that running sonarwhal [url] would first look in the current working directory for a configuration file then look in the user's home directory for the configuration file.

Note that running sonarwhal [url] in an arbitrary directory without package.json, node_modules/, etc. functions as expected, correctly locating and using the ~/.sonarwhalrc configuration file.

This issue is related to PR #718.

Environment

  • sonarwhal version: 1.11.2
  • Node.js version: 10.4.1
  • npm version: 6.1.0

sonarwhal configuration

sonarwhal’s configuration
{
    "extends": [
        "web-recommended",
        "progressive-web-apps"
    ],
    "formatters": "stylish"
}

URL for which sonarwhal failed

Output

Please include the raw output generated by sonarwhal, or if possible,
the raw output from running sonarwhal in debug mode: sonarwhal --debug <URL>.

sonarwhal’s raw output
$ npm install -g sonarwhal @sonarwhal/configuration-progressive-web-apps @sonarwhal/configuration-web-recommended
$ cd ~/some/directory
$ sonarwhal https://sonarwhal.com              

   ┌───────────────────────────────────────────────────────────────┐
   │                                                               │
   │             Couldn't find any valid configuration             │
   │                                                               │
   │       Running sonarwhal with the default configuration.       │
   │                                                               │
   │   Learn more about how to create your own configuration at:   │
   │                                                               │
   │            https://sonarwhal.com/docs/user-guide/             │
   │                                                               │
   └───────────────────────────────────────────────────────────────┘
@molant
Copy link
Member

molant commented Jun 20, 2018

@jgarber623 that's the current expected behavior.

Our way of thinking is that if you are inside a project folder (aka something with a package.json) then sonarwhal should be installed/search things locally.

In general we would like users to install it locally instead of globally. That said, there are a couple things we could do to improve the experience:

  • Do what you propose: even if there's a package.json search also in ~. I can't remember the problems we had with this scenario. Maybe something related to resource loading? @sarvaje do you remember?
  • Don't allow to execute sonarwhal in a folder that has package.json and tell the user to install it locally
  • Something else?

@sonarwhal/core thoughts?

@alrra alrra removed the type:bug label Jun 20, 2018
@alrra
Copy link
Contributor

alrra commented Jun 20, 2018

Don't allow to execute sonarwhal in a folder that has package.json and tell the user to install it locally

Works for me.


If, for example, you run npm i inside a directory without a package.json file it will give you the following:


npm WARN saveError ENOENT: no such file or directory, open '/Users/xxxxx/projects/tmp/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/Users/xxxxx/projects/tmp/package.json'
npm WARN tmp No description
npm WARN tmp No repository field.
npm WARN tmp No README data
npm WARN tmp No license field.

up to date in 0.611s
found 0 vulnerabilities

@molant molant changed the title CLI not locating .sonarwhalrc in user's home directory CLI not locating .hintrc in user's home directory Aug 8, 2018
@molant
Copy link
Member

molant commented Dec 6, 2019

We've moved away from recommending installing webhint globally in 9f13687 because of issues like this one.

Going to close this as the scenario is not supported.

@molant molant closed this as completed Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants