Skip to content

Commit 44b64e4

Browse files
authored
Update ESLint rules to indent case statements (#887)
* Update eslint rules to allow indented switch case statements, and remove subsequently unnecessary exceptions * Conform localChannelStorageService.ts, summaryTreeConverter.ts, and Player.tsx to new switch indentation rule
1 parent 41e6ceb commit 44b64e4

File tree

62 files changed

+120
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+120
-266
lines changed

packages/components/client-ui/src/blob/blobUtils.ts

-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ async function fileToInclusion(file: File): Promise<IGenericBlob> {
5454
arrayBufferReader.readAsArrayBuffer(file);
5555
});
5656

57-
/* eslint-disable @typescript-eslint/indent */
5857
switch (baseInclusion.type) {
5958
case "image": {
6059
const blobP = imageHandler(file, baseInclusion);
@@ -107,7 +106,6 @@ async function fileToInclusion(file: File): Promise<IGenericBlob> {
107106
});
108107
}
109108
}
110-
/* eslint-enable @typescript-eslint/indent */
111109
}
112110

113111
async function imageHandler(imageFile: File, incl: IImageBlob): Promise<IImageBlob> {

packages/components/client-ui/src/controls/canvasCommon.ts

-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export function getShapes(
9191
const polygon = new Polygon([trapezoidP0, trapezoidP3, trapezoidP2, trapezoidP1]);
9292
shapes.push(polygon);
9393

94-
/* eslint-disable @typescript-eslint/indent */
9594
switch (circleInclusive) {
9695
case SegmentCircleInclusive.None:
9796
break;
@@ -108,7 +107,6 @@ export function getShapes(
108107
default:
109108
break;
110109
}
111-
/* eslint-enable @typescript-eslint/indent */
112110

113111
return shapes;
114112
}

packages/components/client-ui/src/controls/flowView.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ function elmOffToSegOff(elmOff: IRangeInfo, span: HTMLSpanElement) {
532532
prevSib = elmOff.elm.previousSibling;
533533
}
534534
while (prevSib) {
535-
/* eslint-disable @typescript-eslint/indent */
536535
switch (prevSib.nodeType) {
537536
case Node.ELEMENT_NODE:
538537
const innerSpan = prevSib as HTMLSpanElement;
@@ -544,7 +543,6 @@ function elmOffToSegOff(elmOff: IRangeInfo, span: HTMLSpanElement) {
544543
default:
545544
break;
546545
}
547-
/* eslint-enable @typescript-eslint/indent */
548546
prevSib = prevSib.previousSibling;
549547
}
550548
return offset;
@@ -2983,7 +2981,7 @@ export interface IListReferenceDoc extends IReferenceDoc {
29832981
}
29842982

29852983
export function makeBlobRef(blob: IGenericBlob, cb: (irdoc: IReferenceDoc) => void) {
2986-
/* eslint-disable @typescript-eslint/indent, default-case */
2984+
/* eslint-disable default-case */
29872985
switch (blob.type) {
29882986
case "image": {
29892987
const image = document.createElement("img");
@@ -3018,7 +3016,7 @@ export function makeBlobRef(blob: IGenericBlob, cb: (irdoc: IReferenceDoc) => vo
30183016
video.load();
30193017
}
30203018
}
3021-
/* eslint-enable @typescript-eslint/indent, default-case */
3019+
/* eslint-enable default-case */
30223020
}
30233021

30243022
export interface IFlowViewModes {
@@ -4890,7 +4888,6 @@ export class FlowView extends ui.Component implements SearchMenu.ISearchMenuHost
48904888
}
48914889

48924890
public keyCmd(charCode: number, shift = false) {
4893-
/* eslint-disable @typescript-eslint/indent */
48944891
switch (charCode) {
48954892
case CharacterCodes.A:
48964893
this.selectAll();
@@ -4949,7 +4946,6 @@ export class FlowView extends ui.Component implements SearchMenu.ISearchMenuHost
49494946
console.log(`got command key ${String.fromCharCode(charCode)} code: ${charCode}`);
49504947
break;
49514948
}
4952-
/* eslint-enable @typescript-eslint/indent */
49534949
}
49544950

49554951
public testWordInfo() {

packages/components/client-ui/src/controls/video.ts

-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export class Video extends ui.Component {
7676

7777
// eslint-disable-next-line @typescript-eslint/no-misused-promises
7878
this.videoMap.on("valueChanged", async (changedValue) => {
79-
/* eslint-disable @typescript-eslint/indent */
8079
switch (changedValue.key) {
8180
case ("play"):
8281
this.videoMap.get(changedValue.key).then((play) => this.playPause(play));
@@ -87,7 +86,6 @@ export class Video extends ui.Component {
8786
default:
8887
break;
8988
}
90-
/* eslint-enable @typescript-eslint/indent */
9189
});
9290
}
9391

packages/components/client-ui/src/text/table.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ export function succinctPrintTable(tableMarker: ITableMarker, tableMarkerPos: nu
743743
endLine = true;
744744
}
745745
}
746-
/* eslint-disable @typescript-eslint/indent, default-case */
746+
/* eslint-disable default-case */
747747
switch (rangeLabel) {
748748
case "table":
749749
lineBuf += "T";
@@ -762,7 +762,7 @@ export function succinctPrintTable(tableMarker: ITableMarker, tableMarkerPos: nu
762762
lineBuf += "CL";
763763
break;
764764
}
765-
/* eslint-enable @typescript-eslint/indent, default-case */
765+
/* eslint-enable default-case */
766766
} else if (marker.refType === MergeTree.ReferenceType.Simple) {
767767
if (marker.properties.columnId) {
768768
lineBuf += "CO";

packages/components/client-ui/src/ui/utils.ts

-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export function hexStrToRGBA(hexStr: string): IColor {
8686
// If it isn"t one of those, then decode the hex string. Otherwise return gray.
8787
// The alpha component is always set to full (255).
8888
export function toColorStruct(color: string): IColor {
89-
/* eslint-disable @typescript-eslint/indent */
9089
switch (color) {
9190
// Ink colors
9291
case "Black": return { r: 0x00, g: 0x00, b: 0x00, a: 0xff };
@@ -103,7 +102,6 @@ export function toColorStruct(color: string): IColor {
103102
default:
104103
return hexStrToRGBA(color);
105104
}
106-
/* eslint-enable @typescript-eslint/indent */
107105
}
108106

109107
// ----------------------------------------------------------------------

packages/components/client-ui/src/utils/youtubeHelper.ts

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export enum PlayerState {
2121
}
2222

2323
export function mapToPlayerState(YTState: number): PlayerState {
24-
/* eslint-disable @typescript-eslint/indent */
2524
switch (YTState) {
2625
case -1:
2726
return PlayerState.unstarted;
@@ -37,7 +36,6 @@ export function mapToPlayerState(YTState: number): PlayerState {
3736
default:
3837
return PlayerState.unknown;
3938
}
40-
/* eslint-enable @typescript-eslint/indent */
4139
}
4240

4341
export function getProposedPlaybackTime(lastChangeUTC: number, playing: boolean, elapsedTime: number): number {

packages/components/markflow/src/clipboard/paste.ts

-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const ignoredTags = [Tag.meta];
3535

3636
function pasteChildren(doc: FlowDocument, root: Node, position: number) {
3737
for (let child: Node | null = root.firstChild; child !== null; child = child.nextSibling) {
38-
/* eslint-disable @typescript-eslint/indent */
3938
switch (child.nodeType) {
4039
case document.TEXT_NODE: {
4140
const text = child as Text;
@@ -66,7 +65,6 @@ function pasteChildren(doc: FlowDocument, root: Node, position: number) {
6665
}
6766
default:
6867
}
69-
/* eslint-enable @typescript-eslint/indent */
7068
}
7169
return position;
7270
}

packages/components/markflow/src/document/index.ts

-6
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export const getDocSegmentKind = (segment: ISegment): DocSegmentKind => {
7171
return DocSegmentKind.text;
7272
} else if (Marker.is(segment)) {
7373
const markerType = segment.refType;
74-
/* eslint-disable @typescript-eslint/indent */
7574
switch (markerType) {
7675
case ReferenceType.Tile:
7776
case ReferenceType.Tile | ReferenceType.NestBegin:
@@ -91,7 +90,6 @@ export const getDocSegmentKind = (segment: ISegment): DocSegmentKind => {
9190
assert.strictEqual(segment.getRangeLabels()[0], DocSegmentKind.beginTags, `Unknown refType '${markerType}'.`);
9291
return DocSegmentKind.endTags;
9392
}
94-
/* eslint-enable @typescript-eslint/indent */
9593
}
9694
};
9795

@@ -224,7 +222,6 @@ export class FlowDocument extends PrimedComponent {
224222
const ops: IMergeTreeRemoveMsg[] = [];
225223

226224
this.visitRange((position: number, segment: ISegment) => {
227-
/* eslint-disable @typescript-eslint/indent */
228225
switch (getDocSegmentKind(segment)) {
229226
case DocSegmentKind.beginTags: {
230227
// Removing a start tag implicitly removes its matching end tag.
@@ -263,7 +260,6 @@ export class FlowDocument extends PrimedComponent {
263260
default:
264261
break;
265262
}
266-
/* eslint-enable @typescript-eslint/indent */
267263
return true;
268264
}, start, end);
269265

@@ -448,7 +444,6 @@ export class FlowDocument extends PrimedComponent {
448444
const s: string[] = [];
449445
this.visitRange((position, segment) => {
450446
const kind = getDocSegmentKind(segment);
451-
/* eslint-disable @typescript-eslint/indent */
452447
switch (kind) {
453448
case DocSegmentKind.text:
454449
s.push((segment as TextSegment).text);
@@ -469,7 +464,6 @@ export class FlowDocument extends PrimedComponent {
469464
default:
470465
s.push(kind);
471466
}
472-
/* eslint-enable @typescript-eslint/indent */
473467
return true;
474468
});
475469
return s.join("");

packages/components/markflow/src/editor/caret.ts

-2
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,13 @@ export class Caret {
5353
let position = this.nodeOffsetToPosition(el, 0);
5454
debug(" inclusion found @%d", position);
5555

56-
/* eslint-disable @typescript-eslint/indent */
5756
switch (detail.direction) {
5857
case Direction.up:
5958
case Direction.left:
6059
break;
6160
default:
6261
position++;
6362
}
64-
/* eslint-enable @typescript-eslint/indent */
6563

6664
// Defer setting the selection to avoid stealing focus and receiving the pending key event.
6765
requestAnimationFrame(() => {

packages/components/markflow/src/editor/editor.ts

-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export class Editor {
8686
return;
8787
}
8888

89-
/* eslint-disable @typescript-eslint/indent */
9089
switch (e.code) {
9190
case KeyCode.F1: {
9291
console.clear();
@@ -129,7 +128,6 @@ export class Editor {
129128
this.consume(e);
130129
}
131130
}
132-
/* eslint-enable @typescript-eslint/indent */
133131
}
134132
};
135133

packages/components/markflow/src/host/searchmenu/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ export class SearchMenuView extends View<ISearchMenuProps, ISearchMenuProps> {
107107
}
108108

109109
private readonly onKeyDown = (e: KeyboardEvent) => {
110-
/* eslint-disable @typescript-eslint/indent */
111110
switch (e.code) {
112111
case KeyCode.enter:
113112
this.complete(e, true);
@@ -117,6 +116,5 @@ export class SearchMenuView extends View<ISearchMenuProps, ISearchMenuProps> {
117116
break;
118117
default:
119118
}
120-
/* eslint-enable @typescript-eslint/indent */
121119
};
122120
}

packages/components/markflow/src/markdown/parser.ts

-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ export class MarkdownParser {
111111
let props: MapLike<string | number>;
112112

113113
const type = node.type;
114-
/* eslint-disable @typescript-eslint/indent */
115114
switch (type) {
116115
case "root":
117116
// Discard the root node.
@@ -157,7 +156,6 @@ export class MarkdownParser {
157156
default:
158157
token = typeToToken[type];
159158
}
160-
/* eslint-enable @typescript-eslint/indent */
161159

162160
if (token === undefined) {
163161
console.warn(token, `Unknown markdown node type: '${type}'`);

packages/components/markflow/src/plaintext/formatter.ts

-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export class PlainTextFormatter<TState extends IFormatterState> extends RootForm
4141

4242
public onKeyDown(layout: Layout, state: Readonly<TState>, caret: Caret, e: KeyboardEvent) {
4343

44-
/* eslint-disable @typescript-eslint/indent */
4544
switch (e.code) {
4645
// Note: Chrome 69 delivers backspace on 'keydown' only (i.e., 'keypress' is not fired.)
4746
case KeyCode.backspace: {
@@ -56,11 +55,9 @@ export class PlainTextFormatter<TState extends IFormatterState> extends RootForm
5655
default:
5756
return false;
5857
}
59-
/* eslint-enable @typescript-eslint/indent */
6058
}
6159

6260
public onKeyPress(layout: Layout, state: Readonly<TState>, caret: Caret, e: KeyboardEvent) {
63-
/* eslint-disable @typescript-eslint/indent */
6461
switch (e.key) {
6562
case KeyCode.enter:
6663
this.insertText(layout, caret, "\n");
@@ -70,7 +67,6 @@ export class PlainTextFormatter<TState extends IFormatterState> extends RootForm
7067
const text = e.key;
7168
this.insertText(layout, caret, text);
7269
}
73-
/* eslint-enable @typescript-eslint/indent */
7470

7571
return true;
7672
}

packages/components/math/src/view.ts

-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export class MathView extends View<IMathInit, IMathProps> {
6969
}
7070

7171
private readonly onKeyDown = (e: KeyboardEvent) => {
72-
/* eslint-disable @typescript-eslint/indent */
7372
switch (e.code) {
7473
case KeyCode.arrowLeft:
7574
if (this.input.selectionEnd === 0) {
@@ -90,7 +89,6 @@ export class MathView extends View<IMathInit, IMathProps> {
9089
default:
9190
this.onInputChanged();
9291
}
93-
/* eslint-enable @typescript-eslint/indent */
9492
};
9593

9694
private verticalCaretEnter(e: ICaretEvent) {
@@ -107,7 +105,6 @@ export class MathView extends View<IMathInit, IMathProps> {
107105
const input = this.input;
108106
input.focus();
109107

110-
/* eslint-disable @typescript-eslint/indent */
111108
switch (e.detail.direction) {
112109
case Direction.left:
113110
input.setSelectionRange(input.value.length, input.value.length, "backward");
@@ -125,6 +122,5 @@ export class MathView extends View<IMathInit, IMathProps> {
125122
break;
126123
default:
127124
}
128-
/* eslint-enable @typescript-eslint/indent */
129125
};
130126
}

packages/components/monaco/src/chaincode.ts

-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ export class MonacoRunner extends PrimedComponent implements
233233
* @param delta The incoming op contents
234234
*/
235235
private mergeDelta(delta: IMergeTreeOp): void {
236-
/* eslint-disable @typescript-eslint/indent */
237236
switch (delta.type) {
238237
case MergeTreeDeltaType.GROUP:
239238
this.mergeDeltaGroup(delta);
@@ -247,7 +246,6 @@ export class MonacoRunner extends PrimedComponent implements
247246
default:
248247
break;
249248
}
250-
/* eslint-enable @typescript-eslint/indent */
251249
}
252250

253251
/**

packages/components/search-menu/src/searchMenu.ts

-2
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ export function inputBoxCreate(
383383
}
384384

385385
function keydown(e: KeyboardEvent) {
386-
/* eslint-disable @typescript-eslint/indent */
387386
switch (e.keyCode) {
388387
case KeyCode.leftArrow:
389388
if (cursor.pos > 0) {
@@ -420,7 +419,6 @@ export function inputBoxCreate(
420419
default:
421420
break;
422421
}
423-
/* eslint-enable @typescript-eslint/indent */
424422
}
425423

426424
function keypress(e: KeyboardEvent) {

packages/components/table-view/src/grid.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export class GridView {
312312
};
313313

314314
private readonly cellKeyDown = (e: KeyboardEvent) => {
315-
/* eslint-disable @typescript-eslint/indent, default-case */
315+
/* eslint-disable default-case */
316316
switch (e.code) {
317317
case KeyCode.escape: { this.cancelInput(); break; }
318318
case KeyCode.arrowUp: { this.moveInputByOffset(e, /* rowOffset: */ -1, /* colOffset */ 0); break; }
@@ -322,7 +322,7 @@ export class GridView {
322322
case KeyCode.tab: { e.preventDefault(); /* fall-through */ }
323323
case KeyCode.arrowRight: { this.moveInputByOffset(e, /* rowOffset: */ 0, /* colOffset */ 1); }
324324
}
325-
/* eslint-enable @typescript-eslint/indent, default-case */
325+
/* eslint-enable default-case */
326326
};
327327

328328
private getCellFromEvent(e: Event) {

packages/components/todo/src/TodoItem/TodoItem.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ export class TodoItem extends PrimedComponent
175175
*/
176176
public async createInnerComponent(type: TodoItemSupportedComponents, props?: any): Promise<void> {
177177
let componentRuntime: IComponentRuntime;
178-
/* eslint-disable @typescript-eslint/indent */
179178
switch (type) {
180179
case "todo":
181180
componentRuntime = await this.context.createSubComponent(TodoItemName, props);
@@ -191,7 +190,6 @@ export class TodoItem extends PrimedComponent
191190
break;
192191
default:
193192
}
194-
/* eslint-enable @typescript-eslint/indent */
195193

196194
await componentRuntime.request({ url: "/" });
197195
componentRuntime.attach();

0 commit comments

Comments
 (0)