Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs - rename jslint-wrapper-files to jslint_wrapper_xxx.xxx #387

Merged
merged 2 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
- fs - rename jslint-wrapper-files to jslint_wrapper_xxx.xxx
  • Loading branch information
kaizhu256 committed Feb 16, 2022
commit 0e45adfc43c4e8a680b02ea2b9bfd89b3f724186
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
.*
!.npmignore

!jslint.cjs
!jslint.mjs
!jslint_wrapper_cjs.cjs
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- perf - improve performance by hoisting inlined regexps out of loops and subfunctions

# v2022.2.1-beta
- fs - rename jslint-wrapper-files to jslint_wrapper_xxx.xxx
- bugfix - fix issue #382 - make fart-related warnings more readable
- bugfix - fix issue #382 - fix warnings against destructured fart
- bugfix - fix issue #379 - warn against naked-statement in fart.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Douglas Crockford <douglas@crockford.com>
- [To create V8 coverage report from Node.js / Npm program in shell:](#to-create-v8-coverage-report-from-nodejs--npm-program-in-shell)
- [To create V8 coverage report from Node.js / Npm program in javascript:](#to-create-v8-coverage-report-from-nodejs--npm-program-in-javascript)

7. [Plugin Vim](#plugin-vim)
7. [Quickstart JSLint in Vim](#quickstart-jslint-in-vim)
- [To run JSLint in Vim:](#to-run-jslint-in-vim)

8. [Description](#description)
Expand Down Expand Up @@ -331,19 +331,19 @@ import jslint from "../jslint.mjs";


<br><br>
# Plugin Vim
# Quickstart JSLint in Vim


<br><br>
### To run JSLint in Vim:
1. Download and save [`jslint.mjs`](https://www.jslint.com/jslint.mjs), [`jslint.vim`](https://www.jslint.com/jslint.vim) to directory `~/.vim/`
2. Add vim-command `:source ~/.vim/jslint.vim` to file `~/.vimrc`
1. Download and save [`jslint.mjs`](https://www.jslint.com/jslint.mjs), [`jslint_wrapper_vim.vim`](https://www.jslint.com/jslint_wrapper_vim.vim) to directory `~/.vim/`
2. Add vim-command `:source ~/.vim/jslint_wrapper_vim.vim` to file `~/.vimrc`
3. Vim can now jslint files (via nodejs):
- with vim-command `:SaveAndJslint`
- with vim-key-combo `<Ctrl-S> <Ctrl-J>`
- screenshot

![screenshot.png](asset_image_jslint_vim_plugin.png)
![screenshot.png](asset_image_jslint_wrapper_vim.png)


<br><br>
Expand Down
Binary file removed asset_image_jslint_vim_plugin.png
Binary file not shown.
Binary file added asset_image_jslint_wrapper_vim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 28 additions & 28 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1273,33 +1273,6 @@
});
}

function jslint_plugin_codemirror(CodeMirror) {

// This function will integrate jslint with CodeMirror's lint addon.
// Requires CodeMirror and jslint.

CodeMirror.registerHelper("lint", "javascript", function (text, options) {
options.result = jslint.jslint(text, options, options.globals);
return options.result.warnings.map(function ({
column,
line,
message,
mode_stop
}) {
return {
from: CodeMirror.Pos(line - 1, column - 1), //jslint-quiet
message,
severity: (
mode_stop
? "error"
: "warning"
),
to: CodeMirror.Pos(line - 1, column) //jslint-quiet
};
});
});
}

async function jslint_ui_call() {
// This function will run jslint in browser and create html-reports.

Expand Down Expand Up @@ -1362,6 +1335,33 @@
editor.setSize(content_width);
}

function jslint_wrapper_codemirror(CodeMirror) {

// This function will integrate jslint with CodeMirror's lint addon.
// Requires CodeMirror and jslint.

CodeMirror.registerHelper("lint", "javascript", function (text, options) {
options.result = jslint.jslint(text, options, options.globals);
return options.result.warnings.map(function ({
column,
line,
message,
mode_stop
}) {
return {
from: CodeMirror.Pos(line - 1, column - 1), //jslint-quiet
message,
severity: (
mode_stop
? "error"
: "warning"
),
to: CodeMirror.Pos(line - 1, column) //jslint-quiet
};
});
});
}

(function () {
let CodeMirror = window.CodeMirror;

Expand Down Expand Up @@ -1406,7 +1406,7 @@

// Init CodeMirror linter.

jslint_plugin_codemirror(CodeMirror);
jslint_wrapper_codemirror(CodeMirror);

// Init event-handling.

Expand Down
20 changes: 10 additions & 10 deletions jslint.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1469,8 +1469,8 @@ async function jslint_cli({
let command;
let data;
let exit_code = 0;
let mode_plugin_vim;
let mode_report;
let mode_wrapper_vim;
let result;

function jslint_from_file({
Expand Down Expand Up @@ -1543,7 +1543,7 @@ async function jslint_cli({
if (result_from_file.warnings.length > 0) {
exit_code = 1;
console_error(
mode_plugin_vim
mode_wrapper_vim

// PR-349 - Print warnings in format readable by vim.

Expand Down Expand Up @@ -1676,17 +1676,17 @@ async function jslint_cli({
}));
return;

// COMMIT-b26d6df2 - Add command jslint_plugin_vim.
// PR-363 - Add command jslint_report.

case "jslint_plugin_vim":
mode_plugin_vim = true;
case "jslint_report":
mode_report = command[1];
process_argv = process_argv.slice(1);
break;

// PR-363 - Add command jslint_report.
// COMMIT-b26d6df2 - Add command jslint_wrapper_vim.

case "jslint_report":
mode_report = command[1];
case "jslint_wrapper_vim":
mode_wrapper_vim = true;
process_argv = process_argv.slice(1);
break;

Expand All @@ -1702,9 +1702,9 @@ async function jslint_cli({

// PR-349 - Detect cli-option --mode-vim-plugin.

mode_plugin_vim = (
mode_wrapper_vim = (
process_argv.slice(2).indexOf("--mode-vim-plugin") >= 0
|| mode_plugin_vim
|| mode_wrapper_vim
);

// Normalize file relative to process.cwd().
Expand Down
File renamed without changes.
9 changes: 5 additions & 4 deletions jslint.vim → jslint_wrapper_vim.vim
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"" jslint.vim
"" jslint plugin for vim
"" jslint_wrapper_vim.vim
""
"" jslint wrapper for vim
""
"" 1. Save this file and "jslint.mjs" to directory "~/.vim/"
"" 2. Add vim-command ":source ~/.vim/jslint.vim" to file "~/.vimrc"
"" 2. Add vim-command ":source ~/.vim/jslint_wrapper_vim.vim" to file "~/.vimrc"
"" 3. Vim can now jslint files (via nodejs):
"" - with vim-command ":SaveAndJslint"
"" - with vim-key-combo "<Ctrl-S> <Ctrl-J>"
Expand All @@ -13,7 +14,7 @@ function! SaveAndJslint(bang)
if a:bang == "!" | write! | else | write | endif
"" jslint file (via nodejs)
let &l:errorformat = "%f:%n:%l:%c:%m"
let &l:makeprg = "node \"" . $HOME . "/.vim/jslint.mjs\" --mode-vim-plugin"
let &l:makeprg = "node \"" . $HOME . "/.vim/jslint.mjs\" jslint_wrapper_vim"
\ . " \"" . fnamemodify(bufname("%"), ":p") . "\""
silent make! | cwindow | redraw!
endfunction
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"counter": 7,
"description": "JSLint, The JavaScript Code Quality and Coverage Tool",
"exports": {
"default": "./jslint.cjs",
"default": "./jslint_wrapper_cjs.cjs",
"import": "./jslint.mjs"
},
"fileCount": 28,
Expand All @@ -17,7 +17,7 @@
"zero-dependency"
],
"license": "UNLICENSE",
"main": "./jslint.cjs",
"main": "./jslint_wrapper_cjs.cjs",
"module": "./jslint.mjs",
"name": "@jslint-org/jslint",
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*jslint beta, node*/
import jslint from "./jslint.mjs";
import jslintCjs from "./jslint.cjs";
import jslintCjs from "./jslint_wrapper_cjs.cjs";
import moduleFs from "fs";
import modulePath from "path";

Expand Down Expand Up @@ -214,15 +214,15 @@ try {
process_exit: processExit1,
source: "["
});
// test plugin-vim handling-behavior
// test jslint_wrapper_vim handling-behavior
jslint.jslint_cli({
// suppress error
console_error: noop,
mode_cli: true,
process_argv: [
"node",
"jslint.mjs",
"jslint_plugin_vim",
"jslint_wrapper_vim",
"syntax-error.js"
],
process_exit: processExit1,
Expand Down