vastec / ember-unused-components

Search for unused components in your Ember project
51 stars 12 forks source link

Better component matching #3

Closed ctjhoa closed 5 years ago

ctjhoa commented 5 years ago

Hi I just discover your repository while trying to write similar addon and it's a great discovery!

You can find my experimental addon here I took a different approach I've written all the main part in a bash script (I don't care about OS compatibility for the moment).

I've discover that your addon miss some cases like inheritance, for example.

// components/concrete.js
import AbstractComponent from 'my-app/components/abstract';

export default AbstractComponent.extend({
   // do stuff
})

or some addons like ember-light-table declare stuff like:

// components/my-table.js
import { computed } from '@ember/object';
import Table from 'ember-light-table';

export default Ember.Component.extend({
  model: null,

  columns: computed(function() {
    return [{
      label: 'Avatar',
      valuePath: 'avatar',
      width: '60px',
      sortable: false,
      cellComponent: 'user-avatar' // <----- here is the issue
    }];
  }),

  table: computed('model', function() {
   return new Table(this.get('columns'), this.get('model'));
  })
});

So I made a PR to fix that -> #2

tniezurawski commented 5 years ago

Hi @ctjhoa, sorry for a very very long delay. You've made awesome work reporting all the issues and creating Pull Requests! Big thank you!

In fact, I was thinking about rewriting this addon into a bash script or pure npm package :D It seems like an addon might be too much here. What do you think about that?

I know there are many cases where this addon is not working properly but TBH I don't have much time to improve it or even test proposed changes.

tniezurawski commented 5 years ago

When it comes to ember-light-table I must admit - addon is not prepared for that.

I'm not sure what approach should I take here. IMO the best would be to check if such an addon is used based on package.json and then use predefined rules. That could help with changes in supported add-ons. Still, not an easy task to do but doable.

ctjhoa commented 5 years ago

2 fix the two issues so I close this ticket