Explorar o código

Removed no plus plus eslint rule and fixed errors from linting

- Relates to #8731
Lovelyfin00 %!s(int64=2) %!d(string=hai) anos
pai
achega
731f96e9a8

+ 0 - 1
.eslintrc.js

@@ -7,7 +7,6 @@ const legacyCode = {
   'max-classes-per-file': 'off',
   'no-continue': 'off',
   'no-else-return': 'off',
-  'no-plusplus': 'off',
   'no-restricted-syntax': 'off',
   'no-this-before-super': 'off',
 };

+ 4 - 2
client/src/components/CommentApp/utils/sequences.ts

@@ -2,9 +2,11 @@ let nextCommentId = 1;
 let nextReplyId = 1;
 
 export function getNextCommentId() {
-  return nextCommentId++;
+  nextCommentId += 1;
+  return nextCommentId;
 }
 
 export function getNextReplyId() {
-  return nextReplyId++;
+  nextReplyId += 1;
+  return nextReplyId;
 }

+ 3 - 2
client/src/components/Sidebar/Sidebar.stories.tsx

@@ -7,6 +7,7 @@ import { PageExplorerMenuItemDefinition } from './menu/PageExplorerMenuItem';
 import { LinkMenuItemDefinition } from './menu/LinkMenuItem';
 import { SubMenuItemDefinition } from './menu/SubMenuItem';
 import { WagtailBrandingModuleDefinition } from './modules/WagtailBranding';
+import { range } from '../../utils/range';
 
 export default {
   title: 'Sidebar/Sidebar',
@@ -323,7 +324,7 @@ export function withLargeSubmenu() {
   const menuModule = bogStandardMenuModule();
 
   const menuItems = [];
-  for (let i = 0; i < 100; i++) {
+  range(0, 100).forEach((i) => {
     menuItems.push(
       new LinkMenuItemDefinition({
         name: `item-${i}`,
@@ -333,7 +334,7 @@ export function withLargeSubmenu() {
         classnames: '',
       }),
     );
-  }
+  });
 
   menuModule.menuItems.push(
     new SubMenuItemDefinition(

+ 1 - 1
client/src/components/Sidebar/SidebarPanel.tsx

@@ -24,7 +24,7 @@ export const SidebarPanel: React.FunctionComponent<SidebarPanelProps> = ({
   const isClosing = isVisible && !isOpen;
   if (isClosing) {
     // When closing, make sure this panel displays behind any new panel that is opening
-    zIndex--;
+    zIndex -= 1;
   }
 
   const style = {

+ 14 - 13
client/src/components/StreamField/blocks/BaseSequenceBlock.js

@@ -9,6 +9,7 @@ import {
   initCollapsiblePanel,
   toggleCollapsiblePanel,
 } from '../../../includes/panels';
+import { range } from '../../../utils/range';
 
 class ActionButton {
   constructor(sequenceChild) {
@@ -474,7 +475,7 @@ export class BaseSequenceBlock {
     const animate = opts && opts.animate;
     const focus = opts && opts.focus;
     const collapsed = opts && opts.collapsed;
-    this.blockCounter++;
+    this.blockCounter += 1;
 
     /*
     a new inserter and block will be inserted AFTER the inserter with the given index;
@@ -490,12 +491,12 @@ export class BaseSequenceBlock {
     $(inserterPlaceholder).insertAfter(blockPlaceholder);
 
     /* shuffle up indexes of all blocks / inserters above this index */
-    for (let i = index; i < this.children.length; i++) {
+    range(index, this.children.length).forEach((i) => {
       this.children[i].setIndex(i + 1);
-    }
-    for (let i = index + 1; i < this.inserters.length; i++) {
+    });
+    range(index + 1, this.inserters.length).forEach((i) => {
       this.inserters[i].setIndex(i + 1);
-    }
+    });
 
     const child = this._createChild(
       childBlockDef,
@@ -557,12 +558,12 @@ export class BaseSequenceBlock {
 
     /* index numbers of children / inserters above this index now need updating to match
     their array indexes */
-    for (let i = index; i < this.children.length; i++) {
+    range(index, this.children.length).forEach((i) => {
       this.children[i].setIndex(i);
-    }
-    for (let i = index; i < this.inserters.length; i++) {
+    });
+    range(index, this.inserters.length).forEach((i) => {
       this.inserters[i].setIndex(i);
-    }
+    });
 
     if (index === 0 && this.children.length > 0) {
       /* we have removed the first child; the new first child cannot be moved up */
@@ -597,15 +598,15 @@ export class BaseSequenceBlock {
 
     /* update index properties of moved items */
     if (newIndex > oldIndex) {
-      for (let i = oldIndex; i <= newIndex; i++) {
+      range(oldIndex, newIndex + 1).forEach((i) => {
         this.inserters[i].setIndex(i);
         this.children[i].setIndex(i);
-      }
+      });
     } else {
-      for (let i = newIndex; i <= oldIndex; i++) {
+      range(newIndex, oldIndex + 1).forEach((i) => {
         this.inserters[i].setIndex(i);
         this.children[i].setIndex(i);
-      }
+      });
     }
 
     /* enable/disable up/down arrows as required */

+ 5 - 4
client/src/components/StreamField/blocks/ListBlock.js

@@ -7,6 +7,7 @@ import {
   BaseInsertionControl,
 } from './BaseSequenceBlock';
 import { escapeHtml as h } from '../../../utils/text';
+import { range } from '../../../utils/range';
 
 /* global $ */
 
@@ -195,14 +196,14 @@ export class ListBlock extends BaseSequenceBlock {
     if (typeof this.blockDef.meta.maxNum === 'number') {
       if (this.children.length >= this.blockDef.meta.maxNum) {
         /* prevent adding new blocks */
-        for (let i = 0; i < this.inserters.length; i++) {
+        range(0, this.inserters.length).forEach((i) => {
           this.inserters[i].disable();
-        }
+        });
       } else {
         /* allow adding new blocks */
-        for (let i = 0; i < this.inserters.length; i++) {
+        range(0, this.inserters.length).forEach((i) => {
           this.inserters[i].enable();
-        }
+        });
       }
     }
   }

+ 3 - 2
client/src/components/StreamField/blocks/StreamBlock.js

@@ -9,6 +9,7 @@ import {
 } from './BaseSequenceBlock';
 import { escapeHtml as h } from '../../../utils/text';
 import { hasOwn } from '../../../utils/hasOwn';
+import { range } from '../../../utils/range';
 
 /* global $ */
 
@@ -332,12 +333,12 @@ export class StreamBlock extends BaseSequenceBlock {
       }
     }
 
-    for (let i = 0; i < this.inserters.length; i++) {
+    range(0, this.inserters.length).forEach((i) => {
       this.inserters[i].setNewBlockRestrictions(
         this.canAddBlock,
         this.disabledBlockTypes,
       );
-    }
+    });
   }
 
   _createChild(

+ 1 - 1
client/src/entrypoints/admin/core.js

@@ -274,7 +274,7 @@ $(() => {
       // for example - " " === "" and "firstword " ==== "firstword"
       if (currentQuery.trim() !== newQuery.trim()) {
         $icon.attr('href', '#icon-spinner');
-        searchNextIndex++;
+        searchNextIndex += 1;
         const index = searchNextIndex;
 
         // Update q, reset to first page, and keep other query params

+ 15 - 14
client/src/entrypoints/contrib/typed_table_block/typed_table_block.js

@@ -1,6 +1,7 @@
 /* global $ */
 
 import { escapeHtml as h } from '../../../utils/text';
+import { range } from '../../../utils/range';
 
 export class TypedTableBlock {
   constructor(blockDef, placeholder, prefix, initialState, initialError) {
@@ -201,12 +202,12 @@ export class TypedTableBlock {
       position: index,
       id: this.columnCountIncludingDeleted,
     };
-    this.columnCountIncludingDeleted++;
+    this.columnCountIncludingDeleted += 1;
     // increase positions of columns after this one
-    for (let i = index; i < this.columns.length; i++) {
-      this.columns[i].position++;
+    range(index, this.columns.length).forEach((i) => {
+      this.columns[i].position += 1;
       this.columns[i].positionInput.value = this.columns[i].position;
-    }
+    });
     this.columns.splice(index, 0, column);
     this.columnCountInput.value = this.columnCountIncludingDeleted;
 
@@ -321,10 +322,10 @@ export class TypedTableBlock {
     this.columns.splice(index, 1);
 
     // reduce position values of remaining columns after this one
-    for (let i = index; i < this.columns.length; i++) {
-      this.columns[i].position--;
+    range(index, this.columns.length).forEach((i) => {
+      this.columns[i].position -= 1;
       this.columns[i].positionInput.value = this.columns[i].position;
-    }
+    });
 
     // if no columns remain, revert to initial empty state with no rows
     if (this.columns.length === 0) {
@@ -346,7 +347,7 @@ export class TypedTableBlock {
       this.tbody.appendChild(rowElement);
     }
     this.rows.splice(index, 0, row);
-    this.rowCountIncludingDeleted++;
+    this.rowCountIncludingDeleted += 1;
     this.rowCountInput.value = this.rowCountIncludingDeleted;
 
     // add a leading cell to contain the 'insert row' button
@@ -407,10 +408,10 @@ export class TypedTableBlock {
     this.deletedFieldsContainer.appendChild(row.deletedInput);
 
     // increment positions of subsequent rows
-    for (let i = index + 1; i < this.rows.length; i++) {
-      this.rows[i].position++;
+    range(index + 1, this.rows.length).forEach((i) => {
+      this.rows[i].position += 1;
       this.rows[i].positionInput.value = this.rows[i].position;
-    }
+    });
 
     return row;
   }
@@ -423,10 +424,10 @@ export class TypedTableBlock {
     this.rows.splice(index, 1);
 
     // reduce position values of remaining rows after this one
-    for (let i = index; i < this.rows.length; i++) {
-      this.rows[i].position--;
+    range(index, this.rows.length).forEach((i) => {
+      this.rows[i].position -= 1;
       this.rows[i].positionInput.value = this.rows[i].position;
-    }
+    });
   }
 
   initCell(cell, column, row, initialState) {