Skip to content

Commit f1bf5ec

Browse files
not-an-aardvarkgyandeeps
authored andcommitted
Chore: convert remaining old-style context.report() calls to the new API (#7763)
1 parent b4f88a9 commit f1bf5ec

File tree

101 files changed

+159
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+159
-203
lines changed

lib/internal-rules/internal-no-invalid-meta.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ module.exports = {
215215

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

lib/rules/accessor-pairs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ module.exports = {
139139
}
140140

141141
if (checkSetWithoutGet && isSetPresent && !isGetPresent) {
142-
context.report(node, "Getter is not present.");
142+
context.report({node, message: "Getter is not present."});
143143
} else if (checkGetWithoutSet && isGetPresent && !isSetPresent) {
144-
context.report(node, "Setter is not present.");
144+
context.report({node, message: "Setter is not present."});
145145
}
146146
}
147147

lib/rules/block-scoped-var.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ module.exports = {
4747
function report(reference) {
4848
const identifier = reference.identifier;
4949

50-
context.report(
51-
identifier,
52-
"'{{name}}' used outside of binding context.",
53-
{name: identifier.name});
50+
context.report({node: identifier, message: "'{{name}}' used outside of binding context.", data: {name: identifier.name}});
5451
}
5552

5653
/**

lib/rules/callback-return.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ module.exports = {
164164

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

170170
}

lib/rules/camelcase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module.exports = {
6161
function report(node) {
6262
if (reported.indexOf(node) < 0) {
6363
reported.push(node);
64-
context.report(node, "Identifier '{{name}}' is not in camel case.", { name: node.name });
64+
context.report({node, message: "Identifier '{{name}}' is not in camel case.", data: { name: node.name }});
6565
}
6666
}
6767

lib/rules/complexity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ module.exports = {
9191
}
9292

9393
if (complexity > THRESHOLD) {
94-
context.report(node, "Function '{{name}}' has a complexity of {{complexity}}.", { name, complexity });
94+
context.report({node, message: "Function '{{name}}' has a complexity of {{complexity}}.", data: { name, complexity }});
9595
}
9696
}
9797

lib/rules/consistent-this.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ module.exports = {
4343
* @returns {void}
4444
*/
4545
function reportBadAssignment(node, alias) {
46-
context.report(node,
47-
"Designated alias '{{alias}}' is not assigned to 'this'.",
48-
{ alias });
46+
context.report({node, message: "Designated alias '{{alias}}' is not assigned to 'this'.", data: { alias }});
4947
}
5048

5149
/**
@@ -64,8 +62,7 @@ module.exports = {
6462
reportBadAssignment(node, name);
6563
}
6664
} else if (isThis) {
67-
context.report(node,
68-
"Unexpected alias '{{name}}' for 'this'.", { name });
65+
context.report({node, message: "Unexpected alias '{{name}}' for 'this'.", data: { name }});
6966
}
7067
}
7168

lib/rules/default-case.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = {
8181
}
8282

8383
if (!comment || !commentPattern.test(comment.value.trim())) {
84-
context.report(node, "Expected a default case.");
84+
context.report({node, message: "Expected a default case."});
8585
}
8686
}
8787
}

lib/rules/func-names.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ module.exports = {
8686

8787
if (never) {
8888
if (name) {
89-
context.report(node, "Unexpected function expression name.");
89+
context.report({node, message: "Unexpected function expression name."});
9090
}
9191
} else {
9292
if (!name && (asNeeded ? !hasInferredName(node) : !isObjectOrClassMethod(node))) {
93-
context.report(node, "Missing function expression name.");
93+
context.report({node, message: "Missing function expression name."});
9494
}
9595
}
9696
}

lib/rules/func-style.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = {
4444
stack.push(false);
4545

4646
if (!enforceDeclarations && node.parent.type !== "ExportDefaultDeclaration") {
47-
context.report(node, "Expected a function expression.");
47+
context.report({node, message: "Expected a function expression."});
4848
}
4949
},
5050
"FunctionDeclaration:exit"() {
@@ -55,7 +55,7 @@ module.exports = {
5555
stack.push(false);
5656

5757
if (enforceDeclarations && node.parent.type === "VariableDeclarator") {
58-
context.report(node.parent, "Expected a function declaration.");
58+
context.report({node: node.parent, message: "Expected a function declaration."});
5959
}
6060
},
6161
"FunctionExpression:exit"() {
@@ -78,7 +78,7 @@ module.exports = {
7878
const hasThisExpr = stack.pop();
7979

8080
if (enforceDeclarations && !hasThisExpr && node.parent.type === "VariableDeclarator") {
81-
context.report(node.parent, "Expected a function declaration.");
81+
context.report({node: node.parent, message: "Expected a function declaration."});
8282
}
8383
};
8484
}

0 commit comments

Comments
 (0)