<commit_before>/**
 * Copyright 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *
 * @emails react-core
*/

'use strict';

module.exports = function(context) {
  function check(node) {
    const name = node.callee.name;
    let msg = null;
    switch (name) {
      case 'Boolean':
        msg = 'To cast a value to a boolean, use double negation: !!value';
        break;
      case 'String':
        msg = 'To cast a value to a string, concat it with the empty string: \'\' + value';
        break;
    }
    if (msg) {
      context.report(node, `Do not use the ${name} constructor. ${msg}`);
    }
  }

  return {
    CallExpression: check,
    NewExpression: check,
  };
};<commit_msg>Add caveat about symbols to string error message<commit_after>/**
 * Copyright 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 *
 * @emails react-core
*/

'use strict';

module.exports = function(context) {
  function report(node, name, msg) {
    context.report(node, `Do not use the ${name} constructor. ${msg}`);
  }

  function check(node) {
    const name = node.callee.name;
    switch (name) {
      case 'Boolean':
        report(
          node,
          name,
          'To cast a value to a boolean, use double negation: !!value'
        );
        break;
      case 'String':
        report(
          node,
          name,
          'To cast a value to a string, concat it with the empty string ' +
          '(unless it\'s a symbol, which have different semantics): ' +
          '\'\' + value'
        );
        break;
    }
  }

  return {
    CallExpression: check,
    NewExpression: check,
  };
};
{'fraction_non_alphanumeric': 0.10614793467819404, 'fraction_numerical': 0.0038424591738712775, 'mean_word_length': 2.3814935064935066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5989002', 'n_tokens_mistral': 612, 'n_tokens_neox': 593, 'n_words': 240}