ember-codemods / es5-getter-ember-codemod

34 stars 14 forks source link

Add support for getProperties with keys passed as Array #32

Closed ctjhoa closed 4 years ago

ctjhoa commented 4 years ago

https://api.emberjs.com/ember/release/functions/@ember%2Fobject/getProperties https://api.emberjs.com/ember/3.17/classes/Component/methods/getProperties?anchor=getProperties

Ember getProperties can take an array of keys as argument. This case wasn't covered previously and leads to an error.

    TypeError: Cannot read property 'indexOf' of undefined

      91 |         // check that there are no "deep" paths (e.g. "foo.bar")
      92 |         return path.node.arguments.every(
    > 93 |           (arg) => arg.value.indexOf('.') === -1
         |                              ^
      94 |         );
      95 |       })
      96 |       .forEach((path) => {

      at indexOf (transforms/es5-getter-ember-codemod/index.js:93:30)
          at Array.every (<anonymous>)
      at every (transforms/es5-getter-ember-codemod/index.js:92:36)
          at Array.filter (<anonymous>)
      at Collection.filter (node_modules/jscodeshift/dist/Collection.js:66:46)
      at filter (transforms/es5-getter-ember-codemod/index.js:82:8)
      at transformGetPropertiesOnObject (transforms/es5-getter-ember-codemod/index.js:167:3)
      at runInlineTest (node_modules/jscodeshift/dist/testUtils.js:28:18)
      at Object.<anonymous> (node_modules/codemod-cli/src/test-support.js:61:13)