Skip to content

Commit ea756db

Browse files
authored
feat: support tsconfig paths (#185)
* feat: add support for tsconfig paths * chore: add `tsconfig-paths-webpack-plugin` dependency * chore: revert test runner adjustments * style: eslint fixes * refactor: clean up async calls * refactor: add `tsconfig` option * docs: add tsconfig to table of contents * refactor: add `jsconfig.json`
1 parent 8ee822a commit ea756db

File tree

63 files changed

+830
-371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+830
-371
lines changed

docs/rules/enforce-consistent-class-order.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ Enforce the order of tailwind classes. It is possible to sort classes alphabetic
8585
**Type**: `string`
8686
**Default**: `undefined`
8787

88+
<br/>
89+
90+
### `tsconfig`
91+
92+
The path to the `tsconfig.json` file. If not specified, the plugin will try to find it automatically.
93+
This can also be set globally via the [`settings` object](../settings/settings.md#tsconfig).
94+
95+
The tsconfig is used to resolve tsconfig [`path`](https://www.typescriptlang.org/tsconfig/#paths) aliases.
96+
97+
**Type**: `string`
98+
**Default**: `undefined`
99+
88100
</details>
89101

90102
<br/>

docs/rules/enforce-consistent-important-position.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ Controls where the important modifier (`!`) should be placed in class names.
8787
**Type**: `string`
8888
**Default**: `undefined`
8989

90+
<br/>
91+
92+
### `tsconfig`
93+
94+
The path to the `tsconfig.json` file. If not specified, the plugin will try to find it automatically.
95+
This can also be set globally via the [`settings` object](../settings/settings.md#tsconfig).
96+
97+
The tsconfig is used to resolve tsconfig [`path`](https://www.typescriptlang.org/tsconfig/#paths) aliases.
98+
99+
**Type**: `string`
100+
**Default**: `undefined`
101+
90102
</details>
91103

92104
<br/>

docs/rules/enforce-consistent-line-wrapping.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,18 @@ Enforce tailwind classes to be broken up into multiple lines. It is possible to
128128
**Type**: `string`
129129
**Default**: `undefined`
130130

131+
<br/>
132+
133+
### `tsconfig`
134+
135+
The path to the `tsconfig.json` file. If not specified, the plugin will try to find it automatically.
136+
This can also be set globally via the [`settings` object](../settings/settings.md#tsconfig).
137+
138+
The tsconfig is used to resolve tsconfig [`path`](https://www.typescriptlang.org/tsconfig/#paths) aliases.
139+
140+
**Type**: `string`
141+
**Default**: `undefined`
142+
131143
</details>
132144

133145
<br/>

docs/rules/no-conflicting-classes.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ Disallow conflicting classes in tailwindcss class strings. Conflicting classes a
8686
**Type**: `string`
8787
**Default**: `undefined`
8888
89+
<br/>
90+
91+
### `tsconfig`
92+
93+
The path to the `tsconfig.json` file. If not specified, the plugin will try to find it automatically.
94+
This can also be set globally via the [`settings` object](../settings/settings.md#tsconfig).
95+
96+
The tsconfig is used to resolve tsconfig [`path`](https://www.typescriptlang.org/tsconfig/#paths) aliases.
97+
98+
**Type**: `string`
99+
**Default**: `undefined`
100+
89101
</details>
90102
91103
<br/>

docs/rules/no-deprecated-classes.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ The following classes will be reported as deprecated:
8383

8484
<br/>
8585

86+
### `entryPoint`
87+
88+
The path to the entry file of the css based tailwind config (eg: `src/global.css`).
89+
If not specified, the plugin will fall back to the default configuration.
90+
91+
**Type**: `string`
92+
**Default**: `undefined`
93+
94+
<br/>
95+
8696
### `tailwindConfig`
8797

8898
Tailwind config file path.
@@ -92,12 +102,15 @@ The following classes will be reported as deprecated:
92102

93103
<br/>
94104

95-
### `entryPoint`
105+
### `tsconfig`
96106

97-
Main CSS file that imports Tailwind CSS.
98-
99-
**Type**: string
100-
**Default**: Default CSS lookup
107+
The path to the `tsconfig.json` file. If not specified, the plugin will try to find it automatically.
108+
This can also be set globally via the [`settings` object](../settings/settings.md#tsconfig).
109+
110+
The tsconfig is used to resolve tsconfig [`path`](https://www.typescriptlang.org/tsconfig/#paths) aliases.
111+
112+
**Type**: `string`
113+
**Default**: `undefined`
101114

102115
</details>
103116

docs/rules/no-unregistered-classes.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ Disallow unregistered classes in tailwindcss class strings. Unregistered classes
9393
**Type**: `string`
9494
**Default**: `undefined`
9595

96+
<br/>
97+
98+
### `tsconfig`
99+
100+
The path to the `tsconfig.json` file. If not specified, the plugin will try to find it automatically.
101+
This can also be set globally via the [`settings` object](../settings/settings.md#tsconfig).
102+
103+
The tsconfig is used to resolve tsconfig [`path`](https://www.typescriptlang.org/tsconfig/#paths) aliases.
104+
105+
**Type**: `string`
106+
**Default**: `undefined`
107+
96108
</details>
97109

98110
<br/>

docs/settings/settings.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- [entryPoint](#entrypoint)
66
- [tailwindConfig](#tailwindconfig)
7+
- [tsconfig](#tsconfig)
78
- [attributes](#attributes)
89
- [callees](#callees)
910
- [variables](#variables)
@@ -55,6 +56,18 @@ To set the settings object, add a `settings` key to the eslint config.
5556
For tailwindcss v4 and the css based config, use the [`entryPoint`](#entrypoint) option instead.
5657

5758
**Type**: `string`
59+
60+
<br/>
61+
62+
### `tsconfig`
63+
64+
The path to the `tsconfig.json` file. If not specified, the plugin will try to find it automatically.
65+
This can also be set globally via the [`settings` object](../settings/settings.md#tsconfig).
66+
67+
The tsconfig is used to resolve tsconfig [`path`](https://www.typescriptlang.org/tsconfig/#paths) aliases.
68+
69+
**Type**: `string`
70+
**Default**: `undefined`
5871

5972
<br/>
6073

package-lock.json

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
"postcss": "^8.5.6",
8383
"postcss-import": "^16.1.1",
8484
"synckit": "^0.11.8",
85-
"tailwind-csstree": "^0.1.1"
85+
"tailwind-csstree": "^0.1.1",
86+
"tsconfig-paths-webpack-plugin": "^4.2.0"
8687
},
8788
"devDependencies": {
8889
"@angular/compiler": "^20.1.0",

src/async-utils/cache.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@ import { env } from "node:process";
33
import { getModifiedDate } from "./fs.js";
44

55

6-
const CACHE = new Map<string, { date: Date; value: any; }>();
6+
interface CacheItem {
7+
date: Date;
8+
value: any;
9+
}
10+
11+
const CACHE = new Map<string, CacheItem>();
712

8-
export function invalidateByModifiedDate(cacheDate: Date, path: string): boolean {
13+
export function invalidateByModifiedDate(cache: CacheItem, path: string): boolean {
914
const modified = getModifiedDate(path);
10-
return !modified || modified > cacheDate;
15+
return !modified || modified > cache.date;
1116
}
1217

13-
export function withCache<Result>(key: string, callback: () => Result, invalidate?: (cacheDate: Date, cacheKey: string) => boolean): Result;
14-
export function withCache<Result>(key: string, callback: () => Promise<Result>, invalidate?: (cacheDate: Date, cacheKey: string) => boolean): Promise<Result>;
15-
export function withCache<Result>(key: string, callback: () => Promise<Result> | Result, invalidate: (cacheDate: Date, cacheKey: string) => boolean = invalidateByModifiedDate): Promise<Result> | Result {
18+
export function withCache<Result>(key: string, callback: () => Result, invalidate?: (cache: CacheItem, cacheKey: string) => boolean): Result;
19+
export function withCache<Result>(key: string, callback: () => Promise<Result>, invalidate?: (cache: CacheItem, cacheKey: string) => boolean): Promise<Result>;
20+
export function withCache<Result>(key: string, callback: () => Promise<Result> | Result, invalidate: (cache: CacheItem, cacheKey: string) => boolean = invalidateByModifiedDate): Promise<Result> | Result {
1621
const cached = CACHE.get(key);
1722

18-
if(env.NODE_ENV !== "test" && cached && !invalidate(cached.date, key)){
23+
if(env.NODE_ENV !== "test" && cached && !invalidate(cached, key)){
1924
return cached.value;
2025
}
2126

0 commit comments

Comments
 (0)