Skip to content

Commit

Permalink
fix(stylelint): correct code frame
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Oct 13, 2022
1 parent 333ba13 commit 443567c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 11 deletions.
8 changes: 5 additions & 3 deletions packages/vite-plugin-checker/src/checkers/stylelint/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import chokidar from 'chokidar'
import stylelint from 'stylelint'
import translateOptions from './options'
import translateOptions from './options.js'
import path from 'path'
import { fileURLToPath } from 'url'
import { parentPort } from 'worker_threads'
Expand All @@ -19,6 +19,7 @@ import {
import { ACTION_TYPES, DiagnosticLevel } from '../../types.js'

const manager = new FileDiagnosticManager()
let createServeAndBuild

import type { CreateDiagnostic } from '../../types.js'

Expand Down Expand Up @@ -134,12 +135,13 @@ export class StylelintChecker extends Checker<'stylelint'> {
}

public init() {
const createServeAndBuild = super.initMainThread()
module.exports.createServeAndBuild = createServeAndBuild
const _createServeAndBuild = super.initMainThread()
createServeAndBuild = _createServeAndBuild
super.initWorkerThread()
}
}

export { createServeAndBuild }
const stylelintChecker = new StylelintChecker()
stylelintChecker.prepare()
stylelintChecker.init()
3 changes: 2 additions & 1 deletion packages/vite-plugin-checker/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ export function normalizeStylelintDiagnostic(
}

const codeFrame = createFrame({
source: diagnostic.source ?? '',
// @ts-ignore
source: diagnostic._postcssResult.css ?? '',
location: loc,
})

Expand Down
52 changes: 45 additions & 7 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 443567c

Please sign in to comment.