deadem / notepad-pp-linter

Notepad++ Linter. Realtime code check against any checkstyle-compatible linter: jshint, eslint, jscs, phpcs, csslint etc
MIT License
37 stars 7 forks source link

Linter stuck on non-existent temp file "Can't execute command:" #27

Closed Zap0 closed 2 months ago

Zap0 commented 1 year ago

I closed NP++ once while a temp file existed, and deleted it manually while NP++ was closed. Now the linter does not lint anything anymore, constantly giving an error message about being unable to lint the temp file I deleted. Relaunching NP++, reinstalling the plugin and rebooting do nothing.

image

my linter.xml:

<NotepadPlus>
  <linter extension=".js" command="C:\PROGRA~1\nodejs\eslint --format checkstyle"/>
</NotepadPlus>

running the command and paths manually in cmd works, and the linter has worked before this happened.

andrija-naglic commented 9 months ago

I have the same issue, except I haven't manually deleted anything. My linter never worked in the first place, I'm having trouble getting passed the "Can't execute command" in the first place. It seems that the .temp.linter.file.tmp never gets created in the first place, and the stdin="1" attribute didn't help with that - the plugin still tries to open the same temp file.

andrija-naglic commented 8 months ago

Ok, I've solved my problem.

I wasn't using eslint but phpcs and the way I got it working was to call a batch file. That batch file calls the php command which I replaced with php-win because the first one was creating an additional cmd window, while the second one doesn't create any output.

To solve the output issue, I have finished thatphp-win line with > some_temp_file.txt to catch the "output". At the end of the batch file I just did type some_temp_file.txt

tom-radboudumc commented 8 months ago

@andrija-naglic what does your batchfile look like exactly? I ran into the same problem but I don't quite follow your explanation 😟

andrija-naglic commented 8 months ago

Sure thing @tom-radboudumc , there you go, my linter.xml:

<NotepadPlus>
  <style color="00FFFF" alpha="100" />
  <linter extension=".php" command="C:\Users\Andrija\AppData\Roaming\Composer\vendor\bin\phpcsw.bat"/>
</NotepadPlus>

And here's the .bat file:

@echo off

setlocal DISABLEDELAYEDEXPANSION
SET BIN_TARGET=C:\Users\Andrija\AppData\Roaming\Composer\vendor\bin/phpcs
SET COMPOSER_RUNTIME_BIN_DIR=C:\Users\Andrija\AppData\Roaming\Composer\vendor\bin

set F=%1
set F=%F:.temp.linter.file.tmp=%
php-win "C:\Users\Andrija\AppData\Roaming\Composer\vendor\bin/phpcs" --report=checkstyle --standard=WordPress "%F%" > D:\temp\linter.tmp

type D:\temp\linter.tmp

The first SET commands are from the original phpcs.bat file - I had problems one batch file calling another one, so I created the phpcsw file.

The second set commands are from some github issue or somewhere.

At the end you output the content of the temp file.

Bear in mind - you have to edit the proper paths for your machine .)

tom-radboudumc commented 8 months ago

It works! Thank you so much!