29 lines
2.2 KiB
JavaScript
29 lines
2.2 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
var _unambiguous = require('eslint-module-utils/unambiguous');
|
||
|
|
||
|
module.exports = {
|
||
|
meta: {},
|
||
|
|
||
|
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.'
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
}; /**
|
||
|
* @fileOverview Report modules that could parse incorrectly as scripts.
|
||
|
* @author Ben Mosher
|
||
|
*/
|
||
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL3VuYW1iaWd1b3VzLmpzIl0sIm5hbWVzIjpbIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwiY3JlYXRlIiwiY29udGV4dCIsInBhcnNlck9wdGlvbnMiLCJzb3VyY2VUeXBlIiwiUHJvZ3JhbSIsImFzdCIsInJlcG9ydCIsIm5vZGUiLCJtZXNzYWdlIl0sIm1hcHBpbmdzIjoiOztBQUtBOztBQUVBQSxPQUFPQyxPQUFQLEdBQWlCO0FBQ2ZDLFFBQU0sRUFEUzs7QUFHZkMsVUFBUSxVQUFVQyxPQUFWLEVBQW1CO0FBQ3pCO0FBQ0EsUUFBSUEsUUFBUUMsYUFBUixDQUFzQkMsVUFBdEIsS0FBcUMsUUFBekMsRUFBbUQ7QUFDakQsYUFBTyxFQUFQO0FBQ0Q7O0FBRUQsV0FBTztBQUNMQyxlQUFTLFVBQVVDLEdBQVYsRUFBZTtBQUN0QixZQUFJLENBQUMsMkJBQVNBLEdBQVQsQ0FBTCxFQUFvQjtBQUNsQkosa0JBQVFLLE1BQV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