Skip to content

Commit

Permalink
fix: stop using deprecated report API
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Jun 14, 2021
1 parent 6559ca5 commit 473a816
Show file tree
Hide file tree
Showing 42 changed files with 88 additions and 65 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ module.exports = {

// eslint-plugin rules:
'eslint-plugin/consistent-output': ['error', 'always'],
'eslint-plugin/no-deprecated-report-api': 'off',
'eslint-plugin/require-meta-docs-url': [
'error',
{
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/alias-model-in-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
const message = 'Alias your model';

const report = function (node) {
context.report(node, message);
context.report({ node, message });
};

const sourceCode = context.getSourceCode();
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/avoid-leaking-state-in-ember-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = {
const report = function (node) {
const message =
'Only string, number, symbol, boolean, null, undefined, and function are allowed as default properties';
context.report(node, message);
context.report({ node, message });
};

const sourceCode = context.getSourceCode();
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/avoid-using-needs-in-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
const report = function (node) {
const message =
'`needs` API has been deprecated, `Ember.inject.controller` should be used instead';
context.report(node, message);
context.report({ node, message });
};

const sourceCode = context.getSourceCode();
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/closure-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {

create(context) {
const report = function (node) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
};

return {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/computed-property-getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
const requireGetters = context.options[0] || 'always-with-setter';

const report = function (node, message) {
context.report(node, message);
context.report({ node, message });
};

const requireGetterOnlyWithASetterInComputedProperty = function (node) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/jquery-ember-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = {

create(context) {
const report = function (node) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
};

let importedEmberName;
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/named-functions-in-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
const message = 'Use named functions defined on objects to handle promises';

const report = function (node) {
context.report(node, message);
context.report({ node, message });
};

return {
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/new-module-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {
type: item.type,
});

context.report(item, message);
context.report({ node: item, message });
}
}
}
Expand Down Expand Up @@ -83,7 +83,7 @@ module.exports = {
type: item.type,
});

context.report(item, message);
context.report({ node: item, message });
}
}
}
Expand Down Expand Up @@ -111,7 +111,7 @@ module.exports = {
// JS module import for it, so do not report the error
if (match) {
const message = buildMessage({ node, fullName, key, match });
context.report(node, message);
context.report({ node, message });
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-actions-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
function reportActionsProp(properties) {
const actionsProp = properties.find((property) => ember.isActionsProp(property));
if (actionsProp) {
context.report(actionsProp, ERROR_MESSAGE);
context.report({ node: actionsProp, message: ERROR_MESSAGE });
}
}

Expand Down
10 changes: 8 additions & 2 deletions lib/rules/no-arrow-function-computed-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ module.exports = {

if (onlyThisContexts) {
if (isThisPresent) {
context.report(node.arguments[node.arguments.length - 1], ERROR_MESSAGE);
context.report({
node: node.arguments[node.arguments.length - 1],
message: ERROR_MESSAGE,
});
}
} else {
context.report(node.arguments[node.arguments.length - 1], ERROR_MESSAGE);
context.report({
node: node.arguments[node.arguments.length - 1],
message: ERROR_MESSAGE,
});
}
},
};
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-attrs-in-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = {

MemberExpression(node) {
if (currentEmberComponent && isThisAttrsExpression(node)) {
context.report(node.property, ERROR_MESSAGE);
context.report({ node: node.property, message: ERROR_MESSAGE });
}
},
};
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-attrs-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {

create(context) {
const report = function (node) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
};

return {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-classic-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = {
const additionalClassImports = options.additionalClassImports || [];

function reportNode(node) {
context.report(node, ERROR_MESSAGE_NO_CLASSIC_CLASSES);
context.report({ node, message: ERROR_MESSAGE_NO_CLASSIC_CLASSES });
}

return {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-classic-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {

create(context) {
const report = function (node) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
};

return {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-computed-properties-in-native-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = {
let computedNodes = [];

const report = function (node) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
};

return {
Expand Down
12 changes: 6 additions & 6 deletions lib/rules/no-controller-access-in-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = {
node.property.name === 'controller'
) {
// Example: this.controller;
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}
},

Expand All @@ -99,7 +99,7 @@ module.exports = {
node.callee.property.name === 'controllerFor'
) {
// Example this.controllerFor(...);
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}

if (
Expand All @@ -112,7 +112,7 @@ module.exports = {
node.arguments[0].value === 'controller'
) {
// Example: this.get('controller');
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}

if (
Expand All @@ -124,7 +124,7 @@ module.exports = {
node.arguments[1].value === 'controller'
) {
// Example: get(this, 'controller');
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}

if (
Expand All @@ -135,7 +135,7 @@ module.exports = {
getPropertiesArgumentsIncludeController(node.arguments)
) {
// Example: this.getProperties('controller');
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}

if (
Expand All @@ -145,7 +145,7 @@ module.exports = {
getPropertiesArgumentsIncludeController(node.arguments.slice(1))
) {
// Example: getProperties(this, 'controller');
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}
},

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
ember.isEmberController(context, node) &&
(node.body.body.length === 0 || !classDeclarationHasProperty(node, 'queryParams'))
) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}
},

Expand All @@ -39,7 +39,7 @@ module.exports = {
(node.arguments.length === 0 ||
!callExpressionClassHasProperty(node, 'queryParams', scopeManager))
) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}
},
};
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-current-route-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
CallExpression(node) {
const { callee } = node;
if (callee.type === 'Identifier' && importAliases.includes(callee.name)) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}
},
};
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/no-ember-testing-in-module-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ module.exports = {
node.parent.object.name === emberImportAliasName
) {
if (context.getScope().variableScope.type === 'module') {
context.report(node.parent, ERROR_MESSAGES[0]);
context.report({ node: node.parent, message: ERROR_MESSAGES[0] });
}
const nodeGrandParent = utils.getPropertyValue(node, 'parent.parent.type');
if (
nodeGrandParent === 'AssignmentExpression' ||
nodeGrandParent === 'VariableDeclarator'
) {
context.report(node.parent.parent, ERROR_MESSAGES[1]);
context.report({ node: node.parent.parent, message: ERROR_MESSAGES[1] });
}
}
},
Expand All @@ -66,7 +66,7 @@ module.exports = {
ancestorNode.init.name === emberImportAliasName
)
) {
context.report(node.parent.parent.parent, ERROR_MESSAGES[2]);
context.report({ node: node.parent.parent.parent, message: ERROR_MESSAGES[2] });
}
},
};
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-empty-attrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
const filePath = context.getFilename();

const report = function (node) {
context.report(node, message);
context.report({ node, message });
};

const sourceCode = context.getSourceCode();
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-empty-glimmer-component-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
return {
ClassDeclaration(node) {
if (isGlimmerComponent(context, node) && node.body.body.length === 0) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}
},
};
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-function-prototype-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = {
};

const report = function (node) {
context.report(node, message);
context.report({ node, message });
};

return {
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ module.exports = {
validateGetPropertiesArguments(node.arguments, ignoreNestedPaths)
) {
// Example: this.getProperties('foo', 'bar');
context.report(node, ERROR_MESSAGE_GET_PROPERTIES);
context.report({ node, message: ERROR_MESSAGE_GET_PROPERTIES });
}

if (
Expand All @@ -274,7 +274,7 @@ module.exports = {
validateGetPropertiesArguments(node.arguments.slice(1), ignoreNestedPaths)
) {
// Example: getProperties(this, 'foo', 'bar');
context.report(node, ERROR_MESSAGE_GET_PROPERTIES);
context.report({ node, message: ERROR_MESSAGE_GET_PROPERTIES });
}
},
};
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-global-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
const tracker = new ReferenceTracker(context.getScope());

for (const { node } of tracker.iterateGlobalReferences(globalMap)) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
function checkArgumentsForInlineFunction(node) {
for (const [index, argument] of node.arguments.entries()) {
if (types.isAnyFunctionExpression(argument)) {
context.report(node.arguments[index], ERROR_MESSAGE);
context.report({ node: node.arguments[index], message: ERROR_MESSAGE });
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-incorrect-computed-macros.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = {
},
});
} else if (node.arguments.length === 0) {
context.report(node, ERROR_MESSAGE_AND_OR);
context.report({ node, message: ERROR_MESSAGE_AND_OR });
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {

create(context) {
const report = function (node) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
};

return {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-legacy-test-waiters.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
node.callee.type === 'Identifier' &&
testWaitersIdentifiers.includes(node.callee.name)
) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}
},
};
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
ImportDeclaration(node) {
const importPath = node.source.value;
if (mixinPathRegex.test(importPath)) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}
},
};
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-new-mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ module.exports = {
return {
CallExpression(node) {
if (ember.isEmberMixin(context, node)) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}
},

ClassDeclaration(node) {
if (ember.isEmberMixin(context, node)) {
context.report(node, ERROR_MESSAGE);
context.report({ node, message: ERROR_MESSAGE });
}
},
};
Expand Down
Loading

0 comments on commit 473a816

Please sign in to comment.