12345678910111213141516171819202122232425262728293031323334353637383940 |
- "use strict"
- const exists = require("./exists")
- const getAllowModules = require("./get-allow-modules")
- module.exports = function checkForExistence(context, targets) {
- const allowed = new Set(getAllowModules(context))
- for (const target of targets) {
- const missingModule =
- target.moduleName != null &&
- !allowed.has(target.moduleName) &&
- target.filePath == null
- const missingFile =
- target.moduleName == null && !exists(target.filePath)
- if (missingModule || missingFile) {
- context.report({
- node: target.node,
- loc: target.node.loc,
- message: '"{{name}}" is not found.',
- data: target,
- })
- }
- }
- }
|