21

Suddenly the JSLint plugin of my notepad++ stopped to work. Whenever i try to parse a .js file, it output this warning:

JSLint can operate only on JavaScript, HTML or CSS files.

The file is named main.js, and it's obviously a javascript file. It refuses any file with .js extension. It works regularly on .css or .html files, but not on .json ones.

I didn't change any extension, any suggestion to fix this?

7
  • Installed it today for the first time, and I am getting the same error message.
    – Henderk
    Nov 7, 2015 at 0:21
  • This happened for me after installing the latest update. I think I was on 6.8.3, and now I'm on 6.8.6, so it may be version related.
    – Necreaux
    Nov 13, 2015 at 15:33
  • Just installed JsLint 0.8.1.117 on Notepad 6.7.3: I do not get the error message. Nov 14, 2015 at 20:59
  • 1
    Since I've hijacked this thread with my bounty, I'll respond. I tried your workaround and wasn't able to get it to work. I tried JsLint 0.8.2 (has to be manually downloaded), also didn't help. I downgraded to 6.8.3, and now it works. I tried all other versions after 6.8.3 and they don't work. So it looks like it was broken in 6.8.4.
    – Necreaux
    Nov 16, 2015 at 15:09
  • 1
    manually download JSLint Plugin like David answered works well. Without the need to downgrade or anything else!
    – Naxos84
    Feb 22, 2016 at 19:51

3 Answers 3

19
+100

This is an incompatibility between the JSLint Plugin for Notepad++ and the last Notepad++ versions. The JSLint Plugin for Notepad++ needs to be fixed to work properly with the new file types in Notepad++.

If you check the JSLint Plugin for Notepad++ source code:

    if (type != L_JS && type != L_HTML && type != L_CSS) {
        ::MessageBox(
            g_nppData._nppHandle, 
            TEXT("JSLint can operate only on JavaScript, HTML or CSS files."),
            TEXT("JSLint"),
            MB_OK | MB_ICONINFORMATION
        );
        return;
    }

You can see also in the Notepad_plus_msgs.h file the file type list included in the plugin:

enum LangType {L_TXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
           L_HTML, L_XML, L_MAKEFILE, L_PASCAL, L_BATCH, L_INI, L_NFO, L_USER,\
           L_ASP, L_SQL, L_VB, L_JS, L_CSS, L_PERL, L_PYTHON, L_LUA,\
           L_TEX, L_FORTRAN, L_BASH, L_FLASH, L_NSIS, L_TCL, L_LISP, L_SCHEME,\
           L_ASM, L_DIFF, L_PROPS, L_PS, L_RUBY, L_SMALLTALK, L_VHDL, L_KIX, L_AU3,\
           L_CAML, L_ADA, L_VERILOG, L_MATLAB, L_HASKELL, L_INNO, L_SEARCHRESULT,\
           L_CMAKE, L_YAML,\
           // The end of enumated language type, so it should be always at the end
           L_EXTERNAL};

The plugin is trying to ensure that the file is one of the supported file types, which was fine until now.

But the last Notepad++ versions include these changes that add a couple of new 'file types' (L_JSON and L_JAVASCRIPT) that are related to this issue. Now the file type list in the latest Notepad++ versions are:

enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
           L_HTML, L_XML, L_MAKEFILE, L_PASCAL, L_BATCH, L_INI, L_ASCII, L_USER,\
           L_ASP, L_SQL, L_VB, L_JS, L_CSS, L_PERL, L_PYTHON, L_LUA,\
           L_TEX, L_FORTRAN, L_BASH, L_FLASH, L_NSIS, L_TCL, L_LISP, L_SCHEME,\
           L_ASM, L_DIFF, L_PROPS, L_PS, L_RUBY, L_SMALLTALK, L_VHDL, L_KIX, L_AU3,\
           L_CAML, L_ADA, L_VERILOG, L_MATLAB, L_HASKELL, L_INNO, L_SEARCHRESULT,\
           L_CMAKE, L_YAML, L_COBOL, L_GUI4CLI, L_D, L_POWERSHELL, L_R, L_JSP,\
           L_COFFEESCRIPT, L_JSON, L_JAVASCRIPT,\
           // The end of enumated language type, so it should be always at the end
           L_EXTERNAL};

In summary, the JSLint Plugin for Notepad++ needs to be modified to identify properly the javascript/json files. If is an active project the proper way to solve this should be to open an issue, I guess. I suppose that you tried assigning directly a language from the menu as workaround but it didn't work.

4
  • 2
    Assigning the language from the menu worked for me, thanks.
    – Mike
    Nov 21, 2015 at 15:39
  • 4
    It works if i assign HTML or CSS as the language. It won't work for either JS and JSON
    – gerryino
    Nov 24, 2015 at 12:02
  • @gerryino, same here. Mar 29, 2016 at 17:23
  • I just switched to using npm and command line instead of using the plugin...annoying, but effective and less painful Jan 6, 2017 at 18:45
11

This is solved in last version of JSLint Plugin, you can download and install the last version of JSLint Plugin for Notepad++ at sourceforge, and manually install it (see txt file when downloaded)

Best.

5

To clarify the workaround mentioned in other comments, use the Language menu to set language of the .js file to CSS. The plugin recognizes and lints the javascript as expected.

Setting language to HTML also seems to work, but CSS highlighting is more useful IMO.

This works with Notepad++ v6.8.6, JSLint v0.8.1.117.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.