eslint-plugin-reviewget
v0.0.1
Published
## Feature - 当用户使用 getXXX get开头的函数的时候 如果不返回值的话 那么就会报错 - 可以 fix - 用户可以自行配置是否 fix
Downloads
62
Readme
eslint-plugin-reviewget
开发思路参考:git commit
Feature
- 当用户使用 getXXX get开头的函数的时候 如果不返回值的话 那么就会报错
- 可以 fix
- 用户可以自行配置是否 fix
BASE ENV
eslint-plugin-xxx: 插件命名规范
测试插件:
1. demo测试
pnpm init -y
pnpm i eslint -D
pnpx eslint --init
配置 .eslintrc.js
module.exports = {
"root": true,
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"overrides": [
],
"parserOptions": {
"ecmaVersion": "latest"
},
"plugins": [
"reviewget"
],
"rules": {
"reviewget/get": ["warn"]
}
}
在eslint-plugin-reviewget/example
下安装本地写好的插件
pnpm i ../
2. 单元测试环境
创建reviewget.spec.js
文件
const { RuleTester } = require("eslint")
const { rules } = require('./index')
const ruleTester = new RuleTester()
ruleTester.run('get', rules.get, {
valid: [
{
name: 'success',
code: `function getName(){ return ''}`
}
],
invalid: [
]
})
watch 模式, 利用 mocha 测试库
pnpm test -- --watch
FINISH
对于一个eslint来说,对 ast 分析 ,从信息里面提取出需要的东西,检测是否符合要求
开发完成插件后,在example中进行使用之前,需要进行如下操作:
发包
先打包,发包的时候使用打包结果
// package.json
"files": [
"index.js",
"package.json"
],
// 表示发布上去的文件
npm login --registry https://registry.npmjs.org
npm publish --registry https://registry.npmjs.org
问题:vscode保存时候自动完成eslint补全