forcedotcom / sfdx-scanner

MIT License
215 stars 49 forks source link

[BUG] False positive "Definition for rule '@lwc/lwc/no-async-operation' was not found" #1161

Closed RupertBarrow closed 1 year ago

RupertBarrow commented 1 year ago

Describe the bug In JavaScript/ES5+, specifying a custom LWC ESLint exclusion does not seem to be identified

To Reproduce Code : timer.js

export function timer(ms) {
  // eslint-disable-next-line @lwc/lwc/no-async-operation
  return new Promise(res => setTimeout(res, ms))
}

ESLint configuration : eslintrc.json

{
  "extends": ["@salesforce/eslint-config-lwc/recommended"],
  "rules": {
    "@lwc/lwc/no-unknown-wire-adapters": "off"
  },
  "overrides": [
    {
      "files": ["./*.js", "*.test.js"],
      "env": {
        "node": true
      }
    }
  ]
}

Expected behavior Should not show an error

Screenshots image

Desktop (please complete the following information):

Additional context I get a similar error with :

// eslint-disable-next-line @lwc/lwc/no-document-query
document.querySelector("#main").appendChild(app)

"Workaround": Have you found any ways to sidestep the problem? No

"Urgency": How severe is this problem? "Business stopping" vs "Not business-stopping". Not business-stopping

jfeingold35 commented 1 year ago

@RupertBarrow , please include the command that you're trying to run.

jfeingold35 commented 1 year ago

@RupertBarrow , are you still experiencing this issue?

RupertBarrow commented 1 year ago

Oups, sorry @jfeingold35 , let me have a look ...

RupertBarrow commented 1 year ago

Well @jfeingold35 , I can't get ESLint to work any more in this repo. I'm stuck with :

ESLint: 8.50.0

ESLint couldn't find the config "@salesforce/eslint-config-lwc/recommended" to extend from. Please check that the name of the config is correct.

The config "@salesforce/eslint-config-lwc/recommended" was referenced from the config file in "/Users/.../.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

I'm linting in a package/x directory in a mono repo, and it's looking for .eslintrc.json in the root directory; that's strange.

I've followed instructions here https://developer.salesforce.com/tools/vscode/en/lwc/linting and support here https://salesforce.stackexchange.com/questions/296012/why-is-eslint-not-working-properly-for-lightning-web-components-in-vs-code-and-h without success.

It's probably because I'm now in a monorepo with 4 packages/... directories to be linted separately. I am not active on this project for the moment, so I will leave this subject as it is. You can close the issue if you like.