Skip to content

Commit

Permalink
- vscode - Add manual lint-on-save command to vscode-jslint extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizhu256 committed Apr 29, 2023
1 parent e31ec0b commit 8f546d2
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 13 deletions.
27 changes: 22 additions & 5 deletions .ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ import moduleFs from "fs";
"onCommand:jslint.clear",
"onCommand:jslint.disableRegion",
"onCommand:jslint.ignoreLine",
"onCommand:jslint.lint"
"onCommand:jslint.lint",
"onCommand:jslint.lintAndSave"
],
"bugs": {
"url": "https://github.com/jslint-org/jslint/issues"
Expand Down Expand Up @@ -364,6 +365,11 @@ import moduleFs from "fs";
"category": "jslint",
"command": "jslint.lint",
"title": "JSLint - Lint File"
},
{
"category": "jslint",
"command": "jslint.lintAndSave",
"title": "JSLint - Lint File and Save"
}
],
"keybindings": [
Expand All @@ -378,6 +384,12 @@ import moduleFs from "fs";
"key": "ctrl+shift+j l",
"mac": "cmd+shift+j l",
"when": "editorTextFocus"
},
{
"command": "jslint.lintAndSave",
"key": "ctrl+shift+j s",
"mac": "cmd+shift+j s",
"when": "editorTextFocus"
}
],
"menus": {
Expand All @@ -388,19 +400,24 @@ import moduleFs from "fs";
"when": "resourceLangId == javascript"
},
{
"command": "jslint.clear",
"command": "jslint.lintAndSave",
"group": "7_modification@2",
"when": "resourceLangId == javascript"
},
{
"command": "jslint.disableRegion",
"command": "jslint.clear",
"group": "7_modification@3",
"when": "resourceLangId == javascript"
},
{
"command": "jslint.ignoreLine",
"command": "jslint.disableRegion",
"group": "7_modification@4",
"when": "resourceLangId == javascript"
},
{
"command": "jslint.ignoreLine",
"group": "7_modification@5",
"when": "resourceLangId == javascript"
}
]
}
Expand All @@ -424,7 +441,7 @@ import moduleFs from "fs";
"type": "git",
"url": "https://github.com/jslint-org/jslint.git"
},
"version": "2022.4.1"
"version": "2022.4.2"
}, undefined, 4)
}
].map(async function ({
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
- jslint - try to improve parser to be able to parse jquery.js without stopping.
- jslint - unify analysis of variable-assignment/function-parameters into one function

# v2022.4.1-beta
# v2022.4.2-beta
- vscode - Add manual lint-on-save command to vscode-jslint extension.
- ci - add custom-shell-ci hooks to script jslint_ci.sh:
shCiArtifactUploadCustom()
shCiBaseCustom()
Expand Down
Binary file modified asset_image_jslint_wrapper_vscode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion jslint.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ let jslint_charset_ascii = (
+ "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
+ "`abcdefghijklmnopqrstuvwxyz{|}~\u007f"
);
let jslint_edition = "v2022.4.1-beta";
let jslint_edition = "v2022.4.2-beta";
let jslint_export; // The jslint object to be exported.
let jslint_fudge = 1; // Fudge starting line and starting
// ... column to 1.
Expand Down
28 changes: 23 additions & 5 deletions jslint_wrapper_vscode.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
/*property
Diagnostic, DiagnosticSeverity, ProgressLocation, Warning, Window, activate,
cancellable, character, clear, column, commands, createDiagnosticCollection,
document, end, endsWith, exports, getText, increment, insert, isEmpty,
jslint, languages, line, lineAt, location, map, message, module, push,
range, rangeIncludingLineBreak, readFileSync, registerTextEditorCommand,
replace, report, runInNewContext, selection, set, slice, start,
subscriptions, title, uri, warnings, window, withProgress
document, end, endsWith, exports, fsPath, getText, increment, insert,
isEmpty, jslint, languages, line, lineAt, location, map, message, module,
promises, push, range, rangeIncludingLineBreak, readFileSync,
registerTextEditorCommand, replace, report, runInNewContext, selection, set,
slice, start, subscriptions, title, uri, warnings, window, withProgress,
writeFile
*/

"use strict";
Expand Down Expand Up @@ -182,6 +183,20 @@ function activate({
});
}

// PR-429 - Add manual lint-on-save command.

async function jslintLintAndSave({
document
}) {
jslintLint({
document
});
await require("fs").promises.writeFile(
document.uri.fsPath,
document.getText()
);
}

// Initialize vscode and jslint.

vscode = require("vscode");
Expand Down Expand Up @@ -222,6 +237,9 @@ function activate({
subscriptions.push(vscode.commands.registerTextEditorCommand((
"jslint.lint"
), jslintLint));
subscriptions.push(vscode.commands.registerTextEditorCommand((
"jslint.lintAndSave"
), jslintLintAndSave));
}

exports.activate = activate;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
"shCiArtifactUpload": 1,
"shCiNpmPublish": 1,
"type": "module",
"version": "2022.4.1-beta"
"version": "2022.4.2-beta"
}

0 comments on commit 8f546d2

Please sign in to comment.