Skip to content

Commit

Permalink
fix: #307
Browse files Browse the repository at this point in the history
w-screen + h-screen ≠ size-screen
  • Loading branch information
francoismassart committed Jan 23, 2024
1 parent aa8ae04 commit 602720e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/rules/enforces-shorthand.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ module.exports = {
}
// Test if the body of the class matches, eg. 'h-' inside 'h-10'
if (mode === 'value') {
return inputSet.some((inputClassPattern) => inputClassPattern === remainingClass.body);
const bodyMatch = inputSet.some((inputClassPattern) => inputClassPattern === remainingClass.body);
// w-screen + h-screen ≠ size-screen (Issue #307)
const validValue =
bodyMatch && !(['w-', 'h-'].includes(remainingClass.body) && ['screen'].includes(remainingClass.value));
return validValue;
}
});

Expand Down
4 changes: 2 additions & 2 deletions lib/util/groupMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ function getSuffix(className, separator = ':') {
/**
* Find the group of a classname
*
* @param {String} name Classname to be find using patterns
* @param {Array} group The group bein tested
* @param {String} name Classname to be find using patterns (without modifiers)
* @param {Array} group The group being tested
* @param {Object} config Tailwind CSS config
* @param {String} parentType The name of the parent group
* @returns {Object} The infos
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"bugs": "https://github.com/francoismassart/eslint-plugin-tailwindcss/issues",
"main": "lib/index.js",
"scripts": {
"wip": "mocha tests/lib/rules/no-arbitrary-value.js",
"test": "mocha tests --recursive"
},
"files": [
Expand Down
3 changes: 3 additions & 0 deletions tests/lib/rules/enforces-shorthand.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ ruleTester.run("shorthands", rule, {
{
code: "<div className={`absolute inset-y-0 left-0 w-1/3 rounded-[inherit] shadow-lg ${className}`}>issue #312</div>",
},
{
code: "<div className={'w-screen h-screen'}>issue #307</div>",
},
],

invalid: [
Expand Down

0 comments on commit 602720e

Please sign in to comment.