atom / spell-check

Spell check Atom package
MIT License
204 stars 121 forks source link

Allow for ES6 checkers that are exported as a default class. #250

Closed dmoonfire closed 6 years ago

dmoonfire commented 6 years ago

Requirements

When I originally wrote the plugin infrastructure, I had to use require.resolve to pass in the paths to the checker for the secondary processes. At the time, I was only using Coffee and ES5, so I just created a new version of the object and returned that.

When using later versions of Typescript and ES6, this is more difficult to do because of how ES6 modules work.

Description of the Change

When we load the checker via require, check to see if require.default exists. If it does, then treat it as a class that needs to be new checker.default().

Alternate Designs

Getting Typescript to generate a top-level instantiated object is difficult but not impossible. I thought it was better to allow working with the language and handling the two cases in the spell-check code instead of jumping through hoops with the plugins.

Benefits

Easier development of plugins.

Possible Drawbacks

A possibility of a class having a default property that is incorrectly tried to be called.

Applicable Issues

This is related to my work on getting additional plugins working with spell-checking.

lee-dohm commented 6 years ago

/cc @nathansobo