Skip to content

Latest commit

 

History

History
110 lines (96 loc) · 2.89 KB

File metadata and controls

110 lines (96 loc) · 2.89 KB

Defaults

Every rule can target multiple class attributes, callee names, variable names or template literal tags.

Read the concepts documentation first to learn why this is important and what different options there are to define where to look for tailwind classes.

The default configuration is designed to work with the most popular tailwind utilities:



If an utility is not supported or you have built your own, you can change the matchers in the configuration. If you want to extend the default config, you can import it from the plugin:



import {
  getDefaultCallees,
  getDefaultClassAttributes,
  getDefaultTags,
  getDefaultVariables
} from "eslint-plugin-readable-tailwind/api/defaults";


Extending the config

import eslintPluginReadableTailwind from "eslint-plugin-readable-tailwind";
import {
  getDefaultCallees,
  getDefaultClassAttributes,
  getDefaultVariables
} from "eslint-plugin-readable-tailwind/api/defaults";
import { MatcherType } from "eslint-plugin-readable-tailwind/api/types";


export default [
  {
    plugins: {
      "readable-tailwind": eslintPluginReadableTailwind
    },
    rules: {
      "readable-tailwind/multiline": ["warn", {
        callees: [
          ...getDefaultCallees(),
          [
            "myFunction", [
              {
                match: MatcherType.String
              }
            ]
          ]
        ]
      }],
      "readable-tailwind/no-duplicate-classes": ["warn", {
        classAttributes: [
          ...getDefaultClassAttributes(),
          [
            "myAttribute", [
              {
                match: MatcherType.String
              }
            ]
          ]
        ]
      }],
      "readable-tailwind/no-unnecessary-whitespace": ["warn", {
        variables: [
          ...getDefaultVariables(),
          [
            "myVariable", [
              {
                match: MatcherType.String
              }
            ]
          ]
        ]
      }],
      "readable-tailwind/sort-classes": ["warn", {
        classAttributes: [
          ...getDefaultTags(),
          [
            "myTag", [
              {
                match: MatcherType.String
              }
            ]
          ]
        ]
      }]
    }
  }
];