Skip to content

Commit 4d04a96

Browse files
fix: no-unnecessary-arbitrary-value with DEFAULT (#340)
fix: #334
1 parent 7070c34 commit 4d04a96

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

lib/rules/no-unnecessary-arbitrary-value.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ module.exports = {
232232
let patchedBody = backBone.substring(parsed.variants.length);
233233
patchedBody = patchedBody.charAt(0) === '-' ? patchedBody.substring(1) : patchedBody;
234234
const noneOrMinus = negativeSubstitutes[idx] ? '-' : '';
235+
if (key === 'DEFAULT') {
236+
return parsed.variants + noneOrMinus + patchedBody.substring(0, patchedBody.length - 1);
237+
}
235238
return parsed.variants + noneOrMinus + patchedBody + key;
236239
})
237240
);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-tailwindcss",
3-
"version": "3.15.1",
3+
"version": "3.15.2",
44
"description": "Rules enforcing best practices while using Tailwind CSS",
55
"keywords": [
66
"eslint",

tests/lib/rules/no-unnecessary-arbitrary-value.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,5 +252,21 @@ ruleTester.run("arbitrary-values", rule, {
252252
options: config,
253253
errors: generateErrors(["sm:-m-[2.5rem]"], [["sm:-m-10"]]),
254254
},
255+
{
256+
code: `
257+
<section>
258+
<pre class={'border-[1px]'}>...</pre>
259+
<pre class={'rounded-[0.25rem]'}>...</pre>
260+
</section>
261+
`,
262+
output: `
263+
<section>
264+
<pre class={'border'}>...</pre>
265+
<pre class={'rounded'}>...</pre>
266+
</section>
267+
`,
268+
options: config,
269+
errors: generateErrors(["border-[1px]", "rounded-[0.25rem]"], [["border"], ["rounded"]]),
270+
},
255271
],
256272
});

0 commit comments

Comments
 (0)