eslint-watch

ESLint with simple watching capabilities
授权协议 MIT License
开发语言 JavaScript
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 戚飞雨
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Eslint Watch

Don't want to import Webpack, Grunt, or some other task package into your project? Then this is the tool for you.Eslint Watch is a simple command line tool that wraps Eslint. Eslint Watch provides file watching and command line improvements to the currently existing Eslint command line interface. All commands that Eslint offers can be used with the addition of a watch command and a couple new templating views. Don't believe me? Checkout the code or some of the features below!

Requirements

To use this tool we require eslint to be installed on your project. The versions supported are:

  • "eslint": ">=7 <8.0.0"
  • node >= 10.0.0 <= LTS Non LTS versions will have limited support.

Getting started

To run eslint-watch without the global install, make an npm script.

NPM

  • npm i -g eslint eslint-watch or npm i -D eslint eslint-watch

Yarn

  • yarn global add eslint eslint-watch or yarn add -D eslint eslint-watch

Features added

  • Watching
    • Multi-directory watching
    • Runs a full directory lint before the watch
    • Press enter to rerun directory lint while watching
    • Include directories to ignore on watch
  • Eslint Overrides
    • Default directory linting. A directory is no longer required.

Options/Usage

Eslint-Watch replaces only a few commands that it needs to take control over. All other commands are forwarded to Eslint unmodified. Please refer to their help text for full command support as the one provided below might not be up to date with the latest Eslint changes.

esw [options][file.js ...] [dir ...]

ESW Options:
-h, --help Show help
-w, --watch Enable file watch
--changed Enables single file linting while watch is enabled
--clear Clear terminal when running lint
-v, --version Prints Eslint-Watch Version
--versions Prints Eslint-Watch and Eslint Versions
--watch-ignore RegExp Regex string of folders to ignore when watching - default: /.git|node_modules|bower_components/
--watch-delay Int Delay(ms) for watcher to wait to trigger re-lint - default: 300

Basic configuration:
--ext [String] Specify JavaScript file extensions - default: .js
--no-eslintrc Disable use of configuration from .eslintrc._
-c, --config path::String Use this configuration, overriding .eslintrc._ config options if present
--env [String] Specify environments
--global [String] Define global variables
--parser String Specify the parser to be used
--parser-options Object Specify parser options
--resolve-plugins-relative-to path::String A folder where plugins should be resolved from CWD by default

Specifying rules and plugins:
--rulesdir [path::String] Use additional rules from this directory
--plugin [String] Specify plugins
--rule Object Specify rules

Fixing problems:
--fix Automatically fix problems
--fix-dry-run Automatically fix problems without saving the changes to the file system
--fix-type Array Specify the types of fixes to apply (problem suggestion, layout)

Ignoring files:
--ignore-path path::String Specify path of ignore file
--no-ignore Disable use of ignore files and patterns
--ignore-pattern [String] Pattern of files to ignore (in addition to those in .eslintignore)

Using stdin:
--stdin Lint code provided on <STDIN> - default: false
--stdin-filename String Specify filename to process STDIN as

Handling warnings:
--quiet Report errors only - default: false
--max-warnings Int Number of warnings to trigger nonzero exit code - default: -1

Output:
-o, --output-file path::String Specify file to write report to
-f, --format String Use a specific output format - default: stylish
--color, --no-color Force enabling/disabling of color

Inline configuration comments:
--no-inline-config Prevent comments from changing config or rules
--report-unused-disable-directives Adds reported errors for unused eslint-disable directives

Caching:
--cache Only check changed files - default: false
--cache-file path::String Path to the cache file. Deprecated: use --cache-location - default: .eslintcache
--cache-location path::String Path to the cache file or directory

Miscellaneous:
--init Run config initialization wizard - default: false
--debug Output debugging information
--print-config path::String Print the configuration for the given file

Other Options

Eslint-Watch uses chokidar under the hood to watch for changes. Chokidar can be configured to poll for changes (this might be necessary if you are running Eslint-Watch inside a VM or Container) by setting the CHOKIDAR_USEPOLLING environment variable to true.

Functionality

Simple lint and watch

Donate:

  • 介绍 阅读前两个章节可以快速应对项目中的eslint规则调整/禁用的场景; 后面的使用示例和常用配置推荐刚刚接触eslint的读者使用。 配置eslint语法规则 module.exports = { // ... "rules": { "semi": ["error", "always"], "camelcase": "off" } } 错误级别 说明 "off"

  • .eslintrc.js 配置 module.exports = { // 环境 env: { browser: true, // es2021: true, es6: true, commonjs: true, node: true, }, // 配置解析器 parserOptions: { ecmaVersion: 12,

  • 其他打包工具 --Rollup Rollup也是一款ESModule打包器,可以将项目中的细小模块打包成整块代码,使得划分的模块可以更好的运行在浏览器环境或者是Nodejs环境。Rollup与Webpack作用非常类似,不过Rollup更为小巧。webpack结合插件可以完成前端工程化的绝大多数工作,而Rollup仅仅是一款ESM打包器,没有其他功能,例如Rollup中并不支持类似HMR这种高级特

  • Failed at the @ watch script 'cross-env NODE_ENV=development 使用cross-env解决跨平台设置NODE_ENV的问题 参考文章: (1)Failed at the @ watch script 'cross-env NODE_ENV=development 使用cross-env解决跨平台设置NODE_ENV的问题 (2)https:

 相关资料
  • 不管是多人合作还是个人项目,代码规范都是很重要的。这样做不仅可以很大程度地避免基本语法错误,也保证了代码的可读性。 配置项 所有的配置文件都在 .eslintrc.js 中。 本项目基本规范是依托于 vue 官方的 eslint 规则 eslint-config-vue 做了少许的修改。大家可以按照自己的需求进行定制化配置。 比如:我个人或者项目组习惯于使用两个空格,但你可能觉得四个空格更顺眼,你

  • ESLint FECS 的 JavaScript 检查是基于 ESLint 结合我们的 JavaScript 编码规范,配置了一些默认的参数,以检查代码中可能存在的质量问题。 使用方式 最常用的方式就是直接调用fecs,此时会递归的扫描当前目录下面的所有的 JavaScript、CSS 和 HTML 文件(默认已经忽略 node_modules, bower_components 目录),然后依次

  • ESLint 是一个开源的JavaScript验证工具,相比JSLint,ESLint具有可配置性。其他跟 JSLint 的不同之处: ESLint 使用 Esprima 来进行 javascript 解析 ESLint 使用 AST 来修改代码模式 ESLint 是完全插件化的,每个规则都是一个插件,用户可以在运行时增加更多的插件  

  • Angular ESLint Monorepo for all the tooling which enables ESLint to lint Angular projects This project is made possible thanks to the continued hard work going into https://github.com/typescript-eslin

  • prettier-eslint (for Atom) DEPRECATED This plugin has been merged with the official prettier-atom plugin. Uninstall prettier-eslint and install prettier-atom. Then enable the ESLint integration: Atom

  • eslint-plugin-sql SQL linting rules for ESLint. In its current form, the plugin has been designed and tested to work with Postgres codebase. eslint-plugin-sql Installation Configuration Settings place