<commit_before>'use strict';

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

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

var eslintTester = new ESLintTester(eslint.linter);
eslintTester.addRuleTest('./lib/rules/no-latethis', {

    valid: [{
        code: 'var self = this, foo = "bar";',
        args: [1, 'self'],
    }, {
        code: 'var self = this; $el.on("click", function () { var $node = $(this); $node.trigger("ok"); });',
        args: [1, 'self']
    }, {
        code: 'console.log(this);'
    }, {
        code: 'this.doSomething();'
    }
    ],

    invalid: [{
        code: 'var that = this; $el.on("click", function () { that.run(); this.trigger("ok"); });',
        errors: [{ message: 'used "this" instead of "that"', }]
    }, {
        code: 'var that = this; $el.on("click", function () { var $node = $(this); $node.trigger("ok"); this.run(); });',
        errors: [{ message: 'used "this" instead of "that"', }]
    },
        // TODO as later part of onevar
        // TODO using this as part of func call, ala $(this)
        // TODO using this in a sub-nested anon function
    ]
});<commit_msg>test: simplify checks for fn invocations<commit_after>'use strict';

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

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

var eslintTester = new ESLintTester(eslint.linter);
eslintTester.addRuleTest('./lib/rules/no-latethis', {

    valid: [{
        code: 'var self = this, foo = "bar";',
        args: [1, 'self'],
    }, {
        code: 'var self = this; $el.on("click", function () { var $node = $(this); $node.trigger("ok"); });',
        args: [1, 'self']
    }, {
        code: 'console.log(this);'
    }, {
        code: 'this.doSomething();'
    }
    ],

    invalid: [{
        code: 'var that = this; $el.on("click", function () { this.trigger("ok"); });',
        errors: [{ message: 'used "this" instead of "that"', }]
    }, {
        code: 'var that = this; $el.on("click", function () { var $node = $(this); $node.trigger("ok"); this.run(); });',
        errors: [{ message: 'used "this" instead of "that"', }]
    }, {
        code: 'var self = this; $el.on("click", function () { this.trigger("ok"); });',
        args: [1, 'self'],
        errors: [{ message: 'used "this" instead of "self"', }]
    }
        // TODO as later part of onevar
        // TODO using this as part of func call, ala $(this)
        // TODO using this in a sub-nested anon function
    ]
});
{'fraction_non_alphanumeric': 0.2985559566787004, 'fraction_numerical': 0.0018050541516245488, 'mean_word_length': 1.7246804326450345, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7450369', 'n_tokens_mistral': 828, 'n_tokens_neox': 821, 'n_words': 219}