unambiguous.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. var _unambiguous = require('eslint-module-utils/unambiguous');
  3. var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };} /**
  4. * @fileOverview Report modules that could parse incorrectly as scripts.
  5. * @author Ben Mosher
  6. */module.exports = { meta: {
  7. type: 'suggestion',
  8. docs: {
  9. url: (0, _docsUrl2['default'])('unambiguous') },
  10. schema: [] },
  11. create: function () {function create(context) {
  12. // ignore non-modules
  13. if (context.parserOptions.sourceType !== 'module') {
  14. return {};
  15. }
  16. return {
  17. Program: function () {function Program(ast) {
  18. if (!(0, _unambiguous.isModule)(ast)) {
  19. context.report({
  20. node: ast,
  21. message: 'This module could be parsed as a valid script.' });
  22. }
  23. }return Program;}() };
  24. }return create;}() };
  25. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy91bmFtYmlndW91cy5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsInR5cGUiLCJkb2NzIiwidXJsIiwic2NoZW1hIiwiY3JlYXRlIiwiY29udGV4dCIsInBhcnNlck9wdGlvbnMiLCJzb3VyY2VUeXBlIiwiUHJvZ3JhbSIsImFzdCIsInJlcG9ydCIsIm5vZGUiLCJtZXNzYWdlIl0sIm1hcHBpbmdzIjoiOzs7OztBQUtBO0FBQ0EscUMsaUpBTkE7Ozt5TEFRQUEsT0FBT0MsT0FBUCxHQUFpQixFQUNmQyxNQUFNO0FBQ0pDLFVBQU0sWUFERjtBQUVKQyxVQUFNO0FBQ0pDLFdBQUssMEJBQVEsYUFBUixDQURELEVBRkY7O0FBS0pDLFlBQVEsRUFMSixFQURTOzs7QUFTZkMsUUFUZSwrQkFTUkMsT0FUUSxFQVNDO0FBQ2Q7QUFDQSx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