eslint / eslint

Find and fix problems in your JavaScript code.
https://eslint.org
MIT License
25.2k stars 4.56k forks source link

2.0 eslint --init doesn't save the config file #5243

Closed pawelgrzybek closed 8 years ago

pawelgrzybek commented 8 years ago
  1. I use version 2.0 (just installed)
  2. I typed in my command line 'eslint --init', answered the questions and tried to save as an js of jaml file
  3. I expected to save my config file on my current directory.
  4. Nothing happened, file didn't save on my directory.
platinumazure commented 8 years ago

I think this is a known issue that will be fixed in 2.0.1. @IanVS can you confirm this is a duplicate?

IanVS commented 8 years ago

Need a little bit more info. @pawelgrzybek, what answer did you give to the first question it asked?

eslintbot commented 8 years ago

Hi @pawelgrzybek, thanks for the issue. It looks like there's not enough information for us to know how to help you. If you're reporting a bug, please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. What you did (the source code and ESLint configuration)
  3. The actual ESLint output complete with numbers
  4. What you expected to happen instead

Requesting a new rule? Please see Proposing a New Rule for instructions.

If it's something else, please just provide as much additional information as possible. Thanks!

mdhooge commented 8 years ago

Same problem here with version v2.0.0: It just stops after the last question, with no errors (even with --debug flag). I tried both answering questions & using popular guide, with output in the 3 formats.

IanVS commented 8 years ago

@mdhooge, what you are experiencing when answering questions is https://github.com/eslint/eslint/issues/5220, which has been fixed and will go out in a patch release after the weekend. I suspect it is also what @pawelgrzybek is reporting.

If you're seeing this when choosing second option (choosing a popular guide), then that is a new issue. I'll try to look into it later, but I'm in the middle of a tiling project right now.

mdhooge commented 8 years ago

I upgraded to commits #980e139 & #098ecad (at least, I do think I did according to the gitHead value of the package.json created by npm…). With the same empty result when using the standard popular style with JSON output.

mdhooge commented 8 years ago

That's ok for me if you look into it later, it isn't a blocking bug :)

pawelgrzybek commented 8 years ago

Hay @IanVS These are my answers:

? How would you like to configure ESLint? Answer questions about your style ? Are you using ECMAScript 6 features? Yes ? Are you using ES6 modules? Yes ? Where will your code run? Node, Browser ? Do you use CommonJS? Yes ? Do you use JSX? Yes ? Do you use React Yes ? What style of indentation do you use? Spaces ? What quotes do you use for strings? Single ? What line endings do you use? Unix ? Do you require semicolons? Yes ? What format do you want your config file to be in? JavaScript

The version that I run is v2.0.0 globally installed. OS X 10.11.3. It just doesn't save a config file at all. I tried different formats (jspn and yaml) with same result.

ilyavolodin commented 8 years ago

@pawelgrzybek Thanks for the details. This is a duplicate of #5220 and has already been fixed. The fix will be released with the next patch version. Closing as fixed.

msolovyov commented 8 years ago

@ilyavolodin I have eslint from the latest commit f3ee22d60c52d8d9437812f971ef3aa441910d1c, I get a .eslintrc file generated when I do the answer questions init, but when I do the use popular style I get nothing.

ilyavolodin commented 8 years ago

@msolovyov Thanks! Reopening the issue. Looks like popular style is still causing problems.

btmills commented 8 years ago
TypeError: Cannot convert undefined or null to object
    at Function.keys (native)
    at check (~/eslint/eslint/lib/util/npm-util.js:77:35)
    at Object.checkDevDeps (~/eslint/eslint/lib/util/npm-util.js:114:12)
    at installModules (~/eslint/eslint/lib/config/config-initializer.js:85:29)
    at getConfigForStyleGuide (~/eslint/eslint/lib/config/config-initializer.js:273:5)
    at null.completed (~/eslint/eslint/lib/config/config-initializer.js:335:22)
    at PromptUI.onCompletion (~/eslint/eslint/node_modules/inquirer/lib/ui/prompt.js:57:10)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.completed (~/eslint/eslint/node_modules/rx-lite/rx.lite.js:1550:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted (~/eslint/eslint/node_modules/rx-lite/rx.lite.js:1489:14)
    at Subject.Rx.Subject.addProperties.onCompleted (~/eslint/eslint/node_modules/rx-lite/rx.lite.js:5871:19)
btmills commented 8 years ago

@msolovyov does the package.json in your directory already have a devDependencies section, or do you not have any devDependencies yet?

btmills commented 8 years ago

I've found at least one bug: If package.json exists, but it does not specify both devDependencies and dependencies, then the check() method in npm-util will fail. Hopefully it's the same issue @msolovyov is seeing.

Working on a fix.

msolovyov commented 8 years ago

I don't have a package json in my project directory. On Feb 14, 2016 10:41 AM, "Brandon Mills" notifications@github.com wrote:

I've found at least one bug: If package.json exists, but it does not specify both devDependencies and dependencies, then the check() method in npm-util will fail. Hopefully it's the same issue @msolovyov https://github.com/msolovyov is seeing.

Working on a fix.

— Reply to this email directly or view it on GitHub https://github.com/eslint/eslint/issues/5243#issuecomment-183948041.

btmills commented 8 years ago

:+1: Got it. I'm able to reproduce that. I'm submitting a PR to fix the issue I found earlier, then I'll see if I can track down what's causing that.

btmills commented 8 years ago

npm-util line 73 is throwing an error (intentionally) saying it can't find the package.json file. Inquirer is suppressing it, and init fails silently. @IanVS what's the intended behavior if no package.json is found?

ilyavolodin commented 8 years ago

@btmills I think it should create one, since we can't install shareable configs without it.

IanVS commented 8 years ago

Hm, setting up a package.json seems a little out of scope for this. I would suggest exiting with a message that sharable configs require an npm project to be initialized. I can work on this, @btmills, if you would like.

btmills commented 8 years ago

Sure, go ahead and take that one.

IanVS commented 8 years ago

Nearly done...

I decided the best thing to do is to wrap everything in try/catches and report any/all errors. --init is too eager at swallowing Errors, otherwise, and we'll continue to scratch our heads.