[eslint] Forbid importing common
code to public
or server
across plugin boundaries
#127829
Labels
DX
Issues related to Developer Experience
impact:needs-assessment
Product and/or Engineering needs to evaluate the impact of the change.
loe:small
Small Level of Effort
Team:Core
Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
In #118826, @mattkime proposed a convention for differentiating between private & public code in a plugin's
common
directory.One thing that came up in the discussion was that we currently aren't putting any restrictions in place for when a plugin imports from a
common
directory that lives in another plugin[0]. The main reasoning for this is, presumably, that we have theextraPublicDirs
setting in the plugin manifest (see #68986), and as a result plugins can technically do static code imports from any directory in another plugin.However,
extraPublicDir
has been deprecated from the beginning as a temporary solution, and we intend to ultimately get rid of it, perhaps eventually formalizingcommon
directories as a first-class concept.We should consider adding eslint rules to enforce the following:
server
directory importing from another plugin'scommon
directorypublic
directory importing from another plugin'scommon
directorycommon
directory importing from another plugin'scommon
directoryserver
orpublic
code importing from its owncommon
directoryThe tradeoff here would be that plugins would need to ignore eslint when importing from another plugin that is using
extraPublicDir
to expose code from acommon
directory. IMO that's an acceptable tradeoff, especially as we are looking to sunsetextraPublicDir
anyway.But there may be something I'm overlooking here. Are there any other downsides I am missing?
cc @stacey-gammon @spalger @tylersmalley
[0] Based on comments I'm reading in other issues, I think historically there has been assumption that we have restricted this behavior, but it looks like this is no longer the case.
The text was updated successfully, but these errors were encountered: