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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With