'use strict';

// this Babel plugin removes configuration comments such as:
//   <!-- template-lint triple-curlies=false -->
//   <!-- template-lint enabled=false -->


module.exports = function() {
  function RemoveConfigurationHtmlCommentsPlugin() {}

  RemoveConfigurationHtmlCommentsPlugin.prototype.transform = function(ast) {
    this.syntax.traverse(ast, {
      CommentStatement: function(node) {
        if (node.value.trim().indexOf('template-lint ') === 0) {
          // remove the entry
          return null;
        }
      }
    });

    return ast;
  };

  return RemoveConfigurationHtmlCommentsPlugin;
};

'use strict';

// this Babel plugin removes configuration comments such as:
//   <!-- template-lint triple-curlies=false -->
//   <!-- template-lint enabled=false -->

var AstNodeInfo = require('ember-template-lint/lib/helpers/ast-node-info');

module.exports = function() {
  function RemoveConfigurationHtmlCommentsPlugin() {}

  RemoveConfigurationHtmlCommentsPlugin.prototype.transform = function(ast) {
    var walker = new this.syntax.Walker();
    var bodyEntry;

    walker.visit(ast, function(node) {
      if (node.type === 'Program') {
        for (var i = 0; i < node.body.length; i++) {
          bodyEntry = node.body[i];

          if(AstNodeInfo.isConfigurationHtmlComment(bodyEntry)) {
            // remove the entry
            node.body.splice(i, 1);
          }
        }
      }
    });

    return ast;
  };

  return RemoveConfigurationHtmlCommentsPlugin;
};

Revert "Use simpler traverse API for removing config comments."
Revert "Use simpler traverse API for removing config comments."

This reverts commit e9f8e286aaadeda26f898db823cafdf4e6c8dd10.

We cannot rely on the newer traverse API here, until we do not support
versions older than Ember 2.1.0.
