tclindner / npm-package-json-lint

Configurable linter for package.json files
https://npmpackagejsonlint.org
MIT License
221 stars 33 forks source link

ESLint plugin/rule #323

Open webberwang opened 4 years ago

webberwang commented 4 years ago

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

tclindner commented 4 years ago

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

scinos commented 3 years ago

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.

einSelbst commented 3 years ago

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

budiirawan-pp commented 1 year ago

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.

JoshuaKGoldberg commented 1 year ago

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