eslint-plugin-tailwindcss
Advanced tools
Comparing version 1.13.5-beta.0 to 1.14.0
@@ -16,2 +16,6 @@ /** | ||
}, | ||
{ | ||
type: 'Dark Mode', | ||
members: '${dark}', | ||
}, | ||
], | ||
@@ -18,0 +22,0 @@ }, |
@@ -21,2 +21,3 @@ /** | ||
recommended: { | ||
plugins: ['tailwind'], | ||
parserOptions: { | ||
@@ -23,0 +24,0 @@ ecmaFeatures: { |
@@ -61,2 +61,7 @@ /** | ||
}, | ||
tags: { | ||
type: 'array', | ||
items: { type: 'string', minLength: 0 }, | ||
uniqueItems: true, | ||
}, | ||
}, | ||
@@ -69,2 +74,3 @@ }, | ||
const callees = getOption(context, 'callees'); | ||
const tags = getOption(context, 'tags'); | ||
const twConfig = getOption(context, 'config'); | ||
@@ -338,2 +344,9 @@ const groupsConfig = getOption(context, 'groups'); | ||
}, | ||
TaggedTemplateExpression: function (node) { | ||
if (!tags.includes(node.tag.name)) { | ||
return; | ||
} | ||
sortNodeArgumentValue(node, node.quasi); | ||
}, | ||
}; | ||
@@ -340,0 +353,0 @@ const templateVisitor = { |
@@ -49,2 +49,7 @@ /** | ||
}, | ||
tags: { | ||
type: 'array', | ||
items: { type: 'string', minLength: 0 }, | ||
uniqueItems: true, | ||
}, | ||
}, | ||
@@ -57,2 +62,3 @@ }, | ||
const callees = getOption(context, 'callees'); | ||
const tags = getOption(context, 'tags'); | ||
const twConfig = getOption(context, 'config'); | ||
@@ -76,2 +82,3 @@ | ||
classNames = attrUtil.sanitizeClassnames(classNames); | ||
// Init assets before sorting | ||
const sorted = groupUtil.initGroupSlots(groups); | ||
@@ -154,2 +161,20 @@ | ||
}, | ||
TaggedTemplateExpression: function (node) { | ||
if (!tags.includes(node.tag.name)) { | ||
return; | ||
} | ||
const allClassnamesForNode = []; | ||
const pushClasses = (classNames, targetNode) => { | ||
if (targetNode === null) { | ||
// Classnames should be parsed in isolation (e.g. conditional expressions) | ||
parseForContradictingClassNames(classNames, node); | ||
} else { | ||
// Gather the classes prior to validation | ||
allClassnamesForNode.push(...classNames); | ||
} | ||
}; | ||
astUtil.parseNodeRecursive(node, node.quasi, pushClasses, true); | ||
parseForContradictingClassNames(allClassnamesForNode, node); | ||
}, | ||
}; | ||
@@ -156,0 +181,0 @@ |
@@ -55,2 +55,7 @@ /** | ||
}, | ||
tags: { | ||
type: 'array', | ||
items: { type: 'string', minLength: 0 }, | ||
uniqueItems: true, | ||
}, | ||
whitelist: { | ||
@@ -68,2 +73,3 @@ type: 'array', | ||
const callees = getOption(context, 'callees'); | ||
const tags = getOption(context, 'tags'); | ||
const twConfig = getOption(context, 'config'); | ||
@@ -134,2 +140,8 @@ const cssFiles = getOption(context, 'cssFiles'); | ||
}, | ||
TaggedTemplateExpression: function (node) { | ||
if (!tags.includes(node.tag.name)) { | ||
return; | ||
} | ||
astUtil.parseNodeRecursive(node, node.quasi, parseForCustomClassNames); | ||
}, | ||
}; | ||
@@ -136,0 +148,0 @@ |
@@ -34,2 +34,4 @@ /** | ||
switch (propName) { | ||
case 'dark': | ||
return config.darkMode === 'class' ? 'dark' : ''; | ||
case 'placeholderColor': | ||
@@ -95,5 +97,10 @@ case 'textColor': | ||
props.forEach((prop) => { | ||
const token = new RegExp('\\$\\{' + prop + '\\}'); | ||
const isNegative = prop.substr(0, 1) === '-'; | ||
const patchedProp = isNegative ? prop.substr(1) : prop; | ||
if (!config.theme || !config.theme[patchedProp]) { | ||
if (prop === 'dark') { | ||
// Special case, not a default property from the theme | ||
replaced = replaced.replace(token, generateOptions(patchedProp, [], config, isNegative)); | ||
return patched + replaced; | ||
} else if (!config.theme || !config.theme[patchedProp]) { | ||
// prop not found in config | ||
@@ -109,3 +116,2 @@ return; | ||
}); | ||
const token = new RegExp('\\$\\{' + prop + '\\}'); | ||
if (keys.length === 0 || replaced.match(token) === null) { | ||
@@ -112,0 +118,0 @@ // empty array |
@@ -30,2 +30,4 @@ 'use strict'; | ||
return true; | ||
case 'tags': | ||
return []; | ||
case 'whitelist': | ||
@@ -32,0 +34,0 @@ return []; |
{ | ||
"name": "eslint-plugin-tailwindcss", | ||
"version": "1.13.5-beta.0", | ||
"version": "1.14.0", | ||
"description": "Rules enforcing best practices while using Tailwind CSS", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -15,4 +15,10 @@ # eslint-plugin-tailwindcss | ||
- Add [`groupByResponsive`](https://github.com/francoismassart/eslint-plugin-tailwindcss/blob/master/docs/rules/classnames-order.md#groupbyresponsive-default-false) option (default: `false`) in `v1.13.0` | ||
- [Performance gains](https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/42) on `no-custom-classname` and `no-contradicting-classname` (by [larrifax](https://github.com/larrifax) π) | ||
- Add support for [tagged templates](https://github.com/francoismassart/eslint-plugin-tailwindcss/pull/41) (by [larrifax](https://github.com/larrifax) π) | ||
- [Include "plugins": ["tailwindcss"]](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/44) in the `recommended` preset(by [kripod](https://github.com/kripod) π) | ||
- [Support dark class](https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/43) when `darkMode` is set to `class` | ||
[View all releases on github](https://github.com/francoismassart/eslint-plugin-tailwindcss/releases) | ||
@@ -19,0 +25,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
79930
2272
0
137