Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
fix: load tslint dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Apr 5, 2021
1 parent f20ac36 commit c2189f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { shim } from "./compat-shim";
import { defaultConfig } from "./config"
import type { ConfigSchema } from "./config"
import type { emit } from 'node:cluster';
import * as Tslint from "tslint";
import type * as Tslint from "tslint";
import type * as Ts from "typescript";
import type { JobMessage, ConfigMessage } from "./workerHelper"
import { RuleFailure } from 'tslint';
Expand Down Expand Up @@ -141,6 +141,8 @@ function getSeverity(failure: RuleFailure) {
return ['info', 'warning', 'error'].includes(severity) ? severity : 'warning';
}

let tslint: undefined | typeof import("tslint")

function loadTslintConfig(Linter: typeof Tslint.Linter, filePath: string) {
let configurationPath: string | undefined
let configuration: Tslint.Configuration.IConfigurationFile | undefined
Expand All @@ -156,7 +158,10 @@ function loadTslintConfig(Linter: typeof Tslint.Linter, filePath: string) {
let configExtends = configuration?.extends ?? []
if (configurationPath !== undefined && configExtends !== undefined && configExtends.length === 0) {
try {
const configurationJson = Tslint.Configuration.readConfigurationFile?.(configurationPath)
if (!tslint) {
tslint = require("tslint") as typeof import("tslint")
}
const configurationJson = tslint.Configuration.readConfigurationFile?.(configurationPath)
const extendsJson = configurationJson.extends
if (typeof extendsJson === "string") {
configExtends = [...configExtends, extendsJson]
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const CommonConfig = {
sourcemap: true,
},
],
external: ["atom"],
external: ["atom", "tslint"],
plugins,
}

Expand Down

0 comments on commit c2189f7

Please sign in to comment.