Skip to content

Commit d910f4f

Browse files
committed
update emmylua check readme
1 parent 03df20a commit d910f4f

File tree

1 file changed

+136
-5
lines changed

1 file changed

+136
-5
lines changed

crates/emmylua_check/README.md

Lines changed: 136 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,146 @@
1-
# EmmyLua Check
1+
<div align="center">
22

3-
a static check tool for Lua, written in Rust.
3+
# 🦀 EmmyLua Check
44

5-
## Installation
5+
[![Crates.io](https://img.shields.io/crates/v/emmylua_check.svg?style=for-the-badge&logo=rust)](https://crates.io/crates/emmylua_check)
6+
[![GitHub license](https://img.shields.io/github/license/CppCXY/emmylua-analyzer-rust?style=for-the-badge&logo=mit&color=blue)](../../LICENSE)
67

8+
</div>
9+
10+
`emmylua_check` is a powerful command-line tool designed to help developers identify and fix potential issues in Lua code during development. It leverages the core analysis engine of `emmylua-analyzer` to provide comprehensive code diagnostics, ensuring code quality and robustness.
11+
12+
---
13+
14+
## ✨ Features
15+
16+
- **⚡ High Performance**: Built with Rust for blazing-fast analysis, capable of handling large codebases.
17+
- **🎯 Comprehensive Diagnostics**: Offers over 50 types of diagnostics, including:
18+
- Syntax errors
19+
- Type mismatches
20+
- Undefined variables and fields
21+
- Unused code
22+
- Code style issues
23+
- ...and more!
24+
- **⚙️ Highly Configurable**: Fine-grained control over each diagnostic via `.emmyrc.json` or `.luarc.json` files, including enabling/disabling and severity levels.
25+
- **💻 Cross-Platform**: Supports Windows, macOS, and Linux.
26+
- **CI/CD Friendly**: Easily integrates into continuous integration workflows to ensure team code quality.
27+
28+
---
29+
30+
## 📦 Installation
31+
32+
Install `emmylua_check` via cargo:
733
```shell
834
cargo install emmylua_check
935
```
1036

11-
## Usage
37+
---
38+
39+
## 🚀 Usage
40+
41+
### Basic Usage
42+
43+
Analyze all Lua files in the current directory:
44+
```shell
45+
emmylua_check .
46+
```
47+
48+
Analyze a specific workspace directory:
49+
```shell
50+
emmylua_check ./src
51+
```
52+
53+
### Advanced Usage
54+
55+
#### Specify Configuration File
56+
57+
Use a specific `.emmyrc.json` configuration file:
58+
```shell
59+
emmylua_check . -c ./config/.emmyrc.json
60+
```
61+
62+
#### Ignore Specific Files or Directories
63+
64+
Ignore files in the `vender` and `test` directories:
65+
```shell
66+
emmylua_check . -i "vender/**,test/**"
67+
```
68+
69+
#### Output in JSON Format
1270

71+
Output diagnostics in JSON format to a file for further processing:
1372
```shell
14-
emmylua_check --help
73+
emmylua_check . -f json --output ./diag.json
74+
```
75+
76+
#### Treat Warnings as Errors
77+
78+
In CI environments, this is a useful option to enforce fixing all warnings:
79+
```shell
80+
emmylua_check .
81+
```
82+
83+
---
84+
85+
## ⚙️ Configuration
86+
87+
`emmylua_check` shares the same configuration system as the EmmyLua Language Server. You can create a `.emmyrc.json` file in your project root to configure diagnostic rules.
88+
89+
**Example `.emmyrc.json`:**
90+
```json
91+
{
92+
"diagnostics": {
93+
"disable": [
94+
"unused"
95+
]
96+
}
97+
}
98+
```
99+
100+
For detailed information on all available diagnostics and configuration options, see the [**EmmyLua Configuration Documentation**](../../docs/config/emmyrc_json_CN.md).
101+
102+
---
103+
104+
## 🛠️ CI/CD Integration
105+
106+
You can easily integrate `emmylua_check` into your GitHub Actions workflow to automate code checks.
107+
108+
**Example `.github/workflows/check.yml`:**
109+
```yaml
110+
name: EmmyLua Check
111+
112+
on: [push, pull_request]
113+
114+
jobs:
115+
check:
116+
runs-on: ubuntu-latest
117+
steps:
118+
- uses: actions/checkout@v4
119+
- name: Install Rust toolchain
120+
uses: dtolnay/rust-toolchain@stable
121+
- name: Install emmylua_check
122+
run: cargo install emmylua_check
123+
- name: Run check
124+
run: emmylua_check .
125+
```
126+
127+
---
128+
129+
## Command Line Options
130+
131+
```
132+
Usage: emmylua_check [OPTIONS] [WORKSPACE]...
133+
134+
Arguments:
135+
[WORKSPACE]... Path(s) to workspace directory
136+
137+
Options:
138+
-c, --config <CONFIG> Path to configuration file. If not provided, ".emmyrc.json" and ".luarc.json" will be searched in the workspace directory
139+
-i, --ignore <IGNORE> Comma-separated list of ignore patterns. Patterns must follow glob syntax
140+
-f, --output-format <OUTPUT_FORMAT> Specify output format [default: text] [possible values: json, text]
141+
--output <OUTPUT> Specify output target (stdout or file path, only used when output_format is json) [default: stdout]
142+
--warnings-as-errors Treat warnings as errors
143+
--verbose Verbose output
144+
-h, --help Print help information
145+
-V, --version Print version information
15146
```

0 commit comments

Comments
 (0)