Js-lingui: [Documentation] prevent @lingui/macro should be listed in the project's dependencies

Created on 3 Dec 2018  路  12Comments  路  Source: lingui/js-lingui

Is your feature request related to a problem? Please describe.
Because @lingui/macro is based on preprocessing files it's part of dev dependencies. However, because it is used as an import in jsx files, eslint complains

[eslint] '@lingui/macro' should be listed in the project's dependencies, not devDependencies. [import/no-extraneous-dependencies]

Describe the solution you'd like
Documentation should describe how to disable this for @lingui/macro only. It would not be undesirable to have to fix this on a file per file basis

Describe alternatives you've considered
You could do individual includes //eslint-disable-line on a line by line basis. But that sucks

accepted 馃摉 documentation

All 12 comments

I've never seen this eslint rule. Could you please send a PR with proposed solution? We should probably also add it to documentation of babel-plugin-macros, because it'll affect all macros.

Thank you for bringing this up! 馃憤

Well, the rulle that gives the error is import/no-extraneous-dependencies. It basically warns you when you include in to be deployed code imports that are in devDependencies instead of dependencies. Perhaps the easiest solution would be to simply put @lingui/macro in dependencies, assuming that tree shaking will prevent it from being included when not necessary.

Yeah, sounds like a good idea. The tree shaking won't be even necessary. The production code won't see macro package as it's removed in build step (even the import).

@tricoder42 should we reopen this issue? Had a chat about the eslint rule here https://github.com/benmosher/eslint-plugin-import/issues/1553

The current thinking is that the macro should indeed be a regular dependency - and that we should update the docs

Hey @magicmark, we should definitely discuss it in https://github.com/kentcdodds/babel-plugin-macros, because it affects all macros. I searched for relevant issues and could find any.

I guess we should:

  1. Open ticket in https://github.com/kentcdodds/babel-plugin-macros with a link to https://github.com/benmosher/eslint-plugin-import/issues/1553 and explain the problem
  2. Create a PR to https://github.com/kentcdodds/babel-plugin-macros mentioning that macros should be listed in production dependencies if the project uses eslint-plugin-import
  3. Update Lingui docs to correctly install @lingui/macro as production dependency.

Maybe in the process we'll find a cue why nobody mentioned it in https://github.com/kentcdodds/babel-plugin-macros repository yet.

If anyone wants to pick it up, any help is appreciated 馃憤

Hi everyone!

Anyone update about this issue.

After integrating this eslint plugin, I have got this issue.

@dshuvalov As you can read there https://github.com/kentcdodds/babel-plugin-macros/issues/141
you can add the stuff as dependency instead of devDependency with no problems

@lucax88x Perfect, would you like to send a PR with updated docs? Please next branch as a base, if you do so.

Got this on the the review of the documentation =) Assign me

Closed in #768

Thank you guys. Where I can check updated docs?

@dshuvalov Latest version from next branch is deployed here https://js-lingui-git-next.lingui-js.now.sh/

Was this page helpful?
0 / 5 - 0 ratings