@fellow/eslint-plugin-coffee (英语)
咖啡文件先是用咖啡纸 然后再检查它们 行 / 列 报告是通过源图数据处理的, 因此它们对于您的咖啡文件是准确的 .
插件忽略了一些无法从 Coffeescript中满足的规则(参见 此文件(中文(简体) )
还要遵守规则 咖啡林2号 在埃斯林特创建了一个假规则, 将咖啡林特2的规则包裹并映射出来.
特别谢谢 改为 亚历山大·梅特纳 用于启动和提供基础代码.
安装
你首先需要安装 ESLint 语录数字 :
$ npm i eslint --save-dev
下一个,安装 @fellow/eslint-plugin-coffee数字 :
$ npm install @fellow/eslint-plugin-coffee --save-dev
说明: 如果在全球安装了 ESLint(使用 -g 您必须安装 @fellow/eslint-plugin-coffee 在全球.
简单使用( E)
编辑您的 .eslintrc 文档。 并添加此插件。 最简单的配置是仅仅扩展所提供的基础配置,以获得一套良好的规则(看这里) (中文(简体) ). 你可以省略这个 eslint-plugin- 配置 eslint 时的前缀.
说明: 如果您喜欢使用标签, 请确保扩展 @fellow/coffee/recommended-tabs 换句话说.
{
"extends": ["plugin:@fellow/coffee/recommended"],
"plugins": [
"@fellow/coffee",
# ...
]
}
手动配置
仅限ESLint规则,添加 @fellow/coffee 到您的插件区 .eslintrc 配置文件 。 如果使用一套良好的基本规则,这将很好地涵盖许多事情。 一如既往,你可以省略 eslint-plugin- 前缀 :
{
"plugins": [
"@fellow/coffee",
# ...
]
}
为了更好地与其他插件兼容(例如. eslint-plugins-imports)),我还提供"parser",由eslint可以钩入. 类似插件 import 插件不通过检查或需要模块运行, 您必须设置此插件来包装您的默认解析器 :
{
"parser": "@fellow/eslint-plugin-coffee",
"parserOptions": {
"parser": "babel-eslint", # original parser goes here (you must specify one to use this option).
"sourceType": "module", # any original parser config options you had.
"ecmaVersion": 6
},
"plugins": [
"@fellow/eslint-plugin-coffee",
# ...
],
"rules": {
"@fellow/coffee/coffeescript-error": ["error", {}],
# ...
}
}
看看你如何加入自己的咖啡林式规则, 切换你的 .eslintrc - > (中文) .eslintrc.js 并添加:
require('@fellow/eslint-plugin-coffee').registerCoffeeLintRule('myRuleModule') 在顶上.
那就把它放进去 rules 区域 .eslintrc.js,通过任何您规则所期望的配置选项.
要学习如何为咖啡林写规则, 检查他们的文件.
编辑器兼容性
虚拟系统
为了在 VS 代码中工作,安装 eslint 扩展并添加到您的工作空间设置中 :
"settings": {
...
"files.associations": {
"*.cjsx": "coffeescript"
},
"eslint.validate": [
"javascript",
"javascriptreact",
"coffeescript"
],
},