Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 55 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"plugin:sonarjs/recommended",
"plugin:cypress/recommended",
"plugin:no-jquery/deprecated",
"plugin:compat/recommended"
"plugin:compat/recommended",
"plugin:unicorn/all"
],
"env": {
"browser": true,
Expand All @@ -34,7 +35,7 @@
"window": true,
"document": true
},
"plugins": ["react", "jsx-a11y", "sonarjs", "cypress", "no-jquery", "compat", "jsdoc"],
"plugins": ["react", "jsx-a11y", "sonarjs", "cypress", "no-jquery", "compat", "jsdoc", "unicorn"],
"settings": {
"import/resolver": {
"webpack": {
Expand Down Expand Up @@ -149,7 +150,58 @@
"no-jquery/no-when": "error",
"react/jsx-no-target-blank": "off",
"comma-dangle": "off",
"arrow-parens": ["error", "as-needed"]
"arrow-parens": ["error", "as-needed"],
"unicorn/filename-case": "off",
"unicorn/prefer-query-selector": "off",
"unicorn/no-null": "off",
"unicorn/prefer-module": "off",
"unicorn/explicit-length-check": "off",
"unicorn/better-regex": "off",
"unicorn/no-keyword-prefix": "off",
"unicorn/no-array-for-each": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/no-this-assignment": "off",
"unicorn/no-document-cookie": "off",
"unicorn/prefer-number-properties": "off",
"unicorn/prefer-spread": "off",
"unicorn/consistent-function-scoping": "off",
"unicorn/prefer-export-from": "off",
"unicorn/no-array-callback-reference": "off",
"unicorn/prefer-ternary": "off",
"unicorn/no-for-loop": "off",
"unicorn/no-array-reduce": "off",
"unicorn/prefer-at": "off",
"unicorn/consistent-destructuring": "off",
"unicorn/prefer-string-slice": "off",
"unicorn/catch-error-name": "off",
"unicorn/no-static-only-class": "off",
"unicorn/prefer-optional-catch-binding": "off",
"unicorn/no-lonely-if": "off",
"unicorn/prefer-set-has": "off",
"unicorn/prefer-switch": "off",
"unicorn/no-useless-switch-case": "off",
"unicorn/prefer-prototype-methods": "off",
// Fix this soon
"unicorn/prefer-dom-node-dataset": "off",
// Look more into this one.
"unicorn/numeric-separators-style": "off",
// Look into this
"unicorn/no-unsafe-regex": "off",
// Consider this one.
"unicorn/prefer-regexp-test": "off",
"unicorn/prefer-logical-operator-over-ternary": "off",
// Maybe fix
"unicorn/prefer-dom-node-text-content": "off",
"unicorn/empty-brace-spaces": "off",
// Probably fix
"unicorn/no-array-push-push": "off",
"unicorn/prefer-array-find": "off",
"unicorn/prefer-add-event-listener": "off",
"unicorn/text-encoding-identifier-case": "off",
"unicorn/prefer-includes": "off",
"unicorn/prefer-modern-dom-apis": "off",
"unicorn/prefer-string-replace-all": "off",
"unicorn/no-useless-promise-resolve-reject": "off"
},
"overrides": [
{
Expand Down
32 changes: 16 additions & 16 deletions js/admin/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
container.innerHTML = '';

const contentWrapper = div( { className: 'frm-applications-index-content' } );
container.appendChild( contentWrapper );
container.append( contentWrapper );

const customTemplatesNav = getCustomTemplatesNav();

contentWrapper.appendChild( customTemplatesNav );
contentWrapper.append( customTemplatesNav );
renderFormidableTemplates( contentWrapper, data.templates );

const hookName = 'frm_application_render_templates';
Expand Down Expand Up @@ -138,13 +138,13 @@
className: 'frm_grid_container frm-application-cards-grid'
} );
addTemplatesToGrid( templates );
contentWrapper.appendChild( getTemplatesNav() );
contentWrapper.appendChild( elements.templatesGrid );
contentWrapper.append( getTemplatesNav() );
contentWrapper.append( elements.templatesGrid );
}

function addTemplatesToGrid( templates ) {
templates.forEach(
application => elements.templatesGrid.appendChild( createApplicationCard( application ) )
application => elements.templatesGrid.append( createApplicationCard( application ) )
);
maybeTriggerSearch();
}
Expand Down Expand Up @@ -187,7 +187,7 @@
categories.forEach( addCategoryToWrapper );
function addCategoryToWrapper( category, index ) {
if ( 0 !== index ) {
wrapper.appendChild( document.createTextNode( '|' ) );
wrapper.append( document.createTextNode( '|' ) );
}
const anchor = a( category );
if ( 0 === index ) {
Expand All @@ -206,7 +206,7 @@
elements.activeCategoryAnchor = anchor;
}
);
wrapper.appendChild( anchor );
wrapper.append( anchor );
}

return wrapper;
Expand Down Expand Up @@ -247,7 +247,7 @@
function handleTemplateSearch( { foundSomething, notEmptySearchText } ) {
if ( false === elements.noTemplateSearchResultsPlaceholder ) {
elements.noTemplateSearchResultsPlaceholder = getNoResultsPlaceholder();
elements.templatesGrid.appendChild( elements.noTemplateSearchResultsPlaceholder );
elements.templatesGrid.append( elements.noTemplateSearchResultsPlaceholder );
}
elements.noTemplateSearchResultsPlaceholder.classList.toggle( 'frm_hidden', ! notEmptySearchText || foundSomething );
}
Expand All @@ -273,8 +273,8 @@
if ( isTemplate ) {
card.classList.add( 'frm-application-template-card' );
card.classList.add( 'frm-locked-application-template' );
card.appendChild( tag( 'hr' ) );
card.appendChild( getCardContent() );
card.append( tag( 'hr' ) );
card.append( getCardContent() );

card.addEventListener(
'click',
Expand Down Expand Up @@ -304,17 +304,17 @@

const templateControl = getUseThisTemplateControl( data );
if ( templateControl.classList.contains( 'frm-delete-application-trigger' ) ) {
header.appendChild( templateControl );
header.append( templateControl );
} else {
titleWrapper.appendChild( templateControl );
titleWrapper.append( templateControl );
}
if ( data.isNew ) {
titleWrapper.appendChild( span( { className: 'frm-new-pill frm-meta-tag frm-fadein', text: __( 'NEW', 'formidable' ) } ) );
titleWrapper.append( span( { className: 'frm-new-pill frm-meta-tag frm-fadein', text: __( 'NEW', 'formidable' ) } ) );
}

const counter = getItemCounter();
if ( false !== counter ) {
header.appendChild( counter );
header.append( counter );
}

return header;
Expand Down Expand Up @@ -363,11 +363,11 @@

function addCount( countValue, pluralDescriptor, singularDescriptor ) {
if ( counter.children.length ) {
counter.appendChild( document.createTextNode( ' | ' ) );
counter.append( document.createTextNode( ' | ' ) );
}

const descriptor = '1' === countValue ? singularDescriptor : pluralDescriptor;
counter.appendChild(
counter.append(
span( countValue + ' ' + descriptor )
);
}
Expand Down
26 changes: 13 additions & 13 deletions js/admin/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
);
const postbox = modal.querySelector( '.postbox' );

postbox.appendChild(
postbox.append(
div( {
className: 'frm_modal_top',
children: [
Expand All @@ -42,12 +42,12 @@
]
} )
);
postbox.appendChild(
postbox.append(
div( { className: 'frm_modal_content' } )
);

if ( footer ) {
postbox.appendChild(
postbox.append(
div( { className: 'frm_modal_footer' } )
);
}
Expand Down Expand Up @@ -596,7 +596,7 @@
child: child,
className: uniqueClassName
} );
appendTo.appendChild( element );
appendTo.append( element );
} else {
redraw( element, child );
}
Expand All @@ -607,8 +607,8 @@
const modal = div( { id, className: 'frm-modal' } );
const postbox = div( { className: 'postbox' } );
const metaboxHolder = div( { className: 'metabox-holder', child: postbox } );
modal.appendChild( metaboxHolder );
document.body.appendChild( modal );
modal.append( metaboxHolder );
document.body.append( modal );
return modal;
}

Expand Down Expand Up @@ -746,13 +746,13 @@
if ( children ) {
children.forEach( child => {
if ( 'string' === typeof child ) {
output.appendChild( document.createTextNode( child ) );
output.append( document.createTextNode( child ) );
} else {
output.appendChild( child );
output.append( child );
}
} );
} else if ( child ) {
output.appendChild( child );
output.append( child );
} else if ( text ) {
output.textContent = text;
}
Expand All @@ -774,7 +774,7 @@
if ( href ) {
const use = document.createElementNS( namespace, 'use' );
use.setAttribute( 'href', href );
output.appendChild( use );
output.append( use );
output.classList.add( 'frmsvg' );
}
return output;
Expand All @@ -796,7 +796,7 @@
child: 'string' === typeof content ? document.createTextNode( content ) : content
} )
} );
container.appendChild( notice );
container.append( notice );

setTimeout(
() => jQuery( notice ).fadeOut( () => notice.remove() ),
Expand All @@ -812,7 +812,7 @@

function redraw( element, child ) {
element.innerHTML = '';
element.appendChild( child );
element.append( child );
}

const allowedHtml = {
Expand Down Expand Up @@ -863,7 +863,7 @@
}
);

node.childNodes.forEach( child => newNode.appendChild( cleanNode( child ) ) );
node.childNodes.forEach( child => newNode.append( cleanNode( child ) ) );
return newNode;
}

Expand Down
Loading