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

Commit

Permalink
Fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Feb 10, 2021
1 parent d598266 commit f28a428
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TypeScriptVersion } from "@definitelytyped/typescript-versions";
import { typeScriptPath } from "@definitelytyped/utils";
import assert = require("assert");
import { pathExists } from "fs-extra";
import { join as joinPaths, normalize, basename, dirname } from "path";
import { basename, dirname, join as joinPaths, normalize } from "path";
import { Configuration, ILinterOptions, Linter } from "tslint";
import * as TsType from "typescript";
type Configuration = typeof Configuration;
Expand Down Expand Up @@ -77,17 +77,18 @@ function testDependencies(
getNewLine: () => "\n",
});

const message = `Errors in typescript@${version} for external dependencies:\n${showDiags}`
const message = `Errors in typescript@${version} for external dependencies:\n${showDiags}`;

// Add an edge-case for someone needing to `npm install` in react when they first edit a DT module which depends on it - #226
const cannotFindDepsDiags = diagnostics.find(d => d.code === 2307 && d.messageText.toString().includes("Cannot find module"))
const cannotFindDepsDiags = diagnostics.find(d => d.code === 2307 && d.messageText.toString().includes("Cannot find module"));
if (cannotFindDepsDiags && cannotFindDepsDiags.file) {
const path = cannotFindDepsDiags.file.fileName
const typesFolder = basename(dirname(path))
const path = cannotFindDepsDiags.file.fileName;
const typesFolder = basename(dirname(path));

return `A module look-up failed, the most common case for this error are dependencies which needs to be \`npm installed\` before you can lint.
Before you debug, first try running:
return `
A module look-up failed, this often occurs when you need to run \`npm install\` on a dependent module before you can lint.
Before you debug, first try running:
npm install --prefix types/${typesFolder}
Then re-run. Full error logs are below.
Expand Down

0 comments on commit f28a428

Please sign in to comment.