@reskript/cli-lint
TypeScript icon, indicating that this package has built-in type declarations

6.2.1 • Public • Published

@reskript/cli-lint

通过eslint检查代码规范。

正常使用

使用skr lint检查代码规范。

Usage: lint [options] [files...]

Lint files, by default .js(x) files under src are linted

Options:
  --changed                    lint only changed files in git workspace
  --staged                     lint only staged (both partially and fully) files in git workspace
  --allow-unsafe-react-method  allow UNSAFE_* methods in react component
  --fix                        fix possible lint errors
  -h, --help                   output usage information

缩小检查范围

对于比较大型的项目,通常全量的检查很消耗时间,此时可以选择仅检查已经修改过的代码:

skr lint --changed

也可以进一步缩小范围,仅检查通过git add添加到版本中的代码:

skr lint --staged

使用git钩子进行检查

推荐使用husky在代码提交前对代码进行检查。

首先安装husky:

npm install --save-dev husky

随后在package.json中增加以下内容:

{
  "husky": {
    "hooks": {
      "pre-commit": "skr lint --staged --fix --auto-stage"
    }
  }
}

在每次git commit提交代码时,都会检查需要提交入库的代码。

直接使用lint配置

如果你需要直接使用eslint的规则,比如通过编辑器的eslint插件进行代码的实时检查,则需要放置一个.eslintrc.js配置文件并引用@reskript/config-lint的规则,具体请参考config-lint的说明

Readme

Keywords

none

Package Sidebar

Install

npm i @reskript/cli-lint

Weekly Downloads

6

Version

6.2.1

License

MIT

Unpacked Size

14.1 kB

Total Files

14

Last publish

Collaborators

  • ecomfe-core
  • otakustay