Skip to content

Commit

Permalink
rename getSortOrder to getClassOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Feb 15, 2022
1 parent bccc4ba commit 153c185
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/setupContextUtils.js
Expand Up @@ -744,7 +744,7 @@ function registerPlugins(plugins, context) {
// sorting could be weird since you still require them in order to make the
// host utitlies work properly. (Thanks Biology)
let parasiteUtilities = new Set([prefix(context, 'group'), prefix(context, 'peer')])
context.getSortOrder = function getSortOrder(classes) {
context.getClassOrder = function getClassOrder(classes) {
let sortedClassNames = new Map()
for (let [sort, rule] of generateRules(new Set(classes), context)) {
if (sortedClassNames.has(rule.raws.tailwind.candidate)) continue
Expand Down
8 changes: 4 additions & 4 deletions tests/getSortOrder.test.js
Expand Up @@ -4,7 +4,7 @@ import bigSign from '../src/util/bigSign'

/**
* This is a function that the prettier-plugin-tailwindcss would use. It would
* do the actual sorting based on the classes and order we return from `getSortOrder`.
* do the actual sorting based on the classes and order we return from `getClassOrder`.
*
* This way the actual sorting logic is done in the plugin which allows you to
* put unknown classes at the end for example.
Expand All @@ -28,7 +28,7 @@ it('should return a list of tuples with the sort order', () => {
let input = 'font-bold underline hover:font-medium unknown'
let config = {}
let context = createContext(resolveConfig(config))
expect(context.getSortOrder(input.split(' '))).toEqual([
expect(context.getClassOrder(input.split(' '))).toEqual([
['font-bold', expect.any(BigInt)],
['underline', expect.any(BigInt)],
['hover:font-medium', expect.any(BigInt)],
Expand Down Expand Up @@ -70,7 +70,7 @@ it.each([
])('should sort "%s" based on the order we generate them in to "%s"', (input, output) => {
let config = {}
let context = createContext(resolveConfig(config))
expect(defaultSort(context.getSortOrder(input.split(' ')))).toEqual(output)
expect(defaultSort(context.getClassOrder(input.split(' ')))).toEqual(output)
})

it.each([
Expand Down Expand Up @@ -110,6 +110,6 @@ it.each([
(input, output) => {
let config = { prefix: 'tw-' }
let context = createContext(resolveConfig(config))
expect(defaultSort(context.getSortOrder(input.split(' ')))).toEqual(output)
expect(defaultSort(context.getClassOrder(input.split(' ')))).toEqual(output)
}
)

0 comments on commit 153c185

Please sign in to comment.