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 1717/** build */
1818function 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
Original file line number Diff line number Diff 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 }
812posix . posix = posix
9- export { dirname , posix }
13+ export { dirname , extname , posix }
1014export default posix
Original file line number Diff line number Diff line change 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
1115 let time = " "
1216 let options = {
1317 filename: " example.svelte" ,
18+ preprocess,
19+ postprocess,
1420 }
1521 let showDiff = false
1622
Original file line number Diff line number Diff line change 66 DEFAULT_RULES_CONFIG ,
77 getURL ,
88 createLinter ,
9+ preprocess ,
10+ postprocess ,
911 } from " ../eslint/scripts/linter.js"
1012
1113 const linter = createLinter ()
6971 let time = " "
7072 let options = {
7173 filename: " example.svelte" ,
74+ preprocess,
75+ postprocess,
7276 }
7377
7478 $: serializedString = (() => {
Original file line number Diff line number Diff line change 22import { rules as pluginRules } from "../../../../../src/utils/rules.ts"
33import { Linter } from "eslint"
44import * 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
68const linter = new Linter ( )
79
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import type { RuleModule } from "./types"
22import { rules as ruleList } from "./utils/rules"
33import base from "./configs/base"
44import recommended from "./configs/recommended"
5- import { processor } from "./processor"
5+ import * as processor from "./processor"
66
77const configs = {
88 base,
Original file line number Diff line number Diff line change 11import type { Linter } from "eslint"
22import type { Shared } from "../shared"
33import { 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 */
2930function filter (
3031 messages : Linter . LintMessage [ ] ,
You can’t perform that action at this time.
0 commit comments