Skip to content

Commit 702dc59

Browse files
committed
no-fallthrough
1 parent 9fcaa19 commit 702dc59

22 files changed

Lines changed: 85 additions & 40 deletions

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"no-empty": "error",
8989
"no-eval": "error",
9090
"no-extra-bind": "error",
91-
"no-fallthrough": "off",
91+
"no-fallthrough": "error",
9292
"no-invalid-this": "off",
9393
"no-multiple-empty-lines": "off",
9494
"no-new-func": "error",

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@
5454
"@types/through2": "latest",
5555
"@types/travis-fold": "latest",
5656
"@types/xml2js": "^0.4.0",
57-
"@typescript-eslint/eslint-plugin": "latest",
58-
"@typescript-eslint/parser": "latest",
57+
"@typescript-eslint/eslint-plugin": "1.10.2",
58+
"@typescript-eslint/parser": "1.10.2",
5959
"azure-devops-node-api": "^8.0.0",
6060
"browser-resolve": "^1.11.2",
6161
"browserify": "latest",
6262
"chai": "latest",
6363
"chalk": "latest",
6464
"convert-source-map": "latest",
6565
"del": "latest",
66-
"eslint": "latest",
66+
"eslint": "5.16.0",
6767
"eslint-formatter-autolinkable-stylish": "latest",
6868
"eslint-plugin-microsoft-typescript": "0.1.11",
6969
"fancy-log": "latest",

src/compiler/binder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ namespace ts {
14901490
if (isObjectLiteralOrClassExpressionMethod(node)) {
14911491
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsObjectLiteralOrClassExpressionMethod;
14921492
}
1493-
// falls through
1493+
// falls through
14941494
case SyntaxKind.Constructor:
14951495
case SyntaxKind.FunctionDeclaration:
14961496
case SyntaxKind.MethodSignature:
@@ -1776,7 +1776,7 @@ namespace ts {
17761776
declareModuleMember(node, symbolFlags, symbolExcludes);
17771777
break;
17781778
}
1779-
// falls through
1779+
// falls through
17801780
default:
17811781
if (!blockScopeContainer.locals) {
17821782
blockScopeContainer.locals = createSymbolTable();
@@ -2114,7 +2114,7 @@ namespace ts {
21142114
bindBlockScopedDeclaration(parentNode as Declaration, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
21152115
break;
21162116
}
2117-
// falls through
2117+
// falls through
21182118
case SyntaxKind.ThisKeyword:
21192119
if (currentFlow && (isExpression(node) || parent.kind === SyntaxKind.ShorthandPropertyAssignment)) {
21202120
node.flowNode = currentFlow;
@@ -2296,7 +2296,7 @@ namespace ts {
22962296
if (!isFunctionLike(node.parent)) {
22972297
return;
22982298
}
2299-
// falls through
2299+
// falls through
23002300
case SyntaxKind.ModuleBlock:
23012301
return updateStrictModeStatementList((<Block | ModuleBlock>node).statements);
23022302

src/compiler/checker.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4796,7 +4796,9 @@ namespace ts {
47964796

47974797
// Type parameters are always visible
47984798
case SyntaxKind.TypeParameter:
4799+
47994800
// Source file and namespace export are always visible
4801+
// falls through
48004802
case SyntaxKind.SourceFile:
48014803
case SyntaxKind.NamespaceExportDeclaration:
48024804
return true;
@@ -24545,7 +24547,7 @@ namespace ts {
2454524547
if ((<CallExpression>node).expression.kind === SyntaxKind.ImportKeyword) {
2454624548
return checkImportCallExpression(<ImportCall>node);
2454724549
}
24548-
/* falls through */
24550+
// falls through
2454924551
case SyntaxKind.NewExpression:
2455024552
return checkCallExpression(<CallExpression>node, checkMode);
2455124553
case SyntaxKind.TaggedTemplateExpression:
@@ -25673,7 +25675,9 @@ namespace ts {
2567325675
switch (d.kind) {
2567425676
case SyntaxKind.InterfaceDeclaration:
2567525677
case SyntaxKind.TypeAliasDeclaration:
25676-
// A jsdoc typedef and callback are, by definition, type aliases
25678+
25679+
// A jsdoc typedef and callback are, by definition, type aliases.
25680+
// falls through
2567725681
case SyntaxKind.JSDocTypedefTag:
2567825682
case SyntaxKind.JSDocCallbackTag:
2567925683
return DeclarationSpaces.ExportType;
@@ -25692,8 +25696,9 @@ namespace ts {
2569225696
return DeclarationSpaces.ExportValue;
2569325697
}
2569425698
d = (d as ExportAssignment).expression;
25695-
/* falls through */
25696-
// The below options all declare an Alias, which is allowed to merge with other values within the importing module
25699+
25700+
// The below options all declare an Alias, which is allowed to merge with other values within the importing module.
25701+
// falls through
2569725702
case SyntaxKind.ImportEqualsDeclaration:
2569825703
case SyntaxKind.NamespaceImport:
2569925704
case SyntaxKind.ImportClause:
@@ -29634,9 +29639,10 @@ namespace ts {
2963429639
if (className) {
2963529640
copySymbol(location.symbol, meaning);
2963629641
}
29637-
// falls through
29642+
2963829643
// this fall-through is necessary because we would like to handle
29639-
// type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration
29644+
// type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration.
29645+
// falls through
2964029646
case SyntaxKind.ClassDeclaration:
2964129647
case SyntaxKind.InterfaceDeclaration:
2964229648
// If we didn't come from static member of class or interface,
@@ -31786,7 +31792,7 @@ namespace ts {
3178631792
switch (prop.kind) {
3178731793
case SyntaxKind.ShorthandPropertyAssignment:
3178831794
checkGrammarForInvalidExclamationToken(prop.exclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
31789-
/* tslint:disable:no-switch-case-fall-through */
31795+
// falls through
3179031796
case SyntaxKind.PropertyAssignment:
3179131797
// Grammar checking for computedPropertyName and shorthandPropertyAssignment
3179231798
checkGrammarForInvalidQuestionMark(prop.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);

src/compiler/core.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,7 @@ namespace ts {
943943
case true:
944944

945945
// relational comparison
946+
// falls through
946947
case Comparison.EqualTo:
947948
continue;
948949

src/compiler/factory.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2773,7 +2773,8 @@ namespace ts {
27732773
break;
27742774
case BundleFileSectionKind.Internal:
27752775
if (stripInternal) break;
2776-
// falls through
2776+
// falls through
2777+
27772778
case BundleFileSectionKind.Text:
27782779
(texts || (texts = [])).push(createUnparsedNode(section, node) as UnparsedTextLike);
27792780
break;

src/compiler/parser.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4646,7 +4646,7 @@ namespace ts {
46464646
case SyntaxKind.TemplateHead: // foo<T> `...${100}...`
46474647
// these are the only tokens can legally follow a type argument
46484648
// list. So we definitely want to treat them as type arg lists.
4649-
4649+
// falls through
46504650
case SyntaxKind.DotToken: // foo<x>.
46514651
case SyntaxKind.CloseParenToken: // foo<x>)
46524652
case SyntaxKind.CloseBracketToken: // foo<x>]
@@ -4674,7 +4674,7 @@ namespace ts {
46744674
// We don't want to treat these as type arguments. Otherwise we'll parse this
46754675
// as an invocation expression. Instead, we want to parse out the expression
46764676
// in isolation from the type arguments.
4677-
4677+
// falls through
46784678
default:
46794679
// Anything else treat as an expression.
46804680
return false;
@@ -5309,6 +5309,7 @@ namespace ts {
53095309
case SyntaxKind.DebuggerKeyword:
53105310
// 'catch' and 'finally' do not actually indicate that the code is part of a statement,
53115311
// however, we say they are here so that we may gracefully parse them and error later.
5312+
// falls through
53125313
case SyntaxKind.CatchKeyword:
53135314
case SyntaxKind.FinallyKeyword:
53145315
return true;
@@ -5394,6 +5395,7 @@ namespace ts {
53945395
return parseThrowStatement();
53955396
case SyntaxKind.TryKeyword:
53965397
// Include 'catch' and 'finally' for error recovery.
5398+
// falls through
53975399
case SyntaxKind.CatchKeyword:
53985400
case SyntaxKind.FinallyKeyword:
53995401
return parseTryStatement();

src/compiler/program.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,8 @@ namespace ts {
17471747
diagnostics.push(createDiagnosticForNode(node, Diagnostics._0_can_only_be_used_in_a_ts_file, "?"));
17481748
return;
17491749
}
1750-
// falls through
1750+
// falls through
1751+
17511752
case SyntaxKind.MethodDeclaration:
17521753
case SyntaxKind.MethodSignature:
17531754
case SyntaxKind.Constructor:
@@ -1829,7 +1830,8 @@ namespace ts {
18291830
diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
18301831
return;
18311832
}
1832-
// falls through
1833+
// falls through
1834+
18331835
case SyntaxKind.VariableStatement:
18341836
// Check modifiers
18351837
if (nodes === (<ClassDeclaration | FunctionLikeDeclaration | VariableStatement>parent).modifiers) {

src/compiler/scanner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ namespace ts {
468468
case CharacterCodes.space:
469469
case CharacterCodes.slash:
470470
// starts of normal trivia
471+
// falls through
471472
case CharacterCodes.lessThan:
472473
case CharacterCodes.bar:
473474
case CharacterCodes.equals:

src/compiler/transformers/ts.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ namespace ts {
369369
case SyntaxKind.ConstKeyword:
370370
case SyntaxKind.DeclareKeyword:
371371
case SyntaxKind.ReadonlyKeyword:
372-
// TypeScript accessibility and readonly modifiers are elided.
373-
372+
// TypeScript accessibility and readonly modifiers are elided
373+
// falls through
374374
case SyntaxKind.ArrayType:
375375
case SyntaxKind.TupleType:
376376
case SyntaxKind.OptionalType:
@@ -400,12 +400,15 @@ namespace ts {
400400
case SyntaxKind.MappedType:
401401
case SyntaxKind.LiteralType:
402402
// TypeScript type nodes are elided.
403+
// falls through
403404

404405
case SyntaxKind.IndexSignature:
405406
// TypeScript index signatures are elided.
407+
// falls through
406408

407409
case SyntaxKind.Decorator:
408410
// TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration.
411+
// falls through
409412

410413
case SyntaxKind.TypeAliasDeclaration:
411414
// TypeScript type-only declarations are elided.

0 commit comments

Comments
 (0)