no-absolute-path.js 3.1 KB

123456789101112131415161718192021222324
  1. 'use strict';var _moduleVisitor = require('eslint-module-utils/moduleVisitor');var _moduleVisitor2 = _interopRequireDefault(_moduleVisitor);
  2. var _importType = require('../core/importType');
  3. var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
  4. module.exports = {
  5. meta: {
  6. type: 'suggestion',
  7. docs: {
  8. url: (0, _docsUrl2.default)('no-absolute-path') },
  9. schema: [(0, _moduleVisitor.makeOptionsSchema)()] },
  10. create: function (context) {
  11. function reportIfAbsolute(source) {
  12. if (typeof source.value === 'string' && (0, _importType.isAbsolute)(source.value)) {
  13. context.report(source, 'Do not import modules using an absolute path');
  14. }
  15. }
  16. const options = Object.assign({ esmodule: true, commonjs: true }, context.options[0]);
  17. return (0, _moduleVisitor2.default)(reportIfAbsolute, options);
  18. } };
  19. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1hYnNvbHV0ZS1wYXRoLmpzIl0sIm5hbWVzIjpbIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwidHlwZSIsImRvY3MiLCJ1cmwiLCJzY2hlbWEiLCJjcmVhdGUiLCJjb250ZXh0IiwicmVwb3J0SWZBYnNvbHV0ZSIsInNvdXJjZSIsInZhbHVlIiwicmVwb3J0Iiwib3B0aW9ucyIsIk9iamVjdCIsImFzc2lnbiIsImVzbW9kdWxlIiwiY29tbW9uanMiXSwibWFwcGluZ3MiOiJhQUFBLGtFO0FBQ0E7QUFDQSxxQzs7QUFFQUEsT0FBT0MsT0FBUCxHQUFpQjtBQUNmQyxRQUFNO0FBQ0pDLFVBQU0sWUFERjtBQUVKQyxVQUFNO0FBQ0pDLFdBQUssdUJBQVEsa0JBQVIsQ0FERCxFQUZGOztBQUtKQyxZQUFRLENBQUUsdUNBQU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