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?

gerryino
  • 380
  • 2
  • 7
  • Installed it today for the first time, and I am getting the same error message. – Henderk Nov 07 '15 at 00: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 '15 at 15:33
  • Just installed JsLint 0.8.1.117 on Notepad 6.7.3: I do not get the error message. – Lars Fischer Nov 14 '15 at 20:59
  • I could reproduce the problem with Notepad++ 6.8.6 and JsLint 0.8.2 and 0.8.1: when the js file was opened in a previous session and then you restart notepad++ the js file is already opened and you get the error. When I closed the js file and reopened it manually, JsLint seemed to work. Can you try closing and reopening the file? – Lars Fischer Nov 15 '15 at 16:41
  • 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 '15 at 15:09
  • Thanks Necreaux, I downgraded to 6.8.3 and JSLint works and I'm happy again. But I found that newly opened .js files were not then automatically associated to JavaScript language. Un-installing then installing 6.8.3 again fixed this. – James Nov 20 '15 at 16:20
  • 1
    manually download JSLint Plugin like David answered works well. Without the need to downgrade or anything else! – Naxos84 Feb 22 '16 at 19:51

3 Answers3

19

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.

artberri
  • 1,327
  • 13
  • 26
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.

David
  • 121
  • 5
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.

Trevedhek
  • 4,138
  • 2
  • 20
  • 16