Giter VIP home page Giter VIP logo

vscode-jshint's Introduction

VS Code JSHint extension

Integrates JSHint into VS Code.

Setup

The extension looks for a jshint module in the current directory and in the global package location. You can install jshint locally with npm install jshint or globally with npm install -g jshint. If your jshint module is in a different location, use the jshint.nodePath setting to specify the correct path. The jshint.packageManager setting can be used to specify which package manager you are using, npm or yarn.

To check where jshint is loaded from, use the JSHint: Show output command after the extension has started to view the extension logs in the output panel.

Configuration Options

The jshint extension uses the standard jshint configuration options described on the jshint web site.

The options can be specified in a number of locations mostly mimicing jshint's default behavior. The extension looks for its configuration options the following way and stops at the first positive match:

  1. An options file specified in the user or workspace settings like this: "jshint.config" : "<file path>". The file path is interpreted relative to the workspace's root folder.
  2. The value of the jshintConfig attribute in a package.json file located in the current directory or any parent of the current directory.
  3. A .jshintrc file located in the current directory or any parent of the current directory.
  4. A .jshintrc file located in the user's home directory.
  5. The values specified within jshint.options in the user or workspace settings. By default jshint.options is empty.

.jshintrc files can be chained using the extends attribute as described here.

Exclude Options

In order to ignore specific files or folders from being linted exclude options can be specified in a number of locations mostly mimicing jshint's default behavior. The extenion looks for its exclude options the following way and stops at the first positive match:

  1. A file specified in the user or workspace settings like this: "jshint.excludePath" : "<file path>". The file path is interpreted relative to the workspace's root folder. The file contains glob patterns specifying files that should be excluded. The glob patterns are interpreted relative to the workspace's root folder.
  2. A .jshintignore file located in the current directory or any parent of the current directory. The glob patterns in this file are interpreted relative to the location of the .jshintignore file.
  3. The value of the jshint.exclude attribute in the user or workspace settings. The attribute has the following form: "jshint.exclude" : { "<glob pattern>" : true, "<glob pattern>" : true }. The glob patterns are interpreted relative to the workspace's root folder.

The glob patterns are interpreted using the npm minimatch module. Be aware that there are slight differences between minimatch and how .gitignore patterns are interpreted. Most noteably, **/name and name are not the same in minimatch whereas they are consider equal in .gitignore. Always use **/name if you want to match a name within a subtree.

No files are excluded by default.

Disable JSHint

In order to disable jshint for a workspace specify "jshint.enable" : false in the workspace settings. jshint is enabled by default.

Contributing

Contributions to the extension are welcome! Please see contributing for information on how to develop the extension.

vscode-jshint's People

Contributors

briangreenery avatar dbaeumer avatar dependabot[bot] avatar hookyqr avatar joaomoreno avatar kieferrm avatar ljqx avatar microsoft-github-policy-service[bot] avatar msftgits 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

Watchers

 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

vscode-jshint's Issues

Failed to load jshint library. Please install jshint .... even after installing jshint

I get following error when I am opening vscode.

Failed to load jshint library. Please install jshint in your workspace folder using 'npm install jshint' or globally using 'npm install -g jshint' and then press Retry.

even after installing jshint globally like sudo npm install -g jshint

which jshint
/usr/bin/jshint

But I do get the hints with the bulb symbol when I highlight my JavaScript code.
I am using a Linux Mint 18.3 system.

Please help

JSHint server should clear diagnostics on buffer clone

We removed some bogus code for 1.3.x from the core which cleared markers on buffer close. We had to remove that to get to a consistent project build story. Now the producer of markers must ensure to clear them if they re not needed anymore (was the contract always)

If you don't do anything fancy you can use the following snippet:
// Clear diagnostics on close.
documents.onDidClose((event) => {
connection.sendDiagnostics({ uri: event.document.uri, diagnostics: [] });
});

Highlight is not correct when using tabs as indent

Here is a screenshot of using tabs as indent, you can see the highlight doesn't mark where goes wrong.
Screenshot

It works fine when using 4 spaces instead of one tab.
Screenshot

Highlight tip is [jshint] 'type' / 'value' is already defined. (W004)

Report warning as errors, warnings do not standout

Hi,
it would be interesting to be able to report warning as errors or choose the color for warnings.
Currently warnings are reported by default in visual studio code and it is not really visible, they do not standout. At the company I work for, code pushes with jshint warnings are rejected.

For example it would be interesting to have a property:
jshint.warning.reportAsError=true

Documentation for how to use compared to 'built in' linting

This may fall into the main VSCode area and not this extension, but I think it needs explaining.

So - before VSC adding extensions, I had used a few properties in my user prefs to define how I wanted linting done. So I currently have this:

"javascript.validate.lint.comparisonOperatorsNotStrict": "error",
"javascript.validate.lint.missingSemicolon": "error",
"javascript.validate.lint.unusedVariables": "warning",

"javascript.validate.lint.unusedFunctions": "warning",

I installed the JSHint extension and it added:

"jshint.enable": true,

So my first question is: Are the previous items no longer necessary? Does VSC use whatever linter is the default (JSLint I believe) and your extension, or just the one?

Secondly (and I apologize for putting more than one thing in a bug, but I feel like it is all related, and I can split this up if needed), I then modified my options like so:

"jshint.options": {
    "strict":false
}

so I'd stop getting 'use strict' errors, but it did not work. So what did I do wrong?

Gallery banner is too dark

Who turned out the lights?
The gallery banner for the JSHint Marketplace page is very dark and it is difficult to read the text.

Frequently getting warnings even if the code formatting is perfect.

I simple created react app using 'create-react-app' command generating default boilerplate code, but the linter gives below warning message for below mentioned code below warning message :

[jshint] Unclosed regular expression. (E015)
[jshint] Unrecoverable syntax error. (50% scanned). (E041)

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

class App extends Component {
  render() {
    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h1 className="App-title">Welcome to React</h1> // warning is here underlined in </h1> closing tag.
        </header>
        <p className="App-intro">
          To get started, edit <code>src/App.js</code> and save to reload.
        </p>
      </div>
    );
  }
}

export default App;

Not able to install JShint extension and getting error message "Failed to load JShint library"

VSCode version: 1.1.0-alpha
OS: Windows10

Steps to Reproduce:

  1. Launch app and try to install JShint extension.
  2. Verify user should get success message.
  3. Click on reload and verify from the installed extensions list.

Actual getting error message : "Failed to load jshint library. Please install jshint in your workspace folder "

jshintextensioninstallerror

Error message from Developer tool:
messageService.ts:119 Failed to load jshint library. Please install jshint in your workspace folder using 'npm install jshint' or globally using 'npm install -g jshint' and then press Retry.e.doShow @ messageService.ts:119e.show @ messageService.ts:103(anonymous function) @ extHostMessageService.ts:88__dirname.undefined.t.Class.derive._oncancel @ winjs.base.raw.js:1901e.$showMessage @ extHostMessageService.ts:58e.handle @ abstractThreadService.ts:100s @ ipcRemoteCom.ts:269f @ ipcRemoteCom.ts:226_combinedTickCallback @ internal/process/next_tick.js:67_tickCallback @ internal/process/next_tick.js:98
shell

Options to run only if there is a .jshintrc file ?

I'm working on multiple projects in VSCode - some using jshint and using eslint (or something else).
Currently I'll have to manually disable vscode-jshint for each workspace that uses something else.
Can I make vscode-jshint run only if it finds a .jshintrc file ?

Thanks

How to ignore some folders

How can i ignore folders like node_modules and bower_components from my jshint check?

we can use something like jsconfig.json exclude paths. Is a bad idea?

VScode unable to recognize whether JShint extension is installed or not.

  • VSCode Version:1.1.0-alpha
  • OS Version: Windows10

Steps to Reproduce:

  1. Launch app and try to install JShint extension.
  2. Verify user should get success message or error message.
  3. If user gets error me message then reload app manually.

Actual:

  1. I observed after reloading app, JShint extension started showing up in both extension install and installed list.

Expected:

  1. if there is no update for the extension then it should not display under install list.
  2. If extension is not installed then it should not display in the installed extensions list.

Getting error message like below:
image

Extension install list:
image

Extension Installed List:

image

Verification steps after reloading window manually:

jshintextensionshowingboththeplaces

The version of jshint is out of date.

The version of jshint is out of date and could not recognize many of the es6 grammars. And there are a lot of error messages which are really disturbing. Please could you help update to the latest version? Thank you very much!

Make "jshint.options" more readable

Hi there:
Please consider replace the empty option object of "jshint.options" with a more readable one, for example (just a copy from jshint source):

{

  /**
   * When set to true, these options will make JSHint produce more warnings about your code.
   */
  "enforcing": {

    /**
     * This option prohibits the use of bitwise operators such as `^` (XOR),
     * `|` (OR) and others. Bitwise operators are very rare in JavaScript
     * programs and quite often `&` is simply a mistyped `&&`.
     */
    "bitwise": true,

    /**
     *
     * This options prohibits overwriting prototypes of native objects such as
     * `Array`, `Date` and so on.
     *
     *     // jshint freeze:true
     *     Array.prototype.count = function (value) { return 4; };
     *     // -> Warning: Extending prototype of native object: 'Array'.
     */
    "freeze": true,

    /**
     * This option allows you to force all variable names to use either
     * camelCase style or UPPER_CASE with underscores.
     *
     * @deprecated JSHint is limiting its scope to issues of code correctness.
     *             If you would like to enforce rules relating to code style,
     *             check out [the JSCS
     *             project](https://github.com/jscs-dev/node-jscs).
     */
    "camelcase": true,

    /**
     * This option requires you to always put curly braces around blocks in
     * loops and conditionals. JavaScript allows you to omit curly braces when
     * the block consists of only one statement, for example:
     *
     *     while (day)
     *       shuffle();
     *
     * However, in some circumstances, it can lead to bugs (you'd think that
     * `sleep()` is a part of the loop while in reality it is not):
     *
     *     while (day)
     *       shuffle();
     *       sleep();
     */
    "curly": true,

    /**
     * This options prohibits the use of `==` and `!=` in favor of `===` and
     * `!==`. The former try to coerce values before comparing them which can
     * lead to some unexpected results. The latter don't do any coercion so
     * they are generally safer. If you would like to learn more about type
     * coercion in JavaScript, we recommend [Truth, Equality and
     * JavaScript](http://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/)
     * by Angus Croll.
     */
    "eqeqeq": true,

    /**
     * This option enables warnings about the use of identifiers which are
     * defined in future versions of JavaScript. Although overwriting them has
     * no effect in contexts where they are not implemented, this practice can
     * cause issues when migrating codebases to newer versions of the language.
     */
    "futurehostile": true,

    /**
     * This option suppresses warnings about invalid `typeof` operator values.
     * This operator has only [a limited set of possible return
     * values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof).
     * By default, JSHint warns when you compare its result with an invalid
     * value which often can be a typo.
     *
     *     // 'fuction' instead of 'function'
     *     if (typeof a == "fuction") { // Invalid typeof value 'fuction'
     *       // ...
     *     }
     *
     * Do not use this option unless you're absolutely sure you don't want
     * these checks.
     */
    "notypeof": true,

    /**
     * This option tells JSHint that your code needs to adhere to ECMAScript 3
     * specification. Use this option if you need your program to be executable
     * in older browsers—such as Internet Explorer 6/7/8/9—and other legacy
     * JavaScript environments.
     *
     * @deprecated Use `esversion: 3` instead.
     */
    "es3": true,

    /**
     * This option enables syntax first defined in [the ECMAScript 5.1
     * specification](http://es5.github.io/). This includes allowing reserved
     * keywords as object properties.
     *
     * @deprecated Use `esversion: 5` instead.
     */
    "es5": true,

    /**
     * This option requires all `for in` loops to filter object's items. The
     * for in statement allows for looping through the names of all of the
     * properties of an object including those inherited through the prototype
     * chain. This behavior can lead to unexpected items in your object so it
     * is generally safer to always filter inherited properties out as shown in
     * the example:
     *
     *     for (key in obj) {
     *       if (obj.hasOwnProperty(key)) {
     *         // We are sure that obj[key] belongs to the object and was not inherited.
     *       }
     *     }
     *
     * For more in-depth understanding of `for in` loops in JavaScript, read
     * [Exploring JavaScript for-in
     * loops](http://javascriptweblog.wordpress.com/2011/01/04/exploring-javascript-for-in-loops/)
     * by Angus Croll.
     */
    "forin": true,

    /**
     * This option suppresses warnings about declaring variables inside of
     * control
     * structures while accessing them later from the outside. Even though
     * JavaScript has only two real scopes—global and function—such practice
     * leads to confusion among people new to the language and hard-to-debug
     * bugs. This is why, by default, JSHint warns about variables that are
     * used outside of their intended scope.
     *
     *     function test() {
     *       if (true) {
     *         var x = 0;
     *       }
     *
     *       x += 1; // Default: 'x' used out of scope.
     *                 // No warning when funcscope:true
     *     }
     */
    "funcscope": true,

    /**
     * This option prohibits the use of immediate function invocations without
     * wrapping them in parentheses. Wrapping parentheses assists readers of
     * your code in understanding that the expression is the result of a
     * function, and not the function itself.
     *
     * @deprecated JSHint is limiting its scope to issues of code correctness.
     *             If you would like to enforce rules relating to code style,
     *             check out [the JSCS
     *             project](https://github.com/jscs-dev/node-jscs).
     */
    "immed": true,

    /**
     * This option suppresses warnings about the `__iterator__` property. This
     * property is not supported by all browsers so use it carefully.
     */
    "iterator": true,

    /**
     * This option requires you to capitalize names of constructor functions.
     * Capitalizing functions that are intended to be used with `new` operator
     * is just a convention that helps programmers to visually distinguish
     * constructor functions from other types of functions to help spot
     * mistakes when using `this`.
     *
     * Not doing so won't break your code in any browsers or environments but
     * it will be a bit harder to figure out—by reading the code—if the
     * function was supposed to be used with or without new. And this is
     * important because when the function that was intended to be used with
     * `new` is used without it, `this` will point to the global object instead
     * of a new object.
     *
     * @deprecated JSHint is limiting its scope to issues of code correctness.
     *             If you would like to enforce rules relating to code style,
     *             check out [the JSCS
     *             project](https://github.com/jscs-dev/node-jscs).
     */
    "newcap": true,

    /**
     * This option prohibits the use of `arguments.caller` and
     * `arguments.callee`.  Both `.caller` and `.callee` make quite a few
     * optimizations impossible so they were deprecated in future versions of
     * JavaScript. In fact, ECMAScript 5 forbids the use of `arguments.callee`
     * in strict mode.
     */
    "noarg": true,

    /**
     * This option prohibits the use of the comma operator. When misused, the
     * comma operator can obscure the value of a statement and promote
     * incorrect code.
     */
    "nocomma": true,

    /**
     * This option warns when you have an empty block in your code. JSLint was
     * originally warning for all empty blocks and we simply made it optional.
     * There were no studies reporting that empty blocks in JavaScript break
     * your code in any way.
     *
     * @deprecated JSHint is limiting its scope to issues of code correctness.
     *             If you would like to enforce rules relating to code style,
     *             check out [the JSCS
     *             project](https://github.com/jscs-dev/node-jscs).
     */
    "noempty": true,

    /**
     * This option warns about "non-breaking whitespace" characters. These
     * characters can be entered with option-space on Mac computers and have a
     * potential of breaking non-UTF8 web pages.
     */
    "nonbsp": true,

    /**
     * This option prohibits the use of constructor functions for side-effects.
     * Some people like to call constructor functions without assigning its
     * result to any variable:
     *
     *     new MyConstructor();
     *
     * There is no advantage in this approach over simply calling
     * `MyConstructor` since the object that the operator `new` creates isn't
     * used anywhere so you should generally avoid constructors like this one.
     */
    "nonew": true,

    /**
     * This option prohibits the use of explicitly undeclared variables. This
     * option is very useful for spotting leaking and mistyped variables.
     *
     *     // jshint undef:true
     *
     *     function test() {
     *       var myVar = 'Hello, World';
     *       console.log(myvar); // Oops, typoed here. JSHint with undef will complain
     *     }
     *
     * If your variable is defined in another file, you can use the `global`
     * directive to tell JSHint about it.
     */
    "undef": true,

    /**
     * This option prohibits the use of the grouping operator when it is not
     * strictly required. Such usage commonly reflects a misunderstanding of
     * unary operators, for example:
     *
     *     // jshint singleGroups: true
     *
     *     delete(obj.attr); // Warning: Unnecessary grouping operator.
     */
    "singleGroups": false,

    /**
     * When set to true, the use of VariableStatements are forbidden.
     * For example:
     *
     *     // jshint varstmt: true
     *
     *     var a; // Warning: `var` declarations are forbidden. Use `let` or `const` instead.
     */
    "varstmt": false,

    /**
     * This option is a short hand for the most strict JSHint configuration as
     * available in JSHint version 2.6.3. It enables all enforcing options and
     * disables all relaxing options that were defined in that release.
     *
     * @deprecated The option cannot be maintained without automatically opting
     *             users in to new features. This can lead to unexpected
     *             warnings/errors in when upgrading between minor versions of
     *             JSHint.
     */
    "enforceall": false
  },

  /**
   * When set to true, these options will make JSHint produce fewer warnings about your code.
   */
  "relaxing": {

    /**
     * This option suppresses warnings about missing semicolons. There is a lot
     * of FUD about semicolon spread by quite a few people in the community.
     * The common myths are that semicolons are required all the time (they are
     * not) and that they are unreliable. JavaScript has rules about semicolons
     * which are followed by *all* browsers so it is up to you to decide
     * whether you should or should not use semicolons in your code.
     *
     * For more information about semicolons in JavaScript read [An Open Letter
     * to JavaScript Leaders Regarding
     * Semicolons](http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding)
     * by Isaac Schlueter and [JavaScript Semicolon
     * Insertion](http://inimino.org/~inimino/blog/javascript_semicolons).
     */
    "asi": true,

    /**
     * This option suppresses warnings about multi-line strings. Multi-line
     * strings can be dangerous in JavaScript because all hell breaks loose if
     * you accidentally put a whitespace in between the escape character (`\`)
     * and a new line.
     *
     * Note that even though this option allows correct multi-line strings, it
     * still warns about multi-line strings without escape characters or with
     * anything in between the escape character and a whitespace.
     *
     *     // jshint multistr:true
     *
     *     var text = "Hello\
     *     World"; // All good.
     *
     *     text = "Hello
     *     World"; // Warning, no escape character.
     *
     *     text = "Hello\
     *     World"; // Warning, there is a space after \
     *
     * @deprecated JSHint is limiting its scope to issues of code correctness.
     *             If you would like to enforce rules relating to code style,
     *             check out [the JSCS
     *             project](https://github.com/jscs-dev/node-jscs).
     */
    "multistr": true,

    /**
     * This option suppresses warnings about the `debugger` statements in your
     * code.
     */
    "debug": true,

    /**
     * This option suppresses warnings about the use of assignments in cases
     * where comparisons are expected. More often than not, code like `if (a =
     * 10) {}` is a typo. However, it can be useful in cases like this one:
     *
     *     for (var i = 0, person; person = people[i]; i++) {}
     *
     * You can silence this error on a per-use basis by surrounding the assignment
     * with parenthesis, such as:
     *
     *     for (var i = 0, person; (person = people[i]); i++) {}
     */
    "boss": true,

    /**
     * This option suppresses warnings about the use of `eval`. The use of
     * `eval` is discouraged because it can make your code vulnerable to
     * various injection attacks and it makes it hard for JavaScript
     * interpreter to do certain optimizations.
    */
    "evil": true,

    /**
     * This option suppresses warnings about the use of global strict mode.
     * Global strict mode can break third-party widgets so it is not
     * recommended.
     *
     * For more info about strict mode see the `strict` option.
     *
     * @deprecated Use `strict: "global"`.
     */
    "globalstrict": true,

    /**
     * This option prohibits the use of unary increment and decrement
     * operators.  Some people think that `++` and `--` reduces the quality of
     * their coding styles and there are programming languages—such as
     * Python—that go completely without these operators.
     */
    "plusplus": true,

    /**
     * This option suppresses warnings about the `__proto__` property.
     */
    "proto": true,

    /**
     * This option suppresses warnings about the use of script-targeted
     * URLs—such as `javascript:...`.
     */
    "scripturl": true,

    /**
     * This option suppresses warnings about using `[]` notation when it can be
     * expressed in dot notation: `person['name']` vs. `person.name`.
     *
     * @deprecated JSHint is limiting its scope to issues of code correctness.
     *             If you would like to enforce rules relating to code style,
     *             check out [the JSCS
     *             project](https://github.com/jscs-dev/node-jscs).
     */
    "sub": true,

    /**
     * This option suppresses warnings about "weird" constructions like
     * `new function () { ... }` and `new Object;`. Such constructions are
     * sometimes used to produce singletons in JavaScript:
     *
     *     var singleton = new function() {
     *       var privateVar;
     *
     *       this.publicMethod  = function () {}
     *       this.publicMethod2 = function () {}
     *     };
     */
    "supernew": true,

    /**
     * This option suppresses most of the warnings about possibly unsafe line
     * breakings in your code. It doesn't suppress warnings about comma-first
     * coding style. To suppress those you have to use `laxcomma` (see below).
     *
     * @deprecated JSHint is limiting its scope to issues of code correctness.
     *             If you would like to enforce rules relating to code style,
     *             check out [the JSCS
     *             project](https://github.com/jscs-dev/node-jscs).
     */
    "laxbreak": true,

    /**
     * This option suppresses warnings about comma-first coding style:
     *
     *     var obj = {
     *         name: 'Anton'
     *       , handle: 'valueof'
     *       , role: 'SW Engineer'
     *     };
     *
     * @deprecated JSHint is limiting its scope to issues of code correctness.
     *             If you would like to enforce rules relating to code style,
     *             check out [the JSCS
     *             project](https://github.com/jscs-dev/node-jscs).
     */
    "laxcomma": true,

    /**
     * This option suppresses warnings about possible strict violations when
     * the code is running in strict mode and you use `this` in a
     * non-constructor function. You should use this option—in a function scope
     * only—when you are positive that your use of `this` is valid in the
     * strict mode (for example, if you call your function using
     * `Function.call`).
     *
     * **Note:** This option can be used only inside of a function scope.
     * JSHint will fail with an error if you will try to set this option
     * globally.
     */
    "validthis": true,

    /**
     * This option suppresses warnings about the use of the `with` statement.
     * The semantics of the `with` statement can cause confusion among
     * developers and accidental definition of global variables.
     *
     * More info:
     *
     * * [with Statement Considered
     *   Harmful](http://yuiblog.com/blog/2006/04/11/with-statement-considered-harmful/)
     */
    "withstmt": true,

    /**
     * This options tells JSHint that your code uses Mozilla JavaScript
     * extensions. Unless you develop specifically for the Firefox web browser
     * you don't need this option.
     *
     * More info:
     *
     * * [New in JavaScript
     *   1.7](https://developer.mozilla.org/en-US/docs/JavaScript/New_in_JavaScript/1.7)
     */
    "moz": true,

    /**
     * This option suppresses warnings about generator functions with no
     * `yield` statement in them.
     */
    "noyield": true,

    /**
     * This option suppresses warnings about `== null` comparisons. Such
     * comparisons are often useful when you want to check if a variable is
     * `null` or `undefined`.
     */
    "eqnull": true,

    /**
     * This option suppresses warnings about missing semicolons, but only when
     * the semicolon is omitted for the last statement in a one-line block:
     *
     *     var name = (function() { return 'Anton' }());
     *
     * This is a very niche use case that is useful only when you use automatic
     * JavaScript code generators.
     */
    "lastsemic": true,

    /**
     * This option suppresses warnings about functions inside of loops.
     * Defining functions inside of loops can lead to bugs such as this one:
     *
     *     var nums = [];
     *
     *     for (var i = 0; i < 10; i++) {
     *       nums[i] = function (j) {
     *         return i + j;
     *       };
     *     }
     *
     *     nums[0](2); // Prints 12 instead of 2
     *
     * To fix the code above you need to copy the value of `i`:
     *
     *     var nums = [];
     *
     *     for (var i = 0; i < 10; i++) {
     *       (function (i) {
     *         nums[i] = function (j) {
     *             return i + j;
     *         };
     *       }(i));
     *     }
     */
    "loopfunc": true,

    /**
     * This option suppresses warnings about the use of expressions where
     * normally you would expect to see assignments or function calls. Most of
     * the time, such code is a typo. However, it is not forbidden by the spec
     * and that's why this warning is optional.
     */
    "expr": true,

    /**
     * This option tells JSHint that your code uses ECMAScript 6 specific
     * syntax. Note that not all browsers implement these features.
     *
     * More info:
     *
     * * [Specification for ECMAScript
     *   6](http://www.ecma-international.org/ecma-262/6.0/index.html)
     *
     * @deprecated Use `esversion: 6` instead.
     */
    "esnext": true,

    /**
     * This option tells JSHint that your code uses ES3 array elision elements,
     * or empty elements (for example, `[1, , , 4, , , 7]`).
     */
    "elision": true
  },

  /**
   * These options let JSHint know about some pre-defined global variables.
   */
  // Third party globals
  "environments": {

    /**
     * This option defines globals exposed by the
     * [MooTools](http://mootools.net/) JavaScript framework.
     */
    "mootools": true,

    /**
     * This option defines globals exposed by
     * [CouchDB](http://couchdb.apache.org/). CouchDB is a document-oriented
     * database that can be queried and indexed in a MapReduce fashion using
     * JavaScript.
     */
    "couch": true,

    /**
     * This option defines globals exposed by [the Jasmine unit testing
     * framework](https://jasmine.github.io/).
     */
    "jasmine": true,

    /**
     * This option defines globals exposed by the [jQuery](http://jquery.com/)
     * JavaScript library.
     */
    "jquery": true,

    /**
     * This option defines globals available when your code is running inside
     * of the Node runtime environment. [Node.js](http://nodejs.org/) is a
     * server-side JavaScript environment that uses an asynchronous
     * event-driven model. This option also skips some warnings that make sense
     * in the browser environments but don't make sense in Node such as
     * file-level `use strict` pragmas and `console.log` statements.
     */
    "node": true,

    /**
     * This option defines globals exposed by [the QUnit unit testing
     * framework](http://qunitjs.com/).
     */
    "qunit": true,

    /**
     * This option defines globals available when your code is running inside
     * of the Rhino runtime environment. [Rhino](http://www.mozilla.org/rhino/)
     * is an open-source implementation of JavaScript written entirely in Java.
     */
    "rhino": true,

    /**
     * This option defines globals exposed by [the ShellJS
     * library](http://documentup.com/arturadib/shelljs).
     */
    "shelljs": true,

    /**
     * This option defines globals exposed by the
     * [Prototype](http://www.prototypejs.org/) JavaScript framework.
     */
    "prototypejs": true,

    /**
     * This option defines globals exposed by the [YUI](http://yuilibrary.com/)
     * JavaScript framework.
     */
    "yui": true,

    /**
     * This option defines globals exposed by the "BDD" and "TDD" UIs of the
     * [Mocha unit testing framework](http://mochajs.org/).
     */
    "mocha": true,

    /**
     * This option informs JSHint that the input code describes an ECMAScript 6
     * module. All module code is interpreted as strict mode code.
     */
    "module": true,

    /**
     * This option defines globals available when your code is running as a
     * script for the [Windows Script
     * Host](http://en.wikipedia.org/wiki/Windows_Script_Host).
     */
    "wsh": true,

    /**
     * This option defines globals available when your code is running inside
     * of a Web Worker. [Web
     * Workers](https://developer.mozilla.org/en/Using_web_workers) provide a
     * simple means for web content to run scripts in background threads.
     */
    "worker": true,

    /**
     * This option defines non-standard but widely adopted globals such as
     * `escape` and `unescape`.
     */
    "nonstandard": true,

    /**
     * This option defines globals exposed by modern browsers: all the way from
     * good old `document` and `navigator` to the HTML5 `FileReader` and other
     * new developments in the browser world.
     *
     * **Note:** This option doesn't expose variables like `alert` or
     * `console`. See option `devel` for more information.
     */
    "browser": true,

    /**
     * This option defines globals available when using [the Browserify
     * tool](http://browserify.org/) to build a project.
     */
    "browserify": true,

    /**
     * This option defines globals that are usually used for logging poor-man's
     * debugging: `console`, `alert`, etc. It is usually a good idea to not
     * ship them in production because, for example, `console.log` breaks in
     * legacy versions of Internet Explorer.
     */
    "devel": true,

    /**
     * This option defines globals exposed by the [Dojo
     * Toolkit](http://dojotoolkit.org/).
     */
    "dojo": true,

    /**
     * This option defines globals for typed array constructors.
     *
     * More info:
     *
     * * [JavaScript typed
     *   arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays)
     */
    "typed": true,

    /**
     * This option defines globals available when your core is running inside
     * of the PhantomJS runtime environment. [PhantomJS](http://phantomjs.org/)
     * is a headless WebKit scriptable with a JavaScript API. It has fast and
     * native support for various web standards: DOM handling, CSS selector,
     * JSON, Canvas, and SVG.
     */
    "phantom": true
  },

  // Obsolete options
  "obsolete": {
    "onecase": true, // if one case switch statements should be allowed
    "regexp": true, // if the . should not be allowed in regexp literals
    "regexdash": true  // if unescaped first/last dash (-) inside brackets
                        // should be tolerated
  }
}

Add support to external .jshintrc file

As in "jscs.preset", it would be nice to have support for a external .jshintrc file. I see that putting the file directly in project is widely recommended, but there are some scenarios in which .jshintrc must be apart. I thought that this feature was covered by "extend" inside "jshint.options" but doesn't seem to work.

JSON schema support for .jshintrc

From @scottaddie on November 22, 2015 4:23

Prior to the 0.10.1 release, the following settings were baked into the editor:

        // Control whether jshint is enabled for JavaScript files or not.
    "jshint.enable": true,

    // The jshint options object to provide args to the jshint command.
    "jshint.options": {},

Now that there's an official JSHint extension, the following schema support should be added by it rather than including it into the editor:

        {
            "fileMatch": [
                "/.jshintrc"
            ],
            "url": "http://json.schemastore.org/jshintrc"
        },

I'd argue the same point regarding the JSCS extension. It should add the following to the settings, rather than baking it into the editor:

        {
            "fileMatch": [
                "/.jscsrc"
            ],
            "url": "http://json.schemastore.org/jscsrc"
        }

Copied from original issue: microsoft/vscode#433

jshint.exclude for internal paths

because this issue will probably take literally years to resolve (it's been baried in the backlog for months now) I thought I could find a workaround and ignore the faulty files for this extension. Yet, no matter what glob I try I can't seem do it, probably because of the pattern relativity to the Workroot (#28) and the "file's" path starting with "git:/" which doesn't map to anything. I don't even know what the "real" path is:

I tried everything

*.js.git
**.js.git
**/*.js.git
**/**.js.git
**/*.js.git*
**/*.js.git**
**/**.js.git**

tried both with / and \\.

I know it's technically not your bug, but I would be very grateful if you could help. Incorporating an internal filter that only allows actual existent files to be linted wouldn't harm to have anyway. Or maybe at least writable files (these .js.git things are readonly) so that new not yet saved files could be still linted.

Thank you.

Failed to load jshint library

I have just updated to the version 0.10.10. When I open javascript file, I got an error that says "Failed to load jshint library. Please install it...". I have jshint package installed globally with command npm install -g jshint. My output from terminal:

22:12 $ jshint -v
jshint v2.9.1

I'm on Fedora 23, jshint 2.9.1, vscode 0.10.10, jshint extension has version 0.10.6

Annoying error messages when using autosave

When editing a jshint config file and having enabled autosave you get annoying error messages about syntax errors in the config file when you briefly pause typing. This is because the server gets a configchanged notification as soon as the autosave kicks in.

How to install

Is this plugin installed by default? When I search for jslint I get some other persons plugin.

Refresh JSHint support

  • Add support for 'extends' in jshintConfig within package.json files
  • Add autocompletions for 'extends' and 'excludes' in jshintrc files
  • Add option to report warnings as errors
  • Investigate bug of highlighting displaying incorrectly (#41)

Failed to install dbaeumer.jshint

I updated VSCode yesterday and I have been getting the above message everytime I tried to reinstall this plugin. Before I would get the message:

Failed to update dbaeumer.jshint

I uninstalled the extension hoping that the reinstall would work but it didn't. I tried to install it manually but it complained about the .vsix file being corrupt.

Return empty diagnostics when file is excluded

Currently we remove null which is bogus.

  1. open a js file with jshint warnings\errors
  2. exclude the file using the workspace settings
  3. reopen the file from step 1
    -> old warnings are still there although the file is excluded

jshint does not recognize typings (.tsd) configurations for node

When using node in VS Code, jshint does not recognize the built in Node types/funcs, such as __dir name, require, etc. This results in erroneous linting errors. Note that VS Code does not recognize these types until the node tsd files are added to a project.

Is there a workaround for this?

Make box solution

When you install the plugin, do check for the npm package 'jshint' is installed on the system, globally or above in the tree 'node_modules'. And in the absence 'jshint', install to current module folder.
So much easier 😄

Error: Config values to remove in 3.0: The `esnext` option is enabled by default.

I cannot figure out how to change/remove the esnext option in order to get rid of this message:

Config values to remove in 3.0: The esnext option is enabled by default.

In my setup, I have a .jshintrc file in one of the parent folders which contains:

{
   ...
   "esnext" : true,
   ...
}

But removing that line from the configuration file does not change anything.

How can I try to narrow down this problem? For one, I'd need to be sure what I have to do about
the message; and I'd also need to make sure where the configuration is really loaded from.

Support different file extensions

Currently the extension only works on js files and I don't see an option nor get it enabled for jsx files.
Since jshint doesn't support file extensions this out of the box (like jscs does), extensions on other editors have implemented this functionality themselves.

It would be great if the configuration could support setting custom file extensions to enable working in .ts, .tsx, .jsx and other possible extensions out there.

I'd propose a setting similar to jscs' own setting:

"jshint.enable": true,
"jshint.fileExtensions": ["js", "jsx", "ts", "tsx"]

how to this...?

OMG... Help me please.

I use React-Native with JSHint
But! See error.
I did Google search. Through the setup, the grammar of es was also applied. But there is an error.

Issues found : #29

2018-02-07 6 48 32
2018-02-07 6 50 38
2018-02-07 6 50 59

Support nested jshint configurations

My application has main .jshintrc configuration in root folder, which works just fine. But for tests there is another configuration located at tests/.jshintrc that has a lot of predefs for test helpers. And the extension ignores tests configuration and applies the main one.

The case is common for most Ember CLI apps.

Clarify documentation on the config options

Configuration Options
jshint.options: an option bag as defined by the JSHint API here. Defaults to an empty option bag.

I suggest that the guidance is that the jshint.options is used to configure how to options for starting jshint through the CLI. Users should use the .jshintrc for defining jshint options.

VS Code doesn't recognize jshint if installed globally via Yarn

OS: Win10 latest insider build
Code: v1.16.1
JSHint: v2.9.5 (installed globally)
JSHint Extenstion: 0.10.15

I installed JSHint globally using Yarn. It's accessible via commandline in cmd, git bash & WSL. Unfortunately VS Code doesn't seem to see it, throwing the following error within the editor:

Failed to load jshint library. Please install jshint in your workspace folder using 'npm install jshint' or globally using 'npm install -g jshint' and then...

Uninstalling the Yarn version and reinstalling via npm globally fixes it with VS Code now seeing JSHint.

Not sure if it's a bug or a config issue.

Would love some help since we'd like to use Yarn.

jshint: Incompatible values for the 'esversion' and 'esnext' linting options

JSHint options set up in workspace settings are incompatible.

I have this in my workspace settings:

{
  "jshint.enable": true,
  "jshint.options": {
  "esversion": 6, 
  "esnext": true, 
  "moz": true}
}

I have "esnext" set to "true" here because I want to be able to use async/await in Node. But in my individual files I then get this message:

[jshint] Incompatible values for the 'esversion' and 'esnext' linting options. (0% scanned). (E059)

Can not install extension anymore

I had some strange VSCode behavior, so I re-installed everything. Now I can't install the jshint extension anymore. This is what I do:

ext install jshint -> "'jshint' was successfully installed. Restart to enable it."

After the restart:
ext -> Lists installed extensions, does not include jshint

Other extensions install fine (e.g. PowerShell). I have the global npm jshint module installed.

Visual Studio Code: 0.10.10 (after re-install, was something older before)
OS: Windows 10 Pro
Node: 4.1.1

"Failed to load jshint library"

Installation goes through successfully but after restarting I just get a error message:

Failed to load jshint library. Please install jshint in your workspace folder using 'npm install jshint' and then press Retry.

Runnning npm install jshint in extensions directory seems to fix this.

[jshint] Bad option: 'overrides'

Since some recent update, this error keeps popping up: "[jshint] Bad option: 'overrides'".

overrides comes as a special option in the cli, same as extends that is indeed supported.

I have the following section in my .jshintrc:

"overrides": {
  "test/**": {
    "mocha":   true,
    "globals": {
      "faker":  true,
      "should": false
    }
  },

  "test/support/factories/**": {
    "globals": {
      "_":         false,
      "Factory":   false,
      "faker":     false,
      "multiline": false,
      "util":      false
    }
  }
}

Has this been changed on purpose? Any idea on how can I fix it?

Exclude patterns should be workspace relative

In the user and workspace settings the exclude patterns should be interpreted relative to the workspace root (if there is a workspace). Need to clarify what happens if there is no workspace.

Enable only when .jshintrc is present

I'm using vscode for various project, and only a few projects have jshintrc and others have eslintrc.
I want to enable this plugin only when .jshintrc is present because it shows many error for es6 syntaxes by default, even the project is checked by eslint.

There is vscode issue for enabling plugin per project but is in Backlog.
microsoft/vscode#15611

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.