Skip to content

Commit

Permalink
Chore: enable object-curly-newline & object-property-newline.(fixes #…
Browse files Browse the repository at this point in the history
…9042) (#9068)

* Chore: enable object-curly-newline & object-property-newline.

* Fix: linting errors.
  • Loading branch information
aladdin-add authored and gyandeeps committed Aug 5, 2017
1 parent 5ae8458 commit de75f9b
Show file tree
Hide file tree
Showing 28 changed files with 593 additions and 352 deletions.
10 changes: 7 additions & 3 deletions lib/rules/id-blacklist.js
Expand Up @@ -67,9 +67,13 @@ module.exports = {
* @private
*/
function report(node) {
context.report({ node, message: "Identifier '{{name}}' is blacklisted.", data: {
name: node.name
} });
context.report({
node,
message: "Identifier '{{name}}' is blacklisted.",
data: {
name: node.name
}
});
}

return {
Expand Down
12 changes: 8 additions & 4 deletions lib/rules/id-match.js
Expand Up @@ -75,10 +75,14 @@ module.exports = {
* @private
*/
function report(node) {
context.report({ node, message: "Identifier '{{name}}' does not match the pattern '{{pattern}}'.", data: {
name: node.name,
pattern
} });
context.report({
node,
message: "Identifier '{{name}}' does not match the pattern '{{pattern}}'.",
data: {
name: node.name,
pattern
}
});
}

return {
Expand Down
10 changes: 7 additions & 3 deletions lib/rules/no-cond-assign.js
Expand Up @@ -112,9 +112,13 @@ module.exports = {
const ancestor = findConditionalAncestor(node);

if (ancestor) {
context.report({ node: ancestor, message: "Unexpected assignment within {{type}}.", data: {
type: NODE_DESCRIPTIONS[ancestor.type] || ancestor.type
} });
context.report({
node: ancestor,
message: "Unexpected assignment within {{type}}.",
data: {
type: NODE_DESCRIPTIONS[ancestor.type] || ancestor.type
}
});
}
}

Expand Down
12 changes: 8 additions & 4 deletions lib/rules/no-inner-declarations.js
Expand Up @@ -63,10 +63,14 @@ module.exports = {
body.distance === 2);

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")
} });
context.report({
node,
message: "Move {{type}} declaration to {{body}} root.",
data: {
type: (node.type === "FunctionDeclaration" ? "function" : "variable"),
body: (body.type === "Program" ? "program" : "function body")
}
});
}
}

Expand Down
30 changes: 19 additions & 11 deletions lib/rules/no-restricted-properties.js
Expand Up @@ -109,20 +109,28 @@ module.exports = {
if (matchedObjectProperty) {
const message = matchedObjectProperty.message ? ` ${matchedObjectProperty.message}` : "";

// eslint-disable-next-line eslint-plugin/report-message-format
context.report({ node, message: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}", data: {
objectName,
propertyName,
message
} });
context.report({
node,
// eslint-disable-next-line eslint-plugin/report-message-format
message: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}",
data: {
objectName,
propertyName,
message
}
});
} else if (globalMatchedProperty) {
const message = globalMatchedProperty.message ? ` ${globalMatchedProperty.message}` : "";

// eslint-disable-next-line eslint-plugin/report-message-format
context.report({ node, message: "'{{propertyName}}' is restricted from being used.{{message}}", data: {
propertyName,
message
} });
context.report({
node,
// eslint-disable-next-line eslint-plugin/report-message-format
message: "'{{propertyName}}' is restricted from being used.{{message}}",
data: {
propertyName,
message
}
});
}
}

Expand Down
12 changes: 8 additions & 4 deletions lib/rules/no-tabs.js
Expand Up @@ -31,10 +31,14 @@ module.exports = {
const match = regex.exec(line);

if (match) {
context.report({ node, loc: {
line: index + 1,
column: match.index + 1
}, message: "Unexpected tab character." });
context.report({
node,
loc: {
line: index + 1,
column: match.index + 1
},
message: "Unexpected tab character."
});
}
});
}
Expand Down
12 changes: 8 additions & 4 deletions lib/rules/prefer-reflect.js
Expand Up @@ -83,10 +83,14 @@ module.exports = {
* @returns {void}
*/
function report(node, existing, substitute) {
context.report({ node, message: "Avoid using {{existing}}, instead use {{substitute}}.", data: {
existing,
substitute
} });
context.report({
node,
message: "Avoid using {{existing}}, instead use {{substitute}}.",
data: {
existing,
substitute
}
});
}

return {
Expand Down
22 changes: 15 additions & 7 deletions lib/rules/valid-jsdoc.js
Expand Up @@ -362,14 +362,22 @@ module.exports = {
// TODO(nzakas): Figure out logical things to do with destructured, default, rest params
if (param.type === "Identifier") {
if (jsdocParams[i] && (name !== jsdocParams[i])) {
context.report({ node: jsdocNode, message: "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.", data: {
name,
jsdocName: jsdocParams[i]
} });
context.report({
node: jsdocNode,
message: "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.",
data: {
name,
jsdocName: jsdocParams[i]
}
});
} else if (!params[name] && !isOverride) {
context.report({ node: jsdocNode, message: "Missing JSDoc for parameter '{{name}}'.", data: {
name
} });
context.report({
node: jsdocNode,
message: "Missing JSDoc for parameter '{{name}}'.",
data: {
name
}
});
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config-eslint/default.yml
Expand Up @@ -115,7 +115,9 @@ rules:
no-whitespace-before-property: "error"
no-with: "error"
no-var: "error"
object-curly-newline: ["error", { "consistent": true, "multiline": true }]
object-curly-spacing: ["error", "always"]
object-property-newline: ["error", { "allowMultiplePropertiesPerLine": true }]
object-shorthand: "error"
one-var-declaration-per-line: "error"
operator-assignment: "error"
Expand Down
10 changes: 6 additions & 4 deletions tests/lib/cli-engine.js
Expand Up @@ -34,10 +34,12 @@ describe("CLIEngine", () => {
const examplePluginName = "eslint-plugin-example",
examplePluginNameWithNamespace = "@eslint/eslint-plugin-example",
requireStubs = {},
examplePlugin = { rules: {
"example-rule": require("../fixtures/rules/custom-rule"),
"make-syntax-error": require("../fixtures/rules/make-syntax-error-rule")
} },
examplePlugin = {
rules: {
"example-rule": require("../fixtures/rules/custom-rule"),
"make-syntax-error": require("../fixtures/rules/make-syntax-error-rule")
}
},
examplePreprocessorName = "eslint-plugin-processor",
originalDir = process.cwd();
let CLIEngine,
Expand Down

0 comments on commit de75f9b

Please sign in to comment.