Not Working? [SOLVED!]
lucknaumann opened this issue · comments
Hi. I hope you are doing well.
I have downloaded the latest version of your plugin from SourceForge and installed it in the Plugins/Linter folder. I installed some checkstyle-compatible linters yet don't see any linting done. I'm not sure if there's something else I need to do. Do I need to init the Linter folder or the global folders where the linters are installed? I'm not familiar with node.js, so any further instructions would be appreciated. Thanks.
Here is my linter config:
<?xml version="1.0" encoding="utf-8"?>
<NotepadPlus>
<linter extension=".js" command="C:\Users\user\AppData\Roaming\npm\jshint.cmd --reporter=checkstyle"/>
<linter extension=".js" command="C:\Users\user\AppData\Roaming\npm\eslint.cmd --format checkstyle"/>
<linter extension=".json" command="C:\Users\user\AppData\Roaming\npm\eslint.cmd --format checkstyle"/>
<linter extension=".md" command="C:\Users\user\AppData\Roaming\npm\eslint.cmd --format checkstyle"/>
<linter extension=".css" command="C:\Users\user\AppData\Roaming\npm\stylint.cmd --format=checkstyle"/>
<linter extension=".css" command="C:\Users\user\AppData\Roaming\npm\stylint-checkstyle-reporter.cmd --reporter=checkstyle"/>
<linter extension=".css" command="C:\Users\user\AppData\Roaming\npm\csslint.cmd --format=checkstyle"/>
<linter extension=".js" command=""C:\Path with spaces\somelint.cmd" --format checkstyle"/>
<linter extension=".php" command="C:\Path_to\phpcs --report=checkstyle"/>
</NotepadPlus>
EDIT: SOLUTION!
These are the steps I took to get this plug-in to work with a global install of ESLint. While this will likely work with any .cmd
linter that requires a config file, the junction point may be necessary for any globally installed .cmd
linter to work. I ran these commands in an Admin. PowerShell (CMD prompt will work, too) unless otherwise stated. Replace USER with your user name.
cd "C:\Users\USER\"
mklink /J "C:\Users\USER\node_modules" "C:\Users\USER\AppData\Roaming\npm\node_modules"
npm --init -y
# -y = Generate it without having it ask any questions. Or answer the Q's if not using -y.
# This will create a "package.json" file for the corresponding "node_modules" folder.
eslint --init
# Answer the questions.
# This will generate the required config file: ".eslintrc.*", where "*" = ".js", ".json", or ".yaml".
# Choose JavaScript to generate a ".eslintrc.js" config file. The ".js" file seems more popular.
# BONUS:
# This will install and configure what's necessary to get Prettier & ESLint working together:
npm i auto-config-eslint-for-prettier -g
# I ran this command from a non-admin. shell, though it might not make a difference:
npx auto-config-eslint-for-prettier
Install any ESLint plugins globally, adding their recommended configs into the .eslint.*
config file.
Did you install linters? Does it lint from command line? Can you show some output of your linter?
I installed some checkstyle-compatible linters, but don't see any linting done.
Well, since they wouldn't run without a config file, I copy/pasted one, and here's the output that I got from running the code gotten from other issues here:
> C:\Users\user\AppData\Roaming\npm\eslint.cmd --format checkstyle C:\Users\user\Desktop\config.json
<?xml version="1.0" encoding="utf-8"?><checkstyle version="4.3"><file name="C:\Users\user\Desktop\config.json"><error line="2" column="9" severity="error" message="Parsing error: Unexpected token :" source="" /></file></checkstyle>
Here's the error message WITHOUT a config file:
Oops! Something went wrong! :(
ESLint: 7.22.0
ESLint couldn't find a configuration file. To set up a configuration file for this project, please run:
eslint --init
So, apparently, a config file IS needed but still no joy from NP++.
Try to reduce the notepad config to single line:
<?xml version="1.0" encoding="utf-8"?>
<NotepadPlus>
<linter extension=".js" command="C:\Users\user\AppData\Roaming\npm\eslint.cmd --format checkstyle"/>
</NotepadPlus>
Thanks for your quick response. I did so and here are the results:
I get no result in NP++ when I open a JavaScript file and start randomly inputting characters that should be flagged as errors.
WITHOUT a config file where the .js file is, I get an error in NP++: "Linter: invalid output format. Only checkstyle-compatible output format allowed."
From the command line:
C:\Users\user\AppData\Roaming\npm\eslint.cmd --format checkstyle C:\Users\user\Desktop\eslint.js
<?xml version="1.0" encoding="utf-8"?><checkstyle version="4.3"><file name="C:\Users\user\Desktop\eslint.js"><error line="46" column="24" severity="error" message="Parsing error: Parenthesized pattern" source="" /></file></checkstyle>
Thank you for responding to my inquiry.
I figured out why it wasn't working with your Linter plugin. The .eslintrc.*
file (which relies on the existence of the node_modules folder) needs to be in the USER folder. By creating a junction point to the node_modules folder, I was able to create the .eslintrc.*
file in the USER folder. I will put this information, with steps, in my first post. This way, others can more easily understand how to get this to work.
Would you be willing to put this information in the README.md with a link to this issue so others can find the solution? It would cut down on the issue traffic.