npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@griffel/postcss-syntax

v1.3.15

Published

postcss syntax for Griffel

Readme

PostCSS syntax for Griffel

A PostCSS custom syntax that exposes the CSS generated by Griffel to CSS tooling, most notably stylelint.

Griffel compiles makeStyles() and makeResetStyles() calls to atomic CSS ahead of time, so that CSS never exists as a .css file and a CSS linter has nothing to read. This package closes that gap: it runs the Griffel transform over a JavaScript/TypeScript file and returns a PostCSS AST of the generated CSS, with source locations that point back to the original JavaScript.

Install

yarn add --dev @griffel/postcss-syntax
# or
npm install --save-dev @griffel/postcss-syntax

⚠️ This package is ESM only. If your project is CommonJS, use stylelint.config.mjs rather than .stylelintrc.js, as the latter is loaded with require().

Usage with stylelint

Stylelint calls a PostCSS syntax a custom syntax. Point customSyntax at this package:

{
  "customSyntax": "@griffel/postcss-syntax",
  "rules": {
    "selector-anb-no-unmatchable": true
  }
}

Then lint your style files:

npx stylelint "src/**/*.styles.ts"

For example, this file:

import { makeStyles } from '@griffel/react';

export const useStyles = makeStyles({
  root: {
    ':nth-child(0)': { color: 'red' },
  },
});

...generates .fwey13v:nth-child(0){color:red;}, which makes stylelint report selector-anb-no-unmatchable. The reported location points at the root slot in example.styles.ts, not at the generated CSS.

Disabling rules

stylelint-disable comments cannot be placed in generated CSS, so use a griffel-csslint-disable comment directive instead. For makeStyles() place it above a slot:

export const useStyles = makeStyles({
  // griffel-csslint-disable selector-anb-no-unmatchable
  root: {
    ':nth-child(0)': { color: 'red' },
  },
});

For makeResetStyles() place it above the declaration:

// griffel-csslint-disable selector-anb-no-unmatchable
export const useResetStyles = makeResetStyles({
  ':nth-child(0)': { color: 'red' },
});

A directive must be a line comment (//) and disables exactly one rule. To disable several rules, use several comments:

export const useStyles = makeStyles({
  // griffel-csslint-disable selector-anb-no-unmatchable
  // griffel-csslint-disable declaration-property-value-no-unknown
  root: {/* ... */},
});

Linting custom wrappers

By default only makeStyles()/makeResetStyles() imported from @griffel/core, @griffel/react or @fluentui/react-components are processed. If your project re-exports them from its own package, use createSyntax() to build a configured syntax:

import { createSyntax } from '@griffel/postcss-syntax';

export default {
  customSyntax: createSyntax({
    importsToTransform: ['@griffel/react', '@myScope/griffel'],
  }),
  rules: {
    'selector-anb-no-unmatchable': true,
  },
};

createSyntax() accepts:

| Option | Type | Default | Description | | ---------------------- | ---------- | ------------------------------------------------------------------- | ------------------------------------------------------------- | | importsToTransform | string[] | ['@griffel/core', '@griffel/react', '@fluentui/react-components'] | Modules whose Griffel imports should be processed. | | functionsToTransform | string[] | ['makeStyles', 'makeResetStyles', 'makeStaticStyles'] | Function names that should be treated as Griffel style calls. |

⚠️ Both options replace their defaults rather than extend them. Keep @griffel/react in the list if you also import from it directly.

API

  • parse(css, options?) — parses a JavaScript/TypeScript source and returns a PostCSS AST of the generated CSS. Supports from, silenceParseErrors, importsToTransform and functionsToTransform.
  • stringify(node, builder) — the matching stringifier.
  • createSyntax(options) — returns a { parse, stringify } syntax configured with the options above.

When a file cannot be parsed, parse() emits a /* Failed to parse griffel styles: <file> */ comment and logs the error. Pass silenceParseErrors: true to suppress the log.

Limitations

  • Only makeStyles() and makeResetStyles() produce CSS, and both must be statically evaluable, see limitations of the build time transform.
  • The stringifier only works on an AST produced by this syntax, as Griffel's ahead of time compilation cannot map generated CSS back to the original JavaScript accurately enough for arbitrary input. For the same reason stylelint's --fix is not supported.