microsoft / tslint-microsoft-contrib

A set of TSLint rules used on some Microsoft projects.
MIT License
702 stars 198 forks source link

$(()=>{}) flags no-jquery-raw-elements #872

Closed kasugaiasuka closed 4 years ago

kasugaiasuka commented 5 years ago

Bug Report

TypeScript code being linted

$(async () => {

})

with tslint.json configuration:

{
    "defaultSeverity": "error",
    "extends": [],
    "jsRules": {},
    "rules": {
        "no-jquery-raw-elements": true
    },
    "rulesDirectory": [
        "node_modules/tslint-microsoft-contrib"
    ]
}

Actual behavior

(Error:no-jquery-raw-elements) Replace HTML string manipulation with jQuery API: $(async () => {

})

Expected behavior

No errors. FYI, tslint-microsoft-contrib@6.1.1 is working properly.

kasugaiasuka commented 5 years ago

Oops, that is not a minimum code ("async" is not needed.)

$(() => {

});

// Replace HTML string manipulation with jQuery API: $(() => {
// 
// })
IllusionMH commented 5 years ago

Looks like regression after migration to the new format.

Previously if first arguments wasn't a string - new walker was created and recursively checked strings for < or > characters in string literals, however new one looks for same characters in any expression text.

Good solution will be to check if first argument is a function expression or an arrow function, and only then check recursively as it was in old implementation.

Accepting PRs

JoshuaKGoldberg commented 4 years ago

💀 It's time! 💀

TSLint is deprecated and no longer accepting pull requests other than security fixes. See #876. ☠️ We recommend you instead use typescript-eslint to lint your TypeScript code with ESLint. ✅

👋 It was a pleasure open sourcing with you!