@sencha/extjs/no-existing-alias-override

Report the overriding of an existing alias

Rule Details

This rule will report when an existing alias is being overridden.

In this example, we are defining several classes that use an alias of an existing Class. Since an alias needs to be unique, overriding an existing alias can cause unexpected results. This problem can easily be caught by enabling this rule.

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-existing-alias-override": "warn"
  22. }
  23. }

JavaScript

  1. // 'dashboard' did not exist in 4 but does in a later version
  2. Ext.define('MyCustomDashboard', {
  3. xtype: 'dashboard'
  4. });
  5. // 'widget.widgetcolumn' did not exist in 4 but does in a later version
  6. Ext.define('MyCustomGridWidgetColumn', {
  7. alias: 'widget.widgetcolumn'
  8. });
  9. // 'breadcrumb' did not exist in 4 but does in a later version
  10. Ext.define('MyCustomBreadCrumb', {
  11. xtype: 'breadcrumb'
  12. });
  13. // 'store.chained' did not exist in 4 but does in a later version
  14. Ext.define('MyCustomChainedStore', {
  15. extend: 'Ext.data.AbstractStore',
  16. alias: 'store.chained',
  17. });

Problem Messages reported by ESLint

  1. Override of existing alias 'widget.dashboard' found for 'Ext.dashboard.Dashboard'
  2. Override of existing alias 'widget.widgetcolumn' found for 'Ext.grid.column.Widget'
  3. Override of existing alias 'widget.breadcrumb' found for 'Ext.toolbar.Breadcrumb'
  4. Override of existing alias 'store.chained' found for 'Ext.data.ChainedStore'