odin-javascript-exercises/node_modules/eslint-plugin-import/lib/rules/no-unresolved.js
2017-12-15 12:56:14 -06:00

47 lines
No EOL
4.8 KiB
JavaScript

'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);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = {
meta: {
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]);
}
}; /**
* @fileOverview Ensures that an imported path exists, given resolution rules.
* @author Ben Mosher
*/
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vLXVucmVzb2x2ZWQuanMiXSwibmFtZXMiOlsibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJzY2hlbWEiLCJjYXNlU2Vuc2l0aXZlIiwidHlwZSIsImRlZmF1bHQiLCJjcmVhdGUiLCJjb250ZXh0IiwiY2hlY2tTb3VyY2VWYWx1ZSIsInNvdXJjZSIsInNob3VsZENoZWNrQ2FzZSIsIm9wdGlvbnMiLCJyZXNvbHZlZFBhdGgi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