All Projects → styled-components → Stylelint Processor Styled Components

styled-components / Stylelint Processor Styled Components

Licence: mit
Lint your styled components with stylelint!

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Stylelint Processor Styled Components

Vscode Stylelint
A Visual Studio Code extension to lint CSS/SCSS/Less with stylelint
Stars: ✭ 260 (-59.31%)
Mutual labels:  linter, stylelint, styled-components
Husky.Net
Git hooks made easy with Husky.Net internal task runner! 🐶 It brings the dev-dependency concept to the .NET world!
Stars: ✭ 394 (-38.34%)
Mutual labels:  stylelint, linting, linter
dockerfile-utils
A library and command line interface for formatting and linting Dockerfiles.
Stars: ✭ 17 (-97.34%)
Mutual labels:  linting, linter
codeclimate-eslint
Code Climate Engine for ESLint
Stars: ✭ 86 (-86.54%)
Mutual labels:  linting, linter
addlint
An example linter written with go/analysis for tutorial purposes
Stars: ✭ 49 (-92.33%)
Mutual labels:  linting, linter
stylelint-config-styled-components
The shareable stylelint config for stylelint-processor-styled-components
Stars: ✭ 66 (-89.67%)
Mutual labels:  stylelint, styled-components
vscode-stylelint-plus
A Visual Studio Code extension to lint CSS/SCSS/Less with stylelint, support auto fix on save.
Stars: ✭ 32 (-94.99%)
Mutual labels:  stylelint, linter
ue5-style-guide
An attempt to make Unreal Engine 4 projects more consistent
Stars: ✭ 2,892 (+352.58%)
Mutual labels:  linting, linter
Golite
Add essential language support for the Go language to Sublime Text 3.
Stars: ✭ 14 (-97.81%)
Mutual labels:  linting, linter
elint
A easy way to lint your code
Stars: ✭ 38 (-94.05%)
Mutual labels:  stylelint, linter
JSONCustomLintr
Library to allow creation, running, and reporting of custom lint rules for JSON files
Stars: ✭ 19 (-97.03%)
Mutual labels:  linting, linter
Android-CICD
This repo demonstrates how to work on CI/CD for Mobile Apps 📱 using Github Actions 💊 + Firebase Distribution 🎉
Stars: ✭ 37 (-94.21%)
Mutual labels:  linting, linter
makefiles
No description or website provided.
Stars: ✭ 23 (-96.4%)
Mutual labels:  linting, linter
li18nt
🌎 Lint your i18n translation files. Detect conflicting properties, duplicates and make it more readable and easier to maintain by formatting it!
Stars: ✭ 29 (-95.46%)
Mutual labels:  linting, linter
react-component-library-lerna
Build your own React component library managed with lerna, presented with storybook and published in private npm registry.
Stars: ✭ 55 (-91.39%)
Mutual labels:  stylelint, styled-components
stylelint-config-xo
Stylelint shareable config for XO
Stars: ✭ 34 (-94.68%)
Mutual labels:  stylelint, linting
flake8-broken-line
🚨 Flake8 plugin to forbid backslashes (\) for line breaks
Stars: ✭ 85 (-86.7%)
Mutual labels:  linting, linter
sonar-css-plugin
SonarQube CSS / SCSS / Less Analyzer
Stars: ✭ 46 (-92.8%)
Mutual labels:  stylelint, linter
therapist
Work out your commitment issues.
Stars: ✭ 29 (-95.46%)
Mutual labels:  linting, linter
stylelint-processor-glamorous
💄 Lint glamorous and related css-in-js with stylelint
Stars: ✭ 18 (-97.18%)
Mutual labels:  stylelint, linter

stylelint-processor-styled-components

Lint your styled components with stylelint!

Build Status Coverage Status Join the community on Spectrum Greenkeeper

Video of project in use

Setup

You need:

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

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

{
  "processors": ["stylelint-processor-styled-components"],
  "extends": [
    "stylelint-config-recommended",
    "stylelint-config-styled-components"
  ]
}

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": [
      "jsx",
      ["decorators", { "decoratorsBeforeExport": true }],
      "classProperties",
      "exportExtensions",
      "functionBind",
      "functionSent"
    ]
  }]]
}
  • 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
styled(Component)``;
styled('div')``;
styled.div``;

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

// special extend calls, which have been deprecated in styled-components v4
Component.extend``;

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

Documentation

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

F.A.Q.

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 [email protected], 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.

License

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

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].