Skip to content

Commit

Permalink
Turn on no-fallthrough rule (#11093)
Browse files Browse the repository at this point in the history
* chore: turn on no-fallthrough

* chore: fix no-fallthrough errors
  • Loading branch information
JLHwung committed Feb 7, 2020
1 parent 5e58903 commit 0b3dea8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions babel.config.js
Expand Up @@ -36,6 +36,7 @@ module.exports = function(api) {
case "standalone":
includeRegeneratorRuntime = true;
unambiguousSources.push("packages/babel-runtime/regenerator");
// fall through
case "rollup":
convertESM = false;
ignoreLib = false;
Expand Down
1 change: 0 additions & 1 deletion eslint/babel-eslint-config-internal/index.js
Expand Up @@ -30,7 +30,6 @@ module.exports = {
"no-console": "off",
"no-constant-condition": "off",
"no-empty": "off",
"no-fallthrough": "off",
"no-inner-declarations": "off",
"no-labels": "off",
"no-loop-func": "off",
Expand Down
1 change: 1 addition & 0 deletions packages/babel-core/src/config/files/module-types.js
Expand Up @@ -21,6 +21,7 @@ export default function* loadCjsOrMjsDefault(
} catch (e) {
if (e.code !== "ERR_REQUIRE_ESM") throw e;
}
// fall through
case "mjs":
if (yield* isAsync()) {
return yield* waitFor(loadMjsDefault(filepath));
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -1058,7 +1058,7 @@ export default class ExpressionParser extends LValParser {

case tt.at:
this.parseDecorators();

// fall through
case tt._class:
node = this.startNode();
this.takeDecorators(node);
Expand Down Expand Up @@ -1111,7 +1111,7 @@ export default class ExpressionParser extends LValParser {
return this.finishNode(node, "PipelinePrimaryTopicReference");
}
}

// fall through
default:
throw this.unexpected();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-parser/src/plugins/flow.js
Expand Up @@ -1441,7 +1441,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
);
}

this.unexpected();
throw this.unexpected();
case tt.num:
return this.parseLiteral(
this.state.value,
Expand Down
8 changes: 6 additions & 2 deletions packages/babel-parser/src/tokenizer/index.js
Expand Up @@ -332,7 +332,7 @@ export default class Tokenizer extends LocationParser {
) {
++this.state.pos;
}

// fall through
case charCodes.lineFeed:
case charCodes.lineSeparator:
case charCodes.paragraphSeparator:
Expand Down Expand Up @@ -736,7 +736,7 @@ export default class Tokenizer extends LocationParser {
}
}
// Anything else beginning with a digit is an integer, octal
// number, or float.
// number, or float. (fall through)
case charCodes.digit1:
case charCodes.digit2:
case charCodes.digit3:
Expand Down Expand Up @@ -1221,6 +1221,7 @@ export default class Tokenizer extends LocationParser {
if (this.input.charCodeAt(this.state.pos) === charCodes.lineFeed) {
++this.state.pos;
}
// fall through
case charCodes.lineFeed:
out += "\n";
break;
Expand Down Expand Up @@ -1268,9 +1269,11 @@ export default class Tokenizer extends LocationParser {
if (this.input.charCodeAt(this.state.pos) === charCodes.lineFeed) {
++this.state.pos;
}
// fall through
case charCodes.lineFeed:
this.state.lineStart = this.state.pos;
++this.state.curLine;
// fall through
case charCodes.lineSeparator:
case charCodes.paragraphSeparator:
return "";
Expand All @@ -1279,6 +1282,7 @@ export default class Tokenizer extends LocationParser {
if (inTemplate) {
return null;
}
// fall through
default:
if (ch >= charCodes.digit0 && ch <= charCodes.digit7) {
const codePos = this.state.pos - 1;
Expand Down
4 changes: 3 additions & 1 deletion packages/babel-types/src/validators/isReferenced.js
Expand Up @@ -54,16 +54,18 @@ export default function isReferenced(
if (parent.params.includes(node)) {
return false;
}
// Fall-through to next case clause to check whether the node is the method's name.
// fall through

// yes: { [NODE]: "" }
// no: { NODE: "" }
// depends: { NODE }
// depends: { key: NODE }
// fall through
case "ObjectProperty":
// no: class { NODE = value; }
// yes: class { [NODE] = value; }
// yes: class { key = NODE; }
// fall through
case "ClassProperty":
case "ClassPrivateProperty":
if (parent.key === node) {
Expand Down

0 comments on commit 0b3dea8

Please sign in to comment.