I'm trying to write an in-house stylelint rule that we want to apply to mixins, e.g.
const mixin = css`
/* Linter rule SHOULD apply here */
`;
but not to styled components, e.g.
const Component = styled.div`
/* Linter rule should NOT apply here */
`;
Basically I want to access the result of isHelper() from within a stylelint rule. One way I could imagine this being implemented is to add another map to index.js (e.g. isHelperMap) and export it, so that in my rule I could run this check:
const { isHelperMap } = require('stylelint-processor-styled-components');
module.exports = stylelint.createPlugin(
ruleName,
(actual, secondary, context) => {
return function(root, result) {
if (isHelperMap[root.source.input.file]) {
// ...
}
}
}
);
It might be even more useful to provide the type of helper in the map, e.g. "css", "keyframes", or "injectGlobal".