npm-package-json-lint icon indicating copy to clipboard operation
npm-package-json-lint copied to clipboard

ESLint plugin/rule

Open webberwang opened this issue 5 years ago • 5 comments

Is there a possibility to make this package an ESLint plugin or rule?

webberwang avatar Aug 12 '20 19:08 webberwang

Hey @webberwang I don't think so unfortunately. Eslint doesn't support AST for JSON. Do you have any ideas for that?

tclindner avatar Aug 31 '20 12:08 tclindner

https://github.com/leo-buneev/eslint-plugin-md solves this by having its own parser (https://www.npmjs.com/package/markdown-eslint-parser) that generates an "empty" AST to fool eslint, but adds an extra property with the content of the Markdown file.

Then they have a rule (https://github.com/leo-buneev/eslint-plugin-md/blob/master/lib/rules/remark.js#L82), that reads that content from the "fake" AST, and calls remark to do the actual linting.

I think a similar system could work? I'll experiment with that idea and raise a PR if it ends up working.

scinos avatar Feb 17 '21 05:02 scinos

I don't know anything about it but I had read something about eslint & AST and how to extend it in the typescript-eslint repo

einSelbst avatar May 12 '21 11:05 einSelbst

Hey @webberwang I don't think so unfortunately. Eslint doesn't support AST for JSON. Do you have any ideas for that?

Hey, first time here, thank you for creating this project! ❤️

I found this JSON parser that supports AST https://github.com/ota-meshi/jsonc-eslint-parser. It might be awesome if we could integrate the rules into ESLint.

budiirawan-pp avatar May 08 '23 17:05 budiirawan-pp

FWIW I'm a maintainer on https://github.com/JoshuaKGoldberg/eslint-plugin-package-json now and would love to unify these tools. It's been a consistent user pain with devs I've talked to how there are so many different tools for linting various areas of code. Getting to unify within ESLint (especially considering https://github.com/eslint/eslint/discussions/16557) would be very nice.

@tclindner I couldn't find an email / other contact for you online, but I'd love to chat!

Tracking refs on my end: https://github.com/JoshuaKGoldberg/eslint-plugin-package-json/issues/28 -> https://github.com/JoshuaKGoldberg/create-typescript-app/issues/839

JoshuaKGoldberg avatar Sep 19 '23 15:09 JoshuaKGoldberg