ember-cli / ember-cli/ember-cli-deprecation-workflow

allow for "budgets" as a deprecation handler

Open
#64 4 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
166
Forks
44
PR merge metrics
No merged PRs in 30d

Description

## Context

Currently, ember-cli-deprecation-workflow supports 3 handlers for deprecations:

silence | Keeps this deprecation from spewing all over the console
-- | --
log | Normal deprecation behavior runs for this deprecation and messages are logged to the console
throw | The error is thrown instead of allowing the deprecated behavior to run. WARNING: APPLICATION MAY GO 💥

While these work for their intended purposes really well, they don't necessarily help cases where you might not be able to address a deprecation right away, but a team wants to prevent the deprecation count from growing from things like copy-pasting code that will cause new deprecations to pile up.

## Proposal

Users of this addon will be able to specify a `budget` option to the `handler` option for each deprecation. If the deprecation is triggered more than the allowed `budget` in certain scenarios (e.g. a test suite run where conditions are more controlled), then the handler will throw. This would allow a team to keep existing code that causes deprecations but fail builds in CI for any new code that increases deprecation use.

For example, take the following `config/deprecation-workflow.js`:

```javascript
// config/deprecation-workflow.js
window.deprecationWorkflow = window.deprecationWorkflow || {};
window.deprecationWorkflow.config = {
workflow: [
{ matchId: 'ember-string-utils.fmt', handler: { budget: 10 } },
]
};
```

if a new pull request was opened with the following code:

`Ember.String.format('some string %s', 'hi')`

This would increase the number of deprecations invoked to `11`, violating the budget, causing `ember-cli-deprecation-workflow` to throw, failing the build.

We would likely also need some facility to make copy/pasting the existing deprecation count (to set the initial budget) to `config/deprecation-workflow.js` from the browser easier as well.

I'd be happy to PR this, just wanted to get thoughts on the idea before going through the effort of writing code.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.