none
VS2017: Decent JSLinter?

    Question

  • Hi all,

    after migrating from VS 2013 to VS 2017 I am currently trying to find a decent linter for javascript.

    My requirement is very simple:

    //The first statement should create a warning.
    if (a == b) { /* Do something */ }
    //The second one should NOT be a warning.
    if (a == null) { /* Do something else */ }

    How can I achieve this in VS 2017?

    Of course, I tried ESLint first, since it is integrated by default. But unfortunately, it is not possible to configure ESLint as detailed as in the spec:

    //Works, but creates an error in both cases.
    {
    	"rules": {
    		"eqeqeq": 2
    	}
    }
    //Does not work, but it should according to Intellisense and the specs of ESLint.
    {
    	"rules": {
    		"eqeqeq": "error"
    	}
    }
    //Does not work either, but according to the specs of ESLint, this is what I want.
    {
    	"rules": {
    		"eqeqeq": ["error", "always", {"null": "ignore"}]
    	}
    }

    Is there any way to get ESLint to work appropriately?

    I would be fine with using any other linter as well, but cannot find a decent AddIn...

    Thank you

    Andreas

    Tuesday, May 02, 2017 1:17 PM

Answers

  • I solved the issue: Visual Studio 2017 (released 2017-03-30) still uses version 2.0.0 (released 2016-02-12) of ESLint.

    There is also some old documentation:

    Having this information, setting the correct rule is easy:

    "eqeqeq": [ 2, "allow-null" ]

    Edit:

    BTW: The links for the ESLint-Errors in the error-window lead to the current documentation of ESLint, not to the one for 2.0.0.


    • Marked as answer by Asopos Wednesday, May 03, 2017 3:50 PM
    • Edited by Asopos Thursday, May 04, 2017 7:09 AM
    Wednesday, May 03, 2017 3:50 PM

All replies

  • Hi Andreas,

    Welcome to the MSDN forum.

    Refer to your description, your issue is about the development issue about ESLint. Since our forum is to discuss the VS IDE, please share the detail information about your project, like the project type or other, and I will search a appropriate forum for your issue, so you can get a more professional support to solve your current issue, thank you for your cooperation.

    If your project is a ASP.NET type, please redirect to this suitable support forum: https://forums.asp.net/130.aspx/1?HTML+CSS+and+JavaScript and start a new thread for your issue to seek for a more professional support, thank you for your understanding.

    Best regards,

    Sara


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 03, 2017 6:06 AM
    Moderator
  • If your project is a ASP.NET type, please redirect to this suitable support forum: https://forums.asp.net/130.aspx/1?HTML+CSS+and+JavaScript and start a new thread for your issue to seek for a more professional support, thank you for your understanding.

    Well, it is an ASP.NET-project, but I am not sure if the forum you referenced is the correct one.

    I installed ESLint outside of VS using node.js. And if I run it from there on the command line, everything is working perfectly fine. Thus it has to be an issue with the integration into Visual Studio.

    But the forum you linked does not have anything to do with Visual Studio as far as I can see.


    Wednesday, May 03, 2017 9:54 AM
  • I solved the issue: Visual Studio 2017 (released 2017-03-30) still uses version 2.0.0 (released 2016-02-12) of ESLint.

    There is also some old documentation:

    Having this information, setting the correct rule is easy:

    "eqeqeq": [ 2, "allow-null" ]

    Edit:

    BTW: The links for the ESLint-Errors in the error-window lead to the current documentation of ESLint, not to the one for 2.0.0.


    • Marked as answer by Asopos Wednesday, May 03, 2017 3:50 PM
    • Edited by Asopos Thursday, May 04, 2017 7:09 AM
    Wednesday, May 03, 2017 3:50 PM
  • Hi Asopos,

    I'm so glad to hear that your issue is solved and thank you for your sharing, it will help other community members who meet the same or similar issue.

    If you have any other issue about VS IDE in the future, please feel free to let me know.

    Best regards,

    Sara


    MSDN Community Support<br/> Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact <a href="mailto:MSDNFSF@microsoft.com">MSDNFSF@microsoft.com</a>.

    Thursday, May 04, 2017 2:31 AM
    Moderator