Skip to content

Commit

Permalink
fix: no-unnecessary-arbitrary-value with DEFAULT (#340)
Browse files Browse the repository at this point in the history
fix: #334
  • Loading branch information
francoismassart authored May 17, 2024
1 parent 7070c34 commit 4d04a96
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/rules/no-unnecessary-arbitrary-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ module.exports = {
let patchedBody = backBone.substring(parsed.variants.length);
patchedBody = patchedBody.charAt(0) === '-' ? patchedBody.substring(1) : patchedBody;
const noneOrMinus = negativeSubstitutes[idx] ? '-' : '';
if (key === 'DEFAULT') {
return parsed.variants + noneOrMinus + patchedBody.substring(0, patchedBody.length - 1);
}
return parsed.variants + noneOrMinus + patchedBody + key;
})
);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-tailwindcss",
"version": "3.15.1",
"version": "3.15.2",
"description": "Rules enforcing best practices while using Tailwind CSS",
"keywords": [
"eslint",
Expand Down
16 changes: 16 additions & 0 deletions tests/lib/rules/no-unnecessary-arbitrary-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,21 @@ ruleTester.run("arbitrary-values", rule, {
options: config,
errors: generateErrors(["sm:-m-[2.5rem]"], [["sm:-m-10"]]),
},
{
code: `
<section>
<pre class={'border-[1px]'}>...</pre>
<pre class={'rounded-[0.25rem]'}>...</pre>
</section>
`,
output: `
<section>
<pre class={'border'}>...</pre>
<pre class={'rounded'}>...</pre>
</section>
`,
options: config,
errors: generateErrors(["border-[1px]", "rounded-[0.25rem]"], [["border"], ["rounded"]]),
},
],
});

0 comments on commit 4d04a96

Please sign in to comment.