File tree Expand file tree Collapse file tree 7 files changed +42
-25
lines changed Expand file tree Collapse file tree 7 files changed +42
-25
lines changed Original file line number Diff line number Diff line change 17
17
/** build */
18
18
function build ( input , out , injects = [ ] ) {
19
19
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 ] )
22
22
fs . writeFileSync ( out , code , "utf8" )
23
23
}
24
24
@@ -28,7 +28,7 @@ function bundle(entryPoint, externals) {
28
28
entryPoints : [ entryPoint ] ,
29
29
format : "esm" ,
30
30
bundle : true ,
31
- external : [ "path" , ... externals ] ,
31
+ external : externals ,
32
32
write : false ,
33
33
} )
34
34
Original file line number Diff line number Diff line change @@ -4,7 +4,11 @@ function dirname(p) {
4
4
return p . split ( "/" ) . slice ( 0 , - 1 ) . join ( "/" ) || p
5
5
}
6
6
7
- const posix = { dirname }
7
+ function extname ( p ) {
8
+ return / \. [ \w $ - ] + $ / iu. exec ( p ) [ 0 ]
9
+ }
10
+
11
+ const posix = { dirname, extname }
8
12
posix . posix = posix
9
- export { dirname , posix }
13
+ export { dirname , extname , posix }
10
14
export default posix
Original file line number Diff line number Diff line change 1
1
<script >
2
2
import { onMount } from " svelte"
3
3
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"
5
9
6
10
const linter = createLinter ()
7
11
11
15
let time = " "
12
16
let options = {
13
17
filename: " example.svelte" ,
18
+ preprocess,
19
+ postprocess,
14
20
}
15
21
let showDiff = false
16
22
Original file line number Diff line number Diff line change 6
6
DEFAULT_RULES_CONFIG ,
7
7
getURL ,
8
8
createLinter ,
9
+ preprocess ,
10
+ postprocess ,
9
11
} from " ../eslint/scripts/linter.js"
10
12
11
13
const linter = createLinter ()
69
71
let time = " "
70
72
let options = {
71
73
filename: " example.svelte" ,
74
+ preprocess,
75
+ postprocess,
72
76
}
73
77
74
78
$: serializedString = (() => {
Original file line number Diff line number Diff line change 2
2
import { rules as pluginRules } from "../../../../../src/utils/rules.ts"
3
3
import { Linter } from "eslint"
4
4
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"
5
7
6
8
const linter = new Linter ( )
7
9
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import type { RuleModule } from "./types"
2
2
import { rules as ruleList } from "./utils/rules"
3
3
import base from "./configs/base"
4
4
import recommended from "./configs/recommended"
5
- import { processor } from "./processor"
5
+ import * as processor from "./processor"
6
6
7
7
const configs = {
8
8
base,
Original file line number Diff line number Diff line change 1
1
import type { Linter } from "eslint"
2
2
import type { Shared } from "../shared"
3
3
import { beginShared , terminateShared } from "../shared"
4
- export const processor = {
5
- preprocess ( code : string , filename : string ) : string [ ] {
6
- if ( filename ) {
7
- beginShared ( filename )
8
- }
9
4
10
- return [ code ]
11
- } ,
5
+ /** preprocess */
6
+ export function preprocess ( code : string , filename : string ) : string [ ] {
7
+ if ( filename ) {
8
+ beginShared ( filename )
9
+ }
12
10
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
+ }
21
13
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
+ }
24
23
25
- supportsAutofix : true ,
24
+ return messages
26
25
}
27
26
27
+ export const supportsAutofix = true
28
+
28
29
/** Filter */
29
30
function filter (
30
31
messages : Linter . LintMessage [ ] ,
You can’t perform that action at this time.
0 commit comments