";let n=document.getElementById("TableOfContents");n&&(n.innerHTML=e)}rerender(){this.renderFilterMenu(),this.renderPageContent(),this.populateRightNav(),this.runHooks("afterRerender")}renderPageContent(){let e={};Object.keys(this.ifFunctionsByRef).forEach(t=>{let s=this.ifFunctionsByRef[t],o=s.value,n=(0,h.reresolveFunctionNode)(s,{variables:this.selectedValsByTraitId});this.ifFunctionsByRef[t]=n,o!==n.value&&(e[t]=n.value)});let t=document.getElementsByClassName("cdoc__toggleable");for(let n=0;n{this.fitCustomizationMenuToScreen()})}addDropdownEventListeners(){let e=document.getElementsByClassName("cdoc-dropdown");for(let t=0;t{let t=e.target;for(;!t.classList.contains("cdoc-dropdown")&&t.parentElement;)t=t.parentElement;let n=t.classList.toggle("cdoc-dropdown__expanded");t.setAttribute("aria-expanded",n.toString())});document.addEventListener("keydown",e=>{if(e.key==="Enter"){let t=e.target;t.classList.contains("cdoc-filter__option")&&t.click()}}),document.addEventListener("click",t=>{for(let n=0;nthis.handleFilterSelectionChange(e));this.addDropdownEventListeners()}locateFilterSelectorEl(){let e=document.getElementById("cdoc-selector");return!!e&&(this.filterSelectorEl=e,!0)}applyFilterSelectionOverrides(){let s=Object.keys(this.selectedValsByTraitId),e=!1,t=this.browserStorage.getTraitVals();Object.keys(t).forEach(n=>{s.includes(n)&&this.selectedValsByTraitId[n]!==t[n]&&(this.selectedValsByTraitId[n]=t[n],e=!0)});let n=(0,j.getTraitValsFromUrl)({url:new URL(window.location.href),traitIds:s});return Object.keys(n).forEach(t=>{this.selectedValsByTraitId[t]!==n[t]&&(this.selectedValsByTraitId[t]=n[t],e=!0)}),e}updateEditButton(){let t=document.getElementsByClassName("toc-edit-btn")[0];if(!t)return;let e=t.getElementsByTagName("a")[0];e&&(e.href=e.href.replace(/\.md\/$/,".mdoc.md/"))}revealPage(){this.runHooks("beforeReveal"),this.filterSelectorEl&&(this.filterSelectorEl.style.position="sticky",this.filterSelectorEl.style.backgroundColor="white",this.filterSelectorEl.style.paddingTop="10px",this.filterSelectorEl.style.visibility="visible",this.filterSelectorEl.style.zIndex="1000");let e=document.getElementById("cdoc-content");e&&(e.style.visibility="visible"),this.runHooks("afterReveal")}renderFilterMenu(){if(!this.filterSelectorEl||!this.filtersManifest)throw new Error("Cannot render filter selector without filtersManifest and filterSelectorEl");let e=(0,l.resolveFilters)({filtersManifest:this.filtersManifest,valsByTraitId:this.selectedValsByTraitId});Object.keys(e).forEach(t=>{let n=e[t];this.selectedValsByTraitId[t]=n.currentValue});let t=(0,y.buildCustomizationMenuUi)(e);this.filterSelectorEl.innerHTML=t,this.fitCustomizationMenuToScreen(),this.addFilterSelectorEventListeners()}fitCustomizationMenuToScreen(){let e=document.getElementById(g);if(!e)return;let s=e.classList.contains(n),t=document.getElementById(v);if(!t)throw new Error("Dropdown menu not found");let o=document.getElementById(b);if(!o)throw new Error("Menu wrapper not found");let i=e.scrollWidth>o.clientWidth;!s&&i?(e.classList.add(n),t.classList.remove(n)):s&&!i&&(e.classList.remove(n),t.classList.add(n))}get cdocsState(){return{selectedValsByTraitId:this.selectedValsByTraitId,ifFunctionsByRef:this.ifFunctionsByRef,filtersManifest:this.filtersManifest,browserStorage:this.browserStorage,filterSelectorEl:this.filterSelectorEl}}};e.ClientFiltersManager=r,t=r,s={value:void 0}}),y=e(e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=j();window.clientFiltersManager=t.ClientFiltersManager.instance}),y()})()Function names must match the name of the assignation.
Este producto no es compatible con el sitio Datadog seleccionado. ().
Esta página aún no está disponible en español. Estamos trabajando en su traducción. Si tienes alguna pregunta o comentario sobre nuestro actual proyecto de traducción, no dudes en ponerte en contacto con nosotros.
Metadata
ID:javascript-code-style/func-name-matching
Language: JavaScript
Severity: Notice
Category: Code Style
Description
Use the same name between your function declaration and the variable or property to which it is assigned.
Non-Compliant Code Examples
letfoo=functionbar(){};letfoo=functionbar(){};foo=functionbar(){};foo&&=functionbar(){};obj.foo||=functionbar(){};obj['foo']??=functionbar(){};obj.foo=functionbar(){};obj.bar.foo=functionbar(){};obj['foo']=functionbar(){};letobj={foo:functionbar(){}};letobj={'foo':functionbar(){}};({['foo']:functionbar(){}});// NOT SUPPORTED
// module.exports = function foo(name) {};
// module.exports = function foo(name) {};
// module.exports = function exports(name) {};
// module['exports'] = function foo(name) {};
// module['exports'] = function foo(name) {};
// module['exports'] = function exports(name) {};
// Object.defineProperty(foo, 'bar', { value: function baz() {} });
// Object.defineProperties(foo, { bar: { value: function baz() {} } });
// Object.create(proto, { bar: { value: function baz() {} } });
// var obj = { value: function foo(name) {} };
// Object.defineProperty(foo, 'bar', { value: function bar() {} });
// Object.defineProperties(foo, { bar: { value: function bar() {} } });
// Object.create(proto, { bar: { value: function bar() {} } });
// Reflect.defineProperty(foo, 'bar', { value: function baz() {} });
// Reflect.defineProperty(foo, 'bar', { value: function bar() {} });
foo({value:functionbar(){}});(obj?.aaa).foo=functionbar(){};// Object?.defineProperty(foo, 'bar', { value: function baz() {} });
// (Object?.defineProperty)(foo, 'bar', { value: function baz() {} });
// Object?.defineProperty(foo, 'bar', { value: function bar() {} });
// (Object?.defineProperty)(foo, 'bar', { value: function bar() {} });
// Object?.defineProperties(foo, { bar: { value: function baz() {} } });
// (Object?.defineProperties)(foo, { bar: { value: function baz() {} } });
// Object?.defineProperties(foo, { bar: { value: function bar() {} } });
// (Object?.defineProperties)(foo, { bar: { value: function bar() {} } });
classC{x=functiony(){};}classC{'x'=functiony(){};}classC{['x']=functiony(){};}classC{staticx=functiony(){};}(class{x=functiony(){};})varobj={'\u1885':functionfoo(){}};
Compliant Code Examples
varfoo;varfoo=functionfoo(){};varfoo=functionfoo(){};varfoo=function(){}varfoo=()=>{}foo=functionfoo(){};foo=functionfoo(){};foo&&=functionfoo(){};obj.foo||=functionfoo(){};obj['foo']??=functionfoo(){};obj.foo=functionfoo(){};obj.foo=functionfoo(){};obj.foo=function(){};obj.foo=function(){};obj.bar.foo=functionfoo(){};obj.bar.foo=functionfoo(){};obj['foo']=functionfoo(){};obj['foo']=functionfoo(){};// This are not equal not sure why eslint skips them
// obj['foo//bar'] = function foo() {};
// obj['foo//bar'] = function foo() {};
// obj['foo//bar'] = function foo() {};
obj[foo]=functionbar(){};obj[foo]=functionbar(){};varobj={foo:functionfoo(){}};varobj={foo:functionfoo(){}};varobj={'foo':functionfoo(){}};varobj={'foo':functionfoo(){}};varobj={foo:function(){}};varobj={foo:function(){}};varobj={foo:function(){}};varobj={[foo]:functionbar(){}}varobj={['x'+2]:functionbar(){}};obj['x'+2]=functionbar(){};var[bar]=[functionbar(){}];functiona(foo=functionbar(){}){}// NOT SUPPORTED
// module.exports = function foo(name) {};
// module['exports'] = function foo(name) {};
// module.exports = function foo(name) {};
// module.exports = function foo(name) {};
// module.exports = function foo(name) {};
// module['exports'] = function foo(name) {};
// module['exports'] = function foo(name) {};
// module['exports'] = function foo(name) {};
({['foo']:functionfoo(){}})({['foo']:functionfoo(){}})({[foo]:functionbar(){}})({[null]:functionfoo(){}})({[1]:functionfoo(){}})({[true]:functionfoo(){}})({[`x`]:functionfoo(){}})({[/abc/]:functionfoo(){}})({[[1,2,3]]:functionfoo(){}})({[{x:1}]:functionfoo(){}})[]=functionfoo(){}({}=functionfoo(){})[a]=functionfoo(){}({a}=functionfoo(){})var[]=functionfoo(){}var{}=functionfoo(){}var[a]=functionfoo(){}var{a}=functionfoo(){}({value:functionvalue(){}})obj.foo=functionfoo(){};obj.bar.foo=functionfoo(){};varobj={foo:functionfoo(){}};varobj={foo:function(){}};varobj={value:functionvalue(){}}// NOT SUPPORTED
// Object.defineProperty(foo, 'bar', { value: function bar() {} })
// Object.defineProperties(foo, { bar: { value: function bar() {} } })
// Object.create(proto, { bar: { value: function bar() {} } })
// Object.defineProperty(foo, 'b' + 'ar', { value: function bar() {} })
// Object.defineProperties(foo, { ['bar']: { value: function bar() {} } })
// Object.create(proto, { ['bar']: { value: function bar() {} } })
// Object.defineProperty(foo, 'bar', { value() {} })
// Object.defineProperties(foo, { bar: { value() {} } })
// Object.create(proto, { bar: { value() {} } })
// Reflect.defineProperty(foo, 'bar', { value: function bar() {} })
// Reflect.defineProperty(foo, 'b' + 'ar', { value: function baz() {} })
// Reflect.defineProperty(foo, 'bar', { value() {} })
foo({value:functionvalue(){}})classC{x=function(){};}classC{x=function(){};}classC{'x'=function(){};}classC{#x=function(){};}classC{#x=function(){};}classC{[x]=function(){};}classC{[x]=function(){};}classC{['x']=function(){};}classC{x=functionx(){};}classC{'x'=functionx(){};}classC{#x=functionx(){};}classC{#x=functionx(){};}classC{#x=functiony(){};}classC{#x=functiony(){};}classC{[x]=functionx(){};}classC{[x]=functionx(){};}classC{[x]=functiony(){};}classC{[x]=functiony(){};}classC{['x']=functionx(){};}classC{1=functionx0(){};}classC{1=functionx1(){};}classC{[1]=functionx0(){};}classC{[1]=functionx1(){};}classC{[f()]=functiong(){};}classC{[f()]=functionf(){};}classC{staticx=functionx(){};}classC{x=(functiony(){})();}classC{x=(functionx(){})();}(class{x=functionx(){};})classC{#x;foo(){this.#x=functionx(){};}}classC{#x;foo(){this.#x=functionx(){};}}classC{#x;foo(){this.#x=functiony(){};}}classC{#x;foo(){this.#x=functiony(){};}}classC{#x;foo(){a.b.#x=functionx(){};}}classC{#x;foo(){a.b.#x=functionx(){};}}classC{#x;foo(){a.b.#x=functiony(){};}}classC{#x;foo(){a.b.#x=functiony(){};}}
Integraciones sin problemas. Prueba Datadog Code Security
Datadog Code Security
Prueba esta regla y analiza tu código con Datadog Code Security
Cómo usar esta regla
1
2
rulesets:- javascript-code-style # Rules to enforce JavaScript code style.
Crea un static-analysis.datadog.yml con el contenido anterior en la raíz de tu repositorio
Utiliza nuestros complementos del IDE gratuitos o añade análisis de Code Security a tus pipelines de CI.