GithubHelp home page GithubHelp logo

nju33 / eslint-plugin-tailwindcss-jit-restrict Goto Github PK

View Code? Open in Web Editor NEW
2.0 0.0 0.0 46.01 MB

To be restricted from using all of or partially arbitrary values in jit mode.

Home Page: https://www.npmjs.com/package/eslint-plugin-tailwindcss-jit-restrict

JavaScript 96.91% Shell 0.74% TypeScript 2.36%
gitpod-workspace

eslint-plugin-tailwindcss-jit-restrict's Introduction

eslint-plugin-tailwindcss-jit-restrict

To be restricted from using all of or partially arbitrary values in jit mode.

Install

yarn add --dev eslint-plugin-tailwindcss-jit-restrict
// or
npm install --save-dev eslint-plugin-tailwindcss-jit-restrict

How to use

Firstly, you'll set tailwindcss-jit-restrict to plugins. Then, its restrict rule is also set.

{
  "plugins": ["tailwindcss-jit-restrict"],
  "rules": {
    "tailwindcss-jit-restrict/restrict": "error"
  }
}

Now, all of arbitrary values—such as w-[500px]—becomes eslint error.

Advanced

If you want to allow some arbitrary values to be useed, you can specify white list by setting the rule option.

For instance, you think that you want only to use w-[500px] mentioned earlier, you do that set in the following.

{
  "plugins": ["tailwindcss-jit-restrict"],
  "rules": {
    "tailwindcss-jit-restrict/restrict": [
      "error",
      { "whiteList": ["w-[500px]"] }
    ]
  }
}

Here, you can set values of the whiteList as array of strings. In other words, you think that you want to add more the whiteList—for instance h-[350px]—, then you just add it.

{
  "plugins": ["tailwindcss-jit-restrict"],
  "rules": {
    "tailwindcss-jit-restrict/restrict": [
      "error",
      { "whiteList": ["w-[500px]", "h-[350px]"] }
    ]
  }
}

However, if you have a lots of white list, This is awful. So, this plugin lets you write by glob.

For instance, you want to allow all of arbitrary values for the width to be used, you should do in the following.

{
  "plugins": ["tailwindcss-jit-restrict"],
  "rules": {
    "tailwindcss-jit-restrict/restrict": ["error", { "whiteList": ["w-*"] }]
  }
}

For instance, you want only to allow not all but some, you can also be in the following. (You only allow w-[350px], w-[500px] and w-[750px] to be used.)

{
  "plugins": ["tailwindcss-jit-restrict"],
  "rules": {
    "tailwindcss-jit-restrict/restrict": [
      "error",
      { "whiteList": ["w-\\[@(350|500|750)px\\]"] }
    ]
  }
}

eslint-plugin-tailwindcss-jit-restrict's People

Stargazers

 avatar  avatar

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.