Skip to content

Commit

Permalink
fix prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
MP281X committed May 10, 2024
1 parent 33f71df commit f0cf22e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"type": "module",
"version": "1.1.19",
"version": "1.1.20",
"name": "@mp281x/shared-config",
"publishConfig": { "registry": "https://npm.pkg.github.com/@mp281x" },

"scripts": { "dev": "tsup-node --watch", "check": "./dist/task-runner.js --check --test" },
"scripts": {
"dev": "tsup-node --watch",
"fix": "./dist/task-runner.js --fix",
"check": "./dist/task-runner.js --check --test"
},

"files": ["./dist/*", "./src/tsconfig.json"],
"bin": { "task-runner": "./dist/task-runner.js" },
Expand Down
2 changes: 1 addition & 1 deletion src/lib/execCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const execCmd = async ({ title, cmd, customCmd, mode, cwd }: ExecCmd) =>

output.stderr.on('data', (msg: Buffer) => void log.error(title, msg))

output.on('exit', (exitCode) => {
output.on('exit', exitCode => {
if (exitCode === 0 || exitCode === null) return resolve()
if (process.argv[2] === 'dev') return resolve()

Expand Down
2 changes: 1 addition & 1 deletion src/lib/findGlob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const gitIgnore = parseConfig<string[]>(`${process.cwd()}/.gitignore`) ?? []
export const findGlob: typeof fs.globSync = (glob, options) =>
fs.globSync(glob, {
cwd: options?.cwd ?? process.cwd(),
exclude: (path) => options?.exclude?.(path) || gitIgnore.includes(path)
exclude: path => options?.exclude?.(path) || gitIgnore.includes(path)
})

if (import.meta.vitest) {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/findProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ const getWorkspaceProjects = (dir: string) => {
type PNPMWorkspace = { packages?: string[] }
globs.push(...(parseConfig<PNPMWorkspace>(`${dir}/pnpm-workspace.yaml`)?.packages ?? []))

return globs.flatMap((glob) => findGlob(glob, { cwd: dir })).filter((path) => fs.existsSync(`${dir}/${path}/package.json`))
return globs.flatMap(glob => findGlob(glob, { cwd: dir })).filter(path => fs.existsSync(`${dir}/${path}/package.json`))
}

export type Project = { cwd: string; name: string; scripts: string[]; lspPlugin: boolean; type: 'node' | 'svelte' }
// find all the projects in a the monorepo/repo
export const findProjects = (dir: string = process.cwd()): Project[] => {
const projects = getWorkspaceProjects(dir).flatMap((project) => findProjects(project))
const projects = getWorkspaceProjects(dir).flatMap(project => findProjects(project))

if (projects.length > 0) return projects
if (!fs.existsSync(`${dir}/package.json`)) return []
Expand All @@ -32,7 +32,7 @@ export const findProjects = (dir: string = process.cwd()): Project[] => {
type TSConfig = { compilerOptions?: { plugins?: { name: string }[] } }
const { compilerOptions } = parseConfig<TSConfig>(`${dir}/tsconfig.json`) ?? {}

const lspPlugin = compilerOptions?.plugins?.find((x) => x.name === 'lsp-plugin') !== undefined
const lspPlugin = compilerOptions?.plugins?.find(x => x.name === 'lsp-plugin') !== undefined

return [
{
Expand Down
8 changes: 4 additions & 4 deletions src/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,18 @@ const parseVitestOutput = (input: string): { name: string; errors: string[] }[]
}
const vitestData = JSON.parse(input) as VitestJSON
if (vitestData.success) return []
return vitestData.testResults.flatMap((testFile) => {
return vitestData.testResults.flatMap(testFile => {
const filePath = testFile.name.replace(process.cwd(), '').split('/').slice(3).join('/')

return testFile.assertionResults
.filter((test) => test.status === 'failed')
.map((test) => ({
.filter(test => test.status === 'failed')
.map(test => ({
name: `\x1b[91m[${filePath} -> "${test.title}"]\x1b[0m`,
// split on lines and on new error
errors: test.failureMessages
.join('\n')
.split('\n')
.filter((logMsg) => logMsg.trim() !== '')
.filter(logMsg => logMsg.trim() !== '')
}))
})
}
4 changes: 2 additions & 2 deletions src/lib/parseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const parseConfig = <Res>(path: string): Res | undefined => {
.readFileSync(path)
.toString()
.split('\n')
.map((line) => line.split('#').shift()?.trim())
.filter((line) => line !== '' && line !== undefined) as string[]
.map(line => line.split('#').shift()?.trim())
.filter(line => line !== '' && line !== undefined) as string[]
}

// @ts-expect-error
Expand Down
3 changes: 2 additions & 1 deletion src/prettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ export default {
printWidth: 150,
singleQuote: true,
trailingComma: 'none',
arrowParens: 'always',
arrowParens: 'avoid',
quoteProps: 'consistent',
experimentalTernaries: true,
overrides: [{ files: '*.json', options: { parser: 'jsonc' } }],
plugins: ['prettier-plugin-svelte', 'prettier-plugin-astro', 'prettier-plugin-tailwindcss']
} satisfies Config

0 comments on commit f0cf22e

Please sign in to comment.