Skip to content
This repository has been archived by the owner before Nov 9, 2022. It is now read-only.


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time


Lint your styled components with stylelint!

Build Status Coverage Status Join the community on Spectrum Greenkeeper

Video of project in use


You need:

(npm install --save-dev \
  stylelint \
  stylelint-processor-styled-components \
  stylelint-config-styled-components \

Now use those in your .stylelintrc and run stylelint with your JavaScript files!

  "processors": ["stylelint-processor-styled-components"],
  "extends": [

NOTE: The processor works with Flow- and TypeScript-typed files too! (we'll assume TypeScript usage if your files end in .ts or .tsx)

And it also has some options. Their default values are,

  "processors": [["stylelint-processor-styled-components", {
    "moduleName": "styled-components",
    "importName": "default",
    "strict": false,
    "ignoreFiles": [],
    "parserPlugins": [
      ["decorators", { "decoratorsBeforeExport": true }],
  • Combining with moduleName, importName and strict, you can tell the processor what kinds of tagged template literals to lint.
import styled, { css, keyframes } from 'styled-components';

// `importName` from `moduleName`, which means where `styled` comes from

// any other imports from `moduleName` (if `strict` is true, they will not be linted)

// special extend calls, which have been deprecated in styled-components v4

  • ignoreFiles is passed to micromatch as the second parameter, which means one or more glob patterns for matching.

  • parserPlugins is used to make the processor's parser be able to parse new syntaxes. All available babel parser plugins and related options can be found in Babel's website.


Further documentation for this processor lives on the styled-components website!


Why does it throw Unexpected token? Even thought the file didn't import styled-components.

You can custom babel plugins by option.parserPlugins now. An API example is our test. But if someone can implement #231, that will be much better.

If your project includes yarn.lock or package-lock.json, an alternative cause can be that babel related dependencies, i.e. @babel/parser and @babel/traverse, are outdated, especially when linting files with new TypeScript syntaxes. You can upgrade them by removing their entries in the lockfile and reinstall dependencies.

Why does it throw unexpected lint errors?

The processor can not always parse interpolations with right things. But you can use interpolation-tagging to help it. If you have ideas to make it more intelligent, feel free to send a PR or share your solution by an new issue.

What's more, if set syntax: css-in-js in stylelint@10, it can extract styles from styled-components without this processor. Even though there are still lots of differences with this processor, we hope this processor's abilities can be migrated to stylelint totally in the future.

I don't want specified tagged template literal to be parsed, i.e. css.

You can set option.strict. More examples are in #258.


Licensed under the MIT License, Copyright © 2017 Maximilian Stoiber. See for more information!

Based on Mapbox' excellent stylelint-processor-markdown, thanks to @davidtheclark!