Skip to content

Commit

Permalink
[CHORE] Fix deprecation warnings; improve tooling (#6836)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav0 authored and runspired committed Dec 2, 2019
1 parent 9dd3cb9 commit 0e7c87a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
10 changes: 7 additions & 3 deletions packages/-ember-data/tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ QUnit.begin(() => {
}
assert.expectNoDeprecation(undefined, undefined, deprecation => {
// only assert EmberData deprecations
const id = deprecation.options.id;
const isEmberDataDeprecation = id.includes('DS') || id.includes('EmberData') || id.includes('ember-data');
const id = deprecation.options.id.toLowerCase();
const isEmberDataDeprecation =
id.includes('ds.') ||
id.includes('emberdata') ||
id.includes('ember-data') ||
id.includes('mismatched-inverse-relationship-data-from-payload');

if (!isEmberDataDeprecation) {
// eslint-disable-next-line no-console
console.log('Detected Non-Ember-Data Deprecation', deprecation);
console.warn('Detected Non-Ember-Data Deprecation:', deprecation.message, deprecation.options.stacktrace);
}

return isEmberDataDeprecation;
Expand Down
15 changes: 12 additions & 3 deletions packages/model/addon/-private/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,18 @@ if (REQUEST_SERVICE) {

let isReloading;
if (REQUEST_SERVICE) {
isReloading = computed(function() {
let requests = this.store.getRequestStateService().getPendingRequestsForRecord(recordIdentifierFor(this));
return !!requests.find(req => req.request.data[0].options.isReloading);
isReloading = computed({
get() {
if (this._isReloading === undefined) {
let requests = this.store.getRequestStateService().getPendingRequestsForRecord(recordIdentifierFor(this));
let value = !!requests.find(req => req.request.data[0].options.isReloading);
return (this._isReloading = value);
}
return this._isReloading;
},
set(_, value) {
return (this._isReloading = value);
},
});
} else {
isReloading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ interface DeprecationConfig {
until: string;
message?: string | RegExp;
url?: string;
stacktrace?: string;
}
interface FoundDeprecation {
message: string;
options: {
id: string;
message?: string;
message?: string | RegExp;
until: string;
url?: string;
stacktrace?: string;
};
}

Expand All @@ -38,6 +40,8 @@ interface AssertNoneResult {
message: string;
}

Error.stackTraceLimit = 50;

/**
* Returns a qunit assert result object which passes if the given deprecation
* `id` was found *exactly* `count` times.
Expand Down Expand Up @@ -118,7 +122,8 @@ export function configureDeprecationHandler() {
HANDLED_DEPRECATIONS_FOR_TEST = [];
});

registerDeprecationHandler(function(message, options /*, next*/) {
registerDeprecationHandler(function(message, options: DeprecationConfig /*, next*/) {
options.stacktrace = new Error().stack;
if (DEPRECATIONS_FOR_TEST) {
DEPRECATIONS_FOR_TEST.push({ message, options });
}
Expand Down

0 comments on commit 0e7c87a

Please sign in to comment.