热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Config:Add"ignoremissingconfig"option

Currently,

Currently,

1
jscs

exits with a non-zero status code when it can't find a config file.

This is great for certain use cases, e.g. as a reminder for when you have forgotten to add a

1
.jscsrc

file to a project directory.

But for other situations, e.g. when you have configured your editor to send any opened "*.js" file to

1
jscs

, and your editor warns you when the program exits with a non-zero status code, then it can be quite annoying to try and edit files from projects which do not use JSCS, as you will be bombarded with "No configuration found." messages.

Trivially, this is the particular case for a GNU Emacs + Flycheck setup defined as follows in a user's

1
~/.emacs

file:

1
2
3
4
5
6
7
8
 lisp

(flycheck-define-checker Javascript-jscs

  "JSCS - Javascript Code Style"

  :command ("jscs" "--reporter=checkstyle" source-inplace)

  :error-parser flycheck-parse-checkstyle

  :modes (js-mode js2-mode js3-mode))



(add-to-list 'flycheck-checkers 'Javascript-jscs)

One workaround is to

1
echo '{}' >> ~/.jscsrc

, but it's not a very good solution, especially if a user doesn't know to do that. This option allows you to no-op your way through the program if a config file is not found.

该提问来源于开源项目:jscs-dev/node-jscs

I do think that exit codes would be good in principle, but currently they would only benefit a single linter out of the set of linter packages you support.



Here's how they each handle errors:
- Atom: console.warns all errors
- Brackets: Doesn't use CLI
- Grunt: Doesn't use CLI
- Gulp: Doesn't use CLI
- Sublime: Doesn't handle exit codes
- Vim: Does handle exit codes
- Visual Studio: Doesn't use CLI
- IntelliJ et al: Exit code handling is commented-out
- and Flycheck: Doesn't differentiate exit codes

So your Vim users might appreciate (3), but it won't have any impact on the other linter packages without significant additions to those packages' APIs. I probably sound like a broken record at this point, but unless you plan on submitting a lot of PRs to improve the above situation, I recommend against creating an exit code lexicon.



I would be fine with (1), (2) or (4), since any of those solve my particular problem.


   



推荐阅读
author-avatar
流血的云_-86097
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有