Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Restore option to specify global .eslintrc path #23

Open
zhaolinlau opened this issue Apr 23, 2022 · 4 comments
Open

Restore option to specify global .eslintrc path #23

zhaolinlau opened this issue Apr 23, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@zhaolinlau
Copy link

Issue Type

Question

Issue Description

May I know how to set the path of .eslintrc like linter-eslint package? Because I need to lint javascript in html & php files, and I did install the eslint-plugin-html in linter-eslint-node directory and added eslint-plugin-html to .eslintrc in that directory too. However, the linter says no eslint configuration found. Besides, linter-eslint package is just work fine with that.

Linter Eslint Node: ![image](https://user-images.githubusercontent.com/68846168/164946944-752c4614-acb0-411e-aa00-62a3231c516a.png)
@savetheclocktower
Copy link
Member

Thanks for reporting this. We removed the Lint HTML files setting because all it did was add a scope to the List of scopes to run ESLint on list above, so I felt it was redundant. But I didn't do extensive testing to make sure this still worked.

Luckily, I just attempted an experiment, and it does work. Here's what I did:

  • Created an empty project, installed eslint and eslint-plugin-html into the project's node_modules folder
  • Created an .eslintrc at the root of the project and included "plugins": ["html"]
  • Created index.html and index.php and gave them identical contents; both had a script block with a linting error
  • Neither one did any linting until I added the correct scope — text.html.basic or text.html.php — to linter-eslint-node's package settings under List of scopes to run ESLint on
  • Once I added those scopes, everything worked

I can think of three things that might be happening for you:

  1. You didn't add text.html.basic or text.html.php as described above. (The settings instruct you to add source.js.embedded.html, but that will only work when the cursor is inside that scope when you save or invoke the Lint command, and that's likely not what you want. I will change those instructions.)
  2. Your .eslintrc exists in a directory above your project root. This is unlikely, but it is another difference between this package and linter-eslint: starting from the file that you're linting, both packages traverse upwards and use the first .eslintrc they find, but linter-eslint-node will only go as far as the project root, whereas linter-eslint will keep going to the root of the volume if need be. One way to test this would be to lint a JavaScript file in your project; if it gets linted, then linter-eslint-node can find your .eslintrc.
  3. Just to be clear, eslint-plugin-html needs to be installed either locally (in your project) or globally, not “in linter-eslint-node directory” as you state, but I think this was just an ambiguous phrasing.

If you try all this and still can't get it working, please run the Linter Eslint Node: Debug command and paste the output, and also include the contents of your .eslintrc.

@savetheclocktower
Copy link
Member

Sorry, I didn't read closely enough. You say that it gives you a “No ESLint configuration found” error message, so it's most likely item 2 in my list. I'm guessing that you'd get that error in all cases, not just for HTML files.

@zhaolinlau
Copy link
Author

Yes, installing eslint-plugin-html and adding .eslintrc in project root actually it's just work fine. But to be more convenient to lint projects, I'm here to request to add .eslintrc path configuration like linter-eslint package so that we don't need to setup eslint everytime. And it's just my request also as my suggestion, not forcing you guys to add it because I understand you guys have your own opinion on it too. That's all from me.

@savetheclocktower
Copy link
Member

Ah, I see. I'll keep this open as a feature request; if other people ask for it, we can see about adding it back in. Thanks!

@savetheclocktower savetheclocktower added the enhancement New feature or request label Apr 24, 2022
@savetheclocktower savetheclocktower changed the title No ESLint Configuration Found Restore option to specify global .eslintrc path Apr 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants