34 lines
2.8 KiB
JavaScript
34 lines
2.8 KiB
JavaScript
'use strict';
|
|
|
|
var _moduleVisitor = require('eslint-module-utils/moduleVisitor');
|
|
|
|
var _moduleVisitor2 = _interopRequireDefault(_moduleVisitor);
|
|
|
|
var _importType = require('../core/importType');
|
|
|
|
var _docsUrl = require('../docsUrl');
|
|
|
|
var _docsUrl2 = _interopRequireDefault(_docsUrl);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
module.exports = {
|
|
meta: {
|
|
docs: {
|
|
url: (0, _docsUrl2.default)('no-absolute-path')
|
|
},
|
|
schema: [(0, _moduleVisitor.makeOptionsSchema)()]
|
|
},
|
|
|
|
create: function (context) {
|
|
function reportIfAbsolute(source) {
|
|
if ((0, _importType.isAbsolute)(source.value)) {
|
|
context.report(source, 'Do not import modules using an absolute path');
|
|
}
|
|
}
|
|
|
|
const options = Object.assign({ esmodule: true, commonjs: true }, context.options[0]);
|
|
return (0, _moduleVisitor2.default)(reportIfAbsolute, options);
|
|
}
|
|
};
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vLWFic29sdXRlLXBhdGguanMiXSwibmFtZXMiOlsibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJkb2NzIiwidXJsIiwic2NoZW1hIiwiY3JlYXRlIiwiY29udGV4dCIsInJlcG9ydElmQWJzb2x1dGUiLCJzb3VyY2UiLCJ2YWx1ZSIsInJlcG9ydCIsIm9wdGlvbnMiLCJPYmplY3QiLCJhc3NpZ24iLCJlc21vZHVsZSIsImNvbW1vbmpzIl0sIm1hcHBpbmdzIjoiOztBQUFBOzs7O0FBQ0E7O0FBQ0E7Ozs7OztBQUVBQSxPQUFPQyxPQUFQLEdBQWlCO0FBQ2ZDLFFBQU07QUFDSkMsVUFBTTtBQUNKQyxXQUFLLHVCQUFRLGtCQUFSO0FBREQsS0FERjtBQ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