Testing: Add lint for Babel runtime dependency in transpiled packages
#14.373 geöffnet am 11. März 2019
Repository-Metriken
- Stars
- (9.607 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 12T 18h) (509 gemergte PRs in 30 T)
Beschreibung
Each package transpiled using Babel is configured to apply the Babel runtime transform (source). Thus, the built output for any package is expected to contain references to the @babel/runtime module. For this reason, the package must explicitly define @babel/runtime as a dependency.
For any package which is transpiled using Babel, we should lint to ensure it also includes an explicit dependency on @babel/runtime.
Implementation:
- A package can be determined as being subject to transpilation if its
package.jsonincludes amainreference to abuild/relative path. - I expect the best option for linting would be a rule from
npm-package-json-lintrequiring a specific dependency to be present, and for each exception package (the minority of cases), a package-specific.npmpackagejsonlintrc.jsonconfiguration override should disable the lint rule.- The lint rule should be applied only in the Gutenberg-specific configuration, not in
@wordpress/npm-package-json-lint-config - As best I can tell, however, there is no rule present which covers this case.
require-dependenciesonly requires that thedependenciesblock be present, andno-restricted-dependenciesis the inverse of what we need. We may need to consider contributing an upstream enhancement.
- The lint rule should be applied only in the Gutenberg-specific configuration, not in
cc @greatislander in case it's of interest to you, as you'd done similarly in the past for #13947 with an upstream enhancement at https://github.com/tclindner/npm-package-json-lint/pull/106 .