the-forest/client/node_modules/eslint-plugin-import/lib/rules/no-unresolved.js
2024-09-17 20:35:18 -04:00

60 lines
7.4 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);
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: {
category: 'Static analysis',
description: 'Ensure imports point to a file/module that can be resolved.',
url: (0, _docsUrl2['default'])('no-unresolved') },
schema: [
(0, _moduleVisitor.makeOptionsSchema)({
caseSensitive: { type: 'boolean', 'default': true },
caseSensitiveStrict: { type: 'boolean', 'default': false } })] },
create: function () {function create(context) {
var options = context.options[0] || {};
function checkSourceValue(source, node) {
// ignore type-only imports and exports
if (node.importKind === 'type' || node.exportKind === 'type') {
return;
}
var caseSensitive = !_resolve.CASE_SENSITIVE_FS && options.caseSensitive !== false;
var caseSensitiveStrict = !_resolve.CASE_SENSITIVE_FS && options.caseSensitiveStrict;
var resolvedPath = (0, _resolve2['default'])(source.value, context);
if (resolvedPath === undefined) {
context.report(
source, 'Unable to resolve path to module \'' + String(
source.value) + '\'.');
} else if (caseSensitive || caseSensitiveStrict) {
var cacheSettings = _ModuleCache2['default'].getSettings(context.settings);
if (!(0, _resolve.fileExistsWithCaseSync)(resolvedPath, cacheSettings, caseSensitiveStrict)) {
context.report(
source, 'Casing of ' + String(
source.value) + ' does not match the underlying filesystem.');
}
}
}
return (0, _moduleVisitor2['default'])(checkSourceValue, options);
}return create;}() };
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9u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