@sencha/extjs/no-deprecated-class-usage

Report the usage of a deprecated Class

Rule Details

This rule will report when a deprecated class is being used.

In this example, we are showing various ways to use a deprecated class. All of these examples are of classes that have been deprecated in earlier versions. So upgrading to the latest version will result in these problems be reported.

ESLint Config

  1. {
  2. "plugins": [
  3. "@sencha/extjs"
  4. ],
  5. "extends": [
  6. // this rule is in the recommended configuration list
  7. // so including this line enables this rule
  8. "plugin:@sencha/extjs/recommended"
  9. ],
  10. "settings": {
  11. "extjs": {
  12. "toolkit": "classic",
  13. "fromVersion": 4,
  14. "toVersion": 'latest'
  15. }
  16. },
  17. "rules": {
  18. // optionally, you can specify the rule explicitly
  19. // and the errorlevel and any options set here
  20. // will override any defaults from the 'extends' section
  21. "@sencha/extjs/no-deprecated-class-usage": "warn"
  22. }
  23. }

JavaScript

  1. // Extending a deprecated Class using Ext.extend()
  2. var MyCustomClass = Ext.extend(Ext.AbstractManager, {
  3. customProp: true
  4. });
  5. // Using a conditional to extend a deprecated Class
  6. var MyCustomDataClass = Ext.extend(true ? Ext.data.Types : Ext.data.Error, {
  7. customProp: true
  8. });
  9. // Defining a new Class that extends a deprecated Class
  10. Ext.define('MyCustomPlugin', {
  11. extend: 'Ext.plugin.Responsive'
  12. });
  13. // Overriding a deprecated Class
  14. Ext.define('overrides.Draggable', {
  15. override: 'Ext.util.Draggable'
  16. });
  17. // Creating an instance of a deprecated Class by calling Ext.create
  18. Ext.create('Ext.util.Draggable', {});
  19. // Creating an instance of a deprecated Class by calling Ext.create and using the 'xclass' property
  20. Ext.create({xclass: 'Ext.util.Draggable'});
  21. // Creating an instance of a deprecated Class by calling Ext.create and using the 'xtype' property
  22. Ext.create({xtype: 'trigger'});
  23. // Creating an instance of a deprecated Class using the 'new' keyword
  24. new Ext.util.Draggable({});
  25. // Adding to the prototoype of a deprecated Class wil give you this warning
  26. Ext.util.Draggable.prototype.customMethod = function () {};

Problem Messages reported by ESLint

  1. Usage of deprecated Class 'Ext.AbstractManager' found
  2. Usage of deprecated Class 'Ext.data.Types' found
  3. Usage of deprecated Class 'Ext.data.Error' found
  4. Usage of deprecated Class 'Ext.plugin.Responsive' found
  5. Usage of deprecated Class 'Ext.util.Draggable' found
  6. Usage of deprecated Class 'Ext.form.field.Trigger' found