This product is not supported for your selected Datadog site. ().
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-new-object
Language: JavaScript
Severity: Notice
Category: Best Practices
Description
For consistency, always use the shorter object literal notation {}.
Non-Compliant Code Examples
varfoo=newObject()newObject();consta=newObject()
Compliant Code Examples
// Scoped re declare not supported
varmyObject={};varmyObject=newCustomObject();varfoo=newfoo.Object()// var Object = function Object() {};
// new Object();
varx=something?MyClass:Object;vary=newx();// class Object {
// constructor(){
// }
// }
// new Object();
// import { Object } from './'
// new Object();
constinit=(canvas,context,t)=>drawDoughnutChart(canvas,t('Chats'),context,labels.map((l)=>t(l)),Object.values(initialData),);
Seamless integrations. Try Datadog Code Security
Datadog Code Security
Try this rule and analyze your code with Datadog Code Security
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 Security scans to your CI pipelines