Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions rules/service-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,35 @@ function getConfig(options) {
return config;
}

/**
* Used only by `ForDeprecatedBehavior()` for making sure it was run only one time
* @type {boolean}
*/
var didWarnForDeprecatedBehavior = false;

/**
* Warn if API is deprecated
* @param {Array.<*>} options
*/
function warnForDeprecatedBehavior(options) {
if (didWarnForDeprecatedBehavior) {
return;
}
didWarnForDeprecatedBehavior = true;

var config = getConfig(options);

/* istanbul ignore if */
if (config.oldBehavior) {
// eslint-disable-next-line
console.warn('The rule `angular/service-name` will be split up to different rules in the next version. Please read the docs for more information');
}
}

module.exports = function(context) {
// Warn if needed for breaking changes in API in new versions
warnForDeprecatedBehavior(context.options);

return {

CallExpression: function(node) {
Expand All @@ -61,9 +89,6 @@ module.exports = function(context) {

if (config.oldBehavior) {
isService = utils.isAngularServiceDeclarationDeprecated(node);
// Warning that the API is deprecated
// eslint-disable-next-line
console.warn('The rule `angular/service-name` will be split up to different rules in the next version. Please read the docs for more information');
} else {
isService = utils.isAngularServiceDeclaration(node);
}
Expand Down