Skip to content

Conversation

@zweimach
Copy link
Contributor

Add support for custom utilities

Description

This PR adds support for recognizing custom utilities as whitelist classnames for no-custom-classname rule.

Only works on custom utilities and does not support other custom plugins

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

npm test

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@zweimach
Copy link
Contributor Author

Please review and refine my small contribution to your preferences, as this is my first time working on ESLint plugins.

@francoismassart
Copy link
Owner

Thanks I'll take the time to try this out after the weekend.

@francoismassart francoismassart merged commit f3cacca into francoismassart:master May 31, 2021
@thebuilder
Copy link
Contributor

This PR seems to break in a few different ways. All the errors occur in the extractPlugin function:
https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/26/files#diff-b8144a7e4161e7f8b23218be5e95d75a9a3b5a01bf897fd4965c52ec37fb7fa4R40

Using official plugins:

require('@tailwindcss/typography')
TypeError: Error while loading rule 'tailwindcss/no-custom-classname': plugin.handler is not a function

Using addVariant in a custom plugin:

      addVariant('dark', ({ modifySelectors, separator }) => {
        modifySelectors(({ className }) => {
          return `.theme-dark .${e(`dark${separator}${className}`)}`;
        });
      });
TypeError: Error while loading rule 'tailwindcss/no-custom-classname': addVariant is not a function

Using variants:

plugin(({ addUtilities, addVariant, variants, e }) => {
      addUtilities(
        {
          '.flip-x': {
            '--tw-scale-x': '-1',
          },
          '.flip-y': {
            '--tw-scale-y': '-1',
          },
        },
        variants('flip')
      );
    }), 
TypeError: Error while loading rule 'tailwindcss/no-custom-classname': variants is not a function

@thebuilder
Copy link
Contributor

@francoismassart this seems to have broken the plugin in 1.9.0.

@francoismassart
Copy link
Owner

Yup I'll revert, I had the same issue with theme

francoismassart added a commit that referenced this pull request May 31, 2021
This reverts commit f3cacca.

# Conflicts:
#	lib/util/plugin.js
@francoismassart
Copy link
Owner

use v1.9.1 for now, I'll unpublish v1.9.0

@zweimach zweimach deleted the custom-plugins branch January 11, 2022 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants