Enable more eslint recommended rules (#11168)
* chore: enable no-constant-condition * chore: enable no-empty rule * chore: enable no-unreachable * chore: enable no-cond-assign * chore: enable no-inner-declarations * chore: remove disabled rules that are not in eslint:recommended * fix: oops
This commit is contained in:
parent
2d1bac9666
commit
afb0f489de
@ -19,29 +19,14 @@ module.exports = {
|
|||||||
browser: true,
|
browser: true,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
camelcase: "off",
|
|
||||||
"consistent-return": "off",
|
|
||||||
curly: ["error", "multi-line"],
|
curly: ["error", "multi-line"],
|
||||||
"linebreak-style": ["error", "unix"],
|
"linebreak-style": ["error", "unix"],
|
||||||
"new-cap": "off",
|
|
||||||
"no-case-declarations": "error",
|
"no-case-declarations": "error",
|
||||||
"no-cond-assign": "off",
|
|
||||||
"no-confusing-arrow": "error",
|
"no-confusing-arrow": "error",
|
||||||
"no-console": "off",
|
"no-empty": ["error", { allowEmptyCatch: true }],
|
||||||
"no-constant-condition": "off",
|
|
||||||
"no-empty": "off",
|
|
||||||
"no-inner-declarations": "off",
|
|
||||||
"no-labels": "off",
|
|
||||||
"no-loop-func": "off",
|
|
||||||
"no-process-exit": "error",
|
"no-process-exit": "error",
|
||||||
"no-return-assign": "off",
|
|
||||||
"no-shadow": "off",
|
|
||||||
"no-underscore-dangle": "off",
|
|
||||||
"no-unreachable": "off",
|
|
||||||
"no-use-before-define": "off",
|
|
||||||
"no-var": "error",
|
"no-var": "error",
|
||||||
"prefer-const": "error",
|
"prefer-const": "error",
|
||||||
strict: "off",
|
|
||||||
"flowtype/define-flow-type": "warn",
|
"flowtype/define-flow-type": "warn",
|
||||||
"flowtype/use-flow-type": "warn",
|
"flowtype/use-flow-type": "warn",
|
||||||
},
|
},
|
||||||
|
|||||||
@ -99,7 +99,7 @@ function ExportDeclaration(node: Object) {
|
|||||||
|
|
||||||
// print "special" specifiers first
|
// print "special" specifiers first
|
||||||
let hasSpecial = false;
|
let hasSpecial = false;
|
||||||
while (true) {
|
for (;;) {
|
||||||
const first = specifiers[0];
|
const first = specifiers[0];
|
||||||
if (
|
if (
|
||||||
t.isExportDefaultSpecifier(first) ||
|
t.isExportDefaultSpecifier(first) ||
|
||||||
@ -149,7 +149,7 @@ export function ImportDeclaration(node: Object) {
|
|||||||
const specifiers = node.specifiers.slice(0);
|
const specifiers = node.specifiers.slice(0);
|
||||||
if (specifiers && specifiers.length) {
|
if (specifiers && specifiers.length) {
|
||||||
// print "special" specifiers first
|
// print "special" specifiers first
|
||||||
while (true) {
|
for (;;) {
|
||||||
const first = specifiers[0];
|
const first = specifiers[0];
|
||||||
if (
|
if (
|
||||||
t.isImportDefaultSpecifier(first) ||
|
t.isImportDefaultSpecifier(first) ||
|
||||||
|
|||||||
@ -78,34 +78,7 @@ function findFile(filepath: string, allowJSON: boolean) {
|
|||||||
return matches[0];
|
return matches[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function get(entryLoc): Array<Suite> {
|
function pushTask(taskName, taskDir, suite, suiteName) {
|
||||||
const suites = [];
|
|
||||||
|
|
||||||
let rootOpts = {};
|
|
||||||
const rootOptsLoc = tryResolve(entryLoc + "/options");
|
|
||||||
if (rootOptsLoc) rootOpts = require(rootOptsLoc);
|
|
||||||
|
|
||||||
for (const suiteName of fs.readdirSync(entryLoc)) {
|
|
||||||
if (shouldIgnore(suiteName)) continue;
|
|
||||||
|
|
||||||
const suite = {
|
|
||||||
options: clone(rootOpts),
|
|
||||||
tests: [],
|
|
||||||
title: humanize(suiteName),
|
|
||||||
filename: entryLoc + "/" + suiteName,
|
|
||||||
};
|
|
||||||
|
|
||||||
assertDirectory(suite.filename);
|
|
||||||
suites.push(suite);
|
|
||||||
|
|
||||||
const suiteOptsLoc = tryResolve(suite.filename + "/options");
|
|
||||||
if (suiteOptsLoc) suite.options = require(suiteOptsLoc);
|
|
||||||
|
|
||||||
for (const taskName of fs.readdirSync(suite.filename)) {
|
|
||||||
push(taskName, suite.filename + "/" + taskName);
|
|
||||||
}
|
|
||||||
|
|
||||||
function push(taskName, taskDir) {
|
|
||||||
const taskDirStats = fs.statSync(taskDir);
|
const taskDirStats = fs.statSync(taskDir);
|
||||||
let actualLoc = findFile(taskDir + "/input");
|
let actualLoc = findFile(taskDir + "/input");
|
||||||
let execLoc = findFile(taskDir + "/exec");
|
let execLoc = findFile(taskDir + "/exec");
|
||||||
@ -277,6 +250,33 @@ export default function get(entryLoc): Array<Suite> {
|
|||||||
// Delete to avoid option validation error
|
// Delete to avoid option validation error
|
||||||
delete test.options.validateLogs;
|
delete test.options.validateLogs;
|
||||||
delete test.options.ignoreOutput;
|
delete test.options.ignoreOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function get(entryLoc): Array<Suite> {
|
||||||
|
const suites = [];
|
||||||
|
|
||||||
|
let rootOpts = {};
|
||||||
|
const rootOptsLoc = tryResolve(entryLoc + "/options");
|
||||||
|
if (rootOptsLoc) rootOpts = require(rootOptsLoc);
|
||||||
|
|
||||||
|
for (const suiteName of fs.readdirSync(entryLoc)) {
|
||||||
|
if (shouldIgnore(suiteName)) continue;
|
||||||
|
|
||||||
|
const suite = {
|
||||||
|
options: clone(rootOpts),
|
||||||
|
tests: [],
|
||||||
|
title: humanize(suiteName),
|
||||||
|
filename: entryLoc + "/" + suiteName,
|
||||||
|
};
|
||||||
|
|
||||||
|
assertDirectory(suite.filename);
|
||||||
|
suites.push(suite);
|
||||||
|
|
||||||
|
const suiteOptsLoc = tryResolve(suite.filename + "/options");
|
||||||
|
if (suiteOptsLoc) suite.options = require(suiteOptsLoc);
|
||||||
|
|
||||||
|
for (const taskName of fs.readdirSync(suite.filename)) {
|
||||||
|
pushTask(taskName, suite.filename + "/" + taskName, suite, suiteName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -142,7 +142,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
modified: { [key: TsModifier]: ?true },
|
modified: { [key: TsModifier]: ?true },
|
||||||
allowedModifiers: T[],
|
allowedModifiers: T[],
|
||||||
): void {
|
): void {
|
||||||
while (true) {
|
for (;;) {
|
||||||
const startPos = this.state.start;
|
const startPos = this.state.start;
|
||||||
const modifier: ?T = this.tsParseModifier(allowedModifiers);
|
const modifier: ?T = this.tsParseModifier(allowedModifiers);
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
): ?(T[]) {
|
): ?(T[]) {
|
||||||
const result = [];
|
const result = [];
|
||||||
|
|
||||||
while (true) {
|
for (;;) {
|
||||||
if (this.tsIsListTerminator(kind)) {
|
if (this.tsIsListTerminator(kind)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,10 +20,9 @@ export function shareCommentsWithSiblings() {
|
|||||||
const next = this.getSibling(this.key + 1);
|
const next = this.getSibling(this.key + 1);
|
||||||
const hasPrev = Boolean(prev.node);
|
const hasPrev = Boolean(prev.node);
|
||||||
const hasNext = Boolean(next.node);
|
const hasNext = Boolean(next.node);
|
||||||
if (hasPrev && hasNext) {
|
if (hasPrev && !hasNext) {
|
||||||
} else if (hasPrev) {
|
|
||||||
prev.addComments("trailing", trailing);
|
prev.addComments("trailing", trailing);
|
||||||
} else if (hasNext) {
|
} else if (hasNext && !hasPrev) {
|
||||||
next.addComments("leading", leading);
|
next.addComments("leading", leading);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,6 +62,7 @@ export default class Renamer {
|
|||||||
|
|
||||||
// retain the `name` of a class/function declaration
|
// retain the `name` of a class/function declaration
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unreachable
|
||||||
if (!path.isFunctionDeclaration() && !path.isClassDeclaration()) return;
|
if (!path.isFunctionDeclaration() && !path.isClassDeclaration()) return;
|
||||||
if (this.binding.kind !== "hoisted") return;
|
if (this.binding.kind !== "hoisted") return;
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ export default class Renamer {
|
|||||||
|
|
||||||
// retain the `name` of a class/function expression
|
// retain the `name` of a class/function expression
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unreachable
|
||||||
if (!path.isFunctionExpression() && !path.isClassExpression()) return;
|
if (!path.isFunctionExpression() && !path.isClassExpression()) return;
|
||||||
if (this.binding.kind !== "local") return;
|
if (this.binding.kind !== "local") return;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user