diff --git a/lib/overrides.js b/lib/overrides.js index 4eaed77a0c8..d8d9f4209a6 100644 --- a/lib/overrides.js +++ b/lib/overrides.js @@ -4,7 +4,6 @@ const validSemverRange = require('semver/ranges/valid'); const DEFAULT_OPTIONS = Object.freeze({ showAllEmberGlobalDeprecations: false, - showAllDotAccessDeprecations: false, }); function* walkAddonTree(project, pathToAddon = []) { @@ -32,8 +31,6 @@ module.exports = class Overrides { } else { return new Overrides(Overrides.addonsInfoFor(project), { showAllEmberGlobalDeprecations: env.EMBER_GLOBAL_DEPRECATIONS === 'all', - showAllDotAccessDeprecations: - env.EMBER_RUNLOOP_AND_COMPUTED_DOT_ACCESS_DEPRECATIONS === 'all', }); } } @@ -216,10 +213,6 @@ module.exports = class Overrides { return !this.hasActionableSuggestions || this.options.showAllEmberGlobalDeprecations; } - get showAllDotAccessDeprecations() { - return !this.hasActionableSuggestions || this.options.showAllDotAccessDeprecations; - } - get details() { let details = '\n### Details ###\n\n' + @@ -333,8 +326,6 @@ module.exports = class Overrides { toModule() { return ` export let onEmberGlobalAccess; - export let onComputedDotAccess; - export let onRunloopDotAccess; ${this.toJS()}; `; @@ -358,17 +349,10 @@ module.exports = class Overrides { ${this.onDotAcces} onEmberGlobalAccess = ${this.onEmberGlobalAccess}; - onComputedDotAccess = onDotAccess; - onRunloopDotAccess = onDotAccess; if (!${this.showAllEmberGlobalDeprecations}) { onEmberGlobalAccess = once(onEmberGlobalAccess); } - - if (!${this.showAllDotAccessDeprecations}) { - onComputedDotAccess = once(onComputedDotAccess); - onRunloopDotAccess = once(onRunloopDotAccess); - } `; } @@ -379,33 +363,4 @@ module.exports = class Overrides { } `; } - - get onDotAcces() { - return ` - function onDotAccess(dotKey, importKey, module) { - let message = - 'Using \`' + dotKey + '\` has been deprecated. Instead, import the value directly from ' + module + ':\\n\\n' + - ' import { ' + importKey + ' } from \\'' + module + '\\';\\n\\n' + - 'These usages may be caused by an outdated ember-cli-babel dependency. ' + - 'Usages of the Ember Global may be caused by an outdated ember-cli-babel dependency. ' + - 'The following steps may help:\\n\\n' + - ${JSON.stringify(Overrides.printList(this.suggestions))}; - - if (!${this.showAllDotAccessDeprecations}) { - message += - '\\n### Important ###\\n\\n' + - 'In order to avoid repeatedly showing the same deprecation messages, ' + - 'no further deprecation messages will be shown for theses deprecated usages ' + - 'until ember-cli-babel is upgraded to v7.26.6 or above.\\n\\n' + - 'To see all instances of this deprecation message, ' + - 'set the \`EMBER_RUNLOOP_AND_COMPUTED_DOT_ACCESS_DEPRECATIONS\` environment variable to "all", ' + - 'e.g. \`EMBER_RUNLOOP_AND_COMPUTED_DOT_ACCESS_DEPRECATIONS=all ember test\`.\\n'; - } - - message += ${JSON.stringify(this.details)}; - - return message; - } - `; - } }; diff --git a/packages/@ember/-internals/overrides/index.d.ts b/packages/@ember/-internals/overrides/index.d.ts index e52fbb81445..c913783fb1d 100644 --- a/packages/@ember/-internals/overrides/index.d.ts +++ b/packages/@ember/-internals/overrides/index.d.ts @@ -5,8 +5,5 @@ type Callback = (...args: TArgs) => TReturn; */ type Handler = Callback; type GlobalAccessHandler = Handler<[]>; -type DotAccessHandler = Handler<[dotKey: string, importKey: string, module: string]>; export let onEmberGlobalAccess: GlobalAccessHandler | undefined; -export let onComputedDotAccess: DotAccessHandler | undefined; -export let onRunloopDotAccess: DotAccessHandler | undefined; diff --git a/packages/@ember/-internals/overrides/index.js b/packages/@ember/-internals/overrides/index.js index 35b83669272..e016036f95e 100644 --- a/packages/@ember/-internals/overrides/index.js +++ b/packages/@ember/-internals/overrides/index.js @@ -1,3 +1 @@ export let onEmberGlobalAccess; -export let onComputedDotAccess; -export let onRunloopDotAccess; diff --git a/packages/@ember/-internals/runtime/tests/system/object/computed_test.js b/packages/@ember/-internals/runtime/tests/system/object/computed_test.js index 5d4c284d519..44552bda829 100644 --- a/packages/@ember/-internals/runtime/tests/system/object/computed_test.js +++ b/packages/@ember/-internals/runtime/tests/system/object/computed_test.js @@ -345,7 +345,9 @@ moduleFor( assert.ok(get(SubClass.create(), 'foo'), 'FOO', 'super value is fetched'); } - ['@test observing computed.reads prop and overriding it in create() works'](assert) { + ['@test observing prop installed with computed macro reads and overriding it in create() works']( + assert + ) { let Obj = EmberObject.extend({ name: reads('model.name'), nameDidChange: observer('name', function () {}), diff --git a/packages/@ember/object/index.js b/packages/@ember/object/index.js index 328b0fa5f2f..5542729c9b3 100644 --- a/packages/@ember/object/index.js +++ b/packages/@ember/object/index.js @@ -1,7 +1,5 @@ -import { DEBUG } from '@glimmer/env'; -import { assert, deprecate } from '@ember/debug'; +import { assert } from '@ember/debug'; import { isElementDescriptor, setClassicDecorator } from '@ember/-internals/metal'; -import { onComputedDotAccess } from '@ember/-internals/overrides'; export { Object as default } from '@ember/-internals/runtime'; @@ -17,136 +15,6 @@ export { trySet, } from '@ember/-internals/metal'; -import { computed } from '@ember/-internals/metal'; - -import { - alias, - and, - bool, - collect, - deprecatingAlias, - empty, - equal, - filterBy, - filter, - gte, - gt, - intersect, - lte, - lt, - mapBy, - map, - match, - max, - min, - none, - notEmpty, - not, - oneWay, - or, - readOnly, - setDiff, - sort, - sum, - union, - uniqBy, - uniq, -} from '@ember/object/computed'; - -// eslint-disable-next-line no-undef -if (DEBUG) { - let defaultHandler = (dotKey, importKey, module) => { - return `Using \`${dotKey}\` has been deprecated. Instead, import the value directly from ${module}:\n\n import { ${importKey} } from '${module}';`; - }; - - let handler = onComputedDotAccess || defaultHandler; - - let defineDeprecatedComputedFunc = (key, func) => { - Object.defineProperty(computed, key, { - get() { - let message = handler(`computed.${key}`, key, '@ember/object/computed'); - - deprecate(message, message === null, { - id: 'deprecated-run-loop-and-computed-dot-access', - until: '4.0.0', - for: 'ember-source', - since: { - enabled: '3.27.0', - }, - }); - - return func; - }, - }); - }; - - defineDeprecatedComputedFunc('alias', alias); - defineDeprecatedComputedFunc('and', and); - defineDeprecatedComputedFunc('bool', bool); - defineDeprecatedComputedFunc('collect', collect); - defineDeprecatedComputedFunc('deprecatingAlias', deprecatingAlias); - defineDeprecatedComputedFunc('empty', empty); - defineDeprecatedComputedFunc('equal', equal); - defineDeprecatedComputedFunc('filterBy', filterBy); - defineDeprecatedComputedFunc('filter', filter); - defineDeprecatedComputedFunc('gte', gte); - defineDeprecatedComputedFunc('gt', gt); - defineDeprecatedComputedFunc('intersect', intersect); - defineDeprecatedComputedFunc('lte', lte); - defineDeprecatedComputedFunc('lt', lt); - defineDeprecatedComputedFunc('mapBy', mapBy); - defineDeprecatedComputedFunc('map', map); - defineDeprecatedComputedFunc('match', match); - defineDeprecatedComputedFunc('max', max); - defineDeprecatedComputedFunc('min', min); - defineDeprecatedComputedFunc('none', none); - defineDeprecatedComputedFunc('notEmpty', notEmpty); - defineDeprecatedComputedFunc('not', not); - defineDeprecatedComputedFunc('oneWay', oneWay); - defineDeprecatedComputedFunc('reads', oneWay); - defineDeprecatedComputedFunc('or', or); - defineDeprecatedComputedFunc('readOnly', readOnly); - defineDeprecatedComputedFunc('setDiff', setDiff); - defineDeprecatedComputedFunc('sort', sort); - defineDeprecatedComputedFunc('sum', sum); - defineDeprecatedComputedFunc('union', union); - defineDeprecatedComputedFunc('uniqBy', uniqBy); - defineDeprecatedComputedFunc('uniq', uniq); -} else { - computed.alias = alias; - computed.and = and; - computed.bool = bool; - computed.collect = collect; - computed.deprecatingAlias = deprecatingAlias; - computed.empty = empty; - computed.equal = equal; - computed.filterBy = filterBy; - computed.filter = filter; - computed.gte = gte; - computed.gt = gt; - computed.intersect = intersect; - computed.lte = lte; - computed.lt = lt; - computed.mapBy = mapBy; - computed.map = map; - computed.match = match; - computed.max = max; - computed.min = min; - computed.none = none; - computed.notEmpty = notEmpty; - computed.not = not; - computed.oneWay = oneWay; - computed.reads = oneWay; - computed.or = or; - computed.readOnly = readOnly; - computed.setDiff = setDiff; - computed.sort = sort; - computed.sum = sum; - computed.union = union; - computed.uniqBy = uniqBy; - computed.uniq = uniq; -} - /** Decorator that turns the target function into an Action which can be accessed directly by reference. diff --git a/packages/@ember/object/lib/computed/computed_macros.js b/packages/@ember/object/lib/computed/computed_macros.js index a18ebdbf7a4..368a3e5640b 100644 --- a/packages/@ember/object/lib/computed/computed_macros.js +++ b/packages/@ember/object/lib/computed/computed_macros.js @@ -24,7 +24,7 @@ function expandPropertiesToArray(predicateName, properties) { for (let i = 0; i < properties.length; i++) { let property = properties[i]; assert( - `Dependent keys passed to computed.${predicateName}() can't have spaces.`, + `Dependent keys passed to \`${predicateName}\` computed macro can't have spaces.`, property.indexOf(' ') < 0 ); @@ -988,11 +988,11 @@ export const or = generateComputedWithPredicate('or', (value) => !value); */ /** - Where `computed.alias` aliases `get` and `set`, and allows for bidirectional - data flow, `computed.oneWay` only provides an aliased `get`. The `set` will - not mutate the upstream property, rather causes the current property to become - the value set. This causes the downstream property to permanently diverge from - the upstream property. + Where the `alias` computed macro aliases `get` and `set`, and allows for + bidirectional data flow, the `oneWay` computed macro only provides an aliased + `get`. The `set` will not mutate the upstream property, rather causes the + current property to become the value set. This causes the downstream property + to permanently diverge from the upstream property. Example: @@ -1061,8 +1061,8 @@ export function oneWay(dependentKey) { } /** - This is a more semantically meaningful alias of `computed.oneWay`, whose name - is somewhat ambiguous as to which direction the data flows. + This is a more semantically meaningful alias of the `oneWay` computed macro, + whose name is somewhat ambiguous as to which direction the data flows. @method reads @static @@ -1074,9 +1074,10 @@ export function oneWay(dependentKey) { */ /** - Where `computed.oneWay` provides oneWay bindings, `computed.readOnly` provides - a readOnly one way binding. Very often when using `computed.oneWay` one does - not also want changes to propagate back up, as they will replace the value. + Where `oneWay` computed macro provides oneWay bindings, the `readOnly` + computed macro provides a readOnly one way binding. Very often when using + the `oneWay` macro one does not also want changes to propagate back up, as + they will replace the value. This prevents the reverse flow, and also throws an exception when it occurs. diff --git a/packages/@ember/object/lib/computed/reduce_computed_macros.js b/packages/@ember/object/lib/computed/reduce_computed_macros.js index d2e80b7a2a2..81f5b1f51fd 100644 --- a/packages/@ember/object/lib/computed/reduce_computed_macros.js +++ b/packages/@ember/object/lib/computed/reduce_computed_macros.js @@ -8,7 +8,7 @@ import { compare, isArray, A as emberA, uniqBy as uniqByArray } from '@ember/-in function reduceMacro(dependentKey, callback, initialValue, name) { assert( - `Dependent key passed to \`computed.${name}\` shouldn't contain brace expanding pattern.`, + `Dependent key passed to \`${name}\` computed macro shouldn't contain brace expanding pattern.`, !/[[\]{}]/g.test(dependentKey) ); @@ -43,7 +43,7 @@ function arrayMacro(dependentKey, additionalDependentKeys, callback) { function multiArrayMacro(_dependentKeys, callback, name) { assert( - `Dependent keys passed to \`computed.${name}\` shouldn't contain brace expanding pattern.`, + `Dependent keys passed to \`${name}\` computed macro shouldn't contain brace expanding pattern.`, _dependentKeys.every((dependentKey) => !/[[\]{}]/g.test(dependentKey)) ); let dependentKeys = _dependentKeys.map((key) => `${key}.[]`); @@ -516,12 +516,12 @@ export function mapBy(dependentKey, propertyKey) { ); assert( - '`computed.mapBy` expects a property string for its second argument, ' + + '`mapBy` computed macro expects a property string for its second argument, ' + 'perhaps you meant to use "map"', typeof propertyKey === 'string' ); assert( - `Dependent key passed to \`computed.mapBy\` shouldn't contain brace expanding pattern.`, + `Dependent key passed to \`mapBy\` computed macro shouldn't contain brace expanding pattern.`, !/[[\]{}]/g.test(dependentKey) ); @@ -745,7 +745,7 @@ export function filterBy(dependentKey, propertyKey, value) { ); assert( - `Dependent key passed to \`computed.filterBy\` shouldn't contain brace expanding pattern.`, + `Dependent key passed to \`filterBy\` computed macro shouldn't contain brace expanding pattern.`, !/[[\]{}]/g.test(dependentKey) ); @@ -913,7 +913,7 @@ export function uniqBy(dependentKey, propertyKey) { ); assert( - `Dependent key passed to \`computed.uniqBy\` shouldn't contain brace expanding pattern.`, + `Dependent key passed to \`uniqBy\` computed macro shouldn't contain brace expanding pattern.`, !/[[\]{}]/g.test(dependentKey) ); @@ -1164,9 +1164,9 @@ export function setDiff(setAProperty, setBProperty) { !isElementDescriptor(Array.prototype.slice.call(arguments)) ); - assert('`computed.setDiff` requires exactly two dependent arrays.', arguments.length === 2); + assert('`setDiff` computed macro requires exactly two dependent arrays.', arguments.length === 2); assert( - `Dependent keys passed to \`computed.setDiff\` shouldn't contain brace expanding pattern.`, + `Dependent keys passed to \`setDiff\` computed macro shouldn't contain brace expanding pattern.`, !/[[\]{}]/g.test(setAProperty) && !/[[\]{}]/g.test(setBProperty) ); @@ -1448,7 +1448,7 @@ export function sort(itemsKey, additionalDependentKeys, sortDefinition) { } assert( - '`computed.sort` can either be used with an array of sort properties or with a sort function. If used with an array of sort properties, it must receive exactly two arguments: the key of the array to sort, and the key of the array of sort properties. If used with a sort function, it may receive up to three arguments: the key of the array to sort, an optional additional array of dependent keys for the computed property, and the sort function.', + 'The `sort` computed macro can either be used with an array of sort properties or with a sort function. If used with an array of sort properties, it must receive exactly two arguments: the key of the array to sort, and the key of the array of sort properties. If used with a sort function, it may receive up to three arguments: the key of the array to sort, an optional additional array of dependent keys for the computed property, and the sort function.', argumentsValid ); } diff --git a/packages/@ember/object/tests/computed/computed_macros_test.js b/packages/@ember/object/tests/computed/computed_macros_test.js index 50817b2e89a..d7a3ba301a2 100644 --- a/packages/@ember/object/tests/computed/computed_macros_test.js +++ b/packages/@ember/object/tests/computed/computed_macros_test.js @@ -23,7 +23,7 @@ import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( 'CP macros', class extends AbstractTestCase { - ['@test Ember.computed.empty'](assert) { + ['@test empty part 1/2'](assert) { let obj = EmberObject.extend({ bestLannister: null, lannisters: null, @@ -44,7 +44,7 @@ moduleFor( assert.equal(get(obj, 'noLannistersKnown'), false, 'empty respects array mutations'); } - ['@test Ember.computed.notEmpty'](assert) { + ['@test notEmpty part 1/2'](assert) { let obj = EmberObject.extend({ bestLannister: null, lannisters: null, @@ -65,7 +65,7 @@ moduleFor( assert.equal(get(obj, 'LannistersKnown'), true, 'empty respects array mutations'); } - ['@test computed.not'](assert) { + ['@test not'](assert) { let obj = { foo: true }; defineProperty(obj, 'notFoo', not('foo')); assert.equal(get(obj, 'notFoo'), false); @@ -75,7 +75,7 @@ moduleFor( assert.equal(get(obj, 'notFoo'), false); } - ['@test computed.empty'](assert) { + ['@test empty part 2/2'](assert) { let obj = { foo: [], bar: undefined, baz: null, quz: '' }; defineProperty(obj, 'fooEmpty', empty('foo')); defineProperty(obj, 'barEmpty', empty('bar')); @@ -92,7 +92,7 @@ moduleFor( assert.equal(get(obj, 'quzEmpty'), false); } - ['@test computed.bool'](assert) { + ['@test bool'](assert) { let obj = { foo() {}, bar: 'asdf', baz: null, quz: false }; defineProperty(obj, 'fooBool', bool('foo')); defineProperty(obj, 'barBool', bool('bar')); @@ -104,7 +104,7 @@ moduleFor( assert.equal(get(obj, 'quzBool'), false); } - ['@test computed.alias'](assert) { + ['@test alias'](assert) { let obj = { bar: 'asdf', baz: null, quz: false }; defineProperty( obj, @@ -137,7 +137,7 @@ moduleFor( assert.equal(get(obj, 'quz'), null); } - ['@test computed.alias set'](assert) { + ['@test alias set'](assert) { let obj = {}; let constantValue = 'always `a`'; @@ -164,7 +164,7 @@ moduleFor( assert.equal(get(obj, 'aliased'), constantValue); } - ['@test computed.match'](assert) { + ['@test match'](assert) { let obj = { name: 'Paul' }; defineProperty(obj, 'isPaul', match('name', /Paul/)); @@ -175,7 +175,7 @@ moduleFor( assert.equal(get(obj, 'isPaul'), false, 'is not Paul anymore'); } - ['@test computed.notEmpty'](assert) { + ['@test notEmpty part 2/2'](assert) { let obj = { items: [1] }; defineProperty(obj, 'hasItems', notEmpty('items')); @@ -186,7 +186,7 @@ moduleFor( assert.equal(get(obj, 'hasItems'), false, 'is empty'); } - ['@test computed.equal'](assert) { + ['@test equal'](assert) { let obj = { name: 'Paul' }; defineProperty(obj, 'isPaul', computedEqual('name', 'Paul')); @@ -197,7 +197,7 @@ moduleFor( assert.equal(get(obj, 'isPaul'), false, 'is not Paul anymore'); } - ['@test computed.gt'](assert) { + ['@test gt'](assert) { let obj = { number: 2 }; defineProperty(obj, 'isGreaterThenOne', gt('number', 1)); @@ -212,7 +212,7 @@ moduleFor( assert.equal(get(obj, 'isGreaterThenOne'), false, 'is not gt'); } - ['@test computed.gte'](assert) { + ['@test gte'](assert) { let obj = { number: 2 }; defineProperty(obj, 'isGreaterOrEqualThenOne', gte('number', 1)); @@ -227,7 +227,7 @@ moduleFor( assert.equal(get(obj, 'isGreaterOrEqualThenOne'), false, 'is not gte'); } - ['@test computed.lt'](assert) { + ['@test lt'](assert) { let obj = { number: 0 }; defineProperty(obj, 'isLesserThenOne', lt('number', 1)); @@ -242,7 +242,7 @@ moduleFor( assert.equal(get(obj, 'isLesserThenOne'), false, 'is not lt'); } - ['@test computed.lte'](assert) { + ['@test lte'](assert) { let obj = { number: 0 }; defineProperty(obj, 'isLesserOrEqualThenOne', lte('number', 1)); @@ -257,7 +257,7 @@ moduleFor( assert.equal(get(obj, 'isLesserOrEqualThenOne'), false, 'is not lte'); } - ['@test computed.and two properties'](assert) { + ['@test and, with two properties'](assert) { let obj = { one: true, two: true }; defineProperty(obj, 'oneAndTwo', and('one', 'two')); @@ -278,7 +278,7 @@ moduleFor( assert.equal(get(obj, 'oneAndTwo'), 2, 'returns truthy value as in &&'); } - ['@test computed.and three properties'](assert) { + ['@test and, with three properties'](assert) { let obj = { one: true, two: true, three: true }; defineProperty(obj, 'oneTwoThree', and('one', 'two', 'three')); @@ -295,7 +295,7 @@ moduleFor( assert.equal(get(obj, 'oneTwoThree'), 3, 'returns truthy value as in &&'); } - ['@test computed.and expand properties'](assert) { + ['@test and, with expand properties'](assert) { let obj = { one: true, two: true, three: true }; defineProperty(obj, 'oneTwoThree', and('{one,two,three}')); @@ -312,7 +312,7 @@ moduleFor( assert.equal(get(obj, 'oneTwoThree'), 3, 'returns truthy value as in &&'); } - ['@test computed.or two properties'](assert) { + ['@test or, with two properties'](assert) { let obj = { one: true, two: true }; defineProperty(obj, 'oneOrTwo', or('one', 'two')); @@ -339,7 +339,7 @@ moduleFor( assert.equal(get(obj, 'oneOrTwo'), 1, 'returns truthy value as in ||'); } - ['@test computed.or three properties'](assert) { + ['@test or, with three properties'](assert) { let obj = { one: true, two: true, three: true }; defineProperty(obj, 'oneTwoThree', or('one', 'two', 'three')); @@ -370,7 +370,7 @@ moduleFor( assert.equal(get(obj, 'oneTwoThree'), 1, 'returns truthy value as in ||'); } - ['@test computed.or expand properties'](assert) { + ['@test or, with expand properties'](assert) { let obj = { one: true, two: true, three: true }; defineProperty(obj, 'oneTwoThree', or('{one,two,three}')); @@ -401,18 +401,18 @@ moduleFor( assert.equal(get(obj, 'oneTwoThree'), 1, 'returns truthy value as in ||'); } - ['@test computed.or and computed.and warn about dependent keys with spaces']() { + ['@test or and and, warn about dependent keys with spaces']() { let obj = { one: true, two: true }; expectAssertion(function () { defineProperty(obj, 'oneOrTwo', or('one', 'two three')); - }, /Dependent keys passed to computed\.or\(\) can't have spaces\./); + }, /Dependent keys passed to `or` computed macro can't have spaces\./); expectAssertion(function () { defineProperty(obj, 'oneAndTwo', and('one', 'two three')); - }, /Dependent keys passed to computed\.and\(\) can't have spaces\./); + }, /Dependent keys passed to `and` computed macro can't have spaces\./); } - ['@test computed.oneWay'](assert) { + ['@test oneWay'](assert) { let obj = { firstName: 'Teddy', lastName: 'Zeenny', @@ -436,7 +436,7 @@ moduleFor( assert.equal(get(obj, 'nickName'), 'TeddyBear'); } - ['@test computed.readOnly'](assert) { + ['@test readOnly'](assert) { let obj = { firstName: 'Teddy', lastName: 'Zeenny', @@ -462,7 +462,7 @@ moduleFor( assert.equal(get(obj, 'nickName'), 'TEDDDDDDDDYYY'); } - ['@test computed.deprecatingAlias'](assert) { + ['@test deprecatingAlias'](assert) { let obj = { bar: 'asdf', baz: null, quz: false }; defineProperty( obj, diff --git a/packages/@ember/object/tests/computed/reduce_computed_macros_test.js b/packages/@ember/object/tests/computed/reduce_computed_macros_test.js index fe336f45f85..32cde245c2a 100644 --- a/packages/@ember/object/tests/computed/reduce_computed_macros_test.js +++ b/packages/@ember/object/tests/computed/reduce_computed_macros_test.js @@ -646,7 +646,7 @@ moduleFor( let [name, macro] = tuple; moduleFor( - `computed.${name}`, + `CP macro \`${name}\``, class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ @@ -741,7 +741,7 @@ moduleFor( }); moduleFor( - 'computed.uniqBy', + 'CP Macro `uniqBy`', class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ @@ -828,7 +828,7 @@ moduleFor( ); moduleFor( - 'computed.intersect', + 'CP Macro `intersect`', class extends AbstractTestCase { beforeEach() { obj = EmberObject.extend({ @@ -935,7 +935,7 @@ moduleFor( array2: emberA([3, 4, 5]), }); }, - /`computed\.setDiff` requires exactly two dependent arrays/, + /`setDiff` computed macro requires exactly two dependent arrays/, 'setDiff requires two dependent arrays' ); @@ -949,7 +949,7 @@ moduleFor( array3: emberA([7]), }); }, - /`computed\.setDiff` requires exactly two dependent arrays/, + /`setDiff` computed macro requires exactly two dependent arrays/, 'setDiff requires two dependent arrays' ); } @@ -1846,19 +1846,19 @@ moduleFor( ['@test it throws on bad inputs']() { expectAssertion(() => { sort('foo', 'bar', 'baz'); - }, /`computed.sort` can either be used with an array of sort properties or with a sort function/); + }, /`sort` computed macro can either be used with an array of sort properties or with a sort function/); expectAssertion(() => { sort('foo', ['bar'], 'baz'); - }, /`computed.sort` can either be used with an array of sort properties or with a sort function/); + }, /`sort` computed macro can either be used with an array of sort properties or with a sort function/); expectAssertion(() => { sort('foo', 'bar', function () {}); - }, /`computed.sort` can either be used with an array of sort properties or with a sort function/); + }, /`sort` computed macro can either be used with an array of sort properties or with a sort function/); expectAssertion(() => { sort('foo', ['bar'], function () {}, 'baz'); - }, /`computed.sort` can either be used with an array of sort properties or with a sort function/); + }, /`sort` computed macro can either be used with an array of sort properties or with a sort function/); } } ); diff --git a/packages/@ember/runloop/index.js b/packages/@ember/runloop/index.js index c78ceaa48a5..e91e934ee3a 100644 --- a/packages/@ember/runloop/index.js +++ b/packages/@ember/runloop/index.js @@ -1,8 +1,6 @@ -import { DEBUG } from '@glimmer/env'; -import { assert, deprecate } from '@ember/debug'; +import { assert } from '@ember/debug'; import { onErrorTarget } from '@ember/-internals/error-handling'; import { flushAsyncObservers } from '@ember/-internals/metal'; -import { onRunloopDotAccess } from '@ember/-internals/overrides'; import Backburner from 'backburner'; let currentRunLoop = null; @@ -741,88 +739,3 @@ export function debounce() { export function throttle() { return _backburner.throttle(...arguments); } - -export let _deprecatedGlobalGetCurrentRunLoop; - -// eslint-disable-next-line no-undef -if (DEBUG) { - let defaultHandler = (dotKey, importKey, module) => { - return `Using \`${dotKey}\` has been deprecated. Instead, import the value directly from ${module}:\n\n import { ${importKey} } from '${module}';`; - }; - - let handler = onRunloopDotAccess || defaultHandler; - - let defineDeprecatedRunloopFunc = (key, func) => { - Object.defineProperty(run, key, { - get() { - let message = handler(`run.${key}`, key, '@ember/runloop'); - - deprecate(message, message === null, { - id: 'deprecated-run-loop-and-computed-dot-access', - until: '4.0.0', - for: 'ember-source', - since: { - enabled: '3.27.0', - }, - }); - - return func; - }, - }); - }; - - _deprecatedGlobalGetCurrentRunLoop = () => { - let message = handler('run.currentRunLoop', 'getCurrentRunLoop', '@ember/runloop'); - - deprecate(message, message === null, { - id: 'deprecated-run-loop-and-computed-dot-access', - until: '4.0.0', - for: 'ember-source', - since: { - enabled: '3.27.0', - }, - }); - - return _getCurrentRunLoop(); - }; - - defineDeprecatedRunloopFunc('backburner', _backburner); - defineDeprecatedRunloopFunc('begin', begin); - defineDeprecatedRunloopFunc('bind', bind); - defineDeprecatedRunloopFunc('cancel', cancel); - defineDeprecatedRunloopFunc('debounce', debounce); - defineDeprecatedRunloopFunc('end', end); - defineDeprecatedRunloopFunc('hasScheduledTimers', _hasScheduledTimers); - defineDeprecatedRunloopFunc('join', join); - defineDeprecatedRunloopFunc('later', later); - defineDeprecatedRunloopFunc('next', next); - defineDeprecatedRunloopFunc('once', once); - defineDeprecatedRunloopFunc('schedule', schedule); - defineDeprecatedRunloopFunc('scheduleOnce', scheduleOnce); - defineDeprecatedRunloopFunc('throttle', throttle); - defineDeprecatedRunloopFunc('cancelTimers', _cancelTimers); - Object.defineProperty(run, 'currentRunLoop', { - get: _deprecatedGlobalGetCurrentRunLoop, - enumerable: false, - }); -} else { - run.backburner = _backburner; - run.begin = begin; - run.bind = bind; - run.cancel = cancel; - run.debounce = debounce; - run.end = end; - run.hasScheduledTimers = _hasScheduledTimers; - run.join = join; - run.later = later; - run.next = next; - run.once = once; - run.schedule = schedule; - run.scheduleOnce = scheduleOnce; - run.throttle = throttle; - run.cancelTimers = _cancelTimers; - Object.defineProperty(run, 'currentRunLoop', { - get: _getCurrentRunLoop, - enumerable: false, - }); -} diff --git a/packages/@ember/runloop/tests/later_test.js b/packages/@ember/runloop/tests/later_test.js index c2f4eb14cca..f8ec7251d28 100644 --- a/packages/@ember/runloop/tests/later_test.js +++ b/packages/@ember/runloop/tests/later_test.js @@ -31,7 +31,7 @@ function pauseUntil(time) { } moduleFor( - 'run.later', + 'runloop `later`', class extends AbstractTestCase { teardown() { _backburner._platform = originalPlatform; diff --git a/packages/@ember/runloop/tests/next_test.js b/packages/@ember/runloop/tests/next_test.js index 124b822ba2f..7c608eaafdd 100644 --- a/packages/@ember/runloop/tests/next_test.js +++ b/packages/@ember/runloop/tests/next_test.js @@ -2,7 +2,7 @@ import { run, next, _getCurrentRunLoop } from '..'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( - 'run.next', + 'runloop `next`', class extends AbstractTestCase { ['@test should invoke immediately on next timeout'](assert) { let done = assert.async(); diff --git a/packages/ember/tests/reexports_test.js b/packages/ember/tests/reexports_test.js index 2ece032df5d..f8befb7a9d2 100644 --- a/packages/ember/tests/reexports_test.js +++ b/packages/ember/tests/reexports_test.js @@ -13,22 +13,14 @@ moduleFor( class extends AbstractTestCase { [`@test Ember exports correctly`](assert) { allExports.forEach((reexport) => { - let [path, moduleId, exportName, isDeprecated] = reexport; + let [path, moduleId, exportName] = reexport; // default path === exportName if none present if (!exportName) { exportName = path; } - confirmExport( - Ember, - assert, - path, - moduleId, - exportName, - isDeprecated, - `Ember.${path} exports correctly` - ); + confirmExport(Ember, assert, path, moduleId, exportName); }); } @@ -297,39 +289,7 @@ let allExports = [ // @ember/object/computed ['ComputedProperty', '@ember/object/computed', 'default'], - ['computed.alias', '@ember/object/computed', 'alias', true], - ['computed.and', '@ember/object/computed', 'and', true], - ['computed.bool', '@ember/object/computed', 'bool', true], - ['computed.collect', '@ember/object/computed', 'collect', true], - ['computed.deprecatingAlias', '@ember/object/computed', 'deprecatingAlias', true], - ['computed.empty', '@ember/object/computed', 'empty', true], - ['computed.equal', '@ember/object/computed', 'equal', true], - ['expandProperties', '@ember/object/computed', 'expandProperties', true], - ['computed.filter', '@ember/object/computed', 'filter', true], - ['computed.filterBy', '@ember/object/computed', 'filterBy', true], - ['computed.gt', '@ember/object/computed', 'gt', true], - ['computed.gte', '@ember/object/computed', 'gte', true], - ['computed.intersect', '@ember/object/computed', 'intersect', true], - ['computed.lt', '@ember/object/computed', 'lt', true], - ['computed.lte', '@ember/object/computed', 'lte', true], - ['computed.map', '@ember/object/computed', 'map', true], - ['computed.mapBy', '@ember/object/computed', 'mapBy', true], - ['computed.match', '@ember/object/computed', 'match', true], - ['computed.max', '@ember/object/computed', 'max', true], - ['computed.min', '@ember/object/computed', 'min', true], - ['computed.none', '@ember/object/computed', 'none', true], - ['computed.not', '@ember/object/computed', 'not', true], - ['computed.notEmpty', '@ember/object/computed', 'notEmpty', true], - ['computed.oneWay', '@ember/object/computed', 'oneWay', true], - ['computed.or', '@ember/object/computed', 'or', true], - ['computed.readOnly', '@ember/object/computed', 'readOnly', true], - ['computed.reads', '@ember/object/computed', 'reads', true], - ['computed.setDiff', '@ember/object/computed', 'setDiff', true], - ['computed.sort', '@ember/object/computed', 'sort', true], - ['computed.sum', '@ember/object/computed', 'sum', true], - ['computed.union', '@ember/object/computed', 'union', true], - ['computed.uniq', '@ember/object/computed', 'uniq', true], - ['computed.uniqBy', '@ember/object/computed', 'uniqBy', true], + ['expandProperties', '@ember/object/computed', 'expandProperties'], // @ember/object/core ['CoreObject', '@ember/object/core', 'default'], @@ -394,27 +354,6 @@ let allExports = [ // @ember/runloop ['run', '@ember/runloop', 'run'], - ['run.backburner', '@ember/runloop', '_backburner', true], - ['run.begin', '@ember/runloop', 'begin', true], - ['run.bind', '@ember/runloop', 'bind', true], - ['run.cancel', '@ember/runloop', 'cancel', true], - ['run.debounce', '@ember/runloop', 'debounce', true], - ['run.end', '@ember/runloop', 'end', true], - ['run.hasScheduledTimers', '@ember/runloop', '_hasScheduledTimers', true], - ['run.join', '@ember/runloop', 'join', true], - ['run.later', '@ember/runloop', 'later', true], - ['run.next', '@ember/runloop', 'next', true], - ['run.once', '@ember/runloop', 'once', true], - ['run.schedule', '@ember/runloop', 'schedule', true], - ['run.scheduleOnce', '@ember/runloop', 'scheduleOnce', true], - ['run.throttle', '@ember/runloop', 'throttle', true], - [ - 'run.currentRunLoop', - '@ember/runloop', - { get: DEBUG ? '_deprecatedGlobalGetCurrentRunLoop' : '_getCurrentRunLoop' }, - true, - ], - ['run.cancelTimers', '@ember/runloop', '_cancelTimers', true], // @ember/service ['Service', '@ember/service', 'default'], diff --git a/packages/internal-test-helpers/lib/confirm-export.js b/packages/internal-test-helpers/lib/confirm-export.js index 20a87a0cf52..beb549f6ddf 100644 --- a/packages/internal-test-helpers/lib/confirm-export.js +++ b/packages/internal-test-helpers/lib/confirm-export.js @@ -14,7 +14,7 @@ function getDescriptor(obj, path) { return Object.getOwnPropertyDescriptor(value, last); } -export default function confirmExport(Ember, assert, path, moduleId, exportName, isDeprecated) { +export default function confirmExport(Ember, assert, path, moduleId, exportName) { try { let desc; @@ -25,10 +25,6 @@ export default function confirmExport(Ember, assert, path, moduleId, exportName, desc = null; } - if (isDeprecated) { - expectDeprecation(); - } - if (desc === null) { let mod = require(moduleId); assert.notEqual(mod[exportName], undefined, `${moduleId}#${exportName} is not \`undefined\``); diff --git a/tests/node/overrides-test.js b/tests/node/overrides-test.js index 90dc4aebe4e..07dc930c30b 100644 --- a/tests/node/overrides-test.js +++ b/tests/node/overrides-test.js @@ -128,14 +128,12 @@ function infoForApp({ function evalJS(overrides) { return eval(` (function () { - let onEmberGlobalAccess, onComputedDotAccess, onRunloopDotAccess; + let onEmberGlobalAccess; ${overrides.toJS()} return { onEmberGlobalAccess: onEmberGlobalAccess, - onComputedDotAccess: onComputedDotAccess, - onRunloopDotAccess: onRunloopDotAccess, }; })() `); @@ -600,11 +598,6 @@ QUnit.module('Overrides', function () { false, 'showAllEmberGlobalDeprecations' ); - assert.strictEqual( - overrides.showAllDotAccessDeprecations, - false, - 'showAllDotAccessDeprecations' - ); assert.deepEqual(overrides.suggestions, [ 'Upgrade your `devDependencies` on `ember-cli-babel` to `^7.26.6`.', ]); @@ -624,7 +617,7 @@ QUnit.module('Overrides', function () { 'overrides.globalMessage' ); - let { onEmberGlobalAccess, onComputedDotAccess, onRunloopDotAccess } = evalJS(overrides); + let { onEmberGlobalAccess } = evalJS(overrides); assert.equal( onEmberGlobalAccess(), @@ -633,36 +626,6 @@ QUnit.module('Overrides', function () { ); assert.strictEqual(onEmberGlobalAccess(), null, 'onEmberGlobalAccess() (second call)'); - - assert.ok( - onComputedDotAccess('computed.reads', 'reads', '@ember/object/computed').startsWith( - 'Using `computed.reads` has been deprecated. ' + - 'Instead, import the value directly from @ember/object/computed:\n\n' + - " import { reads } from '@ember/object/computed';\n\n" - ), - 'onComputedDotAccess() (first call)' - ); - - assert.strictEqual( - onComputedDotAccess('computed.reads', 'reads', '@ember/object/computed'), - null, - 'onComputedDotAccess() (second call)' - ); - - assert.ok( - onRunloopDotAccess('run.next', 'next', '@ember/runloop').startsWith( - 'Using `run.next` has been deprecated. ' + - 'Instead, import the value directly from @ember/runloop:\n\n' + - " import { next } from '@ember/runloop';\n\n" - ), - 'onRunloopDotAccess() (first call)' - ); - - assert.strictEqual( - onRunloopDotAccess('run.next', 'next', '@ember/runloop'), - null, - 'onRunloopDotAccess() (second call)' - ); }); // let project, env;