eslint / rewrite

Monorepo for the new version of ESLint
Apache License 2.0
145 stars 11 forks source link

feat: Add migrate-config CLI tool #26

Closed nzakas closed 4 months ago

nzakas commented 4 months ago

This pull request adds a new package, @eslint/migrate-config, that is just a CLI tool designed to be run via npx.

This is different than other packages in a couple ways:

  1. Because there is no API exposed, we don't generate type definitions or publish to JSR.
  2. There is no need for Rollup so the entrypoint is in src.

Note: This is intended to be a first-pass of this tool to get people started. I'm not intending for this to be a perfect solution, but I've tested the output on a bunch of open source projects and found that it typically gets the config around 90% of the way there.

nzakas commented 4 months ago

Not entirely sure why JSR thinks the directory is dirty. 🤔

mdjermanovic commented 4 months ago

Perhaps we could temporarily add git status here to see which files are causing the issue in CI.

https://github.com/eslint/rewrite/blob/5f0d2e2aab2a396f8ee1f6c813c3a876a29bdba3/packages/compat/package.json#L28

"test:jsr": "git status ; npx jsr@latest publish --dry-run ; git status",
mdjermanovic commented 4 months ago

Seems to be a problem with changing file permissions

diff --git a/packages/migrate-config/src/migrate-config-cli.js b/packages/migrate-config/src/migrate-config-cli.js
old mode 100644
new mode 100755
mdjermanovic commented 4 months ago

I think what happens here is that npm install adds execute permissions to package.bin files, which is in this case src/migrate-config-cli.js. But the file is stored without them in git:

$ git ls-files -s packages/migrate-config/src/migrate-config-cli.js
100644 846046275ddde8f522b125e1fbccd8d5171b0c56 0       packages/migrate-config/src/migrate-config-cli.js

What might help is to do this:

$ git update-index --chmod=+x packages/migrate-config/src/migrate-config-cli.js

After this, you should see new permissions:

$ git ls-files -s packages/migrate-config/src/migrate-config-cli.js
100755 846046275ddde8f522b125e1fbccd8d5171b0c56 0       packages/migrate-config/src/migrate-config-cli.js

Then, commit the file & push.

nzakas commented 4 months ago

Ah, thanks for digging into that. 🙏 Looks like it worked!

mdjermanovic commented 4 months ago

It looks like the build script crashes because it assumes that every package that starts with @eslint is in this repo, but that's not the case with @eslint/eslintrc.

nzakas commented 4 months ago

Fixed the build script. :+1:

nzakas commented 4 months ago

Great feedback, thanks! Updated everything and even cleaned up some unnecessary objects that were being output.

nzakas commented 4 months ago

Updated the .eslintignore conversion. :+1: