eslint-plugin-flowtype icon indicating copy to clipboard operation
eslint-plugin-flowtype copied to clipboard

fix: declare parsers as optional peer dependencies

Open ylemkimon opened this issue 5 years ago • 8 comments

The test shows babel-eslint-plugin is compatible with the latest of all major version of babel-eslint, so * is used.

ylemkimon avatar Aug 21 '20 17:08 ylemkimon

The parser is migrated to monorepo https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser

TrySound avatar Aug 21 '20 17:08 TrySound

So better to not add any dependency to be compatible with both packages. Especially since there is no version restriction.

TrySound avatar Aug 21 '20 18:08 TrySound

@TrySound I wonder how Babel solved the peer dependency problem when moving from Babel 6 to 7.

ylemkimon avatar Aug 21 '20 18:08 ylemkimon

Which problem I don't follow? Babel-eslint bumped babel/core long time ago. https://github.com/babel/babel-eslint/blob/master/package.json#L32

TrySound avatar Aug 21 '20 18:08 TrySound

@TrySound I remember there were lots of packages declaring unscoped Babel packages, e.g. babel-core, as peer dependency. I'm curious how they moved to using scoped Babel packages (@babel/core) as peer dependencies.

One way I can think of is declaring both parser as optional using peerDependenciesMeta. ~I'll update the PR.~ Updated.

ylemkimon avatar Aug 21 '20 18:08 ylemkimon

There was babel-core@7-bridge package which reexported @babel/core. Probably yeah, peerDependenciesMeta can be a way to go. But it should be resolved in recommended config as well.

TrySound avatar Aug 21 '20 18:08 TrySound

@TrySound Now I remember, [email protected]. I've opened an issue at Babel to request to provide the bridge version: https://github.com/babel/babel/issues/11989.

ylemkimon avatar Aug 21 '20 19:08 ylemkimon

By @kaicataldo in https://github.com/babel/babel/issues/11989#issuecomment-693892947

The hard break was intentional here because we've changed how the parser works and there are significant breaking changes. I'm in favor of making things fail faster in this case so that people are aware of the changes if/when they upgrade.

I think declaring both of them as optional peer dependencies is the best way to go.

ylemkimon avatar Sep 21 '20 10:09 ylemkimon