38 lines
3.8 KiB
JavaScript
38 lines
3.8 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: {
|
||
|
type: 'suggestion',
|
||
|
docs: {
|
||
|
category: 'Module systems',
|
||
|
description: 'Forbid potentially ambiguous parse goal (`script` vs. `module`).',
|
||
|
url: (0, _docsUrl2['default'])('unambiguous') },
|
||
|
|
||
|
schema: [] },
|
||
|
|
||
|
|
||
|
create: function () {function create(context) {
|
||
|
// ignore non-modules
|
||
|
if (context.parserOptions.sourceType !== 'module') {
|
||
|
return {};
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
Program: function () {function Program(ast) {
|
||
|
if (!(0, _unambiguous.isModule)(ast)) {
|
||
|
context.report({
|
||
|
node: ast,
|
||
|
message: 'This module could be parsed as a valid script.' });
|
||
|
|
||
|
}
|
||
|
}return Program;}() };
|
||
|
|
||
|
|
||
|
}return create;}() };
|
||
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy91bmFtYmlndW91cy5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsInR5cGUiLCJkb2NzIiwiY2F0ZWdvcnkiLCJkZXNjcmlwdGlvbiIsInVybCIsInNjaGVtYSIsImNyZWF0ZSIsImNvbnRleHQiLCJwYXJzZXJPcHRpb25zIiwic291cmNlVHlwZSIsIlByb2dyYW0iLCJhc3QiLCJyZXBvcnQiLCJub2RlIiwibWVzc2FnZSJdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFLQTtB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