-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
77 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
module.exports = { | ||
extends: ['@u3u'], | ||
ignorePatterns: ['dist', '__fixtures__'], | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { extendConfig } from './utils' | ||
import { require } from './utils/require' | ||
import { extendConfig } from './utils'; | ||
import { require } from './utils/require'; | ||
|
||
export default extendConfig({ | ||
plugins: [require.resolve('prettier-plugin-tailwindcss')], | ||
tailwindAttributes: ['tw'], | ||
tailwindFunctions: ['clsx', 'tw', 'twMerge', 'twJoin'], | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import config from '.' | ||
import { defineConfig } from './utils' | ||
import { require } from './utils/require' | ||
import config from '.'; | ||
import { defineConfig } from './utils'; | ||
import { require } from './utils/require'; | ||
|
||
export default defineConfig({ | ||
...config, | ||
plugins: [require.resolve('./with-twin.macro'), ...config.plugins.slice(1)], | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
declare module '@ianvs/prettier-plugin-sort-imports' { | ||
import { type Plugin } from 'prettier' | ||
import { type Plugin } from 'prettier'; | ||
|
||
const sortImportsPlugin: Required<Plugin> | ||
const sortImportsPlugin: Required<Plugin>; | ||
|
||
export default sortImportsPlugin | ||
export default sortImportsPlugin; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
declare module 'prettier-plugin-twin.macro' { | ||
import { type Plugin } from 'prettier' | ||
import { type Plugin } from 'prettier'; | ||
|
||
const tailwindPlugin: Required<Plugin> | ||
const tailwindPlugin: Required<Plugin>; | ||
|
||
export default tailwindPlugin | ||
export default tailwindPlugin; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './utils/index' | ||
export * from './utils/index'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { type Config } from 'prettier' | ||
import { type Config } from 'prettier'; | ||
|
||
export const defineConfig = <T extends Config>(config: T) => config | ||
export const defineConfig = <T extends Config>(config: T) => config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { type Plugin } from 'prettier' | ||
import { type Plugin } from 'prettier'; | ||
|
||
export const definePlugin = <T extends Plugin>(plugin: T) => plugin | ||
export const definePlugin = <T extends Plugin>(plugin: T) => plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import deepmerge from 'deepmerge' | ||
import { type Config } from 'prettier' | ||
import config from '..' | ||
import deepmerge from 'deepmerge'; | ||
import { type Config } from 'prettier'; | ||
import config from '..'; | ||
|
||
export const extendConfig = <T extends Config | typeof config>(userConfig: T, options?: deepmerge.Options) => { | ||
return deepmerge(config, userConfig, options) | ||
} | ||
return deepmerge(config, userConfig, options); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from './define-config' | ||
export * from './define-plugin' | ||
export * from './extend-config' | ||
export * from './with-sort-plugin' | ||
export * from './define-config'; | ||
export * from './define-plugin'; | ||
export * from './extend-config'; | ||
export * from './with-sort-plugin'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { createRequire } from 'node:module' | ||
import { createRequire } from 'node:module'; | ||
|
||
export const require = createRequire(import.meta.url) | ||
export const require = createRequire(import.meta.url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { withSortPlugin } from './utils' | ||
import { require } from './utils/require' | ||
import { withSortPlugin } from './utils'; | ||
import { require } from './utils/require'; | ||
|
||
export default withSortPlugin(require('prettier-plugin-twin.macro')) | ||
export default withSortPlugin(require('prettier-plugin-twin.macro')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import fs from 'node:fs/promises' | ||
import path from 'node:path' | ||
import prettier from 'prettier' | ||
import { require } from '../src/utils/require' | ||
import fs from 'node:fs/promises'; | ||
import path from 'node:path'; | ||
import prettier from 'prettier'; | ||
import { require } from '../src/utils/require'; | ||
|
||
export const format = async (file: string, config = '@u3u/prettier-config') => { | ||
const filepath = path.resolve('test/__fixtures__', file) | ||
const options = await prettier.resolveConfig('', { config: require.resolve(config) }) | ||
const filepath = path.resolve('test/__fixtures__', file); | ||
const options = await prettier.resolveConfig('', { config: require.resolve(config) }); | ||
|
||
const info = await prettier.getFileInfo(filepath, { | ||
// https://github.com/prettier/prettier-vscode/blob/d5ac67aa66822641491039a53dbe6388e5cd2594/src/PrettierEditService.ts#L420 | ||
plugins: options?.plugins?.filter((item): item is string => typeof item === 'string'), | ||
resolveConfig: true, | ||
}) | ||
}); | ||
|
||
console.log(file, info) | ||
console.log(file, info); | ||
|
||
const buffer = await fs.readFile(filepath) | ||
const code = buffer.toString('utf8') | ||
const buffer = await fs.readFile(filepath); | ||
const code = buffer.toString('utf8'); | ||
|
||
const result = prettier.format(code, { | ||
...options, | ||
filepath, | ||
parser: info.inferredParser || undefined, | ||
}) | ||
}); | ||
|
||
return result | ||
} | ||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
import path from 'node:path' | ||
import { globby } from 'globby' | ||
import { expect, it } from 'vitest' | ||
import { format } from './format' | ||
import path from 'node:path'; | ||
import { globby } from 'globby'; | ||
import { expect, it } from 'vitest'; | ||
import { format } from './format'; | ||
|
||
it('should match snapshots', async () => { | ||
const paths = await globby('*', { | ||
cwd: 'test/__fixtures__', | ||
dot: true, | ||
ignore: ['tw.ts', 'twin.macro.ts'], | ||
}) | ||
}); | ||
|
||
for (const filepath of paths) { | ||
const result = await format(filepath) | ||
const result = await format(filepath); | ||
|
||
expect(result).toMatchSnapshot(path.basename(filepath)) | ||
expect(result).toMatchSnapshot(path.basename(filepath)); | ||
} | ||
}) | ||
}); | ||
|
||
it('tailwindcss classes should sorted', async () => { | ||
const result = await format('tw.ts', '@u3u/prettier-config/tw') | ||
const result = await format('tw.ts', '@u3u/prettier-config/tw'); | ||
|
||
expect(result).toMatchSnapshot() | ||
}) | ||
expect(result).toMatchSnapshot(); | ||
}); | ||
|
||
it('twin.macro classes should sorted', async () => { | ||
const result = await format('twin.macro.ts', '@u3u/prettier-config/twin.macro') | ||
const result = await format('twin.macro.ts', '@u3u/prettier-config/twin.macro'); | ||
|
||
expect(result).toMatchSnapshot() | ||
}) | ||
expect(result).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { defineConfig } from 'tsup' | ||
import { defineConfig } from 'tsup'; | ||
|
||
export default defineConfig({ | ||
clean: true, | ||
dts: { resolve: true }, | ||
entry: ['src/*.ts'], | ||
format: ['cjs', 'esm'], | ||
shims: true, | ||
}) | ||
}); |