This repository was archived by the owner on Aug 7, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -57,12 +57,12 @@ export interface ConfigSchema {
57
57
globalNodePath : string | null ,
58
58
}
59
59
60
- export const defaultConfig = {
60
+ export const defaultConfig = Object . freeze ( {
61
61
enableSemanticRules : false ,
62
62
rulesDirectory : "" ,
63
63
fixOnSave : false ,
64
64
ignoreTypings : false ,
65
65
useLocalTslint : true ,
66
66
useGlobalTslint : false ,
67
67
globalNodePath : "" ,
68
- }
68
+ } as const )
Original file line number Diff line number Diff line change @@ -3,12 +3,12 @@ import path from 'path';
3
3
import { promises } from 'fs' ;
4
4
const { stat } = promises ;
5
5
import { WorkerHelper } from './workerHelper' ;
6
- import { defaultConfig } from "./config"
6
+ import { defaultConfig , ConfigSchema } from "./config"
7
7
8
8
const grammarScopes = [ 'source.ts' , 'source.tsx' ] ;
9
9
const editorClass = 'linter-tslint-compatible-editor' ;
10
10
const idleCallbacks = new Set ( ) ;
11
- const config = defaultConfig ;
11
+ const config : ConfigSchema = { ... defaultConfig } // copy of default config
12
12
13
13
// Worker still hasn't initialized, since the queued idle callbacks are
14
14
// done in order, waiting on a newly queued idle callback will ensure that
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { getRuleUri } from 'tslint-rule-documentation';
7
7
import ChildProcess from 'child_process' ;
8
8
import getPath from 'consistent-path' ;
9
9
import { shim } from "./compat-shim" ;
10
+ import { defaultConfig } from "./config"
10
11
import type { ConfigSchema } from "./config"
11
12
import type { emit } from 'node:cluster' ;
12
13
import type * as Tslint from "tslint" ;
@@ -17,9 +18,7 @@ process.title = 'linter-tslint worker';
17
18
18
19
const tslintModuleName = 'tslint' ;
19
20
const tslintCache = new Map < string , typeof Tslint . Linter > ( ) ;
20
- const config : ConfigSchema = {
21
- useLocalTslint : false ,
22
- } ;
21
+ const config : ConfigSchema = { ...defaultConfig } // copy of default config
23
22
24
23
let fallbackLinter : typeof Tslint . Linter ;
25
24
let requireResolve : typeof import ( "resolve" ) ;
@@ -233,6 +232,7 @@ async function TsLintWorker(initialConfig: ConfigSchema) {
233
232
234
233
process . on ( 'message' , async ( message : JobMessage | ConfigMessage ) => {
235
234
if ( message . messageType === 'config' ) {
235
+ // set the config for the worker
236
236
config [ message . message . key ] = message . message . value ;
237
237
238
238
if ( message . message . key === 'useLocalTslint' ) {
Original file line number Diff line number Diff line change @@ -81,8 +81,8 @@ export class WorkerHelper {
81
81
export type ConfigMessage = {
82
82
messageType : 'config' ,
83
83
message : {
84
- key : string ,
85
- value : any ,
84
+ key : keyof ConfigSchema ,
85
+ value : boolean | string | null ,
86
86
}
87
87
}
88
88
You can’t perform that action at this time.
0 commit comments