New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from May 25, 2018

Conversation

Projects
None yet
3 participants
@dmoonfire
Contributor

dmoonfire commented Apr 23, 2018

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.

dmoonfire added some commits Apr 23, 2018

Allow for ES6 checkers that are exported as a default class.
* Updated documentation with an example.
@lee-dohm

This comment has been minimized.

Member

lee-dohm commented May 1, 2018

@daviwil

Looks good to me!

@daviwil daviwil merged commit a4313c9 into atom:master May 25, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment