jscs-ember-deprecations
This is a JSCS plugin to include errors for features that are deprecated in Ember.js
Installation
npm install jscs-ember-deprecations --save-devYou'll also need to tell JSCS to load the plugin. Modify your .jscsrc file to include
"plugins": [
"jscs-ember-deprecations"
],
"disallowObjectController": true,
"disallowInstanceInInitializer": true,
"disallowPrototypeExtension": true,
"disallowAtEachLeafNode": true,
// ...If you invoke JSCS with --fix (see http://jscs.info/overview#cli) some deprecation errors can be fixed automatically.
See Supported deprecations for valid keys
Why
Migrating to a newer Ember version can be tricky if you haven't already gone back and removed all uses of deprecated features. Instead, this plugin intends to enable a migration path in a codebase, where developers can be warned when they use deprecated features.
A sample use case is to:
- Use a tool like Lint Review to automagically annotate pull requests. Developers will be warned if they're using a feature that is deprecated. Put these "aspirational" rules in
.toolbot_jscsrc - Use
broccoli-jscsso that JSCS gets run at the same time you're running unit tests. Put rules that are "mandatory" in your codebase's.jscsrc. Any violations of those rules will result in the test suite failing.
This way a codebase can be gradually brought into compliance over time.
Supported deprecations
Deprecations added in Ember 1.11
disallowObjectControllerwill warn you if you use the deprecatedEmber.ObjectController. See http://emberjs.com/deprecations/v1.x/#toc_objectcontroller for details.disallowInstanceInInitializerwill warn you if you are looking up instances within an initializer. See http://emberjs.com/deprecations/v1.x/#toc_access-to-instances-in-initializers for details.
Deprecations added in Ember 1.12
disallowCoreViewwill warn you if you use the deprecatedEmber.CoreView. See https://github.com/emberjs/ember.js/pull/10585 for details.disallowEmberTryCatchwill warn you if you use the deprecatedEmber.tryCatchorEmber.tryCatchFinallyhelpers. See https://github.com/emberjs/ember.js/pull/10667 for details.disallowEmberRequiredwill warn you if you use the deprecatedEmber.required()helper. See https://github.com/emberjs/ember.js/pull/10668 for details.disallowDualGetterSetterwill warn you if you use a dual setter/getter function argument toEmber.computed(). See http://emberjs.com/deprecations/v1.x/#toc_computed-properties-with-a-shared-getter-and-setter for details.
Deprecations added in Ember 1.13
disallowAtEachLeafNodewill warn you if you use the deprecatedfoo.@eachnotation. See https://github.com/emberjs/ember.js/pull/11994 for details.disallowArrayComputedwill warn you if you use the deprecatedEmber.ArrayComputedPropertyorEmber.arrayComputed(). See https://github.com/emberjs/ember.js/pull/11403 for details.disallowReduceComputedwill warn you if you use the deprecatedEmber.ReduceComputedPropertyorEmber.reduceComputed(). See https://github.com/emberjs/ember.js/pull/11403 for details.disallowEmberCreatewill warn you if you use the deprecatedEmber.create()function. See http://emberjs.com/deprecations/v1.x/#toc_ember-create for details.disallowEmberKeyswill warn you if you use the deprecatedEmber.keys()function. See http://emberjs.com/deprecations/v1.x/#toc_ember-keys for details.disallowEmberOnewaywill warn you if you use the deprecatedEmber.oneWay()function. See http://emberjs.com/deprecations/v1.x/#toc_ember-oneway for details.disallowEmberViewwill warn you if you use the deprecatedEmber.View,Ember.LinkView,Ember.Select,Ember.ContainerView, orEmber.CollectionViewclasses. See http://emberjs.com/deprecations/v1.x/#toc_ember-view for details.disallowPositionalParamsExtendwill warn you if you usepositionalParamswithin.extend()instead of setting it as a static property on the class itself. See http://emberjs.com/deprecations/v1.x/#toc_set-code-positionalparams-code-as-a-static-property-on-the-class for details.disallowBeforeObserverwill warn you if you use the deprecatedEmber.addBeforeObserver(),Ember.removeBeforeObserver(), orEmber.beforeObserversFor()functions. Additionally, it will warn you if you use the deprecated.observesBefore()prototype extenion. Note that.observesBefore()is also deprecated in disallowPrototypeExtension. See http://emberjs.com/deprecations/v1.x/#toc_beforeobserver for details.disallowImmediateObserverwill warn you if you use the deprecatedEmber.immediateObserverhelper. See http://emberjs.com/deprecations/v1.x/#toc_ember-immediateobserver for details.disallowArrayControllerwill warn you if you use the deprecatedEmber.ArrayController. See http://emberjs.com/deprecations/v1.x/#toc_arraycontroller for details.disallowControllerNeedswill warn you if you're doing dependency injection via theneedsproperty on a controller. See http://emberjs.com/deprecations/v1.x/#toc_controller-needs for details.disallowFreezableMixinwill warn you if you use the deprecatedEmber.Freezablemixin. See http://emberjs.com/deprecations/v1.x/#toc_ember-freezeable for details.disallowObserverArgumentOrderingrequires thatEmber.observer()takes callable argument as the final argument. See http://emberjs.com/deprecations/v1.x/#toc_reversed-ember-observer-arguments for details.disallowCreateWithMixinswill warn you if you use the deprecatedEmber.Object.createWithMixinsmethod. See http://emberjs.com/deprecations/v1.x/#toc_ember-createwithmixins for details.disallowComputedAnywill warn you if you use the deprecatedEmber.computed.any()helper. See http://emberjs.com/deprecations/v1.x/#toc_ember-computed-any for details.disallowHandlebarsHelperswill warn you if you use the deprecatedEmber.HTMLBars.makeBoundHelper()orEmber.Handlebars.registerHelper()helpers. See http://emberjs.com/deprecations/v1.x/#toc_handlebars-htmlbars-helpers for details.
Deprecations added in Ember 2.0
None. Ember 2.0 removed support for the above deprecations.
Deprecations added in Ember 2.1
disallowInitializerAritywill warn you if you have more than 1 argument to an initializer. See http://emberjs.com/deprecations/v2.x/#toc_initializer-arity for details.disallowPrivateRegistryPropertywill warn you if you use one of the privateapp.registry.*deprecations. See http://emberjs.com/deprecations/v2.x/#toc_ember-application-registry-ember-applicationinstance-registry for details.disallowAppInstanceContainerwill warn you if you use the privateapp.container.lookup()depreprecation in an initializer. See http://emberjs.com/deprecations/v2.x/#toc_ember-applicationinstance-container for details.disallowDebugMissingArgumentswill warn you if you use one of theEmber.warn(),Ember.deprecate(),Ember.deprecateFunc()orEmber.computed.deprecatingAlias()function without passing in an options object that at a minimum contains anidproperty. See http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options for details.disallowDefaultLayoutwill warn you if you use thedefaultLayoutproperty inside a Component. See http://emberjs.com/deprecations/v2.x/#toc_ember-component-defaultlayout for details.disallowCurrentStatewill warn you if you use the privatecurrentStateor_currentStateproperty inside a Component. See http://emberjs.com/deprecations/v2.x/#toc_ember-component-currentstate for details.
Other Ember best practices
disallowPrototypeExtensionwill warn you if you are using.property(),.observes()orobservesBefore(). See http://guides.emberjs.com/v1.10.0/configuring-ember/disabling-prototype-extensions/#toc_functions for details.
Deprecations added in Ember 2.3
disallowInjectedContainerAccesswill warn you if you are using the injected container (this.container). See http://emberjs.com/deprecations/v2.x/#toc_injected-container-access for details.
License
This library is lovingly brought to you by @minichate. It is released under the MIT license.