Skip to content

Commit

Permalink
Chore: Enable comma-dangle on ESLint codebase (fixes #7725) (#7906)
Browse files Browse the repository at this point in the history
  • Loading branch information
not-an-aardvark authored and kaicataldo committed Jan 12, 2017
1 parent 075ec25 commit d6150e3
Show file tree
Hide file tree
Showing 63 changed files with 259 additions and 258 deletions.
2 changes: 1 addition & 1 deletion lib/ast-utils.js
Expand Up @@ -1037,7 +1037,7 @@ module.exports = {

return {
start: Object.assign({}, start),
end: Object.assign({}, end),
end: Object.assign({}, end)
};
},

Expand Down
2 changes: 1 addition & 1 deletion lib/config/config-initializer.js
Expand Up @@ -317,7 +317,7 @@ function promptUser(callback) {
default: false,
when(answers) {
return answers.styleguide === "airbnb";
},
}
},
{
type: "input",
Expand Down
2 changes: 1 addition & 1 deletion lib/formatters/codeframe.js
Expand Up @@ -56,7 +56,7 @@ function formatMessage(message, parentResult) {
`${type}:`,
`${msg}`,
ruleId ? `${ruleId}` : "",
sourceCode ? `at ${filePath}:` : `at ${filePath}`,
sourceCode ? `at ${filePath}:` : `at ${filePath}`
].filter(String).join(" ");

const result = [firstLine];
Expand Down
2 changes: 1 addition & 1 deletion lib/internal-rules/internal-consistent-docs-description.js
Expand Up @@ -71,7 +71,7 @@ function checkMetaDocsDescription(context, exportsNode) {
if (description === "") {
context.report({
node: metaDocsDescription.value,
message: "`meta.docs.description` should not be empty.",
message: "`meta.docs.description` should not be empty."
});
return;
}
Expand Down
12 changes: 6 additions & 6 deletions lib/rules/comma-dangle.js
Expand Up @@ -20,7 +20,7 @@ const DEFAULT_OPTIONS = Object.freeze({
objects: "never",
imports: "never",
exports: "never",
functions: "ignore",
functions: "ignore"
});

/**
Expand Down Expand Up @@ -53,7 +53,7 @@ function normalizeOptions(optionValue) {
exports: optionValue,

// For backward compatibility, always ignore functions.
functions: "ignore",
functions: "ignore"
};
}
if (typeof optionValue === "object" && optionValue !== null) {
Expand All @@ -62,7 +62,7 @@ function normalizeOptions(optionValue) {
objects: optionValue.objects || DEFAULT_OPTIONS.objects,
imports: optionValue.imports || DEFAULT_OPTIONS.imports,
exports: optionValue.exports || DEFAULT_OPTIONS.exports,
functions: optionValue.functions || DEFAULT_OPTIONS.functions,
functions: optionValue.functions || DEFAULT_OPTIONS.functions
};
}

Expand Down Expand Up @@ -121,7 +121,7 @@ module.exports = {
additionalProperties: false
}
]
},
}
]
},

Expand Down Expand Up @@ -312,7 +312,7 @@ module.exports = {
"always-multiline": forceTrailingCommaIfMultiline,
"only-multiline": allowTrailingCommaIfMultiline,
never: forbidTrailingComma,
ignore: lodash.noop,
ignore: lodash.noop
};

return {
Expand All @@ -330,7 +330,7 @@ module.exports = {
FunctionExpression: predicate[options.functions],
ArrowFunctionExpression: predicate[options.functions],
CallExpression: predicate[options.functions],
NewExpression: predicate[options.functions],
NewExpression: predicate[options.functions]
};
}
};
2 changes: 1 addition & 1 deletion lib/rules/comma-style.js
Expand Up @@ -48,7 +48,7 @@ module.exports = {
FunctionDeclaration: true,
FunctionExpression: true,
ImportDeclaration: true,
ObjectPattern: true,
ObjectPattern: true
};

if (context.options.length === 2 && context.options[1].hasOwnProperty("exceptions")) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/lines-around-directive.js
Expand Up @@ -31,7 +31,7 @@ module.exports = {
},
after: {
enum: ["always", "never"]
},
}
},
additionalProperties: false,
minProperties: 2
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/max-lines.js
Expand Up @@ -134,7 +134,7 @@ module.exports = {
message: "File must be at most {{max}} lines long. It's {{actual}} lines long.",
data: {
max,
actual: lines.length,
actual: lines.length
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/max-statements-per-line.js
Expand Up @@ -60,7 +60,7 @@ module.exports = {
data: {
numberOfStatementsOnThisLine,
maxStatementsPerLine,
statements: numberOfStatementsOnThisLine === 1 ? "statement" : "statements",
statements: numberOfStatementsOnThisLine === 1 ? "statement" : "statements"
}
});
}
Expand Down
10 changes: 5 additions & 5 deletions lib/rules/no-await-in-loop.js
Expand Up @@ -10,25 +10,25 @@ const loopTypes = new Set([
"ForOfStatement",
"ForInStatement",
"WhileStatement",
"DoWhileStatement",
"DoWhileStatement"
]);

// Node types at which we should stop looking for loops. For example, it is fine to declare an async
// function within a loop, and use await inside of that.
const boundaryTypes = new Set([
"FunctionDeclaration",
"FunctionExpression",
"ArrowFunctionExpression",
"ArrowFunctionExpression"
]);

module.exports = {
meta: {
docs: {
description: "disallow `await` inside of loops",
category: "Possible Errors",
recommended: false,
recommended: false
},
schema: [],
schema: []
},
create(context) {
return {
Expand Down Expand Up @@ -69,7 +69,7 @@ module.exports = {
}
}
}
},
}
};
}
};
2 changes: 1 addition & 1 deletion lib/rules/no-dupe-keys.js
Expand Up @@ -123,7 +123,7 @@ module.exports = {
node: info.node,
loc: node.key.loc,
message: "Duplicate key '{{name}}'.",
data: { name },
data: { name }
});
}

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-return-await.js
Expand Up @@ -35,7 +35,7 @@ module.exports = {
context.report({
node: context.getSourceCode().getFirstToken(node),
loc: node.loc,
message,
message
});
}

Expand Down Expand Up @@ -88,7 +88,7 @@ module.exports = {
if (isInTailCallPosition(node) && !hasErrorHandler(node)) {
reportUnnecessaryAwait(node);
}
},
}
};
}
};
8 changes: 4 additions & 4 deletions lib/rules/no-useless-return.js
Expand Up @@ -213,7 +213,7 @@ module.exports = {
scopeInfo = {
upper: scopeInfo,
uselessReturns: [],
codePath,
codePath
};
},

Expand All @@ -226,7 +226,7 @@ module.exports = {
message: "Unnecessary return statement.",
fix(fixer) {
return isRemovable(node) ? fixer.remove(node) : null;
},
}
});
}

Expand All @@ -238,7 +238,7 @@ module.exports = {
onCodePathSegmentStart(segment) {
const info = {
uselessReturns: getUselessReturns([], segment.allPrevSegments),
returned: false,
returned: false
};

// Stores the info.
Expand Down Expand Up @@ -287,7 +287,7 @@ module.exports = {
WithStatement: markReturnStatementsOnCurrentSegmentsAsUsed,
ExportNamedDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
ExportDefaultDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
ExportAllDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed,
ExportAllDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed
};
}
};
2 changes: 1 addition & 1 deletion lib/rules/quotes.js
Expand Up @@ -269,7 +269,7 @@ module.exports = {
node,
message: "Strings must use {{description}}.",
data: {
description: settings.description,
description: settings.description
},
fix(fixer) {
if (isPartOfDirectivePrologue(node)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/require-await.js
Expand Up @@ -51,7 +51,7 @@ module.exports = {
function enterFunction() {
scopeInfo = {
upper: scopeInfo,
hasAwait: false,
hasAwait: false
};
}

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/sort-keys.js
Expand Up @@ -64,7 +64,7 @@ const isValidOrders = {
},
descIN(a, b) {
return isValidOrders.ascIN(b, a);
},
}
};

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -147,7 +147,7 @@ module.exports = {
prevName,
order,
insensitive: insensitive ? "insensitive " : "",
natual: natual ? "natural " : "",
natual: natual ? "natural " : ""
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/space-before-function-paren.js
Expand Up @@ -159,7 +159,7 @@ module.exports = {
return {
FunctionDeclaration: validateSpacingBeforeParentheses,
FunctionExpression: validateSpacingBeforeParentheses,
ArrowFunctionExpression: validateSpacingBeforeParentheses,
ArrowFunctionExpression: validateSpacingBeforeParentheses
};
}
};
6 changes: 3 additions & 3 deletions lib/testers/rule-tester.js
Expand Up @@ -213,7 +213,7 @@ Object.defineProperties(RuleTester, {
RuleTester[DESCRIBE] = value;
},
configurable: true,
enumerable: true,
enumerable: true
},
it: {
get() {
Expand All @@ -226,8 +226,8 @@ Object.defineProperties(RuleTester, {
RuleTester[IT] = value;
},
configurable: true,
enumerable: true,
},
enumerable: true
}
});

RuleTester.prototype = {
Expand Down
2 changes: 1 addition & 1 deletion lib/util/glob-util.js
Expand Up @@ -165,7 +165,7 @@ function listFilesToProcess(globPatterns, options) {
const globOptions = {
nodir: true,
dot: true,
cwd,
cwd
};

new GlobSync(pattern, globOptions, shouldIgnore).found.forEach(globMatch => {
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config-eslint/default.yml
Expand Up @@ -13,6 +13,7 @@ rules:
camelcase: ["error", { properties: "never" }]
callback-return: ["error", ["cb", "callback", "next"]]
class-methods-use-this: "error"
comma-dangle: "error"
comma-spacing: "error"
comma-style: ["error", "last"]
consistent-return: "error"
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/ast-utils.js
Expand Up @@ -759,7 +759,7 @@ describe("ast-utils", () => {
"class A { static *foo() {} }": "static generator method 'foo'",
"class A { static async foo() {} }": "static async method 'foo'",
"class A { static get foo() {} }": "static getter 'foo'",
"class A { static set foo(a) {} }": "static setter 'foo'",
"class A { static set foo(a) {} }": "static setter 'foo'"
};

Object.keys(expectedResults).forEach(key => {
Expand Down Expand Up @@ -832,7 +832,7 @@ describe("ast-utils", () => {
"class A { static *foo() {} }": [10, 21],
"class A { static async foo() {} }": [10, 26],
"class A { static get foo() {} }": [10, 24],
"class A { static set foo(a) {} }": [10, 24],
"class A { static set foo(a) {} }": [10, 24]
};

Object.keys(expectedResults).forEach(key => {
Expand Down Expand Up @@ -877,7 +877,7 @@ describe("ast-utils", () => {
const expectedResults = {
"{}": true,
"{ a }": false,
a: false,
a: false
};

Object.keys(expectedResults).forEach(key => {
Expand All @@ -895,7 +895,7 @@ describe("ast-utils", () => {
"(function foo() { a })": false,
"(a) => {}": true,
"(a) => { a }": false,
"(a) => a": false,
"(a) => a": false
};

Object.keys(expectedResults).forEach(key => {
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/formatters/codeframe.js
Expand Up @@ -146,7 +146,7 @@ describe("formatter:codeframe", () => {
line: 1,
column: 7,
ruleId: "no-unused-vars"
}],
}]
}];

it("should return a string with multiple entries", () => {
Expand Down

0 comments on commit d6150e3

Please sign in to comment.