Skip to content

Commit

Permalink
Chore: Use object-shorthand batch 3 (refs #6407)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo committed Aug 16, 2016
1 parent 644a337 commit 5024d70
Show file tree
Hide file tree
Showing 225 changed files with 780 additions and 779 deletions.
4 changes: 2 additions & 2 deletions lib/rules/accessor-pairs.js
Expand Up @@ -90,7 +90,7 @@ module.exports = {
additionalProperties: false
}]
},
create: function(context) {
create(context) {
const config = context.options[0] || {};
const checkGetWithoutSet = config.getWithoutSet === true;
const checkSetWithoutGet = config.setWithoutGet !== false;
Expand Down Expand Up @@ -146,7 +146,7 @@ module.exports = {
}

return {
ObjectExpression: function(node) {
ObjectExpression(node) {
if (checkSetWithoutGet || checkGetWithoutSet) {
checkLonelySetGet(node);
}
Expand Down
20 changes: 10 additions & 10 deletions lib/rules/array-bracket-spacing.js
Expand Up @@ -39,7 +39,7 @@ module.exports = {
}
]
},
create: function(context) {
create(context) {
const spaced = context.options[0] === "always",
sourceCode = context.getSourceCode();

Expand All @@ -55,7 +55,7 @@ module.exports = {
}

const options = {
spaced: spaced,
spaced,
singleElementException: isOptionSet("singleValue"),
objectsInArraysException: isOptionSet("objectsInArrays"),
arraysInArraysException: isOptionSet("arraysInArrays")
Expand All @@ -73,10 +73,10 @@ module.exports = {
*/
function reportNoBeginningSpace(node, token) {
context.report({
node: node,
node,
loc: token.loc.start,
message: "There should be no space after '" + token.value + "'.",
fix: function(fixer) {
fix(fixer) {
const nextToken = sourceCode.getTokenAfter(token);

return fixer.removeRange([token.range[1], nextToken.range[0]]);
Expand All @@ -92,10 +92,10 @@ module.exports = {
*/
function reportNoEndingSpace(node, token) {
context.report({
node: node,
node,
loc: token.loc.start,
message: "There should be no space before '" + token.value + "'.",
fix: function(fixer) {
fix(fixer) {
const previousToken = sourceCode.getTokenBefore(token);

return fixer.removeRange([previousToken.range[1], token.range[0]]);
Expand All @@ -111,10 +111,10 @@ module.exports = {
*/
function reportRequiredBeginningSpace(node, token) {
context.report({
node: node,
node,
loc: token.loc.start,
message: "A space is required after '" + token.value + "'.",
fix: function(fixer) {
fix(fixer) {
return fixer.insertTextAfter(token, " ");
}
});
Expand All @@ -128,10 +128,10 @@ module.exports = {
*/
function reportRequiredEndingSpace(node, token) {
context.report({
node: node,
node,
loc: token.loc.start,
message: "A space is required before '" + token.value + "'.",
fix: function(fixer) {
fix(fixer) {
return fixer.insertTextBefore(token, " ");
}
});
Expand Down
14 changes: 7 additions & 7 deletions lib/rules/array-callback-return.js
Expand Up @@ -142,7 +142,7 @@ module.exports = {
schema: []
},

create: function(context) {
create(context) {
let funcInfo = {
upper: null,
codePath: null,
Expand All @@ -165,7 +165,7 @@ module.exports = {
funcInfo.codePath.currentSegments.some(isReachable)
) {
context.report({
node: node,
node,
loc: getLocation(node, context.getSourceCode()).loc.start,
message: funcInfo.hasReturn
? "Expected to return a value at the end of this function."
Expand All @@ -177,10 +177,10 @@ module.exports = {
return {

// Stacks this function's information.
onCodePathStart: function(codePath, node) {
onCodePathStart(codePath, node) {
funcInfo = {
upper: funcInfo,
codePath: codePath,
codePath,
hasReturn: false,
shouldCheck:
TARGET_NODE_TYPE.test(node.type) &&
Expand All @@ -190,18 +190,18 @@ module.exports = {
},

// Pops this function's information.
onCodePathEnd: function() {
onCodePathEnd() {
funcInfo = funcInfo.upper;
},

// Checks the return statement is valid.
ReturnStatement: function(node) {
ReturnStatement(node) {
if (funcInfo.shouldCheck) {
funcInfo.hasReturn = true;

if (!node.argument) {
context.report({
node: node,
node,
message: "Expected a return value."
});
}
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/arrow-body-style.js
Expand Up @@ -49,7 +49,7 @@ module.exports = {
}
},

create: function(context) {
create(context) {
const options = context.options;
const always = options[0] === "always";
const asNeeded = !options[0] || options[0] === "as-needed";
Expand All @@ -67,7 +67,7 @@ module.exports = {
if (arrowBody.type === "BlockStatement") {
if (never) {
context.report({
node: node,
node,
loc: arrowBody.loc.start,
message: "Unexpected block statement surrounding arrow body."
});
Expand All @@ -85,7 +85,7 @@ module.exports = {

if (asNeeded && blockBody[0].type === "ReturnStatement") {
context.report({
node: node,
node,
loc: arrowBody.loc.start,
message: "Unexpected block statement surrounding arrow body."
});
Expand All @@ -94,7 +94,7 @@ module.exports = {
} else {
if (always || (asNeeded && requireReturnForObjectLiteral && arrowBody.type === "ObjectExpression")) {
context.report({
node: node,
node,
loc: arrowBody.loc.start,
message: "Expected block statement surrounding arrow body."
});
Expand Down
20 changes: 10 additions & 10 deletions lib/rules/arrow-parens.js
Expand Up @@ -34,7 +34,7 @@ module.exports = {
]
},

create: function(context) {
create(context) {
const message = "Expected parentheses around arrow function argument.";
const asNeededMessage = "Unexpected parentheses around single function argument.";
const asNeeded = context.options[0] === "as-needed";
Expand Down Expand Up @@ -62,9 +62,9 @@ module.exports = {
) {
if (token.type === "Punctuator" && token.value === "(") {
context.report({
node: node,
node,
message: requireForBlockBodyMessage,
fix: function(fixer) {
fix(fixer) {
const paramToken = context.getTokenAfter(token);
const closingParenToken = context.getTokenAfter(paramToken);

Expand All @@ -84,9 +84,9 @@ module.exports = {
) {
if (token.type !== "Punctuator" || token.value !== "(") {
context.report({
node: node,
node,
message: requireForBlockBodyNoParensMessage,
fix: function(fixer) {
fix(fixer) {
return fixer.replaceText(token, "(" + token.value + ")");
}
});
Expand All @@ -98,9 +98,9 @@ module.exports = {
if (asNeeded && node.params.length === 1 && node.params[0].type === "Identifier") {
if (token.type === "Punctuator" && token.value === "(") {
context.report({
node: node,
node,
message: asNeededMessage,
fix: function(fixer) {
fix(fixer) {
const paramToken = context.getTokenAfter(token);
const closingParenToken = context.getTokenAfter(paramToken);

Expand All @@ -120,9 +120,9 @@ module.exports = {
// (x) => x
if (after.value !== ")") {
context.report({
node: node,
message: message,
fix: function(fixer) {
node,
message,
fix(fixer) {
return fixer.replaceText(token, "(" + token.value + ")");
}
});
Expand Down
14 changes: 7 additions & 7 deletions lib/rules/arrow-spacing.js
Expand Up @@ -34,7 +34,7 @@ module.exports = {
]
},

create: function(context) {
create(context) {

// merge rules with default
const rule = { before: true, after: true },
Expand All @@ -60,7 +60,7 @@ module.exports = {
}
const after = sourceCode.getTokenAfter(t);

return { before: before, arrow: t, after: after };
return { before, arrow: t, after };
}

/**
Expand All @@ -72,7 +72,7 @@ module.exports = {
const before = tokens.arrow.range[0] - tokens.before.range[1];
const after = tokens.after.range[0] - tokens.arrow.range[1];

return { before: before, after: after };
return { before, after };
}

/**
Expand All @@ -93,7 +93,7 @@ module.exports = {
context.report({
node: tokens.before,
message: "Missing space before =>.",
fix: function(fixer) {
fix(fixer) {
return fixer.insertTextBefore(tokens.arrow, " ");
}
});
Expand All @@ -105,7 +105,7 @@ module.exports = {
context.report({
node: tokens.before,
message: "Unexpected space before =>.",
fix: function(fixer) {
fix(fixer) {
return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]);
}
});
Expand All @@ -119,7 +119,7 @@ module.exports = {
context.report({
node: tokens.after,
message: "Missing space after =>.",
fix: function(fixer) {
fix(fixer) {
return fixer.insertTextAfter(tokens.arrow, " ");
}
});
Expand All @@ -131,7 +131,7 @@ module.exports = {
context.report({
node: tokens.after,
message: "Unexpected space after =>.",
fix: function(fixer) {
fix(fixer) {
return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]);
}
});
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/block-scoped-var.js
Expand Up @@ -19,7 +19,7 @@ module.exports = {
schema: []
},

create: function(context) {
create(context) {
let stack = [];

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ module.exports = {
}

return {
Program: function(node) {
Program(node) {
stack = [node.range];
},

Expand Down
10 changes: 5 additions & 5 deletions lib/rules/block-spacing.js
Expand Up @@ -26,7 +26,7 @@ module.exports = {
]
},

create: function(context) {
create(context) {
const always = (context.options[0] !== "never"),
message = always ? "Requires a space" : "Unexpected space(s)",
sourceCode = context.getSourceCode();
Expand Down Expand Up @@ -95,10 +95,10 @@ module.exports = {
// Check.
if (!isValid(openBrace, firstToken)) {
context.report({
node: node,
node,
loc: openBrace.loc.start,
message: message + " after '{'.",
fix: function(fixer) {
fix(fixer) {
if (always) {
return fixer.insertTextBefore(firstToken, " ");
}
Expand All @@ -109,10 +109,10 @@ module.exports = {
}
if (!isValid(lastToken, closeBrace)) {
context.report({
node: node,
node,
loc: closeBrace.loc.start,
message: message + " before '}'.",
fix: function(fixer) {
fix(fixer) {
if (always) {
return fixer.insertTextAfter(lastToken, " ");
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/brace-style.js
Expand Up @@ -33,7 +33,7 @@ module.exports = {
]
},

create: function(context) {
create(context) {
const style = context.options[0] || "1tbs",
params = context.options[1] || {},
sourceCode = context.getSourceCode();
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/callback-return.js
Expand Up @@ -22,7 +22,7 @@ module.exports = {
}]
},

create: function(context) {
create(context) {

const callbacks = context.options[0] || ["callback", "cb", "next"],
sourceCode = context.getSourceCode();
Expand Down Expand Up @@ -110,7 +110,7 @@ module.exports = {
//--------------------------------------------------------------------------

return {
CallExpression: function(node) {
CallExpression(node) {

// if we're not a callback we can return
if (!isCallback(node)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/camelcase.js
Expand Up @@ -30,7 +30,7 @@ module.exports = {
]
},

create: function(context) {
create(context) {

//--------------------------------------------------------------------------
// Helpers
Expand Down Expand Up @@ -73,7 +73,7 @@ module.exports = {

return {

Identifier: function(node) {
Identifier(node) {

/*
* Leading and trailing underscores are commonly used to flag
Expand Down

0 comments on commit 5024d70

Please sign in to comment.