Skip to content

Commit

Permalink
Chore: enable operator-linebreak on ESLint codebase (#8064)
Browse files Browse the repository at this point in the history
This enables operator-linebreak on the ESLint codebase, with the default configuration. All of the changes were made with ESLint's autofixer.
  • Loading branch information
not-an-aardvark authored and ilyavolodin committed Feb 12, 2017
1 parent 6445d2a commit 591b74a
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 51 deletions.
4 changes: 2 additions & 2 deletions lib/code-path-analysis/code-path-state.js
Expand Up @@ -467,8 +467,8 @@ class CodePathState {
* Creates the next path from own true/false fork context.
*/
const prevForkContext =
context.kind === "&&" ? context.trueForkContext :
/* kind === "||" */ context.falseForkContext;
context.kind === "&&" ? context.trueForkContext
/* kind === "||" */ : context.falseForkContext;

forkContext.replaceHead(prevForkContext.makeNext(0, -1));
prevForkContext.clear();
Expand Down
4 changes: 2 additions & 2 deletions lib/config/autoconfig.js
Expand Up @@ -300,8 +300,8 @@ class Registry {
// (https://github.com/eslint/eslint/issues/5992)
// (https://github.com/eslint/eslint/issues/7860)
if (
lintedRegistry.rules[result.ruleId]
&& lintedRegistry.rules[result.ruleId][ruleSetIdx]
lintedRegistry.rules[result.ruleId] &&
lintedRegistry.rules[result.ruleId][ruleSetIdx]
) {
lintedRegistry.rules[result.ruleId][ruleSetIdx].errorCount += 1;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/config/config-file.js
Expand Up @@ -380,9 +380,9 @@ function applyExtends(config, filePath, relativeTo) {
* If the `extends` path is relative, use the directory of the current configuration
* file as the reference point. Otherwise, use as-is.
*/
parentPath = (!path.isAbsolute(parentPath) ?
path.join(relativeTo || path.dirname(filePath), parentPath) :
parentPath
parentPath = (!path.isAbsolute(parentPath)
? path.join(relativeTo || path.dirname(filePath), parentPath)
: parentPath
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/eslint.js
Expand Up @@ -864,8 +864,8 @@ module.exports = (function() {
(parseResult && parseResult.services ? parseResult.services : {})
);

const rule = ruleCreator.create ? ruleCreator.create(ruleContext) :
ruleCreator(ruleContext);
const rule = ruleCreator.create ? ruleCreator.create(ruleContext)
: ruleCreator(ruleContext);

// add all the node types as listeners
Object.keys(rule).forEach(nodeType => {
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/capitalized-comments.js
Expand Up @@ -264,9 +264,9 @@ module.exports = {
commentValid = isCommentValid(comment, options);

if (!commentValid) {
const message = capitalize === "always" ?
ALWAYS_MESSAGE :
NEVER_MESSAGE;
const message = capitalize === "always"
? ALWAYS_MESSAGE
: NEVER_MESSAGE;

context.report({
node: null, // Intentionally using loc instead
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/comma-spacing.js
Expand Up @@ -96,9 +96,9 @@ module.exports = {
return fixer.replaceTextRange([start, end], newText);

},
message: options[dir] ?
"A space is required {{dir}} ','." :
"There should be no space {{dir}} ','.",
message: options[dir]
? "A space is required {{dir}} ','."
: "There should be no space {{dir}} ','.",
data: {
dir
}
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/constructor-super.js
Expand Up @@ -209,9 +209,9 @@ module.exports = {

if (!calledInEveryPaths) {
context.report({
message: calledInSomePaths ?
"Lacked a call of 'super()' in some code paths." :
"Expected to call 'super()'.",
message: calledInSomePaths
? "Lacked a call of 'super()' in some code paths."
: "Expected to call 'super()'.",
node: node.parent
});
}
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/default-case.js
Expand Up @@ -31,9 +31,9 @@ module.exports = {

create(context) {
const options = context.options[0] || {};
const commentPattern = options.commentPattern ?
new RegExp(options.commentPattern) :
DEFAULT_COMMENT_PATTERN;
const commentPattern = options.commentPattern
? new RegExp(options.commentPattern)
: DEFAULT_COMMENT_PATTERN;

const sourceCode = context.getSourceCode();

Expand Down
6 changes: 3 additions & 3 deletions lib/rules/eqeqeq.js
Expand Up @@ -63,9 +63,9 @@ module.exports = {
const options = context.options[1] || {};
const sourceCode = context.getSourceCode();

const nullOption = (config === "always") ?
options.null || "always" :
"ignore";
const nullOption = (config === "always")
? options.null || "always"
: "ignore";
const enforceRuleForNull = (nullOption === "always");
const enforceInverseRuleForNull = (nullOption === "never");

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/id-blacklist.js
Expand Up @@ -55,8 +55,8 @@ module.exports = {
* @returns {boolean} whether an error should be reported or not
*/
function shouldReport(effectiveParent, name) {
return effectiveParent.type !== "CallExpression"
&& effectiveParent.type !== "NewExpression" &&
return effectiveParent.type !== "CallExpression" &&
effectiveParent.type !== "NewExpression" &&
isInvalid(name);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/rules/id-length.js
Expand Up @@ -104,9 +104,9 @@ module.exports = {
if (isValidExpression && (isValidExpression === true || isValidExpression(parent, node))) {
context.report({
node,
message: isShort ?
"Identifier name '{{name}}' is too short (< {{min}})." :
"Identifier name '{{name}}' is too long (> {{max}}).",
message: isShort
? "Identifier name '{{name}}' is too short (< {{min}})."
: "Identifier name '{{name}}' is too long (> {{max}}).",
data: { name, min: minLength, max: maxLength }
});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/id-match.js
Expand Up @@ -63,8 +63,8 @@ module.exports = {
* @returns {boolean} whether an error should be reported or not
*/
function shouldReport(effectiveParent, name) {
return effectiveParent.type !== "CallExpression"
&& effectiveParent.type !== "NewExpression" &&
return effectiveParent.type !== "CallExpression" &&
effectiveParent.type !== "NewExpression" &&
isInvalid(name);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/rules/no-cond-assign.js
Expand Up @@ -101,9 +101,9 @@ module.exports = {
function testForAssign(node) {
if (node.test &&
(node.test.type === "AssignmentExpression") &&
(node.type === "ForStatement" ?
!isParenthesised(node.test) :
!isParenthesisedTwice(node.test)
(node.type === "ForStatement"
? !isParenthesised(node.test)
: !isParenthesisedTwice(node.test)
)
) {

Expand Down
6 changes: 3 additions & 3 deletions lib/rules/no-extend-native.js
Expand Up @@ -60,9 +60,9 @@ module.exports = {
return;
}

const affectsProto = lhs.object.computed ?
lhs.object.property.type === "Literal" && lhs.object.property.value === "prototype" :
lhs.object.property.name === "prototype";
const affectsProto = lhs.object.computed
? lhs.object.property.type === "Literal" && lhs.object.property.value === "prototype"
: lhs.object.property.name === "prototype";

if (!affectsProto) {
return;
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/no-extra-parens.js
Expand Up @@ -557,8 +557,7 @@ module.exports = {
!(
(node.object.type === "Literal" &&
typeof node.object.value === "number" &&
astUtils.isDecimalInteger(node.object))
||
astUtils.isDecimalInteger(node.object)) ||

// RegExp literal is allowed to have parens (#1589)
(node.object.type === "Literal" && node.object.regex)
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/no-inner-declarations.js
Expand Up @@ -64,10 +64,10 @@ module.exports = {

if (!valid) {
context.report({ node, message: "Move {{type}} declaration to {{body}} root.", data: {
type: (node.type === "FunctionDeclaration" ?
"function" : "variable"),
body: (body.type === "Program" ?
"program" : "function body")
type: (node.type === "FunctionDeclaration"
? "function" : "variable"),
body: (body.type === "Program"
? "program" : "function body")
} });
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/no-lone-blocks.js
Expand Up @@ -34,9 +34,9 @@ module.exports = {
function report(node) {
const parent = context.getAncestors().pop();

context.report({ node, message: parent.type === "Program" ?
"Block is redundant." :
"Nested block is redundant."
context.report({ node, message: parent.type === "Program"
? "Block is redundant."
: "Nested block is redundant."
});
}

Expand Down
6 changes: 3 additions & 3 deletions lib/rules/object-property-newline.js
Expand Up @@ -34,9 +34,9 @@ module.exports = {

create(context) {
const allowSameLine = context.options[0] && Boolean(context.options[0].allowMultiplePropertiesPerLine);
const errorMessage = allowSameLine ?
"Object properties must go on a new line if they aren't all on the same line." :
"Object properties must go on a new line.";
const errorMessage = allowSameLine
? "Object properties must go on a new line if they aren't all on the same line."
: "Object properties must go on a new line.";

const sourceCode = context.getSourceCode();

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/strict.js
Expand Up @@ -212,8 +212,8 @@ module.exports = {
*/
function enterFunction(node) {
const isBlock = node.body.type === "BlockStatement",
useStrictDirectives = isBlock ?
getUseStrictDirectives(node.body.body) : [];
useStrictDirectives = isBlock
? getUseStrictDirectives(node.body.body) : [];

if (mode === "function") {
enterFunctionInFunctionMode(node, useStrictDirectives);
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config-eslint/default.yml
Expand Up @@ -98,6 +98,7 @@ rules:
object-curly-spacing: ["error", "always"]
object-shorthand: "error"
one-var-declaration-per-line: "error"
operator-linebreak: "error"
prefer-arrow-callback: "error"
prefer-const: "error"
prefer-promise-reject-errors: "error"
Expand Down

0 comments on commit 591b74a

Please sign in to comment.