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

Report the overriding of an existing method

Rule Details

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

In this example, getModel is an existing method of the Ext.app.Application Class since version 4 and getName is an existing getter method from the name config of the Ext.app.Application Class since version 5. It goes without saying that accidentally overriding these methods could cause your application to not start or to have unexpected results. And what could have been an ok method to override or define in an earlier version of the framework could be conflicting in the version you wish to upgrade to. So by configuring to use this no-existing-method-override rule, problems will be reported when you accidentally do so.

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

JavaScript

  1. Ext.define('MyApp.Application', {
  2. extend: 'Ext.app.Application',
  3. name: 'MyApp',
  4. getModel: Ext.emptyFn,
  5. getName: Ext.emptyFn
  6. });

Problem Messages reported by ESLint

  1. Override of existing method 'getModel' found for 'Ext.app.Application'
  2. Override of existing method 'getName', for the 'name' config, found for 'Ext.app.Application'