Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for eslint-plugin-jsonc plugin #3872

Closed
jpesce opened this issue Aug 14, 2021 · 5 comments · Fixed by #3873
Closed

Add support for eslint-plugin-jsonc plugin #3872

jpesce opened this issue Aug 14, 2021 · 5 comments · Fixed by #3873
Labels
new tool Support for new linters, fixers, etc.

Comments

@jpesce
Copy link
Contributor

jpesce commented Aug 14, 2021

Name: eslint with eslint-plugin-jsonc plugin
URL: https://ota-meshi.github.io/eslint-plugin-jsonc/

Linter and fixer for JSON, JSONC and JSON5 files that uses eslint. Since eslint is already supported for other filetypes, this should be trivial. I'll make a very basic pull request with the minimum required configuration and let me know if it makes sense supporting it so I can improve it. 🐸

Cheers

@jpesce jpesce added the new tool Support for new linters, fixers, etc. label Aug 14, 2021
hsanson pushed a commit that referenced this issue Aug 21, 2021
… JSON5 (#3873)

* Add eslint as linter for JSON, JSONC and JSON5

Use the same lint configuration as eslint for javascript.

* Add documentation for JSON* eslint support

* Fix spacing in documentation

* Update docs to be unopinionated about plugins

Remove any preference for eslint plugins, since there are more thant one
that would work

* Reorder languages and tools in alphabetic order

* Fix misalignment

* Change orders to pass the tests
@redbmk
Copy link
Contributor

redbmk commented Oct 22, 2021

I think I'm running into an issue with this. I recently updated ALE and am now seeing eslint errors in json files, presumably because I don't have this plugin installed. Is there a config to turn off eslint for json, or should there be a new ticket to make it so that it only tries json files if the plugin is installed?

Every line of the json file is underlined and I get the following error:

[eslint] Expected an assignment or function call and instead saw an expression. [Error no-unused-expressions]

Or maybe I need to update my eslintrc to ignore json files (or add the plugin)?

@redbmk
Copy link
Contributor

redbmk commented Oct 22, 2021

I also just tried adding *.json to .eslintignore which prevents underlining the whole file, but I get a warning now:

[eslint] File ignored because of a matching ignore pattern. Use "--no-ignore" to override. [Warning]

@hsanson
Copy link
Contributor

hsanson commented Oct 24, 2021

Try configuring g:ale_linters so json is not linted by eslint.

@redbmk
Copy link
Contributor

redbmk commented Oct 25, 2021

Nice, this worked well:

let g:ale_linters = {'json': []}

Since I tend to use prettier instead of eslint for json, I see this working fine for me, but I feel like that approach might not be the best if e.g. I wanted it to be on for some projects and not for others. For example I use mypy in some python projects and pytype in others. I can have them both configured with ALE and if one isn't installed it just won't (can't) run it and I don't see any errors.

The tricky part here is that eslint is installed, but not the json plugin.

@jpesce
Copy link
Contributor Author

jpesce commented Oct 25, 2021

I wanted it to be on for some projects and not for others

This can be achieved by having project-specific vim configurations. There are many alternatives for this:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new tool Support for new linters, fixers, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants