({inputSourceArch, isopackCache, sources,
sourceProcessorSet, watchSet})
| 702 | }); |
| 703 | |
| 704 | function runLinters({inputSourceArch, isopackCache, sources, |
| 705 | sourceProcessorSet, watchSet}) { |
| 706 | // The buildmessage context here is for linter warnings only! runLinters |
| 707 | // should not do anything that can have a real build failure. |
| 708 | buildmessage.assertInCapture(); |
| 709 | |
| 710 | if (sourceProcessorSet.isEmpty()) { |
| 711 | return; |
| 712 | } |
| 713 | |
| 714 | // First we calculate the symbols imported into the current package by |
| 715 | // packages we depend on. This is because most JS linters are going to want to |
| 716 | // warn about the use of unknown global variables, and the linker import |
| 717 | // system works by doing something that looks a whole lot like using |
| 718 | // undeclared globals! That said, we don't actually know the imports that |
| 719 | // will be active when an app is built if the versions of the imported |
| 720 | // packages differ from those available at package lint time. But it's a good |
| 721 | // heuristic, at least. (If we transition from linker to ES2015 modules, we |
| 722 | // won't have the issue any more.) |
| 723 | |
| 724 | // We want to look at the arch of the used packages that matches the arch |
| 725 | // we're compiling. Normally when we call compiler.eachUsedUnibuild, we're |
| 726 | // either specifically looking at archinfo.host() because we're doing |
| 727 | // something related to plugins (which always run in the host environment), or |
| 728 | // we're in the process of building a bundler Target (a program), which has a |
| 729 | // specific arch which is never 'os'. In this odd case, though, we're trying |
| 730 | // to run eachUsedUnibuild at package-compile time (not bundle time), so the |
| 731 | // only 'arch' we've heard of might be 'os', if we're building a portable |
| 732 | // unibuild. In that case, we should look for imports in the host arch if it |
| 733 | // exists instead of failing because a dependency does not have an 'os' |
| 734 | // unibuild. |
| 735 | const whichArch = inputSourceArch.arch === 'os' |
| 736 | ? archinfo.host() : inputSourceArch.arch; |
| 737 | |
| 738 | // For linters, figure out what are the global imports from other packages |
| 739 | // that we use directly, or are implied. |
| 740 | const globalImports = ['Package']; |
| 741 | |
| 742 | if (archinfo.matches(inputSourceArch.arch, "os")) { |
| 743 | globalImports.push('Npm', 'Assets'); |
| 744 | } |
| 745 | |
| 746 | compiler.eachUsedUnibuild({ |
| 747 | dependencies: inputSourceArch.uses, |
| 748 | arch: whichArch, |
| 749 | isopackCache: isopackCache, |
| 750 | skipUnordered: true, |
| 751 | // don't import symbols from debugOnly, prodOnly and testOnly |
| 752 | // packages, because if the package is not linked it will cause a |
| 753 | // runtime error. the code must access them with |
| 754 | // `Package["my-package"].MySymbol`. |
| 755 | skipDebugOnly: true, |
| 756 | skipProdOnly: true, |
| 757 | skipTestOnly: true, |
| 758 | }, (unibuild) => { |
| 759 | if (unibuild.pkg.name === inputSourceArch.pkg.name) { |
| 760 | return; |
| 761 | } |
no test coverage detected
searching dependent graphs…