Skip to content
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

[WIP] [BREAKING] add this.warn method to plugin contexts #1231

Merged
merged 3 commits into from
Jan 6, 2017
Merged

Conversation

Rich-Harris
Copy link
Contributor

@Rich-Harris Rich-Harris commented Jan 6, 2017

See #1140. This adds this.warn to plugin transform hooks. Usage:

// simple case — a string
this.warn( 'a message' );

// equivalent to
this.warn({ message: 'a message' });

// custom code/other data
this.warn({
  code: 'MY_CUSTOM_CODE', // defaults to 'PLUGIN_WARNING'
  message: 'a message',
  foo: 'bar'
});

// include a character position that the warning pertains to. this
// will cause `pos`, `loc` and `frame` properties to be added
// to the warning object, as with internal `module.warn(...)`
this.warn( 'a message', 42 );

In addition to code, pos, loc and frame properties, a plugin property will be added which is the plugin's name.

TODO:

  • this.error(...) helper
  • Update toString method to include plugin name
  • Update CLI to print plugin name

@Rich-Harris Rich-Harris changed the title [WIP] add this.warn method to plugin contexts [WIP] [BREAKING] add this.warn method to plugin contexts Jan 6, 2017
@Rich-Harris
Copy link
Contributor Author

Technically a breaking change (it no longer manipulates error messages) so should be a 0.41 release, though unlikely to actually cause breakage in the wild.

@Rich-Harris Rich-Harris merged commit e955ea7 into master Jan 6, 2017
@Rich-Harris Rich-Harris deleted the gh-1140 branch January 6, 2017 21:59
@tivac
Copy link
Contributor

tivac commented Jan 6, 2017

@Rich-Harris do you have time to document this on the wiki? I'd love to add support but I haven't had a chance to fully grok this yet. Even some light docs would be really useful!

@Rich-Harris
Copy link
Contributor Author

@tivac
Copy link
Contributor

tivac commented Jan 7, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants