github-pages-deploy-action/node_modules/eslint-plugin-import/lib/rules/no-unresolved.js

58 lines
5.3 KiB
JavaScript
Raw Normal View History

2020-03-07 11:45:40 +08:00
'use strict';
var _resolve = require('eslint-module-utils/resolve');
var _resolve2 = _interopRequireDefault(_resolve);
var _ModuleCache = require('eslint-module-utils/ModuleCache');
var _ModuleCache2 = _interopRequireDefault(_ModuleCache);
var _moduleVisitor = require('eslint-module-utils/moduleVisitor');
var _moduleVisitor2 = _interopRequireDefault(_moduleVisitor);
var _docsUrl = require('../docsUrl');
var _docsUrl2 = _interopRequireDefault(_docsUrl);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @fileOverview Ensures that an imported path exists, given resolution rules.
* @author Ben Mosher
*/
module.exports = {
meta: {
type: 'problem',
docs: {
url: (0, _docsUrl2.default)('no-unresolved')
},
schema: [(0, _moduleVisitor.makeOptionsSchema)({
caseSensitive: { type: 'boolean', default: true }
})]
},
create: function (context) {
function checkSourceValue(source) {
const shouldCheckCase = !_resolve.CASE_SENSITIVE_FS && (!context.options[0] || context.options[0].caseSensitive !== false);
const resolvedPath = (0, _resolve2.default)(source.value, context);
if (resolvedPath === undefined) {
context.report(source, `Unable to resolve path to module '${source.value}'.`);
} else if (shouldCheckCase) {
const cacheSettings = _ModuleCache2.default.getSettings(context.settings);
if (!(0, _resolve.fileExistsWithCaseSync)(resolvedPath, cacheSettings)) {
context.report(source, `Casing of ${source.value} does not match the underlying filesystem.`);
}
}
}
return (0, _moduleVisitor2.default)(checkSourceValue, context.options[0]);
}
};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby11bnJlc29sdmVkLmpzIl0sIm5hbWVzIjpbIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwidHlwZSIsImRvY3MiLCJ1cmwiLCJzY2hlbWEiLCJjYXNlU2Vuc2l0aXZlIiwiZGVmYXV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