Skip to content
Permalink
Browse files

Chore: enable object-curly-spacing on ESLint codebase (refs #7725) (#…

  • Loading branch information...
not-an-aardvark committed Dec 14, 2016
1 parent 7d1dc7e commit 75b7ba4113db4d9bc1661a4600c8728cf3bfbf2b
Showing 342 changed files with 4,610 additions and 4,609 deletions.
@@ -170,7 +170,7 @@ function generateBlogPost(releaseInfo) {
* instead of getting matched with the `no-undef` rule followed by the string "ined".
*/
.sort((ruleA, ruleB) => ruleB.length - ruleA.length);
const output = ejs.render(cat("./templates/blogpost.md.ejs"), Object.assign({ruleList}, releaseInfo)),
const output = ejs.render(cat("./templates/blogpost.md.ejs"), Object.assign({ ruleList }, releaseInfo)),
now = new Date(),
month = now.getMonth() + 1,
day = now.getDate(),
@@ -229,7 +229,7 @@ function generateRuleIndexPage(basedir) {
recommended: rule.meta.docs.recommended || false,
fixable: !!rule.meta.fixable
},
category = lodash.find(categoriesData.categories, {name: rule.meta.docs.category});
category = lodash.find(categoriesData.categories, { name: rule.meta.docs.category });

if (!category.rules) {
category.rules = [];
@@ -239,7 +239,7 @@ function generateRuleIndexPage(basedir) {
}
});

const output = yaml.safeDump(categoriesData, {sortKeys: true});
const output = yaml.safeDump(categoriesData, { sortKeys: true });

output.to(outputFile);
}
@@ -936,7 +936,7 @@ function downloadMultifilesTestTarget(cb) {
} else {
mkdir("-p", PERF_MULTIFILES_TARGET_DIR);
echo("Downloading the repository of multi-files performance test target.");
exec(`git clone -b v1.10.3 --depth 1 https://github.com/eslint/eslint.git "${PERF_MULTIFILES_TARGET_DIR}"`, {silent: true}, cb);
exec(`git clone -b v1.10.3 --depth 1 https://github.com/eslint/eslint.git "${PERF_MULTIFILES_TARGET_DIR}"`, { silent: true }, cb);
}
}

@@ -1036,7 +1036,7 @@ module.exports = {
*/
const lineNumber = lodash.sortedLastIndex(lineIndices, rangeIndex);

return {line: lineNumber, column: rangeIndex - lineIndices[lineNumber - 1]};
return { line: lineNumber, column: rangeIndex - lineIndices[lineNumber - 1] };

},

@@ -442,7 +442,7 @@ function CLIEngine(options) {
options = Object.assign(
Object.create(null),
defaultOptions,
{cwd: process.cwd()},
{ cwd: process.cwd() },
options
);

@@ -117,10 +117,10 @@ function CodePathSegment(id, allPrevSegments, reachable) {
this.reachable = reachable;

// Internal data.
Object.defineProperty(this, "internal", {value: {
Object.defineProperty(this, "internal", { value: {
used: false,
loopedPrevSegments: []
}});
} });

/* istanbul ignore if */
if (debug.enabled) {
@@ -49,7 +49,7 @@ function CodePath(id, upper, onLooped) {
Object.defineProperty(
this,
"internal",
{value: new CodePathState(new IdGenerator(`${id}_`), onLooped)});
{ value: new CodePathState(new IdGenerator(`${id}_`), onLooped) });

// Adds this into `childCodePaths` of `upper`.
if (upper) {
@@ -231,7 +231,7 @@ Registry.prototype = {
*/
createConfig() {
const ruleIds = Object.keys(this.rules),
config = {rules: {}};
config = { rules: {} };

ruleIds.forEach(ruleId => {
if (this.rules[ruleId].length === 1) {
@@ -290,7 +290,7 @@ Registry.prototype = {
ruleSetIdx = 0;

ruleSets.forEach(ruleSet => {
const lintConfig = Object.assign({}, config, {rules: ruleSet});
const lintConfig = Object.assign({}, config, { rules: ruleSet });
const lintResults = eslint.verify(sourceCodes[filename], lintConfig);

lintResults.forEach(result => {
@@ -235,7 +235,7 @@ function loadConfigFile(file) {
function writeJSONConfigFile(config, filePath) {
debug(`Writing JSON config file: ${filePath}`);

const content = stringify(config, {cmp: sortByKey, space: 4});
const content = stringify(config, { cmp: sortByKey, space: 4 });

fs.writeFileSync(filePath, content, "utf8");
}
@@ -253,7 +253,7 @@ function writeYAMLConfigFile(config, filePath) {
// lazy load YAML to improve performance when not used
const yaml = require("js-yaml");

const content = yaml.safeDump(config, {sortKeys: true});
const content = yaml.safeDump(config, { sortKeys: true });

fs.writeFileSync(filePath, content, "utf8");
}
@@ -268,7 +268,7 @@ function writeYAMLConfigFile(config, filePath) {
function writeJSConfigFile(config, filePath) {
debug(`Writing JS config file: ${filePath}`);

const content = `module.exports = ${stringify(config, {cmp: sortByKey, space: 4})};`;
const content = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};`;

fs.writeFileSync(filePath, content, "utf8");
}
@@ -148,7 +148,7 @@ function configureRules(answers, config) {
registry = registry.lintSourceCode(sourceCodes, newConfig, total => {
bar.tick((BAR_TOTAL - BAR_SOURCE_CODE_TOTAL) / total); // Subtract out ticks used at beginning
});
debug(`\nRegistry: ${util.inspect(registry.rules, {depth: null})}`);
debug(`\nRegistry: ${util.inspect(registry.rules, { depth: null })}`);

// Create a list of recommended rules, because we don't want to disable them
const recRules = Object.keys(recConfig.rules).filter(ruleId => ConfigOps.isErrorSeverity(recConfig.rules[ruleId]));
@@ -209,7 +209,7 @@ function configureRules(answers, config) {
* @returns {Object} config object
*/
function processAnswers(answers) {
let config = {rules: {}, env: {}};
let config = { rules: {}, env: {} };

if (answers.es6) {
config.env.es6 = true;
@@ -260,10 +260,10 @@ function processAnswers(answers) {
*/
function getConfigForStyleGuide(guide) {
const guides = {
google: {extends: "google"},
airbnb: {extends: "airbnb", plugins: ["react", "jsx-a11y", "import"]},
"airbnb-base": {extends: "airbnb-base", plugins: ["import"]},
standard: {extends: "standard", plugins: ["standard", "promise"]}
google: { extends: "google" },
airbnb: { extends: "airbnb", plugins: ["react", "jsx-a11y", "import"] },
"airbnb-base": { extends: "airbnb-base", plugins: ["import"] },
standard: { extends: "standard", plugins: ["standard", "promise"] }
};

if (!guides[guide]) {
@@ -291,16 +291,16 @@ function promptUser(callback) {
message: "How would you like to configure ESLint?",
default: "prompt",
choices: [
{name: "Answer questions about your style", value: "prompt"},
{name: "Use a popular style guide", value: "guide"},
{name: "Inspect your JavaScript file(s)", value: "auto"}
{ name: "Answer questions about your style", value: "prompt" },
{ name: "Use a popular style guide", value: "guide" },
{ name: "Inspect your JavaScript file(s)", value: "auto" }
]
},
{
type: "list",
name: "styleguide",
message: "Which style guide do you want to follow?",
choices: [{name: "Google", value: "google"}, {name: "Airbnb", value: "airbnb"}, {name: "Standard", value: "standard"}],
choices: [{ name: "Google", value: "google" }, { name: "Airbnb", value: "airbnb" }, { name: "Standard", value: "standard" }],
when(answers) {
answers.packageJsonExists = npmUtil.checkPackageJson();
return answers.source === "guide" && answers.packageJsonExists;
@@ -382,7 +382,7 @@ function promptUser(callback) {
name: "env",
message: "Where will your code run?",
default: ["browser"],
choices: [{name: "Browser", value: "browser"}, {name: "Node", value: "node"}]
choices: [{ name: "Browser", value: "browser" }, { name: "Node", value: "node" }]
},
{
type: "confirm",
@@ -432,21 +432,21 @@ function promptUser(callback) {
name: "indent",
message: "What style of indentation do you use?",
default: "tab",
choices: [{name: "Tabs", value: "tab"}, {name: "Spaces", value: 4}]
choices: [{ name: "Tabs", value: "tab" }, { name: "Spaces", value: 4 }]
},
{
type: "list",
name: "quotes",
message: "What quotes do you use for strings?",
default: "double",
choices: [{name: "Double", value: "double"}, {name: "Single", value: "single"}]
choices: [{ name: "Double", value: "double" }, { name: "Single", value: "single" }]
},
{
type: "list",
name: "linebreak",
message: "What line endings do you use?",
default: "unix",
choices: [{name: "Unix", value: "unix"}, {name: "Windows", value: "windows"}]
choices: [{ name: "Unix", value: "unix" }, { name: "Windows", value: "windows" }]
},
{
type: "confirm",
@@ -780,7 +780,7 @@ module.exports = (function() {

if (envInFile) {
if (!config || !config.env) {
config = Object.assign({}, config || {}, {env: envInFile});
config = Object.assign({}, config || {}, { env: envInFile });
} else {
config = Object.assign({}, config);
config.env = Object.assign({}, config.env, envInFile);
@@ -215,7 +215,7 @@ module.exports = {

"Program:exit"() {
if (!isCorrectExportsFormat(exportsNode)) {
context.report({node: exportsNode, message: "Rule does not export an Object. Make sure the rule follows the new rule format."});
context.report({ node: exportsNode, message: "Rule does not export an Object. Make sure the rule follows the new rule format." });
return;
}

@@ -139,9 +139,9 @@ module.exports = {
}

if (checkSetWithoutGet && isSetPresent && !isGetPresent) {
context.report({node, message: "Getter is not present."});
context.report({ node, message: "Getter is not present." });
} else if (checkGetWithoutSet && isGetPresent && !isSetPresent) {
context.report({node, message: "Setter is not present."});
context.report({ node, message: "Setter is not present." });
}
}

@@ -37,7 +37,7 @@ module.exports = {
{
type: "object",
properties: {
requireReturnForObjectLiteral: {type: "boolean"}
requireReturnForObjectLiteral: { type: "boolean" }
},
additionalProperties: false
}
@@ -47,7 +47,7 @@ module.exports = {
function report(reference) {
const identifier = reference.identifier;

context.report({node: identifier, message: "'{{name}}' used outside of binding context.", data: {name: identifier.name}});
context.report({ node: identifier, message: "'{{name}}' used outside of binding context.", data: { name: identifier.name } });
}

/**
@@ -22,7 +22,7 @@ module.exports = {
fixable: "whitespace",

schema: [
{enum: ["always", "never"]}
{ enum: ["always", "never"] }
]
},

@@ -164,7 +164,7 @@ module.exports = {

// as long as you're the child of a function at this point you should be asked to return
if (findClosestParentOfType(node, ["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"])) {
context.report({node, message: "Expected return with your callback function."});
context.report({ node, message: "Expected return with your callback function." });
}

}
@@ -61,7 +61,7 @@ module.exports = {
function report(node) {
if (reported.indexOf(node) < 0) {
reported.push(node);
context.report({node, message: "Identifier '{{name}}' is not in camel case.", data: { name: node.name }});
context.report({ node, message: "Identifier '{{name}}' is not in camel case.", data: { name: node.name } });
}
}

@@ -112,11 +112,11 @@ module.exports = {
{
type: "object",
properties: {
arrays: {$refs: "#/defs/valueWithIgnore"},
objects: {$refs: "#/defs/valueWithIgnore"},
imports: {$refs: "#/defs/valueWithIgnore"},
exports: {$refs: "#/defs/valueWithIgnore"},
functions: {$refs: "#/defs/valueWithIgnore"}
arrays: { $refs: "#/defs/valueWithIgnore" },
objects: { $refs: "#/defs/valueWithIgnore" },
imports: { $refs: "#/defs/valueWithIgnore" },
exports: { $refs: "#/defs/valueWithIgnore" },
functions: { $refs: "#/defs/valueWithIgnore" }
},
additionalProperties: false
}
@@ -91,7 +91,7 @@ module.exports = {
}

if (complexity > THRESHOLD) {
context.report({node, message: "Function '{{name}}' has a complexity of {{complexity}}.", data: { name, complexity }});
context.report({ node, message: "Function '{{name}}' has a complexity of {{complexity}}.", data: { name, complexity } });
}
}

@@ -86,7 +86,7 @@ module.exports = {
if (node.type === "Program") {

// The head of program.
loc = {line: 1, column: 0};
loc = { line: 1, column: 0 };
type = "program";
} else if (node.type === "ArrowFunctionExpression") {

@@ -113,7 +113,7 @@ module.exports = {
node,
loc,
message: "Expected to return a value at the end of this {{type}}.",
data: {type}
data: { type }
});
}

@@ -43,7 +43,7 @@ module.exports = {
* @returns {void}
*/
function reportBadAssignment(node, alias) {
context.report({node, message: "Designated alias '{{alias}}' is not assigned to 'this'.", data: { alias }});
context.report({ node, message: "Designated alias '{{alias}}' is not assigned to 'this'.", data: { alias } });
}

/**
@@ -62,7 +62,7 @@ module.exports = {
reportBadAssignment(node, name);
}
} else if (isThis) {
context.report({node, message: "Unexpected alias '{{name}}' for 'this'.", data: { name }});
context.report({ node, message: "Unexpected alias '{{name}}' for 'this'.", data: { name } });
}
}

@@ -261,7 +261,7 @@ module.exports = {
const isRealLoop = toSegment.prevSegments.length >= 2;

funcInfo.codePath.traverseSegments(
{first: toSegment, last: fromSegment},
{ first: toSegment, last: fromSegment },
segment => {
const info = segInfoMap[segment.id];
const prevSegments = segment.prevSegments;
@@ -81,7 +81,7 @@ module.exports = {
}

if (!comment || !commentPattern.test(comment.value.trim())) {
context.report({node, message: "Expected a default case."});
context.report({ node, message: "Expected a default case." });
}
}
}
@@ -114,7 +114,7 @@ module.exports = {
function getOperatorLocation(node) {
const opToken = sourceCode.getTokenAfter(node.left);

return {line: opToken.loc.start.line, column: opToken.loc.start.column};
return { line: opToken.loc.start.line, column: opToken.loc.start.column };
}

/**
@@ -129,7 +129,7 @@ module.exports = {
node,
loc: getOperatorLocation(node),
message: "Expected '{{expectedOperator}}' and instead saw '{{actualOperator}}'.",
data: {expectedOperator, actualOperator: node.operator},
data: { expectedOperator, actualOperator: node.operator },
fix(fixer) {

// If the comparison is a `typeof` comparison or both sides are literals with the same type, then it's safe to fix.
@@ -86,11 +86,11 @@ module.exports = {

if (never) {
if (name) {
context.report({node, message: "Unexpected function expression name."});
context.report({ node, message: "Unexpected function expression name." });
}
} else {
if (!name && (asNeeded ? !hasInferredName(node) : !isObjectOrClassMethod(node))) {
context.report({node, message: "Missing function expression name."});
context.report({ node, message: "Missing function expression name." });
}
}
}
Oops, something went wrong.

0 comments on commit 75b7ba4

Please sign in to comment.
You can’t perform that action at this time.