Skip to content

Commit e1e0252

Browse files
authored
fix site (#82)
1 parent 6183b6e commit e1e0252

File tree

7 files changed

+42
-25
lines changed

7 files changed

+42
-25
lines changed

docs-svelte-kit/build-system/build.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ build(
1717
/** build */
1818
function build(input, out, injects = []) {
1919
console.log(`build@ ${input}`)
20-
let code = bundle(input, injects)
21-
code = transform(code, injects)
20+
let code = bundle(input, ["path", ...injects])
21+
code = transform(code, ["path", ...injects])
2222
fs.writeFileSync(out, code, "utf8")
2323
}
2424

@@ -28,7 +28,7 @@ function bundle(entryPoint, externals) {
2828
entryPoints: [entryPoint],
2929
format: "esm",
3030
bundle: true,
31-
external: ["path", ...externals],
31+
external: externals,
3232
write: false,
3333
})
3434

docs-svelte-kit/shim/path.mjs

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ function dirname(p) {
44
return p.split("/").slice(0, -1).join("/") || p
55
}
66

7-
const posix = { dirname }
7+
function extname(p) {
8+
return /\.[\w$-]+$/iu.exec(p)[0]
9+
}
10+
11+
const posix = { dirname, extname }
812
posix.posix = posix
9-
export { dirname, posix }
13+
export { dirname, extname, posix }
1014
export default posix

docs-svelte-kit/src/lib/components/ESLintCodeBlock.svelte

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<script>
22
import { onMount } from "svelte"
33
import ESLintEditor from "../eslint/ESLintEditor.svelte"
4-
import { createLinter } from "../eslint/scripts/linter.js"
4+
import {
5+
createLinter,
6+
preprocess,
7+
postprocess,
8+
} from "../eslint/scripts/linter.js"
59
610
const linter = createLinter()
711
@@ -11,6 +15,8 @@
1115
let time = ""
1216
let options = {
1317
filename: "example.svelte",
18+
preprocess,
19+
postprocess,
1420
}
1521
let showDiff = false
1622

docs-svelte-kit/src/lib/components/ESLintPlayground.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
DEFAULT_RULES_CONFIG,
77
getURL,
88
createLinter,
9+
preprocess,
10+
postprocess,
911
} from "../eslint/scripts/linter.js"
1012
1113
const linter = createLinter()
@@ -69,6 +71,8 @@
6971
let time = ""
7072
let options = {
7173
filename: "example.svelte",
74+
preprocess,
75+
postprocess,
7276
}
7377
7478
$: serializedString = (() => {

docs-svelte-kit/src/lib/eslint/scripts/linter.js

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import { rules as pluginRules } from "../../../../../src/utils/rules.ts"
33
import { Linter } from "eslint"
44
import * as svelteEslintParser from "svelte-eslint-parser"
5+
// eslint-disable-next-line node/file-extension-in-import -- ignore
6+
export { preprocess, postprocess } from "../../../../../src/processor/index.ts"
57

68
const linter = new Linter()
79

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { RuleModule } from "./types"
22
import { rules as ruleList } from "./utils/rules"
33
import base from "./configs/base"
44
import recommended from "./configs/recommended"
5-
import { processor } from "./processor"
5+
import * as processor from "./processor"
66

77
const configs = {
88
base,

src/processor/index.ts

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
import type { Linter } from "eslint"
22
import type { Shared } from "../shared"
33
import { beginShared, terminateShared } from "../shared"
4-
export const processor = {
5-
preprocess(code: string, filename: string): string[] {
6-
if (filename) {
7-
beginShared(filename)
8-
}
94

10-
return [code]
11-
},
5+
/** preprocess */
6+
export function preprocess(code: string, filename: string): string[] {
7+
if (filename) {
8+
beginShared(filename)
9+
}
1210

13-
postprocess(
14-
[messages]: Linter.LintMessage[][],
15-
filename: string,
16-
): Linter.LintMessage[] {
17-
const shared = terminateShared(filename)
18-
if (shared) {
19-
return filter(messages, shared)
20-
}
11+
return [code]
12+
}
2113

22-
return messages
23-
},
14+
/** postprocess */
15+
export function postprocess(
16+
[messages]: Linter.LintMessage[][],
17+
filename: string,
18+
): Linter.LintMessage[] {
19+
const shared = terminateShared(filename)
20+
if (shared) {
21+
return filter(messages, shared)
22+
}
2423

25-
supportsAutofix: true,
24+
return messages
2625
}
2726

27+
export const supportsAutofix = true
28+
2829
/** Filter */
2930
function filter(
3031
messages: Linter.LintMessage[],

0 commit comments

Comments
 (0)