Giter VIP home page Giter VIP logo

brackets-jshint's People

Contributors

bengarnett avatar busykai avatar cfjedimaster avatar cgcgbcbc avatar d1sover avatar hacker112 avatar hirse avatar iamkevla avatar lichtjaeger avatar maciejsmolinski avatar mitchellmebane avatar mturkson23 avatar santhoshtr avatar thefirstofthe300 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brackets-jshint's Issues

Remove javascript comments from .jshintrc before loading

JSHint supports javascript style comments in .jshintrc. When a project contains such config file and brackets opens it, brackets-jshint fails to parse it because of comments.

Please use the following method to strip comments before you do JSON.parse in main.js

    /**
     * Removes JavaScript comments from a string by replacing
     * everything between block comments and everything after
     * single-line comments in a non-greedy way.
     *
     * English version of the regex:
     *   match '/*'
     *   then match zero or more instances of any character (incl. \n)
     *   except for instances of '* /' (without a space, obv.)
     *   then match '* /' (again, without a space)
     *
     * @param {string} str a string with potential JavaScript comments.
     * @returns {string} a string without JavaScript comments.
     */
    function removeComments(str) {
        str = str || "";

        str = str.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\//g, "");
        str = str.replace(/\/\/[^\n\r]*/g, ""); // Everything after '//'

        return str;
    }

This is the same approach jshint uses with its command line interface.

I considered giving a pull request, but somehow you are using non consistent line endings in main.js and it mess up the patch. So I did not bother.

Add license and copyright

@cfjedimaster : could we please add a license and copyright notice to the project?

I'm not submitting a PR since I'm not certain which license you'd like to have. If you'd confirm that it is MIT license, I can submit a PR to address this adding MIT license and the copyright notice to your name.

.jshintrc file not picked up

I have installed this extension from within Brackets, and for some reason my jshintrc file is not getting picked up. Can you help me troubleshoot the problem?

wrong '[variable-name] is already defined' warning

Hey,

If you make something like this:

if(a == b)
  var x= 1;
else
  var x= 2;

console.log(x);

he will complain about redefining of x. But I think he should detect that x always only once will be defined.

Use `JsHint` instead of `JSHint` in brackets.json settings file ?

Hello,
I use Brackets 1.4 on Windows7.
I was not able to make jshint work until I made a change in the global "Preference File" (menu Debug > Open Preference file).
I use 'JsHint' instead of 'JSHint' here:

    "language": {
      "javascript": {
          "linting.prefer": "JsHint",
          "linting.usePreferredOnly": true
      }

I am not sure if it is the right solution (should README.md be updated ?) or if I missed something.
Thank you for your attention.

Add keywords "lint" and/or "linter" to package.json

When I search for "lint" or "linter" in the Available tab of the Extension Manager, this extension does not show up.

Adding it to a keywords property in your package.json should fix it. I haven't actually tested if "lint" acts like a wildcard pattern, covering "lint", "linter", and "linting", or if you have to enter all three words. You will have to play around with it and see what works.

Also, for completeness, might want to consider adding a categories property with value linting. It's not used yet but, hey, why not? See https://github.com/adobe/brackets/wiki/Extension-package-format#categories.

Display error and warning codes

It would be great if brackets-jshint could display the warning and error codes for each JSHint line similar to what grunt-contrib-jshint does. ie:

26 (W015) Expected 'case' to have an indentation at 25 instead at 29.

instead of the current

26 Expected 'case' to have an indentation at 25 instead at 29.

It would make it easier to identify the specific error/warning types.

Global .jshintrc file?

It seems rather curious that a JSHint extension would not have its own .jshintrc for linting. Is it possible to add one so that users who want to contribute (namely me) know what kind of options I should pay attention to?

JSHint also hints on HTML files

When opening a HTML file it also show's the JSHint toolbox below. The original JSLint extension does not.

Can you turn that off? Or maybe it is configurable?

2.5.4

Would you mind pulling in 2.5.4 and publishing? There are some nice fixes, and a new global.

Auto collapsing on no issues?

I am thinking that it would be nice to have this extension operate in a similar manner to the JSLint extension with the auto collapse of the panel when no issues are found. If I figured out how to do so, would you accept a pull request?

Read parent folder .jshintrc

First off, I love your plugin (so nice to use this instead of JSLint) 👍

My folder structure is:

  • Home
    • Sites
      • Project 1
      • Project 2
      • etc.

When I place my .jshintrc file into each project folder it works perfectly. However, when I move it into my Sites folder it stops working, giving me these errors:

  • 'angular' is not defined
  • 'alert' is not defined

This seems to not match the behavior described in the JSHint docs:

In case of .jshintrc, JSHint will start looking for this file in the
same directory as the file that's being linted. If not found, it will
move one level up the directory tree all the way up to the filesystem
root.

I'd like to have just one .jshintrc file in the parent Sites folder that each project folder reads. Is this possible?

Thank you :)

wrong 'used out of scope' warning

Hey,

JSHint always complains about '[variable-name] used out of scope' when I define a variable with 'var' in an if or loop block and then use it outside the block like this:

if(a == b){
  var x= 'test';
}else{
  var x= 'big string with text';
  }

console.log(x);

This behavior is wrong because the scope for variables defined with var only changes in function blocks.
Hope you can fix this, it is relay annoying.

Run JSHint without saving

I use Brackets to develop with Meteor, which has a file watcher and automatically restarts the server when it detects that project files have been updated. When I save .js files in order to JSHint them, that causes an artificial restart of the server.

Any way to run JSHint without saving the .js file? Maybe by saving to a temporary file?

ignore shebang

i use a shebang on my first code line for server scripts, as it is legal with node.js.

#!/usr/bin/env node

jslint in brackets moans about them and stops linting. please fix it.

Support extends in .jshintrc

It's good that .jshintrc files now don't have to be in the project root, but when I try to place one in a subfolder, that becomes the only file used. Could we change this to match the behaviour of the JSHint CLI, which implements this sort of thing (jshint/jshint#1314)?

window is undefined

JSLint don't recognize that 'window' (window.navigator.userAgent;) is a global variable, and display a warning like this:

'window' is not defined. (W117)

/*global window */

will supress this warning, but it should know that is a global.

Add note to README about suppressing JSLint in Brackets 1.1

Before Brackets 1.1, I think the JSHint extension automatically suppressed JSLint errors. In 1.1, with the new multiple linter support, JSLint errors started showing up again. It might be good to put a note in your README about adding the proper preference to .brackets.json to re-suppress the JSLint errors:

    "language": {
        "javascript": {
            "linting.prefer": "JSHint",
            "linting.usePreferredOnly": true
        }
    }

Or maybe there's a way you could set that preference programmatically by default (though you'd have to make sure that the user's own .brackets.json would properly override that).

Install problem on Windows

I am doing meteor dev and looking to try jshint with brackets. Instructions state "To install, place in your brackets/src/extensions/user folder." Brackets install was from the .msi and I do not find any such location. How do I install jshint?

Doesn't do anything?

I don't see this plugin doing anything whatsoever. No new main menu items as far as I could find, no new context menu items, and my assumption that JS files are hinted on save was apparently wrong too. So I can't work out how make this plugin go...

Could you explain (on the project front page preferrably) how to work this plugin?

Issue when panel is not showing

Hello,

I got an issue where when I clicked on "Enable JsHint" nothing happened. I looked a little and it appears LanguageManager.getLanguageForPath(fileEntry) failed to return javascript for my file (the name was : footer.js).

I hardcoded "javascript" as default language as a quick fix, but i guess i'm not alone in this case.

Anyway, great work.
Christian

JSP support

Is it possibile to hint JS code inside a JSP file?

Thank you!!!

Use .jshintrc which is not in root directory

GIven as structure

/ (project root)
/assets
    /.jshintrc
    /components
        /dashboard.js
/tests
    /.jshintrc
    /components
        /dashboard.js

The .jshintrc files are not being loaded in Brackets-JSHint extension.

See JSHint documentation

...In case of .jshintrc, JSHint will start looking for this file in the same directory as the file that's being linted. If not found, it will move one level up the directory tree all the way up to the filesystem root.

Search for .jshintrc file by scanning up directories from the current file instead of checking the root of the project only

JSHint docs current state:

"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)"

However, brackets-jshint currently only scans the project root directory for this file.

Can we update the extension to behave the way JSHint was designed?

Support .jshintignore

In addition to .jshintrc, there's a .jshintignore file that can be used to exclude files or folders. It would be nice if this extension also ignored those files and didn't pop up the errors panel when you open one. Especially useful if you're pairing it with a bulk-linting extension like my Lint All the Things.

There are basically no official docs on the file format that I could find. This forum post is the closest thing: https://groups.google.com/d/msg/jshint/62N12QUhBCs/v9a1XC7I_j8J. So it looks like just a list of standard globs (Brackets includes a globmatch library that you can probably use for this).

"JSHint has timed out after waiting for 10000 ms"

In the latest version, 2.2.16, I get this error for every file that I try to lint. Reverting back to 2.2.15 lints all of the same files just fine (and super quickly).

Running in the following Brackets version: Release 1.3 build 1.3.0-16022 (release cd0a6aae5)

Timout in brackets

Hi,
since I updated brackets to 0.44 whn I save a js file brackets freezes for a while and tells me JSHint has reached ist timeout ...
"JSHint hat die Zeitbegrenzung von 10000 ms überschritten "
Any idea what to do or where to look ?

Regards
Karsten

Sprint 44 Experimenteller Build 0.44.0-14876 (release 6d2d33d80)

Support for JSX?

Hey cfjedimaster,

I recently created a clone of brackets-jshint to add support for React.js JSX files (https://github.com/globexdesigns/brackets-jsxhint). The code is almost identical to brackets-jshint, but with with 10 new lines and React.js' JSXTransformer.js file. Which leads me to wonder... would it be better if I created a pull request here to merge that feature in? Or should your extension only focus on Javascript files?

I'm a little torn, because having a bunch of very similar linting extensions in Brackets feels frustrating to users and difficult to maintain for developers, but on the other hard, having JSX support in a JSHint extension might be beyond its original intent.

What do you think?

.jshintrc not loading

I use 'sprint 42 experimental build'. I've tried to put .jshintrc inside my root/js, root(even both together) folder of my project and jshint doesn't apply my configuration:

{
    "curly": true,
    "eqeqeq": true,
    "eqnull": true,
    "expr": true,
    "latedef": true,
    "newcap": true,
    "onevar": true,
    "noarg": true,
    "node": true,
    "trailing": true,
    "undef": true,
    "strict": true,
    "unused": true,
    "trailing": true
}

Cursor is placed one character to the right

After double-clicking on a warning, the cursor lands one character to the right of where the troublesome statement starts. Example:

console.log('food'); console.log('bar');

The cursor will be under 'o', not under 'c'.

Brackets hangs during JSHint scan of large file

I have a JS file that's an array of arrays used for games that need a dictionary. It's 1362KB in size, and upon loading it in Brackets, JSLint embarks on an epic journey to try to lint it.

Well, it doesn't need linting--just editing. Brackets hangs up like a jilted girlfriend during the lint; the current web version of JSHint eventually struggles through the file, but it takes a very long time.

Not your fault, for sure, but still an issue. An option for the plug-in that disallowed linting any file larger than X KB would likely resolve this and still allow linting files of a more sane size. Any JS file larger than 100K probably needs to be broken down into smaller modules. Unfortunately for the dictionary, breaking it down into smaller files isn't really an option.

Will not work in Brackets Sprint 34

This extension uses the NativeFileSystem.FileReader API, which has been removed. In the next release of Brackets, the extension will crash when trying to read the file.

It should be straightforward to switch to an alternative such as the new File.read() API or the existing FileUtils.readAsText() API. You can release this update in advance if you want, since users of Brackets Sprint 33 (the current release) will still be able to install the older version of your extension that is compatible with their build.

See the migration guide and discussion thread for details.

.jshintrc support

As an user I would like to see support for a .jshintrc file so I can define all my JSHint rules on a project base level.

Is it possible in this current extension to implement?

.jshintrc not recognized in latest version and Brackets 34

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.

Skip blocks of minified code

Can we somehow make JSHint skip minified blocks of code?

I make it a habit to put blocks of minified (third-party) code at the top of my main JS file, so I don't have to combine them before deploying. Mind you it's minified, not packed. But minified code oftenly starts with a semicolon, so maybe ignore such lines?

Errors in .jshintrc fail in a bad way

Having incorrect variables in the in the .jshintrc file currently cause errors to be thrown into the Brackets console and the Linting API to fail.

Here is an example .jshintrc that will cause an issue.

{
    "foo": true
}

In this example, the failure occurs due to the incorrect "foo" variable. Brackets will report the error as: "Uncaught TypeError: Cannot read property 'length' of undefined". But looking into it further, the failure actually happens inside JSHint which states: "Bad option: 'foo'." as part of the "messageOb" variable in the extension.

Such errors should be reported back to the user in a friendly way without breaking the Brackets linting API.

Additionally, the "es5" option is also complaining - even though it's a valid JSHint option.

{
    "es5": true
}

The response from JSHint is: ES5 option is now set per default.

I believe that should be handled as a warning and not cause bracket-jshint to break.

"white" option ignored when using .jshintrc

I know "white" is going to be deprecated soon, but from what I can see it hasn't been yet.

When using .jshintrc with "white:true" -- the rule isn't being used. However, if I remove .jshintrc from my project and add "/jshint white:true/" at the top of my file -- the rule is enabled.

How come there is this inconsistency? Any chance we can keep the rule enabled via .jshintrc?

JSHint using project .jshintrc file instead of the one in the current folder

Hello

I have a project which has a .jshintrc file at the root of the folder and i have a subfolder where i want a different jshint configuration, is it possible to look to use the .jshintrc file in current folder ?

attached screenshot shows my setup, the problem being the jshintrc file inside the src folder isn't used.

screenshot 2014-04-28 at 16 47 19

Inline notifications for errors

Instead of the big ol' screen popping up, how about marking the lines with exclamation marks next to the line number or different color?

This way, when you are in the mids of writing new things which are broken because they aren't finished yet, you wouldn't lose screen realestate & focus for the JSHint screen every time you save.

Something like this would bind the notifications better to the workflow - ie. get things together first, then clean up the linting/hinting problems. So, by definition, syntax errors etc. should be more visible than lint/hint errors. By changing them to something less visible, the human brain sorts out the priority by itself. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.