One of the key benefits of the PostCSS ecosystem is its flexibility—it allows any developer to create any plugin, or adapt existing ones, as long as the license allows for further development!
To help retain a sense of consistency, the developer has issued a series of mandatory guidelines, which should be followed where practical:
The name of your plugin should clearly indicate the purpose of that plugin—for example, if you built one to mimic the CSS4
:hover
pseudo-class, thenpostcss-hover
would be a good example.It is better to create a plugin that does one thing well, and not one that tries to perform multiple tasks at the same time.
Always use the
postcss.plugin
method when creating plugins—you are then hooking into a common plugin API.Where possible, try to use asynchronous methods—you should also set a
node.source
for each node, so that PostCSS can generate an accurate source map.Do not use the console when displaying errors—some PostCSS runners do not allow...