Kaynağa Gözat

Fix ‘Unexpected lexical declaration in case block no-case-declarations’ lint errors

See https://eslint.org/docs/rules/no-case-declarations for more details.
Jason Grout 5 yıl önce
ebeveyn
işleme
d6a3ec2a04

+ 4 - 2
packages/application-extension/src/index.tsx

@@ -522,7 +522,7 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void {
     widget: Widget
   ): DockLayout.ITabAreaConfig | null => {
     switch (area.type) {
-      case 'split-area':
+      case 'split-area': {
         const iterator = iter(area.children);
         let tab: DockLayout.ITabAreaConfig | null = null;
         let value: DockLayout.AreaConfig | undefined;
@@ -533,9 +533,11 @@ function addCommands(app: JupyterLab, palette: ICommandPalette | null): void {
           }
         } while (!tab && value);
         return tab;
-      case 'tab-area':
+      }
+      case 'tab-area': {
         const { id } = widget;
         return area.widgets.some(widget => widget.id === id) ? area : null;
+      }
       default:
         return null;
     }

+ 4 - 1
packages/apputils/src/dialog.ts

@@ -295,7 +295,9 @@ export class Dialog<T> extends Widget {
         event.preventDefault();
         this.reject();
         break;
-      case 9: // Tab.
+      case 9: {
+        // Tab.
+
         // Handle a tab on the last button.
         const node = this._buttonNodes[this._buttons.length - 1];
         if (document.activeElement === node && !event.shiftKey) {
@@ -304,6 +306,7 @@ export class Dialog<T> extends Widget {
           this._first.focus();
         }
         break;
+      }
       case 13: // Enter.
         event.stopPropagation();
         event.preventDefault();

+ 10 - 5
packages/codemirror/src/editor.ts

@@ -883,14 +883,15 @@ export class CodeMirrorEditor implements CodeEditor.IEditor {
     this._changeGuard = true;
     const doc = this.doc;
     switch (args.type) {
-      case 'insert':
+      case 'insert': {
         const pos = doc.posFromIndex(args.start);
         // Replace the range, including a '+input' orign,
         // which indicates that CodeMirror may merge changes
         // for undo/redo purposes.
         doc.replaceRange(args.value, pos, pos, '+input');
         break;
-      case 'remove':
+      }
+      case 'remove': {
         const from = doc.posFromIndex(args.start);
         const to = doc.posFromIndex(args.end);
         // Replace the range, including a '+input' orign,
@@ -898,6 +899,7 @@ export class CodeMirrorEditor implements CodeEditor.IEditor {
         // for undo/redo purposes.
         doc.replaceRange('', from, to, '+input');
         break;
+      }
       case 'set':
         doc.setValue(args.value);
         break;
@@ -1449,7 +1451,7 @@ namespace Private {
   ): void {
     const el = editor.getWrapperElement();
     switch (option) {
-      case 'lineWrap':
+      case 'lineWrap': {
         const lineWrapping = value === 'off' ? false : true;
         const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;
         const maxWidth =
@@ -1460,7 +1462,8 @@ namespace Private {
         lines.style.setProperty('width', width);
         editor.setOption('lineWrapping', lineWrapping);
         break;
-      case 'wordWrapColumn':
+      }
+      case 'wordWrapColumn': {
         const { lineWrap } = config;
         if (lineWrap === 'wordWrapColumn' || lineWrap === 'bounded') {
           const lines = el.querySelector('.CodeMirror-lines') as HTMLDivElement;
@@ -1468,6 +1471,7 @@ namespace Private {
           lines.style[prop] = `${value}ch`;
         }
         break;
+      }
       case 'tabSize':
         editor.setOption('indentUnit', value);
         break;
@@ -1477,7 +1481,7 @@ namespace Private {
       case 'autoClosingBrackets':
         editor.setOption('autoCloseBrackets', value);
         break;
-      case 'rulers':
+      case 'rulers': {
         const rulers = value as Array<number>;
         editor.setOption(
           'rulers',
@@ -1489,6 +1493,7 @@ namespace Private {
           })
         );
         break;
+      }
       case 'readOnly':
         el.classList.toggle(READ_ONLY_CLASS, value);
         editor.setOption(option, value);

+ 6 - 2
packages/completer/src/widget.ts

@@ -421,7 +421,8 @@ export class Completer extends Widget {
       return;
     }
     switch (event.keyCode) {
-      case 9: // Tab key
+      case 9: {
+        // Tab key
         event.preventDefault();
         event.stopPropagation();
         event.stopImmediatePropagation();
@@ -442,6 +443,7 @@ export class Completer extends Widget {
           this.update();
         }
         return;
+      }
       case 27: // Esc key
         event.preventDefault();
         event.stopPropagation();
@@ -451,13 +453,15 @@ export class Completer extends Widget {
       case 33: // PageUp
       case 34: // PageDown
       case 38: // Up arrow key
-      case 40: // Down arrow key
+      case 40: {
+        // Down arrow key
         event.preventDefault();
         event.stopPropagation();
         event.stopImmediatePropagation();
         const cycle = Private.keyCodeMap[event.keyCode];
         this._cycle(cycle);
         return;
+      }
       default:
         return;
     }

+ 6 - 3
packages/console/src/foreign.ts

@@ -99,7 +99,7 @@ export class ForeignHandler implements IDisposable {
     const parentMsgId = parentHeader.msg_id as string;
     let cell: CodeCell | undefined;
     switch (msgType) {
-      case 'execute_input':
+      case 'execute_input': {
         const inputMsg = msg as KernelMessage.IExecuteInputMsg;
         cell = this._newCell(parentMsgId);
         const model = cell.model;
@@ -108,10 +108,11 @@ export class ForeignHandler implements IDisposable {
         model.trusted = true;
         parent.update();
         return true;
+      }
       case 'execute_result':
       case 'display_data':
       case 'stream':
-      case 'error':
+      case 'error': {
         cell = this._parent.getCell(parentMsgId);
         if (!cell) {
           return false;
@@ -123,13 +124,15 @@ export class ForeignHandler implements IDisposable {
         cell.model.outputs.add(output);
         parent.update();
         return true;
-      case 'clear_output':
+      }
+      case 'clear_output': {
         const wait = (msg as KernelMessage.IClearOutputMsg).content.wait;
         cell = this._parent.getCell(parentMsgId);
         if (cell) {
           cell.model.outputs.clear(wait);
         }
         return true;
+      }
       default:
         return false;
     }

+ 2 - 1
packages/docmanager/src/widgetmanager.ts

@@ -235,12 +235,13 @@ export class DocumentWidgetManager implements IDisposable {
       case 'close-request':
         void this.onClose(handler as Widget);
         return false;
-      case 'activate-request':
+      case 'activate-request': {
         const context = this.contextForWidget(handler as Widget);
         if (context) {
           this._activateRequested.emit(context.path);
         }
         break;
+      }
       default:
         break;
     }

+ 3 - 1
packages/filebrowser/src/listing.ts

@@ -950,7 +950,8 @@ export class DirListing extends Widget {
    */
   private _evtKeydown(event: KeyboardEvent): void {
     switch (event.keyCode) {
-      case 13: // Enter
+      case 13: {
+        // Enter
         // Do nothing if any modifier keys are pressed.
         if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey) {
           return;
@@ -969,6 +970,7 @@ export class DirListing extends Widget {
         const item = this._sortedItems[i];
         this._handleOpen(item);
         break;
+      }
       case 38: // Up arrow
         this.selectPrevious(event.shiftKey);
         event.stopPropagation();

+ 2 - 1
packages/markdownviewer/src/widget.ts

@@ -106,11 +106,12 @@ export class MarkdownViewer extends Widget {
       case 'lineHeight':
         style.setProperty('line-height', value ? value.toString() : null);
         break;
-      case 'lineWidth':
+      case 'lineWidth': {
         const padding = value ? `calc(50% - ${(value as number) / 2}ch)` : null;
         style.setProperty('padding-left', padding);
         style.setProperty('padding-right', padding);
         break;
+      }
       case 'renderTimeout':
         if (this._monitor) {
           this._monitor.timeout = value as number;

+ 2 - 1
packages/notebook/src/actions.tsx

@@ -941,7 +941,7 @@ export namespace NotebookActions {
       case 'above':
         index = notebook.activeCellIndex - 1;
         break;
-      case 'replace':
+      case 'replace': {
         // Find the cells to delete.
         const toDelete: number[] = [];
 
@@ -962,6 +962,7 @@ export namespace NotebookActions {
         }
         index = toDelete[0];
         break;
+      }
       default:
         break;
     }

+ 4 - 2
packages/notebook/src/widget.ts

@@ -1779,14 +1779,15 @@ export class Notebook extends StaticNotebook {
 
     // If in select mode, update the selection
     switch (this._mouseMode) {
-      case 'select':
+      case 'select': {
         const target = event.target as HTMLElement;
         const index = this._findCell(target);
         if (index !== -1) {
           this.extendContiguousSelectionTo(index);
         }
         break;
-      case 'couldDrag':
+      }
+      case 'couldDrag': {
         // Check for a drag initialization.
         const data = this._dragData!;
         const dx = Math.abs(event.clientX - data.pressX);
@@ -1796,6 +1797,7 @@ export class Notebook extends StaticNotebook {
           this._startDrag(data.index, event.clientX, event.clientY);
         }
         break;
+      }
       default:
         break;
     }

+ 2 - 1
packages/outputarea/src/widget.ts

@@ -503,10 +503,11 @@ export class OutputArea extends Widget {
         output = { ...msg.content, output_type: msgType };
         model.add(output);
         break;
-      case 'clear_output':
+      case 'clear_output': {
         const wait = (msg as KernelMessage.IClearOutputMsg).content.wait;
         model.clear(wait);
         break;
+      }
       case 'update_display_data':
         output = { ...msg.content, output_type: 'display_data' };
         targets = this._displayIdMap.get(displayId);

+ 2 - 1
packages/services/src/kernel/default.ts

@@ -1291,7 +1291,7 @@ export class KernelConnection implements Kernel.IKernelConnection {
     }
     if (msg.channel === 'iopub') {
       switch (msg.header.msg_type) {
-        case 'status':
+        case 'status': {
           // Updating the status is synchronous, and we call no async user code
           const executionState = (msg as KernelMessage.IStatusMsg).content
             .execution_state;
@@ -1312,6 +1312,7 @@ export class KernelConnection implements Kernel.IKernelConnection {
           }
           this._updateStatus(executionState);
           break;
+        }
         case 'comm_open':
           if (this.handleComms) {
             await this._handleCommOpen(msg as KernelMessage.ICommOpenMsg);