Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@stylelint/postcss-css-in-js

stylelint2.7mMITdeprecated0.38.0

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

PostCSS syntax for parsing CSS in JS literals

postcss, syntax, emotion, aphrodite, glamor, glamorous, react-native, react-style, reactcss, styled-components, styletron-react, typestyle, css-in-js, css

readme

PostCSS CSS-in-JS Syntax

NPM version Build Status

PostCSS syntax for parsing CSS in JS literals:

Getting Started

First thing's first, install the module:

npm install postcss-syntax @stylelint/postcss-css-in-js --save-dev

Use Cases

const postcss = require("postcss");
const stylelint = require("stylelint");
const syntax = require("postcss-syntax");
postcss([stylelint({ fix: true })])
  .process(source, { syntax: syntax })
  .then(function (result) {
    // An alias for the result.css property. Use it with syntaxes that generate non-CSS output.
    result.content;
  });

input:

import glm from "glamorous";
const Component1 = glm.a({
  flexDirectionn: "row",
  display: "inline-block",
  color: "#fff"
});

output:

import glm from "glamorous";
const Component1 = glm.a({
  color: "#fff",
  display: "inline-block",
  flexDirectionn: "row"
});

Advanced Use Cases

Add support for more css-in-js package:

const syntax = require("postcss-syntax")({
  "i-css": (index, namespace) => namespace[index + 1] === "addStyles",
  "styled-components": true
});

See: postcss-syntax

Style Transformations

The main use case of this plugin is to apply PostCSS transformations to CSS code in template literals & styles as object literals.

changelog

Changelog

0.38.0

  • Removed: hardcoded transform from float to cssFloat in objects (#172)
  • Fixed: silent fail if @babel/plugin-proposal-decorators is in user's Babel configuration (#237)

0.37.3

  • Fixed: silent fail if Babel config is present (#258).

0.37.2

  • Fixed: use HTTPS url instead of HTTP for postcss logo in README (#39).

0.37.1

  • Fixed: maximum call stack size exceeded error (#31).

0.37.0

  • Fixed: babel configuration conflict when using TypeScript (#2).
  • Fixed: parsing/stringifying for nested tagged template literals (#17).

Previous changes

See postcss-jsx releases.