Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
Metadata
ID:javascript-code-style/no-multi-assign
Language: JavaScript
Severity: Notice
Category: Best Practices
Description
Assigning multiple variables at once can be hard to understand. Make one expression per assignment instead.
vara,b,c,d=0;vara=1;varb=2;varc=3;vard=0;vara=1+(b===10?5:4);consta=1,b=2,c=3;consta=1;constb=2;constc=3;for(vara=0,b=0;;){}for(leta=0,b=0;;){}for(consta=0,b=0;;){}exportleta,b;exportleta,b=0;// ignore non declaration option not supported
// const x = {};const y = {};x.one = y.one = 1;
// let a, b;a = b = 1
classC{[foo=0]=0}
Seamless integrations. Try Datadog Code Analysis
Datadog Code Analysis
Try this rule and analyze your code with Datadog Code Analysis
How to use this rule
1
2
rulesets:- javascript-code-style # Rules to enforce JavaScript code style.
Create a static-analysis.datadog.yml with the content above at the root of your repository
Use our free IDE Plugins or add Code Analysis scans to your CI pipelines