jlvandenhout / docusaurus-plugin-docs-editor

56 stars 13 forks source link

Add linter & formatter #36

Closed Josh-Cena closed 3 years ago

Josh-Cena commented 3 years ago

As a would-be contributor, I really hope you can install a linter/formatter like Prettier/ESLint to unify the code style. Things like semicolons, spacing, etc., seem to be inconsistent in the source already, and if this repo accepts contributions without formatting them, this would just lead to unmaintainable code in the future.

I can offer to help, but @jlvandenhout you probably know your own style preferences best😉

Also, I can help to migrate the plugin to TypeScript; would you like to have one .d.ts file, or is it fine if I change all JS files to TS?

jlvandenhout commented 3 years ago

Thank you for having a look at it! Yes, until now I've been exploring to just see what is possible technically and did not have the time yet to make this a consistent code base.

I'm just a hobby dev, so if you already have a style you could recommend for open source JS projects, feel free to propose it!

I've no experience with TS, so I rather keep it JS for now. Is there a tool to derive types to support TS or something?

Josh-Cena commented 3 years ago

If you don't have experience with TS it's fine that we only provide a .d.ts file. This is more like an interface definition for library users about "what the exported objects are like", and won't interfere with the code base itself.

Still I'd prefer completely migrating to TS: a lot of the variable types can be implicitly inferred (derived), so you don't necessarily have to write a lot of type definitions, but you get nice static checks. And TS is a superset of JS—you can still write AnyScript with no type definitions and build would pass, so I would say it's a gain with no foreseeable loss. I can also help with any issues.

Anyways, TS is probably lower priority than linters, so I'll work on the latter in the coming weeks.