<commit_before>/**
 * @fileoverview Tests for react-in-jsx-scope
 * @author <NAME>
 */

'use strict';

// -----------------------------------------------------------------------------
// Requirements
// -----------------------------------------------------------------------------

var eslint = require('eslint').linter;
var ESLintTester = require('eslint-tester');

// -----------------------------------------------------------------------------
// Tests
// -----------------------------------------------------------------------------

var eslintTester = new ESLintTester(eslint);
eslintTester.addRuleTest('lib/rules/react-in-jsx-scope', {
    valid: [
        {code: 'var React, App; <App />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}},
        {code: 'var React; <img />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}},
        {code: 'var React; <x-gif />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}},
        {code: 'var React, App, a=1; <App attr={a} />;', ecmaFeatures: {jsx: true}},
        {code: 'var React, App, a=1; function elem() { return <App attr={a} />; }', ecmaFeatures: {jsx: true}},
        {code: 'var React, App; <App />;', args: [1, {vars: 'all'}], ecmaFeatures: {globalReturn: true, jsx: true}},
        {code: '/** @jsx Foo */ var Foo, App; <App />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}},
        {code: '/** @jsx Foo.Bar */ var Foo, App; <App />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}}
    ],
    invalid: [
        {code: 'var App, a = <App />;',
         errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
        {code: 'var a = <App />;',
         errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
        {code: 'var a = <img />;',
         errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
        {code: '/** @jsx React.DOM */ var a = <img />;',
         errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
        {code: '/** @jsx Foo.bar */ var React, a = <img />;',
         errors: [{message: '\'Foo\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}}<commit_msg>Reproduce error using ES6 imports<commit_after>/**
 * @fileoverview Tests for react-in-jsx-scope
 * @author <NAME>
 */

'use strict';

// -----------------------------------------------------------------------------
// Requirements
// -----------------------------------------------------------------------------

var eslint = require('eslint').linter;
var ESLintTester = require('eslint-tester');

// -----------------------------------------------------------------------------
// Tests
// -----------------------------------------------------------------------------

var eslintTester = new ESLintTester(eslint);
eslintTester.addRuleTest('lib/rules/react-in-jsx-scope', {
    valid: [
        {code: 'var React, App; <App />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}},
        {code: 'var React; <img />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}},
        {code: 'var React; <x-gif />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}},
        {code: 'var React, App, a=1; <App attr={a} />;', ecmaFeatures: {jsx: true}},
        {code: 'var React, App, a=1; function elem() { return <App attr={a} />; }', ecmaFeatures: {jsx: true}},
        {code: 'var React, App; <App />;', args: [1, {vars: 'all'}], ecmaFeatures: {globalReturn: true, jsx: true}},
        {code: '/** @jsx Foo */ var Foo, App; <App />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}},
        {code: '/** @jsx Foo.Bar */ var Foo, App; <App />;', args: [1, {vars: 'all'}], ecmaFeatures: {jsx: true}},
        {code: [
            'import React from \'react/addons\';',
            'const Button = React.createClass({',
            '  render() {',
            '    return (',
            '      <button {...this.props}>{this.props.children}</button>',
            '    )',
            '  }',
            '});',
            'export default Button;'
          ].join('\n'),
          ecmaFeatures: {blockBindings: true, objectLiteralShorthandMethods: true, modules: true, jsx: true}
        }
    ],
    invalid: [
        {code: 'var App, a = <App />;',
         errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
        {code: 'var a = <App />;',
         errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
        {code: 'var a = <img />;',
         errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
        {code: '/** @jsx React.DOM */ var a = <img />;',
         errors: [{message: '\'React\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}},
        {code: '/** @jsx Foo.bar */ var React, a = <img />;',
         errors: [{message: '\'Foo\' must be in scope when using JSX'}], ecmaFeatures: {jsx: true}}
{'fraction_non_alphanumeric': 0.3191065017949741, 'fraction_numerical': 0.0033905065815715996, 'mean_word_length': 1.7722498618021005, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '3937585', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1569, 'n_words': 456}