liferay / liferay-frontend-projects

A monorepo containing assorted Frontend Infrastructure Team projects
Other
69 stars 68 forks source link

Migrate to @liferay/eslint-plugin #9

Closed wincent closed 2 years ago

wincent commented 4 years ago

This is something that I have been putting off for a while, because renaming packages is a pain, but I think we'll eventually have to do it: move eslint-config-liferay to eslint-plugin-liferay.

As I explained in 5850f26d0f9e4c03872a2:

ESLint surprisingly doesn't make it easy for you to bundle rules with a config, requiring you to publish a separate package. That is, if you have "eslint-config-foo", you have to stick your rules in "eslint-plugin-foo". The inverse doesn't appear to be true: if you have "eslint-plugin-foo", you can bundle configs with it without having to create "eslint-config-foo".

We however, have "eslint-config-liferay", and I don't want to create yet another package, so we use a horrifying but well-contained hack that is hidden away in utils/local.js to enable us to bundle local rules with our config.

The trouble with this hack is that:

Overall, things are working for now, but this feels like a liability. It would be much better to be able to freely update ESLint without worrying about whether the hack still works, or having to deal with edge cases stemming from people using the config in different ways.

Tentative plan of action:

I wish we'd known back in 2017 that a plugin would be better than a config, but we didn't and so them's the breaks. For reference, there are currently 1,187 NPM packages with the keyword "eslint-plugin" vs 809 with keyword "eslint-config". Examples of popular packages which are plugins bundling both rules and config include:

(All of which, we already use).

wincent commented 3 years ago

Seeing as I just linked to here from https://github.com/liferay/generator-liferay-fragments/commit/1300901a37da8f4175ebd143ed5f277bd65ef427 — it should be noted that this ticket was created before migrating the contents of the eslint-config-liferay repo into this monorepo, and before we started using the named @liferay/ scope on npm.

Bear that in mind when reading the description above; we still want to do this, but it won't be via eslint-plugin-liferay, but rather @liferay/eslint-plugin. Other than that, the above all still applies.

bryceosterhaus commented 2 years ago

Closing and spawned off new ticket to update existing projects, https://github.com/liferay/liferay-frontend-projects/issues/677