src/options/quotes.js
function(ast) {
    let value = this.value;

    ast.traverseByType('string', function(string) {
      if (string.content[0] === '"' && value === 'single') {
        string.content = string.content
            // Unescape all escaped double quotes
            .replace(/\\"/g, '"')
            // Escape all the single quotes
            .replace(/([^\\])'/g, '$1\\\'')
            // Replace the first and the last quote
            .replace(/^"|"$/g, '\'');
      } else if (string.content[0] === '\'' && value === 'double') {
        string.content = string.content
            // Unescape all escaped single quotes
            .replace(/\\'/g, '\'')
            // Escape all the double quotes
            .replace(/([^\\])"/g, '$1\\\"')
            // Replace the first and the last quote
            .replace(/^'|'$/g, '"');
      }
    });
  }
function(ast) {
    let value = this.value;

    ast.traverseByType('string', function(string) {
      if (string.content[0] === '"' && value === 'single') {
        string.content = string.content
            // Unescape all escaped double quotes
            .replace(/\\"/g, '"')
            // Escape all the single quotes
            .replace(/([^\\])'/g, '$1\\\'')
            // Replace the first and the last quote
            .replace(/^"|"$/g, '\'');
      } else if (string.content[0] === '\'' && value === 'double') {
        string.content = string.content
            // Unescape all escaped single quotes
            .replace(/\\'/g, '\'')
            // Escape all the double quotes
            .replace(/([^\\])"/g, '$1\\\"')
            // Replace the first and the last quote
            .replace(/^'|'$/g, '"');
      }
    });
  }
function ( ast ) { let value = this . value ; ast . traverseByType ( 'string' , function ( string ) { if ( string . content [ 0 ] === '"' && value === 'single' ) { string . content = string . content // Unescape all escaped double quotes . replace ( / \\" / g , '"' ) // Escape all the single quotes . replace ( / ([^\\])' / g , '$1\\\'' ) // Replace the first and the last quote . replace ( / ^"|"$ / g , '\'' ) ; } else if ( string . content [ 0 ] === '\'' && value === 'double' ) { string . content = string . content // Unescape all escaped single quotes . replace ( / \\' / g , '\'' ) // Escape all the double quotes . replace ( / ([^\\])" / g , '$1\\\"' ) // Replace the first and the last quote . replace ( / ^'|'$ / g , '"' ) ; } } ) ; }
Processes tree node.
@param {node} ast
Processes tree node .