Closed jonathantneal closed 5 years ago
Removed: warnings and noValueNotifications options, as this should be the job of a linter tool.
Not sure a linter will be able to properly check all of this, especially for cases where the custom properties are defined in separate files, or imported from JS.
@pascalduez, I’ll look into it, but this could also be added in a future minor if there is significant demand. Otherwise, linters should add similar importFrom
functionality; this would be especially true for postcss-preset-env users, who might skip running this plugin altogether based upon their browserslist.
this would be especially true for postcss-preset-env users, who might skip running this plugin altogether based upon their browserslist.
Good point! :)
@jonathantneal @pascalduez adding my +1 to bring back the warnings option even though it probably should be a linter responsibility. Looked into using stylelint led to a dead end: https://github.com/stylelint/stylelint/issues/2220
@gpoitch I'll give a try at creating a stylelint plugin, makes me quite curious.
@gpoitch, @pascalduez, that poor issue was opened before its time. 😞
If it helps, I spent some time tonight trying to learn how one writes a stylelint plugin. Maybe this is an okay template?
https://github.com/csstools/stylelint-value-no-unknown-custom-properties
@pascalduez, @gpoitch. I’ve published the plugin.
https://github.com/csstools/stylelint-value-no-unknown-custom-properties
New features
exportTo
function to specify where to export custom properties to.importFrom
option to specify where to import custom properties from.html
rules.:root
are not also transformed.preserve
istrue
.Removed features
strict
option, as using the fallback value isn’t necessarily more valid.preserve: "computed"
option, as there seems to be little use in preserving custom property declarations while removing all usages of them.warnings
andnoValueNotifications
options, as this should be the job of a linter tool.variables
option, which is now replaced byimportFrom
appendVariables
option, which is now replaced byexportTo
Resolves
Resolves #80 Resolves #100 Resolves #102 Resolves #109 Resolves #113 Resolves #122 Resolves #124 Resolves #125 Resolves #129 Resolves #131
With this update, all of the “custom” plugins (Custom Properties, Custom Selectors, and Custom Media) will be able to import and export variables to and from CSS, JS, and JSON files.
These features and some fixes resolve every open single issue in the repository. Namely, this update resolves the issue with Webpack users needing to reference variables from a single, master file.
This update also allows communication from PostCSS to client-side libraries that want to reference custom properties, selectors, or media in JS. This update also allows communication to PostCSS from design apps that can export master files of custom properties, selectors, and media themselves.