Configured rules but failed to take effect on vscode

Hello, welcome to the community! And thank you for your report.

Would it be possible for you to share additional information? E.g a full capture from a file analysis - the parts in the SonarLint Output between Queuing analysis of file '...' and Found x issues.

Also, we have a known limitation of the JS analyzer in the SonarLint context: some rules (like the one you highlighted) rely on type inference that is performed by the TypeScript compiler; when run in SonarQube or SonarCloud, the analyzer performs a “trick” to let the TS compiler analyze JS code, and this trick does not work in SonarLint.

You might want to watch the aforementioned GitHub issue, or the related feature specification.

Thanks Reply。Don’t know if this is what you need

Hello, thanks for the additional details.

As per the FAQ, could you please:

  • set sonarlint.output.showAnalyzerLogs and sonarlint.output.showVerboseLogs to true in your user settings
  • close and re-open your JS file to trigger an analysis
  • go to the SonarLint Output, copy the contents of the output pane and paste it here enclosed within a ``` block

This (the showAnalyzerLogs part) will give us some insights about what prevents the analyzer from doing its job correctly.

thaks,this is all the output

[Trace - 8:08:04 PM] Sending notification 'textDocument/didOpen'.
[Trace - 8:08:04 PM] Sending request 'textDocument/codeAction - (8)'.
[Trace - 8:08:04 PM] Sending notification '$/cancelRequest'.
[Trace - 8:08:04 PM] Sending request 'textDocument/codeAction - (9)'.
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.221] Queuing analysis of file 'file:///Users/prince/Documents/project/ops_admin_fe/src/test.js'
[Trace - 8:08:04 PM] Received request 'sonarlint/isIgnoredByScm - (9)'.
[Trace - 8:08:04 PM] Received response 'textDocument/codeAction - (8)' in 59ms. Request failed: The request (id: 8, method: 'textDocument/codeAction') has been cancelled (-32800).
[Trace - 8:08:04 PM] Received response 'textDocument/codeAction - (9)' in 63ms.
[Trace - 8:08:04 PM] Sending response 'sonarlint/isIgnoredByScm - (9)'. Processing request took 32ms
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.287] Cached SCM ignore status for file 'file:///Users/prince/Documents/project/ops_admin_fe/src/test.js'
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Info - 20:08:04.288] Analyzing file 'file:///Users/prince/Documents/project/ops_admin_fe/src/test.js'...
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.289] Analysis triggered on 'file:///Users/prince/Documents/project/ops_admin_fe/src/test.js' with configuration:
baseDir: /Users/prince/Documents/project/ops_admin_fe
extraProperties: {}
moduleKey: file:///Users/prince/Documents/project/ops_admin_fe
excludedRules: []
includedRules: []
ruleParameters: {}
inputFiles: [
file:///Users/prince/Documents/project/ops_admin_fe/src/test.js (UTF-8) [js]
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.327] Start analysis
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Info - 20:08:04.339] Index files
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.341] Language of file 'file:///Users/prince/Documents/project/ops_admin_fe/src/test.js' is set to 'JavaScript'
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Info - 20:08:04.343] 1 file indexed
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.476] 'JavaSensor' skipped because there is no related file in current project
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.477] 'Python Sensor' skipped because there is no related file in current project
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.478] Execute Sensor: JavaXmlSensor
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.479] Execute Sensor: HTML
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.481] 'PHP sensor' skipped because there is no related file in current project
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.481] 'Analyzer for "php.ini" files' skipped because there is no related file in current project
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.482] Execute Sensor: Sonar Secrets Detection Sensor
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.484] Execute Sensor: JavaScript analysis
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.503] eslint-bridge server is up, no need to start.
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Warn - 20:08:04.503] Generating temporary tsconfig is not supported in SonarLint context.
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Info - 20:08:04.504] 1 source file to be analyzed
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.512] initializing linter with for-loop-increment-sign,no-empty-group,no-accessor-field-mismatch,no-collection-size-mischeck,unverified-certificate,no-empty-collection,no-unthrown-error,updated-const-var,no-duplicate-imports,no-globals-shadowing,unverified-hostname,null-dereference,no-extra-arguments,no-redundant-jump,no-redeclare,constructor-for-side-effects,no-octal,post-message,no-identical-functions,no-element-overwrite,prefer-regex-literals,sonar-no-regex-spaces,weak-ssl,no-empty-alternatives,no-useless-increment,no-throw-literal,no-same-line-conditional,sonar-no-control-regex,conditional-indentation,no-use-of-empty-return-value,session-regeneration,no-associative-arrays,super-invocation,no-try-promise,no-weak-keys,existing-groups,void-use,comma-or-logical-or-case,label-position,no-with,no-unused-collection,single-character-alternation,unused-named-groups,no-global-this,no-sequences,no-array-delete,no-alphabetical-sort,arguments-order,inconsistent-function-call,file-uploads,prefer-for-of,no-inverted-boolean-check,sonar-no-misleading-character-class,xml-parser-xxe,default-param-last,new-operator-misuse,non-existent-operator,duplicates-in-character-class,todo-tag,fixme-tag,no-sparse-arrays,no-invalid-await,anchor-precedence,no-equals-in-for-termination,no-infinite-loop,array-callback-without-return,prefer-default-last,no-commented-code,no-primitive-wrappers,sonar-no-fallthrough,no-empty-pattern,no-gratuitous-expressions,no-dupe-keys,sonar-no-invalid-regexp,file-name-differ-from-class,no-self-assign,no-new-symbol,no-dupe-args,no-small-switch,no-unsafe-finally,prefer-while,sonar-no-unused-vars,index-of-compare-to-positive-number,argument-type,empty-string-repetition,in-operator-type-error,prefer-promise-shorthand,no-unreachable,prefer-immediate-return,regex-complexity,no-identical-expressions,no-empty-after-reluctant,future-reserved-words,no-useless-catch,no-labels,bitwise-operators,no-shadow,no-extra-semi,no-redundant-parentheses,no-unenclosed-multiline-block,no-unused-expressions,no-empty,call-argument-line,max-params,generator-without-yield,no-caller,no-ignored-return,no-duplicated-branches,no-one-iteration-loop,cognitive-complexity,misplaced-loop-counter,use-isnan,deprecation,no-nested-template-literals,max-switch-cases,no-unsafe-negation,function-inside-loop,class-name,no-multi-str,unused-import,prefer-single-boolean-return,no-redundant-boolean,no-nested-assignment,concise-regex,no-delete-var,encryption-secure-mode,updated-loop-counter,no-setter-return,no-weak-cipher,no-identical-conditions,different-types-comparison,function-return-type,no-all-duplicated-branches,no-case-label-in-switch,no-in-misuse,no-misleading-array-reverse,no-redundant-assignments,no-return-await,no-nested-conditional,insecure-jwt-token,no-dead-store,no-invariant-returns,no-implicit-global,no-parameter-reassignment,no-empty-function,stateful-regex
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Info - 20:08:04.577] 1/1 source file has been analyzed
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Debug - 20:08:04.579] Execute Sensor: TypeScript analysis
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Info - 20:08:04.581] No input files found for analysis
[Trace - 8:08:04 PM] Received notification 'window/logMessage'.
[Info - 20:08:04.596] Found 0 issues
[Trace - 8:08:04 PM] Received notification 'textDocument/publishDiagnostics'.

Thanks for the full trace. The line below seems to confirm that you are hitting the limitation I was mentioning above:

[Warn - 20:08:04.503] Generating temporary tsconfig is not supported in SonarLint context.

AFAICT there is little to do: this limitation is known an the ticket is part of the analyzer backlog. I tried to build a workaround by creating a tsconfig.json for the analyzer to pick up, but it seems that it is ignored when analyzing JS files.

first of all, i’m sorry that i wasn’t really follow what your mean up there

I am a front-end programmer who support the author to modulate a code criteria

I just simply try to attest this rules below

and here’s my code

let array = [1, 3, 4, 5] => {
   // none 

and i was expecting an error report on the merge request page, but there’s none

I clicked the 「limitation」you paste in your reply and it says i don’t have permission

Could you be specific to show us what should we do to reach the result that we expected? , thx

Hello, sorry for the above link: it belongs to a JIRA project that until very recently was public but is now private.

Here is the related GitHub issue.

Unfortunately, I have no suggestion other than wait for this issue to be solved, I did not manage to build a workaround for the behavior that you reported.


I confirm the analysis of @JBL_SonarSource , and we have started to work on the mentioned feature to remove this limitation, we should release it in a few weeks if everything goes well