42 lines
2.8 KiB
JavaScript
42 lines
2.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: {
|
||
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy91bmFtYmlndW91cy5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsInR5cGUiLCJkb2NzIiwidXJsIiwiY3JlYXRlIiwiY29udGV4dCIsInBhcnNlck9wdGlvbnMiLCJzb3VyY2VUeXBlIiwiUHJvZ3JhbSIsImFzdCIsInJlcG9ydCIsIm5vZGUiLCJtZXNzYWdlIl0sIm1hcHBpbmdzIjoiOztBQUtBOztBQUNBOzs7Ozs7QUFOQTs7Ozs7QUFRQUEsT0FBT0MsT0FBUCxHQUFpQjtBQUNmQyxRQUFNO0FBQ0pDLFVBQ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