123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- '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 };}
- 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) {
-
- 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;}() };
|