Skip to content

Commit

Permalink
fix: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Jul 17, 2021
1 parent c4c6887 commit 5b2d475
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/vite-plugin-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@babel/code-frame": "^7.12.13",
"ansi-escapes": "^4.3.0",
"chokidar": "^3.5.1",
"commander": "^8.0.0",
"fast-glob": "^3.2.7",
"lodash.debounce": "^4.0.8",
"lodash.pick": "^4.4.0",
Expand All @@ -44,8 +45,7 @@
"vscode-languageclient": "^7.0.0",
"vscode-languageserver": "^7.0.0",
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-uri": "^3.0.2",
"commander": "^8.0.0"
"vscode-uri": "^3.0.2"
},
"peerDependencies": {
"vite": "^2.0.0"
Expand Down
10 changes: 5 additions & 5 deletions packages/vite-plugin-checker/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ export enum DiagnosticLevel {

export function diagnosticToTerminalLog(d: NormalizedDiagnostic): string {
const labelMap: Record<DiagnosticLevel, string> = {
[DiagnosticLevel.Error]: chalk.bold.red('ERROR'),
[DiagnosticLevel.Warning]: chalk.bold.yellow('WARNING'),
[DiagnosticLevel.Suggestion]: chalk.bold.blue('SUGGESTION'),
[DiagnosticLevel.Message]: chalk.bold.cyan('MESSAGE'),
[DiagnosticLevel.Error]: chalk.bold.bgRed.rgb(0, 0, 0)(' ERROR '),
[DiagnosticLevel.Warning]: chalk.bold.bgYellow.rgb(0, 0, 0)(' WARNING '),
[DiagnosticLevel.Suggestion]: chalk.bold.bgBlue.rgb(0, 0, 0)(' SUGGESTION '),
[DiagnosticLevel.Message]: chalk.bold.bgCyan.rgb(0, 0, 0)(' MESSAGE '),
}

const levelLabel = labelMap[d.level || DiagnosticLevel.Error]
const fileLabel = chalk.green.bold('FILE') + ' '
const fileLabel = chalk.bgGreen.rgb(0, 0, 0).bold(' FILE ') + ' '
const position = d.loc
? chalk.yellow(d.loc.start.line) + ':' + chalk.yellow(d.loc.start.column)
: ''
Expand Down
3 changes: 1 addition & 2 deletions packages/vite-plugin-checker/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function createScript<T extends Partial<BuildInCheckers>>({
): ConfigureServeChecker => {
const isBuild = env.command === 'build'
const worker = new Worker(absFilename, {
workerData: { env, checkerConfig, columns: process.stdout.columns },
workerData: { env, checkerConfig },
})

// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
Expand Down Expand Up @@ -75,7 +75,6 @@ export function createScript<T extends Partial<BuildInCheckers>>({
let diagnostic: CheckerDiagnostic | null = null
if (!parentPort) throw Error('should have parentPort as file runs in worker thread')
const isBuild = workerData.env.command === 'build'
process.stdout.columns = workerData.columns
// only run bin command and do not listen message in build mode

const port = parentPort.on(
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5b2d475

Please sign in to comment.