eslint-plugin-tailwindcss
Advanced tools
Comparing version 3.8.0-beta.0 to 3.8.0
@@ -70,2 +70,3 @@ /** | ||
const twConfig = getOption(context, 'config'); | ||
const classRegex = getOption(context, 'classRegex'); | ||
const removeDuplicates = getOption(context, 'removeDuplicates'); | ||
@@ -131,4 +132,6 @@ | ||
case 'ObjectExpression': | ||
const isUsedByClassNamesPlugin = node.callee && node.callee.name === 'classnames'; | ||
arg.properties.forEach((prop) => { | ||
sortNodeArgumentValue(node, prop.key); | ||
sortNodeArgumentValue(node, isUsedByClassNamesPlugin ? prop.key : prop.value); | ||
}); | ||
@@ -202,3 +205,3 @@ return; | ||
const attributeVisitor = function (node) { | ||
if (!astUtil.isClassAttribute(node) || skipClassAttribute) { | ||
if (!astUtil.isClassAttribute(node, classRegex) || skipClassAttribute) { | ||
return; | ||
@@ -205,0 +208,0 @@ } |
@@ -11,3 +11,2 @@ /** | ||
const groupUtil = require('../util/groupMethods'); | ||
const removeDuplicatesFromClassnamesAndWhitespaces = require('../util/removeDuplicatesFromClassnamesAndWhitespaces'); | ||
const getOption = require('../util/settings'); | ||
@@ -64,2 +63,3 @@ const parserUtil = require('../util/parser'); | ||
const twConfig = getOption(context, 'config'); | ||
const classRegex = getOption(context, 'classRegex'); | ||
@@ -107,4 +107,6 @@ const mergedConfig = customConfig.resolve(twConfig); | ||
case 'ObjectExpression': | ||
const isUsedByClassNamesPlugin = node.callee && node.callee.name === 'classnames'; | ||
arg.properties.forEach((prop) => { | ||
parseForNegativeArbitraryClassNames(node, prop.key); | ||
parseForNegativeArbitraryClassNames(node, isUsedByClassNamesPlugin ? prop.key : prop.value); | ||
}); | ||
@@ -149,3 +151,3 @@ return; | ||
const attributeVisitor = function (node) { | ||
if (!astUtil.isClassAttribute(node) || skipClassAttribute) { | ||
if (!astUtil.isClassAttribute(node, classRegex) || skipClassAttribute) { | ||
return; | ||
@@ -152,0 +154,0 @@ } |
@@ -63,2 +63,3 @@ /** | ||
const twConfig = getOption(context, 'config'); | ||
const classRegex = getOption(context, 'classRegex'); | ||
@@ -158,4 +159,6 @@ const mergedConfig = customConfig.resolve(twConfig); | ||
case 'ObjectExpression': | ||
const isUsedByClassNamesPlugin = node.callee && node.callee.name === 'classnames'; | ||
arg.properties.forEach((prop) => { | ||
parseForShorthandCandidates(node, prop.key); | ||
parseForShorthandCandidates(node, isUsedByClassNamesPlugin ? prop.key : prop.value); | ||
}); | ||
@@ -238,6 +241,7 @@ return; | ||
const hasY = sameVariantAndValue.some((c) => c.shorthand === 'y') || (hasT && hasB); | ||
const hasAll = | ||
sameVariantAndValue.some((c) => c.shorthand === 'all') || !supportCorners | ||
? hasY && hasX | ||
: (hasL && hasR) || (hasT && hasB); | ||
const hasAllProp = sameVariantAndValue.some((c) => c.shorthand === 'all'); | ||
const hasAllPropNoCorner = hasY && hasX; | ||
const hasAllPropWithCorners = (hasL && hasR) || (hasT && hasB); | ||
const hasAllEquivalent = !supportCorners ? hasAllPropNoCorner : hasAllPropWithCorners; | ||
const hasAll = hasAllProp || hasAllEquivalent; | ||
const important = cls.important ? '!' : ''; | ||
@@ -377,3 +381,3 @@ const isNegative = ('' + cls.value).substring(0, 1) === '-'; | ||
const attributeVisitor = function (node) { | ||
if (!astUtil.isClassAttribute(node) || skipClassAttribute) { | ||
if (!astUtil.isClassAttribute(node, classRegex) || skipClassAttribute) { | ||
return; | ||
@@ -380,0 +384,0 @@ } |
@@ -68,2 +68,3 @@ /** | ||
const twConfig = getOption(context, 'config'); | ||
const classRegex = getOption(context, 'classRegex'); | ||
@@ -260,3 +261,3 @@ const mergedConfig = customConfig.resolve(twConfig); | ||
const attributeVisitor = function (node) { | ||
if (!astUtil.isClassAttribute(node) || skipClassAttribute) { | ||
if (!astUtil.isClassAttribute(node, classRegex) || skipClassAttribute) { | ||
return; | ||
@@ -263,0 +264,0 @@ } |
@@ -62,2 +62,3 @@ /** | ||
const twConfig = getOption(context, 'config'); | ||
const classRegex = getOption(context, 'classRegex'); | ||
@@ -105,4 +106,6 @@ const mergedConfig = customConfig.resolve(twConfig); | ||
case 'ObjectExpression': | ||
const isUsedByClassNamesPlugin = node.callee && node.callee.name === 'classnames'; | ||
arg.properties.forEach((prop) => { | ||
parseForArbitraryValues(node, prop.key); | ||
parseForArbitraryValues(node, isUsedByClassNamesPlugin ? prop.key : prop.value); | ||
}); | ||
@@ -147,3 +150,3 @@ return; | ||
const attributeVisitor = function (node) { | ||
if (!astUtil.isClassAttribute(node) || skipClassAttribute) { | ||
if (!astUtil.isClassAttribute(node, classRegex) || skipClassAttribute) { | ||
return; | ||
@@ -150,0 +153,0 @@ } |
@@ -63,2 +63,3 @@ /** | ||
const twConfig = getOption(context, 'config'); | ||
const classRegex = getOption(context, 'classRegex'); | ||
@@ -157,3 +158,3 @@ const mergedConfig = customConfig.resolve(twConfig); | ||
const attributeVisitor = function (node) { | ||
if (!astUtil.isClassAttribute(node) || skipClassAttribute) { | ||
if (!astUtil.isClassAttribute(node, classRegex) || skipClassAttribute) { | ||
return; | ||
@@ -160,0 +161,0 @@ } |
@@ -85,2 +85,3 @@ /** | ||
const whitelist = getOption(context, 'whitelist'); | ||
const classRegex = getOption(context, 'classRegex'); | ||
@@ -142,3 +143,3 @@ const mergedConfig = customConfig.resolve(twConfig); | ||
const attributeVisitor = function (node) { | ||
if (!astUtil.isClassAttribute(node) || skipClassAttribute) { | ||
if (!astUtil.isClassAttribute(node, classRegex) || skipClassAttribute) { | ||
return; | ||
@@ -145,0 +146,0 @@ } |
@@ -17,5 +17,6 @@ /** | ||
* @param {ASTNode} node The AST node being checked | ||
* @param {String} classRegex Regex to test the attribute that is being checked against | ||
* @returns {Boolean} | ||
*/ | ||
function isClassAttribute(node) { | ||
function isClassAttribute(node, classRegex) { | ||
if (!node.name) { | ||
@@ -32,3 +33,3 @@ return false; | ||
} | ||
return /^class(Name)?$/.test(name); | ||
return new RegExp(classRegex).test(name); | ||
} | ||
@@ -86,6 +87,7 @@ | ||
* @param {ASTNode} node The AST node being checked | ||
* @param {String} classRegex Regex to test the attribute that is being checked against | ||
* @returns {Boolean} | ||
*/ | ||
function isValidJSXAttribute(node) { | ||
if (!isClassAttribute(node)) { | ||
function isValidJSXAttribute(node, classRegex) { | ||
if (!isClassAttribute(node, classRegex)) { | ||
// Only run for class[Name] attributes | ||
@@ -215,3 +217,11 @@ return false; | ||
arg.properties.forEach((prop) => { | ||
parseNodeRecursive(node, prop.key, cb, skipConditional, forceIsolation); | ||
const isUsedByClassNamesPlugin = node.callee && node.callee.name === 'classnames'; | ||
parseNodeRecursive( | ||
node, | ||
isUsedByClassNamesPlugin ? prop.key : prop.value, | ||
cb, | ||
skipConditional, | ||
forceIsolation | ||
); | ||
}); | ||
@@ -218,0 +228,0 @@ return; |
@@ -29,2 +29,4 @@ 'use strict'; | ||
return []; | ||
case 'classRegex': | ||
return "^class(Name)?$" | ||
} | ||
@@ -31,0 +33,0 @@ } |
{ | ||
"name": "eslint-plugin-tailwindcss", | ||
"version": "3.8.0-beta.0", | ||
"version": "3.8.0", | ||
"description": "Rules enforcing best practices while using Tailwind CSS", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -40,28 +40,6 @@ # eslint-plugin-tailwindcss | ||
- ADD: New option `skipClassAttribute` you can turn on to only lint the `callees` | ||
- feat: [Lint values in a object](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/135) | ||
- feat: [Support for Object syntax in custom callees beside `classnames`](https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/185)(by [dipsaus9](https://github.com/dipsaus9) π) | ||
- feat: [New option `skipClassAttribute`](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/154) you can turn on to only lint the `callees` | ||
- FIX: support for Tailwind CSS version `3.2.3` | ||
- FIX: [prefix parsing when using attribute variants](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/164) | ||
- FIX: [add support for contradicting arbitrary properties](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/163) | ||
- FIX: [conflicting rules with ambiguous arbitrary values](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/152)(by [acewf](https://github.com/acewf) π) | ||
- FIX: [`parseNodeRecursive`: Correctly recurse into TemplateLiteral expressions](https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/138) (by [mpsijm](https://github.com/mpsijm) π) | ||
- FIX: [Prevent rule crash on class/className attributes with no value](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/157) (by [threehams](https://github.com/threehams) π) | ||
- ADD: support for [new features from Tailwind CSS v3.1.0](https://github.com/tailwindlabs/tailwindcss/releases/tag/v3.1.0) | ||
> Custom `dark` class, `.grid-flow-dense`, `.text-start`, `.text-end`, `.mix-blend-plus-lighter`, `.border-spacing...` | ||
- **BREAKING CHANGE:** `groups`, `groupByResponsive`, `officialSorting` and `prependCustom` are deprecated β οΈ. | ||
The official sorting from `prettier-plugin-tailwindcss` is always used by `classnames-order`. | ||
> This was required in order to support classnames generated by plugins. | ||
- FIX: [Many fixes](https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/132) including support for classnames generated by plugins. | ||
- FIX: [speeds up `enforces-shorthand` and `classnames-order`](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/136) with `officialSorting: true` by introducing WeakMap caches to reduce duplicate calculations (by [mpsijm](https://github.com/mpsijm) π) | ||
- New strategy for whitespaces and linebreaks: the plugin will attempt to leave them intact | ||
- New option `officialSorting` for [`classnames-order`](docs/rules/classnames-order.md#officialsorting-default-false) can be set to `true` in order to use the same ordering order as the official [`prettier-plugin-tailwindcss`](https://www.npmjs.com/package/prettier-plugin-tailwindcss) | ||
- FIX: `enforces-shorthand` rule [fixer](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/120) and [fix prefix](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/121) | ||
- FIX: [`enforces-shorthand` rule loses the importance flag](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/114) | ||
- New rule: [`enforces-negative-arbitrary-values`](docs/rules/enforces-negative-arbitrary-values.md): prefers `top-[-5px]` instead of `-top-[5px]` | ||
- FIX: [allowing negative arbitrary values in dash prefixed classnames](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/112) | ||
- FIX: deprecated message for `ring-opacity-*` in `migration-from-tailwind-2` rule | ||
- FIX: `migration-from-tailwind-2` and `enforces-shorthand` fixer with `@angular-eslint/template-parser` | ||
- FIX: [`no-custom-classname` rule prevents `migration-from-tailwind-2` rule](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/88) | ||
- FIX: [Escaping special characters in the `prefix`](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/73) | ||
- FIX: [Formating HTML files](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/85) is now possible using `@angular-eslint/template-parser` | ||
- New feature: [crawling `ArrayExpression` elements and `ObjectExpression`](https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/103), see [issue #99](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/99) (by [matt-tingen](https://github.com/matt-tingen) π) | ||
@@ -185,2 +163,4 @@ [View all releases on github](https://github.com/francoismassart/eslint-plugin-tailwindcss/releases) | ||
whitelist: [], | ||
tags: [], | ||
classRegex: "^class(Name)?$", // can be modified to support custom attributes. E.g. "^tw$" for `twin.macro` | ||
}, | ||
@@ -187,0 +167,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4372
0
156405
198