<commit_before>/**
 * @fileoverview Prevent common casing typos
 */
'use strict';

const Components = require('../util/Components');
const docsUrl = require('../util/docsUrl');

// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------

const STATIC_CLASS_PROPERTIES = ['propTypes', 'contextTypes', 'childContextTypes', 'defaultProps'];
const LIFECYCLE_METHODS = [
  'componentWillMount',
  'componentDidMount',
  'componentWillReceiveProps',
  'shouldComponentUpdate',
  'componentWillUpdate',
  'componentDidUpdate',
  'componentWillUnmount',
  'render'
];

const PROP_TYPES = Object.keys(require('prop-types'));

module.exports = {
  meta: {
    docs: {
      description: 'Prevent common typos',
      category: 'Stylistic Issues',
      recommended: false,
      url: docsUrl('no-typos')
    },
    schema: []
  },

  create: Components.detect((context, components, utils) => {
    function checkValidPropTypeQualfier(node) {
      if (node.name !== 'isRequired') {
        context.report({
          node: node,
          message: `Typo in prop type chain qualifier: ${node.name}`
        });
      }
    }

    function checkValidPropType(node) {
      if (node.name && !PROP_TYPES.some(propTypeName => propTypeName === node.name)) {
        context.report({
          node: node,
          message: `Typo in declared prop type: ${node.name}`
        });
      }
    }

    /* eslint-disable no-use-before-define */
    function checkValidProp(node) {
      if (node && node.type === 'MemberExpression' && node.object.type === 'MemberExpression') {
        checkValidPropType(node.object.property);
        checkValidPropTypeQualfier(node.property);
      } else if (node && node.type === 'MemberExpression' && node.object.type === 'Identifier' && node.property.name !== 'isRequired') {
        checkValidPropType(node.property);
      } else if (node && (
        node.type === 'MemberExpression' && node.object.type === 'CallExpression' || node.type === 'CallExpression'
      )) {
        if (node.type === 'MemberExpression') {
          checkValidPropTypeQualfier(node.property);
          node = node.object;
        }
        const callee = node.callee;
        if (callee.type === 'MemberExpression' && callee.property.name === 'shape') {
          checkValidPropObject(node.arguments[0]);
        } else if (callee.type === 'MemberExpression' && callee.property.name === 'oneOfType') {
          const args = node.arguments[0];
          if (args && args.type === 'ArrayExpression') {
            args.elements.forEach(el => checkValidProp(el));
          }
        }
      }
    }

    function checkValidPropObject (node) {
      if (node && node.type === 'ObjectExpression') {
        node.properties.forEach(prop => checkValidProp(prop.value));
      }
    }
    /* eslint-enable no-use-before-define */

    function reportErrorIfClassPropertyCasingTypo(node, propertyName) {<commit_msg>Remove unneeded comment<commit_after>/**
 * @fileoverview Prevent common casing typos
 */
'use strict';

const Components = require('../util/Components');
const docsUrl = require('../util/docsUrl');

// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------

const STATIC_CLASS_PROPERTIES = ['propTypes', 'contextTypes', 'childContextTypes', 'defaultProps'];
const LIFECYCLE_METHODS = [
  'componentWillMount',
  'componentDidMount',
  'componentWillReceiveProps',
  'shouldComponentUpdate',
  'componentWillUpdate',
  'componentDidUpdate',
  'componentWillUnmount',
  'render'
];

const PROP_TYPES = Object.keys(require('prop-types'));

module.exports = {
  meta: {
    docs: {
      description: 'Prevent common typos',
      category: 'Stylistic Issues',
      recommended: false,
      url: docsUrl('no-typos')
    },
    schema: []
  },

  create: Components.detect((context, components, utils) => {
    function checkValidPropTypeQualfier(node) {
      if (node.name !== 'isRequired') {
        context.report({
          node: node,
          message: `Typo in prop type chain qualifier: ${node.name}`
        });
      }
    }

    function checkValidPropType(node) {
      if (node.name && !PROP_TYPES.some(propTypeName => propTypeName === node.name)) {
        context.report({
          node: node,
          message: `Typo in declared prop type: ${node.name}`
        });
      }
    }

    /* eslint-disable no-use-before-define */
    function checkValidProp(node) {
      if (node && node.type === 'MemberExpression' && node.object.type === 'MemberExpression') {
        checkValidPropType(node.object.property);
        checkValidPropTypeQualfier(node.property);
      } else if (node && node.type === 'MemberExpression' && node.object.type === 'Identifier' && node.property.name !== 'isRequired') {
        checkValidPropType(node.property);
      } else if (node && (
        node.type === 'MemberExpression' && node.object.type === 'CallExpression' || node.type === 'CallExpression'
      )) {
        if (node.type === 'MemberExpression') {
          checkValidPropTypeQualfier(node.property);
          node = node.object;
        }
        const callee = node.callee;
        if (callee.type === 'MemberExpression' && callee.property.name === 'shape') {
          checkValidPropObject(node.arguments[0]);
        } else if (callee.type === 'MemberExpression' && callee.property.name === 'oneOfType') {
          const args = node.arguments[0];
          if (args && args.type === 'ArrayExpression') {
            args.elements.forEach(el => checkValidProp(el));
          }
        }
      }
    }

    function checkValidPropObject (node) {
      if (node && node.type === 'ObjectExpression') {
        node.properties.forEach(prop => checkValidProp(prop.value));
      }
    }

    function reportErrorIfClassPropertyCasingTypo(node, propertyName) {
{'fraction_non_alphanumeric': 0.19399767866025536, 'fraction_numerical': 0.000663239927043608, 'mean_word_length': 2.367950865438303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1032585', 'n_tokens_mistral': 1686, 'n_tokens_neox': 1670, 'n_words': 324}