Skip to content

Commit ad2865c

Browse files
committed
fix: resolve build/test failures and relax eslint callback rules
1 parent 4283b25 commit ad2865c

File tree

7 files changed

+30
-23
lines changed

7 files changed

+30
-23
lines changed

eslint.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ export default icebreaker(
44
{
55
ignores: ['**/fixtures/**', 'website/public/_pagefind'],
66
},
7+
{
8+
rules: {
9+
'dot-notation': 'off',
10+
'prefer-arrow-callback': 'off',
11+
},
12+
},
713
)

packages/config/src/defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function getDefaultTransformerConfig(): TransformerOptions {
3232
include: defaultPipelineInclude,
3333
exclude: defaultPipelineExclude,
3434
},
35-
disabled: process.env.NODE_ENV === 'development',
35+
disabled: process.env['NODE_ENV'] === 'development',
3636
registry: {
3737
file: '.tw-patch/tw-class-list.json',
3838
mapping: {

packages/shared/test/classGenerator.behavior.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ClassGenerator } from '@/classGenerator'
2+
import process from 'node:process'
23

34
describe('ClassGenerator behaviour', () => {
45
it('respects include/exclude filters and ignore rules', () => {
@@ -51,21 +52,21 @@ describe('ClassGenerator behaviour', () => {
5152
})
5253

5354
it('skips logging when reserved name is encountered without log flag', () => {
54-
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => undefined)
55+
const writeSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true)
5556
const generator = new ClassGenerator({
5657
reserveClassName: [/^tw-a$/u],
5758
})
5859

5960
const result = generator.generateClassName('foo')
6061
expect(result.name).toBe('tw-b')
6162
expect(generator.newClassSize).toBe(2)
62-
expect(logSpy).not.toHaveBeenCalled()
63+
expect(writeSpy).not.toHaveBeenCalled()
6364

64-
logSpy.mockRestore()
65+
writeSpy.mockRestore()
6566
})
6667

6768
it('falls back to default generator and skips reserved results', () => {
68-
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => undefined)
69+
const writeSpy = vi.spyOn(process.stdout, 'write').mockImplementation(() => true)
6970
const generator = new ClassGenerator({
7071
reserveClassName: [/^tw-a$/u],
7172
log: true,
@@ -74,8 +75,8 @@ describe('ClassGenerator behaviour', () => {
7475
const result = generator.generateClassName('foo')
7576
expect(result.name).toBe('tw-b')
7677
expect(generator.newClassSize).toBe(2)
77-
expect(logSpy).toHaveBeenCalledWith('The class name has been reserved. tw-a')
78+
expect(writeSpy).toHaveBeenCalledWith('The class name has been reserved. tw-a\n')
7879

79-
logSpy.mockRestore()
80+
writeSpy.mockRestore()
8081
})
8182
})

packages/tailwindcss-patch/src/cache/store.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,12 @@ export class CacheStore {
308308
return undefined
309309
}
310310

311-
const values = toStringArray(record.values)
311+
const values = toStringArray(record['values'])
312312
if (values.length === 0) {
313313
return undefined
314314
}
315315

316-
const contextRecord = asObject(record.context)
316+
const contextRecord = asObject(record['context'])
317317
if (!contextRecord) {
318318
return undefined
319319
}
@@ -361,7 +361,7 @@ export class CacheStore {
361361
optionsHash,
362362
},
363363
values,
364-
updatedAt: typeof record.updatedAt === 'string' ? record.updatedAt : new Date(0).toISOString(),
364+
updatedAt: typeof record['updatedAt'] === 'string' ? record['updatedAt'] : new Date(0).toISOString(),
365365
}
366366

367367
return normalized
@@ -380,11 +380,11 @@ export class CacheStore {
380380
return { kind: 'invalid' }
381381
}
382382

383-
if (record.schemaVersion !== CACHE_SCHEMA_VERSION) {
383+
if (record['schemaVersion'] !== CACHE_SCHEMA_VERSION) {
384384
return { kind: 'invalid' }
385385
}
386386

387-
const contextsRecord = asObject(record.contexts)
387+
const contextsRecord = asObject(record['contexts'])
388388
if (!contextsRecord) {
389389
return { kind: 'invalid' }
390390
}
@@ -406,7 +406,7 @@ export class CacheStore {
406406
kind: 'v2',
407407
data: {
408408
schemaVersion: CACHE_SCHEMA_VERSION,
409-
updatedAt: typeof record.updatedAt === 'string' ? record.updatedAt : new Date(0).toISOString(),
409+
updatedAt: typeof record['updatedAt'] === 'string' ? record['updatedAt'] : new Date(0).toISOString(),
410410
contexts,
411411
},
412412
}

packages/unplugin-tailwindcss-mangle/src/utils.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ export function getGroupedEntries<T>(
4040
return 'other'
4141
}
4242
})
43-
if (!groupedEntries.css) {
44-
groupedEntries.css = []
43+
if (!groupedEntries['css']) {
44+
groupedEntries['css'] = []
4545
}
46-
if (!groupedEntries.html) {
47-
groupedEntries.html = []
46+
if (!groupedEntries['html']) {
47+
groupedEntries['html'] = []
4848
}
49-
if (!groupedEntries.js) {
50-
groupedEntries.js = []
49+
if (!groupedEntries['js']) {
50+
groupedEntries['js'] = []
5151
}
52-
if (!groupedEntries.other) {
53-
groupedEntries.other = []
52+
if (!groupedEntries['other']) {
53+
groupedEntries['other'] = []
5454
}
5555
return groupedEntries as Record<'css' | 'html' | 'js' | 'other', [string, T][]>
5656
}

packages/unplugin-tailwindcss-mangle/test/transform.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const {
3434
})
3535

3636
vi.mock('@tailwindcss-mangle/core', () => {
37-
const Context = vi.fn(() => {
37+
const Context = vi.fn(function MockContext() {
3838
return mockCtx
3939
})
4040
return {

packages/unplugin-tailwindcss-mangle/test/webpack.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const { mockCtx, mockCssHandler, mockHtmlHandler, mockJsHandler } = vi.hoisted((
2828
})
2929

3030
vi.mock('@tailwindcss-mangle/core', () => {
31-
const Context = vi.fn(() => {
31+
const Context = vi.fn(function MockContext() {
3232
return mockCtx
3333
})
3434
return {

0 commit comments

Comments
 (0)