Skip to content

Commit

Permalink
Several small fixes
Browse files Browse the repository at this point in the history
closes #4, closes #5, closes #6, closes #7
  • Loading branch information
vknabel committed Feb 21, 2020
1 parent 7691cd9 commit 2cd5d25
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.0.4

- Fixed: Unexpected end of JSON input #4 and #7
- Fixed: `ERR_CHILD_PROCESS_STDIO_MAXBUFFER` stdout maxBuffer length exceeded #5
- Fixed: No lintable files found at paths #6

## 1.0.3

- Fixed: `swiftlint.configSearchPaths` was not respected
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "git",
"url": "https://github.com/vknabel/vscode-swiftlint"
},
"version": "1.0.3",
"version": "1.0.4",
"license": "MIT",
"author": {
"name": "Valentin Knabel",
Expand Down
26 changes: 21 additions & 5 deletions src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export async function diagnosticsForDocument(request: {
if (input.trim() === "") {
return [];
}
const lintingPaths = request.parameters || [];
if (lintingPaths.length === 0) {
return [];
}
const lintingResults = await execSwiftlint(
request.document.uri,
request.parameters || [],
Expand All @@ -44,11 +48,16 @@ export async function diagnosticsForDocument(request: {
input
}
);
const reports: Report[] = JSON.parse(lintingResults) || [];
const diagnostics = reports.map(
reportToPreciseDiagnosticForDocument(request.document)
);
return diagnostics;
try {
const reports: Report[] = JSON.parse(lintingResults) || [];
const diagnostics = reports.map(
reportToPreciseDiagnosticForDocument(request.document)
);
return diagnostics;
} catch (error) {
console.log("[Parsing linting results]", error);
return [];
}
}

export async function diagnosticsForFolder(request: {
Expand Down Expand Up @@ -177,6 +186,13 @@ function execSwiftlint(
(error, stdout, stderr) => {
if (error && isExecException(error) && error.code === 2) {
return resolve(stdout);
} else if (
error &&
"code" in error &&
error["code"] === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER"
) {
console.log("stderr", stderr);
return resolve("[]");
} else if (error) {
console.log("stderr", stderr);
return reject(error);
Expand Down

0 comments on commit 2cd5d25

Please sign in to comment.