Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.
This repository was archived by the owner on May 14, 2021. It is now read-only.

Distinguish helpers/mixins from component styles #244

@TrevorBurnham

Description

@TrevorBurnham

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".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions