8000 fix: #307 · valcosmos/eslint-plugin-tailwindcss@602720e · GitHub
Skip to content

Commit 602720e

Browse files
w-screen + h-screen ≠ size-screen
1 parent aa8ae04 commit 602720e

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

lib/rules/enforces-shorthand.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,11 @@ module.exports = {
243243
}
244244
// Test if the body of the class matches, eg. 'h-' inside 'h-10'
245245
if (mode === 'value') {
246-
return inputSet.some((inputClassPattern) => inputClassPattern === remainingClass.body);
246+
const bodyMatch = inputSet.some((inputClassPattern) => inputClassPattern === remainingClass.body);
247+
// w-screen + h-screen ≠ size-screen (Issue #307)
248+
const validValue =
249+
bodyMatch && !(['w-', 'h-'].includes(remainingClass.body) && ['screen'].includes(remainingClass.value));
250+
return validValue;
247251
}
248252
});
249253

lib/util/groupMethods.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ function getSuffix(className, separator = ':') {
486486
/**
487487
* Find the group of a classname
488488
*
489-
* @param {String} name Classname to be find using patterns
490-
* @param {Array} group The group bein tested
489+
* @param {String} name Classname to be find using patterns (without modifiers)
490+
* @param {Array} group The group being tested
491491
* @param {Object} config Tailwind CSS config
492492
* @param {String} parentType The name of the parent group
493493
* @returns {Object} The infos

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"bugs": "https://github.com/francoismassart/eslint-plugin-tailwindcss/issues",
1919
"main": "lib/index.js",
2020
"scripts": {
21-
"wip": "mocha tests/lib/rules/no-arbitrary-value.js",
2221
"test": "mocha tests --recursive"
2322
},
2423
"files": [

tests/lib/rules/enforces-shorthand.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ ruleTester.run("shorthands", rule, {
129129
{
130130
code: "<div className={`absolute inset-y-0 left-0 w-1/3 rounded-[inherit] shadow-lg ${className}`}>issue #312</div>",
131131
},
132+
{
133+
code: "<div className={'w-screen h-screen'}>issue #307</div>",
134+
},
132135
],
133136

134137
invalid: [

0 commit comments

Comments
 (0)