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": case "standalone":
includeRegeneratorRuntime = true; includeRegeneratorRuntime = true;
unambiguousSources.push("packages/babel-runtime/regenerator"); unambiguousSources.push("packages/babel-runtime/regenerator");
// fall through
case "rollup": case "rollup":
convertESM = false; convertESM = false;
ignoreLib = false; ignoreLib = false;

View File

@ -30,7 +30,6 @@ module.exports = {
"no-console": "off", "no-console": "off",
"no-constant-condition": "off", "no-constant-condition": "off",
"no-empty": "off", "no-empty": "off",
"no-fallthrough": "off",
"no-inner-declarations": "off", "no-inner-declarations": "off",
"no-labels": "off", "no-labels": "off",
"no-loop-func": "off", "no-loop-func": "off",

View File

@ -21,6 +21,7 @@ export default function* loadCjsOrMjsDefault(
} catch (e) { } catch (e) {
if (e.code !== "ERR_REQUIRE_ESM") throw e; if (e.code !== "ERR_REQUIRE_ESM") throw e;
} }
// fall through
case "mjs": case "mjs":
if (yield* isAsync()) { if (yield* isAsync()) {
return yield* waitFor(loadMjsDefault(filepath)); return yield* waitFor(loadMjsDefault(filepath));

View File

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

View File

@ -1441,7 +1441,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
); );
} }
this.unexpected(); throw this.unexpected();
case tt.num: case tt.num:
return this.parseLiteral( return this.parseLiteral(
this.state.value, this.state.value,

View File

@ -332,7 +332,7 @@ export default class Tokenizer extends LocationParser {
) { ) {
++this.state.pos; ++this.state.pos;
} }
// fall through
case charCodes.lineFeed: case charCodes.lineFeed:
case charCodes.lineSeparator: case charCodes.lineSeparator:
case charCodes.paragraphSeparator: case charCodes.paragraphSeparator:
@ -736,7 +736,7 @@ export default class Tokenizer extends LocationParser {
} }
} }
// Anything else beginning with a digit is an integer, octal // Anything else beginning with a digit is an integer, octal
// number, or float. // number, or float. (fall through)
case charCodes.digit1: case charCodes.digit1:
case charCodes.digit2: case charCodes.digit2:
case charCodes.digit3: case charCodes.digit3:
@ -1221,6 +1221,7 @@ export default class Tokenizer extends LocationParser {
if (this.input.charCodeAt(this.state.pos) === charCodes.lineFeed) { if (this.input.charCodeAt(this.state.pos) === charCodes.lineFeed) {
++this.state.pos; ++this.state.pos;
} }
// fall through
case charCodes.lineFeed: case charCodes.lineFeed:
out += "\n"; out += "\n";
break; break;
@ -1268,9 +1269,11 @@ export default class Tokenizer extends LocationParser {
if (this.input.charCodeAt(this.state.pos) === charCodes.lineFeed) { if (this.input.charCodeAt(this.state.pos) === charCodes.lineFeed) {
++this.state.pos; ++this.state.pos;
} }
// fall through
case charCodes.lineFeed: case charCodes.lineFeed:
this.state.lineStart = this.state.pos; this.state.lineStart = this.state.pos;
++this.state.curLine; ++this.state.curLine;
// fall through
case charCodes.lineSeparator: case charCodes.lineSeparator:
case charCodes.paragraphSeparator: case charCodes.paragraphSeparator:
return ""; return "";
@ -1279,6 +1282,7 @@ export default class Tokenizer extends LocationParser {
if (inTemplate) { if (inTemplate) {
return null; return null;
} }
// fall through
default: default:
if (ch >= charCodes.digit0 && ch <= charCodes.digit7) { if (ch >= charCodes.digit0 && ch <= charCodes.digit7) {
const codePos = this.state.pos - 1; const codePos = this.state.pos - 1;

View File

@ -54,16 +54,18 @@ export default function isReferenced(
if (parent.params.includes(node)) { if (parent.params.includes(node)) {
return false; return false;
} }
// Fall-through to next case clause to check whether the node is the method's name. // fall through
// yes: { [NODE]: "" } // yes: { [NODE]: "" }
// no: { NODE: "" } // no: { NODE: "" }
// depends: { NODE } // depends: { NODE }
// depends: { key: NODE } // depends: { key: NODE }
// fall through
case "ObjectProperty": case "ObjectProperty":
// no: class { NODE = value; } // no: class { NODE = value; }
// yes: class { [NODE] = value; } // yes: class { [NODE] = value; }
// yes: class { key = NODE; } // yes: class { key = NODE; }
// fall through
case "ClassProperty": case "ClassProperty":
case "ClassPrivateProperty": case "ClassPrivateProperty":
if (parent.key === node) { if (parent.key === node) {