eslint-plugin-tailwindcss
Advanced tools
Comparing version 3.1.0-beta.0 to 3.1.0-beta.1
@@ -185,6 +185,4 @@ /** | ||
classNames = attrUtil.sanitizeClassnames(classNames); | ||
// Init assets before sorting | ||
const parsed = []; | ||
// Move each classname inside its dedicated group | ||
classNames.forEach((className, index) => { | ||
@@ -301,3 +299,3 @@ parsed.push(groupUtil.parseClassname(className, targetGroups, mergedConfig, index)); | ||
// Generates the validated attribute value | ||
const union = validated.map((val) => val.name); | ||
const union = validated.map((val) => val.leading + val.name + val.trailing); | ||
@@ -304,0 +302,0 @@ if (before !== null) { |
@@ -497,4 +497,18 @@ /** | ||
function parseClassname(name, arr, config, index = null) { | ||
const classPrefixes = getPrefixes(name, config.separator); | ||
const classSuffix = getSuffix(name, config.separator); | ||
const leadingRe = new RegExp('^(?<leading>\\s*)'); | ||
const trailingRe = new RegExp('(?<trailing>\\s*)$'); | ||
let leading = ''; | ||
let core = ''; | ||
let trailing = ''; | ||
const leadingRes = leadingRe.exec(name); | ||
if (leadingRes && leadingRes.groups) { | ||
leading = leadingRes.groups.leading || ''; | ||
} | ||
const trailingRes = trailingRe.exec(name); | ||
if (trailingRes && trailingRes.groups) { | ||
trailing = trailingRes.groups.trailing || ''; | ||
} | ||
core = name.substring(leading.length, name.length - trailing.length); | ||
const classPrefixes = getPrefixes(core, config.separator); | ||
const classSuffix = getSuffix(core, config.separator); | ||
let slot = null; | ||
@@ -513,6 +527,6 @@ arr.forEach((group) => { | ||
const off = isNegative ? 1 : 0; | ||
const body = name.substr(0, name.length - value.length + off).substr(variants.length + off); | ||
const body = core.substr(0, core.length - value.length + off).substr(variants.length + off); | ||
return { | ||
index: index, | ||
name: name, | ||
name: core, | ||
variants: variants, | ||
@@ -523,2 +537,4 @@ parentType: slot ? slot.group : '', | ||
shorthand: slot ? slot.shorthand : '', | ||
leading: leading, | ||
trailing: trailing, | ||
}; | ||
@@ -525,0 +541,0 @@ } |
{ | ||
"name": "eslint-plugin-tailwindcss", | ||
"version": "3.1.0-beta.0", | ||
"version": "3.1.0-beta.1", | ||
"description": "Rules enforcing best practices while using Tailwind CSS", | ||
@@ -21,2 +21,3 @@ "keywords": [ | ||
"scripts": { | ||
"wip": "mocha tests/lib/rules/enforces-shorthand.js", | ||
"test": "mocha tests --recursive" | ||
@@ -23,0 +24,0 @@ }, |
@@ -75,2 +75,3 @@ # eslint-plugin-tailwindcss | ||
- [`classnames-order`](docs/rules/classnames-order.md): order classnames by target properties then by variants (`[size:][theme:][state:]`) | ||
- [`enforces-shorthand`](docs/rules/enforces-shorthand.md): merge multiple classnames into shorthand if possible e.g. `mx-5 my-5` should become `m-5` | ||
- [`migration-from-tailwind-2`](docs/rules/migration-from-tailwind-2.md) for easy upgrade from TailwindCSS `v2` to `v3` | ||
@@ -127,2 +128,3 @@ - [`no-custom-classname`](docs/rules/no-custom-classname.md): only allow classnames from Tailwind CSS and the values from the `whitelist` option | ||
"tailwindcss/classnames-order": "warn", | ||
"tailwindcss/enforces-shorthand": "warn", | ||
"tailwindcss/migration-from-tailwind-2": "warn", | ||
@@ -172,4 +174,2 @@ "tailwindcss/no-custom-classname": "warn", | ||
- `enforces-shorthand`: Make sure you group properties inside a shorthand when possible e.g. `mx-5 my-5` should become `m-5` | ||
- `validate-modifiers`: I don't know if possible, but I'd like to make sure all the modifiers prefixes of a classname are valid e.g. `yolo:bg-red` should throw an error... | ||
@@ -176,0 +176,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
136567
3784