41 lines
2.7 KiB
JavaScript
41 lines
2.7 KiB
JavaScript
'use strict';
|
|
|
|
var _unambiguous = require('eslint-module-utils/unambiguous');
|
|
|
|
var _docsUrl = require('../docsUrl');
|
|
|
|
var _docsUrl2 = _interopRequireDefault(_docsUrl);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* @fileOverview Report modules that could parse incorrectly as scripts.
|
|
* @author Ben Mosher
|
|
*/
|
|
|
|
module.exports = {
|
|
meta: {
|
|
docs: {
|
|
url: (0, _docsUrl2.default)('unambiguous')
|
|
}
|
|
},
|
|
|
|
create: function (context) {
|
|
// ignore non-modules
|
|
if (context.parserOptions.sourceType !== 'module') {
|
|
return {};
|
|
}
|
|
|
|
return {
|
|
Program: function (ast) {
|
|
if (!(0, _unambiguous.isModule)(ast)) {
|
|
context.report({
|
|
node: ast,
|
|
message: 'This module could be parsed as a valid script.'
|
|
});
|
|
}
|
|
}
|
|
};
|
|
}
|
|
};
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3VuYW1iaWd1b3VzLmpzIl0sIm5hbWVzIjpbIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwiZG9jcyIsInVybCIsImNyZWF0ZSIsImNvbnRleHQiLCJwYXJzZXJPcHRpb25zIiwic291cmNlVHlwZSIsIlByb2dyYW0iLCJhc3QiLCJyZXBvcnQiLCJub2RlIiwibWVzc2FnZSJdLCJtYXBwaW5ncyI6Ijs7QUFLQTs7QUFDQTs7Ozs7O0FBTkE7Ozs7O0FBUUFBLE9BQU9DLE9BQVAsR0FBaUI7QUFDZkMsUUFBTTtBQUNKQyxVQUFNO0FBQ0pDLFdBQUssdUJBQVEsYUFBUjtBQUREO0FBREYsR0FEUzs7QUFPZkMsVUFBUSxVQUFVQyxPQUFWLEVBQW1CO0FBQ3pCO0FBQ0EsUUFBSUEsUUFBU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