JavaScript ES6 for NPP 64-bit.
-
I found notes about JSLint to extend NotePad++ for using Javascript with ECMAScript 6 (ES6), but it’s a 32-bit plugin, hence not suitable for NotePad++ 64-bit 7.8.9. Is JSLintNPP or something similar available as 64-bit Version? Or is it possible to load 32-bit extensions into NPP.
It seems that NPP doesn’t yet include ES6, as arrow functions, default function parameters and perhaps other ES6 extensions aren’t supported there. I mean the last version of JSLintNPP 0.8.3 is from 2015.
-
This setup is quite easy to do and will work with any version of NPP/ ESlint (it does require NodeJS):
- Install eslint with npm (
npm i -g eslint
ornpm i --save-dev eslint
) - Make sure you have a valid
.eslintrc
in the project directory - In Notepad++, open the run Dialog and save 1 of these commands:
- ESlint current file
cmd /k eslint --fix-dry-run $(FULL_CURRENT_PATH)
- ESlint project
cmd /k eslint --fix-dry-run $(CURRENT_DIRECTORY)
(this will only work if NPP is opened on a file in the project root, or if “Follow current document” is not checked in NPP Preferences > Default directory.
- ESlint current file
This will open a terminal with the results of the ESlint check.
If you’d like ESLint to fix the problems too instead of reporting them only, substitute--fix-dry-run
with--fix
in the commands above. - Install eslint with npm (
-
https://github.com/deadem/notepad-pp-linter available also from PluginAdmin might be of interest.
-
@chcg It doesn’t work and I don’t know why. I replaced “deadem” with my user designation in the config file. It seems that the cmd-files (eslint.cmd …) as listed in the config shall be in the folders listed there, but (of course) there is none.
From where shall I get them? What is the content of this files?
What shall I put in for replacement of “Path with spaces\somelint.cmd”? -
@webketje Sorry, it doesn’t work. I installed with
npm i --save-dev eslint
.
What is the.eslintrc
? I suppose it’s a file, but it’s not installed with eslint. Where shall I get this and what shall be its content?
Startingcmd /k eslint --fix-dry-run $(FULL_CURRENT_PATH)
from the project directory, where the file is located, does’nt find eslint. -
Half solutions shown here. NPP stays unable to work with ES6/ECMA2015.
-
@H-R-30
and which other half is missing? -
@Ekopalypse The other half which make ES6 work withNPP
-
I see - thanks for letting me know.
-
@H-R-30 Sorry I forgot to follow up on this topic, but the conclusion is incorrect. I’ve used the solution I proposed extensively, it is tested and working and certainly not half.
.eslintrc
is the ESlint configuration file, which a Google Search would have given you as a first result. Here is an example. Naturally, if you don’t define any options, eslint won’t know what to look for.If eslint is not recognized, it means you haven’t told Windows to look in
node_modules\.bin
to find executables. So change the command tocmd /k node_modules\.bin\eslint --fix-dry-run $(FULL_CURRENT_PATH)
. Or edit the Windows PATH variable and addnode_modules\.bin\eslint
to it if it is not there. For globally installed npm executables add%AppData%\npm\node_modules\.bin
too. Restart Notepad++ to be sure the changes are in effect.