@glideapps/prettier-plugin-glide-tailwind
Advanced tools
Comparing version 2.2.18 to 2.2.19
@@ -1,2 +0,2 @@ | ||
import type TWClassesSorter from 'tailwind-classes-sorter'; | ||
import type TWClassesSorter from "tailwind-classes-sorter"; | ||
export default function functionCalls(twClassesSorter: TWClassesSorter, node: any, functionNames: string[]): any; |
@@ -7,8 +7,8 @@ "use strict"; | ||
if (node && | ||
node.type === 'CallExpression' && | ||
node.type === "CallExpression" && | ||
node.callee && | ||
node.callee.type === 'Identifier' && | ||
node.callee.type === "Identifier" && | ||
functionNames.some(functionName => functionName === node.callee.name)) { | ||
node.arguments.forEach(arg => { | ||
if (arg.type !== 'StringLiteral' && arg.type !== 'Literal') { | ||
if (arg.type !== "StringLiteral" && arg.type !== "Literal") { | ||
return; | ||
@@ -18,6 +18,6 @@ } | ||
const spacesAfter = arg.value.length - arg.value.trimEnd().length; | ||
const newValue = `${' '.repeat(spacesBefore)}${twClassesSorter | ||
const newValue = `${" ".repeat(spacesBefore)}${twClassesSorter | ||
.sortClasslist(arg.value) | ||
.join(' ')}${' '.repeat(spacesAfter)}`; | ||
if (arg.type === 'StringLiteral') { | ||
.join(" ")}${" ".repeat(spacesAfter)}`; | ||
if (arg.type === "StringLiteral") { | ||
arg.value = newValue; | ||
@@ -29,3 +29,3 @@ if (arg.extra) { | ||
} | ||
else if (arg.type === 'Literal') { | ||
else if (arg.type === "Literal") { | ||
arg.value = newValue; | ||
@@ -32,0 +32,0 @@ arg.raw = `"${newValue}"`; |
@@ -1,2 +0,2 @@ | ||
import type TWClassesSorter from 'tailwind-classes-sorter'; | ||
import type TWClassesSorter from "tailwind-classes-sorter"; | ||
export default function functionTemplates(twClassesSorter: TWClassesSorter, node: any, functionNames: string[]): any; |
@@ -7,11 +7,11 @@ "use strict"; | ||
if (node && | ||
node.type === 'TaggedTemplateExpression' && | ||
node.type === "TaggedTemplateExpression" && | ||
node.tag && | ||
node.tag.type === 'Identifier' && | ||
functionNames.some((functionName) => functionName === node.tag.name) && | ||
node.tag.type === "Identifier" && | ||
functionNames.some(functionName => functionName === node.tag.name) && | ||
node.quasi && | ||
node.quasi.type === 'TemplateLiteral' && | ||
node.quasi.type === "TemplateLiteral" && | ||
node.quasi.quasis) { | ||
node.quasi.quasis.forEach((quasi) => { | ||
if (quasi.type !== 'TemplateElement' || !quasi.value) { | ||
node.quasi.quasis.forEach(quasi => { | ||
if (quasi.type !== "TemplateElement" || !quasi.value) { | ||
return; | ||
@@ -21,5 +21,5 @@ } | ||
const spacesAfter = quasi.value.raw.length - quasi.value.raw.trimEnd().length; | ||
const newValue = `${' '.repeat(spacesBefore)}${twClassesSorter | ||
const newValue = `${" ".repeat(spacesBefore)}${twClassesSorter | ||
.sortClasslist(quasi.value.raw) | ||
.join(' ')}${' '.repeat(spacesAfter)}`; | ||
.join(" ")}${" ".repeat(spacesAfter)}`; | ||
quasi.value = Object.assign(Object.assign({}, quasi.value), { raw: newValue, cooked: newValue }); | ||
@@ -26,0 +26,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import type TWClassesSorter from 'tailwind-classes-sorter'; | ||
import type TWClassesSorter from "tailwind-classes-sorter"; | ||
export default function jsxAttributes(twClassesSorter: TWClassesSorter, node: any, attributeNames: string[]): any; |
@@ -7,10 +7,10 @@ "use strict"; | ||
if (node && | ||
node.type === 'JSXAttribute' && | ||
node.type === "JSXAttribute" && | ||
node.name && | ||
node.name.type === 'JSXIdentifier' && | ||
node.name.type === "JSXIdentifier" && | ||
attributeNames.includes(node.name.name) && | ||
node.value && | ||
(node.value.type === 'StringLiteral' || node.value.type === 'Literal')) { | ||
(node.value.type === "StringLiteral" || node.value.type === "Literal")) { | ||
// TODO: Handle new line breaks smarter. | ||
const newValue = twClassesSorter.sortClasslist(node.value.value).join(' \n'); | ||
const newValue = twClassesSorter.sortClasslist(node.value.value).join(" "); | ||
node.value.value = newValue; | ||
@@ -17,0 +17,0 @@ node.value.extra = Object.assign(Object.assign({}, (node.value.extra || {})), { rawValue: newValue, raw: `"${newValue}"` }); |
@@ -1,2 +0,2 @@ | ||
import type TWClassesSorter from 'tailwind-classes-sorter'; | ||
import type TWClassesSorter from "tailwind-classes-sorter"; | ||
export default function twin(twClassesSorter: TWClassesSorter, node: any): any; |
@@ -14,8 +14,8 @@ "use strict"; | ||
if (node && | ||
node.type === 'TaggedTemplateExpression' && | ||
node.type === "TaggedTemplateExpression" && | ||
node.tag && | ||
node.tag.name === 'tw' && | ||
node.tag.name === "tw" && | ||
node.quasi && | ||
Array.isArray(node.quasi.quasis)) { | ||
node.quasi.quasis.forEach((q) => { | ||
node.quasi.quasis.forEach(q => { | ||
if (q.value && q.value.raw) { | ||
@@ -25,22 +25,22 @@ const rawValue = q.value.raw; | ||
const normalClasses = twClassesSorter | ||
.sortClasslist(rawValue.replace(TW_MARCO_EXP, (str) => { | ||
.sortClasslist(rawValue.replace(TW_MARCO_EXP, str => { | ||
const groupNames = str | ||
.match(TW_MARCO_GROUP_NAMES_EXP) | ||
.map((groupName) => groupName.substr(0, groupName.length - 1)) | ||
.map(groupName => groupName.substr(0, groupName.length - 1)) | ||
.sort(group_names_sorter_1.default()); | ||
const content = twClassesSorter | ||
.sortClasslist(str.match(TW_MARCO_GROUP_CONTENT_EXP)[1]) | ||
.join('twintop'); | ||
.join(" "); | ||
groups.push({ | ||
names: groupNames, | ||
content | ||
content, | ||
}); | ||
return ''; | ||
return ""; | ||
})) | ||
.join(' '); | ||
.join(" \n"); | ||
// Sort groups | ||
groups.sort(group_names_sorter_1.default((val) => val.names[0])); | ||
groups.sort(group_names_sorter_1.default(val => val.names[0])); | ||
const finalStr = `${normalClasses} ${groups | ||
.map(({ names, content }) => `${names.join(':')}:(${content})`) | ||
.join('twins')}`.trim(); | ||
.map(({ names, content }) => `${names.join(":")}:(${content})`) | ||
.join(" \n")}`.trim(); | ||
q.value.raw = finalStr; | ||
@@ -47,0 +47,0 @@ if (q.value.cooked) { |
@@ -1,2 +0,2 @@ | ||
import type TWClassesSorter from 'tailwind-classes-sorter'; | ||
import type TWClassesSorter from "tailwind-classes-sorter"; | ||
declare const _default: (twClassesSorter: TWClassesSorter) => { | ||
@@ -3,0 +3,0 @@ html: any; |
{ | ||
"name": "@glideapps/prettier-plugin-glide-tailwind", | ||
"version": "2.2.18", | ||
"version": "2.2.19", | ||
"description": "Formatting and sorting for glide tailwind classes", | ||
@@ -5,0 +5,0 @@ "author": "Original author - Ari Seyhun | Modified by Bry Nguyen", |
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
72818