cfjedimaster / brackets-jshint

Adds JSHint support to Brackets
MIT License
130 stars 41 forks source link

.jshintrc not recognized in latest version and Brackets 34 #20

Closed damacster closed 8 years ago

damacster commented 11 years ago

hi, i have a .jshintrc in the project's root directory but it doesn't appear to get picked up by the extension.

i'm using Brackets 34 and the latest version of the extension (2.0.14).

if there's anything i can do to troubleshoot the issue, do let me know.

busykai commented 11 years ago

@damacster, there's a pull request to enable support for .jshintrc in the new filesystem -- once @cfjedimaster merges it, you'll be back to normal.

damacster commented 11 years ago

@busykai, that is great news. many thanks for the reply.

EvHaus commented 10 years ago

Just confirming that it isn't working for me with the latest extension version [11/28/2013]. I don't see any outstanding pull requests open.

busykai commented 10 years ago

I'll recover my installed build and try to reproduce. Meanwhile, if you open developer tools (Debug->Show Developer Tools), do you see any error message in the console?

busykai commented 10 years ago

@globexdesigns : I've restored Sprint 34 and installed extension from the registry. It does work for me. Apart from checking the console log, could you also do Help -> Show Extensions Folder, go to user/camden.jshint and paste here the content of package json from that directory.

EvHaus commented 10 years ago

@busykai Still not working as of the latest update to the extension [11/29/2013]. Here is the output from package.json. I am using sprint 35 development build 0.35.0-0 with latest Github Brackets code.

{
    "name": "camden.jshint",
    "title": "JSHint",
    "description": "Adds JSHint support to Brackets.",
    "homepage": "https://github.com/cfjedimaster/brackets-jshint",
    "version": "2.0.17",
    "author": "Raymond Camden <raymondcamden@gmail.com> (http://www.raymondcamden.com)",
    "license": "MIT",
    "engines": {
        "brackets": ">=0.34.0"
    }
}

There are no errors in the console log. Even when switching files.

Does the .jshintrc have to be at the root of the Brackets project? Or will the extension do the right thing and walk up each directory until it finds it?

EvHaus commented 10 years ago

Ah, looking at the source code for the extension, I see now that it's not walking up the directories and its expecting the file to be at the root of the Brackets project. This is why its not working for me. Can this be fixed to use the method as described here: http://www.jshint.com/docs/

In case of .jshintrc, JSHint will look for this file in the current working directory and, if not found, will move one level up the directory tree all the way up to the filesystem root. (Note that if the input comes from stdin, JSHint doesn't attempt to find a configuration file)
busykai commented 10 years ago

It has to be in the root -- that's the most common way people use it. I'll add behavior for "real" jshint-node which is mostly needed in the case submodules are used. I still couldn't get to add this functionality.

I've updated README.md this morning to describe what the users should expect: README.md.

damacster commented 10 years ago

i have been using the latest version of Brackets (Sprint 34) and have the .jshintrc file in root of the project tree, and it's been working just fine.

EvHaus commented 10 years ago

I'll also note that when I have .jshintrc in the root of the project, it loads it, but Linting in brackets is disabled and the following error shows up the Console log:

Uncaught TypeError: Cannot read property 'length' of undefined (CodeInspection.js:229)

Manually opening the JSHint panel seems to show my errors, but Brackets is unhappy with something. Looking into it a little further it looks like brackets-jshint is sending the code line number as -1.

busykai commented 10 years ago

Apparently, JSHint does not provide a code snippet for an hint. Does it happen on all the files or some specific file? Could you share a file on which it happens?

EvHaus commented 10 years ago

Doing some debugging it looks like it's caused by specifying an invalid option in .jshintrc. I have "vars:true" in there and apparently "vars" isn't a valid option in JSHint. It also didn't like that I had "es5: true" because that option is set by default.

Sounds like brackets-jshint needs to validate the .jshintrc file before sending it to Brackets and alerting the user that they have invalid options, etc...

busykai commented 10 years ago

Good point. Could you file a separate issue? This issue needs to closed and the discussion should be continued in the new one. If you could provide a minimal test case (example .jshintrc) to reproduce, it would be nice.

EvHaus commented 10 years ago

Separate bugs created here:

https://github.com/cfjedimaster/brackets-jshint/issues/24 https://github.com/cfjedimaster/brackets-jshint/issues/25

This issue can be closed.

jetand commented 8 years ago

I also had this problem and it turned out the problem was that it does not read contents of the .jshintrc file if it does not have UTF-8 BOM (byte order mark). It opened the file which I confirmed by using Process Monitor but failed to read the settings from the file. Brackets showed no errors and no warnings about this. It just failed silently. You can set the encoding in for example Notepad++. Make sure you delete all invalid UTF-8 from the file. encoding

erik-slack commented 8 years ago

I'm having issues with brackets not applying my .jshintrc file. It's in my project's root and if I use a per-file directive then it recognizes that in jshint, but for some reason I can't get it to detect the .jshintrc whether I put it in the root of the project or in the folder with the file I'm looking at.

Can anyone help me get this to work?

cfjedimaster commented 8 years ago

If you open up the dev console, do you see any errors perhaps?

erik-slack commented 8 years ago

I figured it out sorry! It was a silly mistake: I gave the .jshintrc file a name like: myhintrules.jshintrc instead of just .jshintrc.

That's why it couldn't be detected. I don't know how I missed that.

cfjedimaster commented 8 years ago

No worries.