Code Monkey home page Code Monkey logo

prettier-react-tachyons's Introduction

@observablehq/prettier-react-tachyons

Node CI

A prettier custom parser plugin for users of React and tachyons. It adds an extra prettier transform for className= attributes on JSX elements, that takes care of the following:

  • Eliminating redundant classes
  • Sorting classes in a predictable order

How do you use it?

This is admittedly a little bleeding-edge: prettier supports custom parsers, but not custom rules / reformatters, so this essentially augments prettier's babylon-based parser for JavaScript. You can configure prettier to point to it with the parser option. For instance, here's how we configure prettier in our .prettierrc:

{
  "parser": "./node_modules/@observablehq/prettier-react-tachyons"
}

Example:

in:

<div className='h1 h1 w2 pv2 bg-transparent red' />

out:

<div className='w2 h1 pv2 red bg-transparent' />

prettier-react-tachyons's People

Contributors

jashkenas avatar tmcw avatar visnup avatar wiltsecarpenter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

prettier-react-tachyons's Issues

This is awesome! ๐Ÿ’ฅ

Just a token of appreciation from Accurat developers team ๐Ÿ˜„

Do you have any idea if it would be difficult to implement as an eslint plugin?

Markdown usage appears broken

When using this parser, I get a Prettier: failed to parse buffer error for markdown files. I'm just editing a README in a pretty standard app using create-react-app

Here's my prettier config from package.json:

  "prettier": {
    "parser": "./node_modules/@observablehq/prettier-react-tachyons",
    "autoformat": 0,
    "semi": false,
    "arrowParens": "avoid",
    "trailingComma": "none",
    "jsxBracketSameLine": false,
    "bracketSpacing": true,
    "singleQuote": true
  }

flex-column is not a display class, should not go first

This diff is wrong:

-        className="flex-column w2 items-stretch black-50 hover-bg-light-gray ba b--black-10 br2 inline-flex pointer overflow-hidden"
+        className="flex-column inline-flex w2 items-stretch black-50 hover-bg-light-gray ba b--black-10 br2 pointer overflow-hidden"

flex-column is being treated like it's a variation of flex like flex-ns but it should not be, it only augments a flex or inline-flex class.

Doesn't work with prettier-atom

Hey, first congrats on this project, it's awesome!

I wanted to try it with prettier-atom since it runs prettier on the file save, but it's not working, I'm getting this error even after having installed the dependency.

image

Any way it could work with the atom editor?

Recursively deal with expressions

                className={`inline-flex f6 items-center inline-flex pa1 ${creator.following
                  ? "black-70 bg-white"
                  : "black-20"} hover-bg-light-gray ba b--black-10 br2 fw5 pointer`}

I've been punting on this one, but... it's possible and I should think about handling it, at least.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.