Turn on no-fallthrough rule (#11093)

* chore: turn on no-fallthrough

* chore: fix no-fallthrough errors
This commit is contained in:
Huáng Jùnliàng 2020-02-08 06:05:19 +09:00 committed by GitHub
parent 5e58903250
commit 0b3dea8f54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 7 deletions

View File

@ -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;

View File

@ -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",

View File

@ -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));

View File

@ -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);
@ -1111,7 +1111,7 @@ export default class ExpressionParser extends LValParser {
return this.finishNode(node, "PipelinePrimaryTopicReference");
}
}
// fall through
default:
throw this.unexpected();
}

View File

@ -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,

View File

@ -332,7 +332,7 @@ export default class Tokenizer extends LocationParser {
) {
++this.state.pos;
}
// fall through
case charCodes.lineFeed:
case charCodes.lineSeparator:
case charCodes.paragraphSeparator:
@ -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:
@ -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;
@ -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 "";
@ -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;

View File

@ -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) {