Skip to content

Commit

Permalink
fix: entry point option
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Jan 23, 2025
1 parent a943f34 commit 8b74109
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 11 additions & 1 deletion docs/rules/sort-classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ Enforce the order of tailwind classes. It is possible to sort classes alphabetic

<br/>

- `entryPoint`

The path to the entry file of the tailwind css config. If not specified, the plugin will fall back to the default configuration.
The tailwind config is used to determine the sorting order.

**Type**: `string`
**Default**: `undefined`

<br/>

- `tailwindConfig`

The path to the tailwind config file. If not specified, the plugin will try to find it automatically or falls back to the default configuration.
The path to the `tailwind.config.js` file. If not specified, the plugin will try to find it automatically or falls back to the default configuration.
The tailwind config is used to determine the sorting order.

**Type**: `string`
Expand Down
12 changes: 10 additions & 2 deletions src/rules/tailwind-sort-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ import type {

export type Options = [
Partial<
AttributeOption &
AttributeOption
&
CalleeOption &
TagOption &
VariableOption &
{
entryPoint?: string;
order?: "asc" | "desc" | "improved" | "official" ;
tailwindConfig?: string;
}
Expand Down Expand Up @@ -250,6 +252,10 @@ export const tailwindSortClasses: ESLintRule<Options> = {
...getAttributesSchema(defaultOptions.attributes),
...getVariableSchema(defaultOptions.variables),
...getTagsSchema(defaultOptions.tags),
entryPoint: {
description: "The path to the css entry point of the project. If not specified, the plugin will fall back to the default tailwind classes.",
type: "string"
},
order: {
default: defaultOptions.order,
description: "The algorithm to use when sorting classes.",
Expand Down Expand Up @@ -350,7 +356,9 @@ export function getOptions(ctx?: Rule.RuleContext) {
ctx?.settings["readable-tailwind"]?.tags ??
defaultOptions.tags;

const tailwindConfig = options.tailwindConfig ??
const tailwindConfig = options.tailwindConfig ?? options.entryPoint ??
ctx?.settings["eslint-plugin-readable-tailwind"]?.tailwindConfig ??
ctx?.settings["readable-tailwind"]?.tailwindConfig ??
ctx?.settings["eslint-plugin-readable-tailwind"]?.entryPoint ??
ctx?.settings["readable-tailwind"]?.entryPoint;

Expand Down

0 comments on commit 8b74109

Please sign in to comment.