Files
polaris-react/documentation/Console messages.md
Kaelig Deloumeau-Prigent a5e6e3b386 [Documentation] Add syntax highlighting to console logging guidelines (#764)
@tmlayton as mentioned earlier, this is where we have _some_ docs around deprecation.

This PR just makes it look nicer.
2018-12-17 10:37:18 -08:00

1.9 KiB
Raw Permalink Blame History

Console message guidelines

A console message provides developers with information that helps with debugging and maintaining code. Types of console messages include Deprecation and Recommendation.

Content guidelines

Its important to write console messages consistently and succinctly so its easy for developers to scan and understand quickly. To do this, follow this general content formula (fill in the blanks):

console.[type]('[prefix] message [url]');

Pro tip: Always mention the affected component.

Selecting the right message type

  • Use warn for messages that call for action, like Deprecationand Recommendation messages.
console.warn(
  'Deprecation: The `title` property on Tabs has been deprecated. Use `content` instead.',
);
  • For informative messages, use info
console.info('Your project is currently using v1.8.6');
  • If more than one message is necessary, wrap them with group and groupEnd
console.group('Polaris');
console.info('Your project is currently using v1.18.0');
console.warn(
  'Deprecation: The `title` property on Tabs has been deprecated. Use `content` instead. Read more in the v2.0.0 upgrade guide https://github.com/Shopify/polaris-react/blob/master/CHANGELOG.md#tabs-no-longer-accept-title-prop',
);
console.groupEnd();

Selecting the right prefix

  • Use Deprecation for messages that warn developers when component APIs are in the process of being replaced. Its important to notify developers of breaking changes ahead of their release.
  • Use Recommendation for messages that suggest actions that will optimize a developer workflow. For example, upgrading to a new version of the @shopify/polaris npm package.

Providing next steps and a call to action

Whenever possible provide a way for the developer to fix their code and if documentation is available, link to it.

For example: Read more at [url]