73rhodes/Sublime-JSLint

语言: JavaScript

git: https://github.com/73rhodes/Sublime-JSLint

用于Sublime Text 2和3的JSLint。
JSLint for Sublime Text 2 and 3.
README.md (中文)

崇高的JSLint

轻松的JSLint为Sublime文本。

  • 它内置了JSLint;只需在系统上安装Node.JS。
  • 保存.js文件时,它可以自动运行JSLint。
  • 支持ES6:好零件。
  • 现在支持JSON。
  • 完全可配置的linting选项。
  • 使用F4 / Shift + F4跳转到错误。
  • 适用于Linux,MacOS和Windows。

先决条件

NodeJS必须安装在您的系统上,您必须能够从命令行运行“node”。或者,如果您的系统上已安装了不同的jslint实用程序,则可以更新设置以使用它。

安装

使用包控制:

  • 如果没有,请安装Package Control插件
  • 按Ctrl + Shift + P调出命令调色板(或使用工具>命令调色板菜单)
  • 选择包控制:安装包
  • 键入“JSLint”以查找Sublime Text 2的JSLint(带节点)
  • 选择“用于Sublime Text 2的JSLint(带节点)”进行安装

不使用包控制:

  • 从包存档中获取文件
  • 解压缩到Packages / JSLint目录(使用“2”或“3”取决于您拥有的版本): Linux:〜/ .config / sublime-text-2 / Packages / JSLint Mac:〜/ Library / Application Support / Sublime Text 2 / Packages / JSLint Windows:%APPDATA%/ Sublime Text 2 / Packages / JSLint
  • 重新启动Sublime文本

用法

以下任何一项都有效:

  • 打开命令调色板(OS X上的Command + Shift + P,Linux / Windows上的Control + Shift + P),然后键入JSLint。
  • 单击工具> JSLint菜单项。
  • 按CTRL + L.
  • 只需保存.js文件即可。

设置

  • 导航到首选项>包设置> JSLint>设置 - 默认。
  • 要保留自定义设置:
  • 将默认设置复制到首选项>包设置> JSLint>设置 - 用户
  • 根据您的要求修改它们

故障排除

保存时“没有这样的文件或目录”

在保存.js文件时,你得到这个:

[Errno 2] No such file or directory
[cmd:  [u'node', ...]]

运行节点的命令可能不在您的路径中。

Mac OS X用户,确保/ usr / local / bin位于$ PATH环境变量中。

Linux用户,如果你的node命令是'nodejs',就像从一些Linux repos安装一样, 导航到首选项>包设置> JSLint>设置 - 用户更改它,例如

{
   "jslint": ["nodejs", "~/.config/sublime-text-2/Packages/JSLint/linter.js"]
}

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

Sublime-JSLint

Easy JSLint for Sublime Text.

  • It has JSLint built in; requires only Node.JS installed on your system.
  • It can automatically run JSLint when you save a .js file.
  • Support for ES6: The Good Parts.
  • Now supports JSON.
  • Fully configurable linting options.
  • Jump to errors using F4 / Shift+F4.
  • Works on Linux, MacOS and Windows.

Prerequisites

NodeJS must be installed on your system and you must be able to run 'node' from the command line. Alternatively, if you have a different jslint utility already installed on your system, you may update the settings to use it instead.

Installation

Using Package Control:

  • Install the Package Control plugin if you don't have it
  • Press Ctrl+Shift+P to bring up the Command Palette (or use Tools > Command Palette menu)
  • Select Package Control: Install Package
  • Type 'JSLint' to find JSLint (with node) for Sublime Text 2
  • Select 'JSLint (with node) for Sublime Text 2' to install

Not using Package Control:

  • Get files from the package archive
  • unzip to Packages/JSLint directory (use "2" or "3" depending on which version you have):
    • Linux: ~/.config/sublime-text-2/Packages/JSLint
    • Mac: ~/Library/Application Support/Sublime Text 2/Packages/JSLint
    • Windows: %APPDATA%/Sublime Text 2/Packages/JSLint
  • Relaunch Sublime Text

Usage

Any of the following will work:

  • Bring up the Command Palette (Command+Shift+P on OS X, Control+Shift+P on Linux/Windows), then type JSLint.
  • Click the Tools > JSLint menu entry.
  • Press CTRL+L.
  • Just save a .js file.

Settings

  • Navigate to Preferences > Package Settings > JSLint > Settings - Default.
  • To preserve custom settings:
  • copy default settings to Preferences > Package Settings > JSLint > Settings - User
  • modify them to your requirements

Troubleshooting

"No such file or directory" when saving

When, on saving a .js file, you get this:

[Errno 2] No such file or directory
[cmd:  [u'node', ...]]

the command to run node might not be in your path.

Mac OS X users, ensure that /usr/local/bin is in your $PATH environment variable.

Linux users, if your node command is 'nodejs', as is the case when installing from some Linux repos,
navigate to Preferences > Package Settings > JSLint > Settings - User to change it, e.g.

{
   "jslint": ["nodejs", "~/.config/sublime-text-2/Packages/JSLint/linter.js"]
}