nanos-lint 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 vugi99
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,211 @@
1
+ # nanos-lint
2
+
3
+ [![CI](https://github.com/vugi99/nanos-lint/actions/workflows/ci.yml/badge.svg)](https://github.com/vugi99/nanos-lint/actions/workflows/ci.yml)
4
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D24-brightgreen.svg)](https://nodejs.org/)
5
+ [![Lua Version](https://img.shields.io/badge/Lua-5.4.9-blue.svg)](https://www.lua.org/manual/5.4/)
6
+ [![LuaLS Version](https://img.shields.io/badge/LuaLS-3.19.1-brightgreen.svg)](https://github.com/LuaLS/lua-language-server)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
+
9
+ A dedicated, fast linter and type-checker for **[nanos world](https://nanos.world)** Lua scripts powered by the **[Lua Language Server (LuaLS)](https://github.com/LuaLS/lua-language-server)**.
10
+
11
+ ---
12
+
13
+ ## Features
14
+
15
+ - **Accurate nanos world Type Checking**: Bundles verified nanos world API annotations (Lua 5.4.9).
16
+ - **Zero-Install Local CLI**: Run directly via `npx nanos-lint [path]` without installing anything.
17
+ - **Native GitHub Action**: Use `vugi99/nanos-lint` directly in CI workflows with inline GitHub PR annotations.
18
+ - **Workspace Config Merging**: Fully respects local `.luarc.json` files, merging your project globals and disabled diagnostics on top of the nanos API.
19
+ - **Cross-Platform**: Works on **Windows x64** and **Linux amd64** (plus macOS). Automatically downloads and caches platform LuaLS binaries.
20
+ - **Modern Node.js Runtime**: Built targeting Node.js (>= 24) with zero runtime dependencies.
21
+
22
+ ---
23
+
24
+ ## Requirements
25
+
26
+ - **Node.js**: `>= 24.0.0` (required for npm/npx CLI usage; standalone release bundles include all dependencies)
27
+
28
+ ---
29
+
30
+ ## Quick Start
31
+
32
+ ### 1. Run via `npx` (No installation needed)
33
+
34
+ Check the current directory:
35
+ ```bash
36
+ npx nanos-lint
37
+ ```
38
+
39
+ Check a specific directory or file:
40
+ ```bash
41
+ npx nanos-lint check ./my-package
42
+ npx nanos-lint check ./my-package/Server/Index.lua
43
+ ```
44
+
45
+ ### 2. Global Installation
46
+
47
+ ```bash
48
+ npm install -g nanos-lint
49
+
50
+ # Then use anywhere
51
+ nanos-lint check .
52
+ ```
53
+
54
+ ### 3. Setup VS Code / Neovim IntelliSense
55
+
56
+ To configure autocompletion, type annotations, and diagnostics in your local editor:
57
+ ```bash
58
+ npx nanos-lint init
59
+ ```
60
+ This generates a `.luarc.json` file in your workspace pointing to the nanos world definitions and schemas.
61
+
62
+ ---
63
+
64
+ ## GitHub Actions Integration
65
+
66
+ Add `nanos-lint` to your repository's workflow (e.g. `.github/workflows/lint.yml`):
67
+
68
+ ```yaml
69
+ name: Lint Lua Scripts
70
+
71
+ on:
72
+ push:
73
+ branches: [ main, master ]
74
+ pull_request:
75
+ branches: [ main, master ]
76
+
77
+ jobs:
78
+ lint:
79
+ runs-on: ubuntu-latest
80
+ steps:
81
+ - name: Checkout repository
82
+ uses: actions/checkout@v7
83
+
84
+ - name: Lint nanos world Lua scripts
85
+ uses: vugi99/nanos-lint@v2
86
+ with:
87
+ path: '.'
88
+ checklevel: 'Warning'
89
+ ```
90
+
91
+ ### Action Inputs
92
+
93
+ | Input | Description | Default |
94
+ | :--- | :--- | :--- |
95
+ | `path` | Path to workspace directory or Lua file to check | `.` |
96
+ | `checklevel` | Minimum severity to report (`Error`, `Warning`, `Information`, `Hint`) | `Warning` |
97
+ | `config` | Path to a custom `.luarc.json` configuration file | `""` |
98
+ | `ignore` | Files or directories to ignore (supports glob patterns, newline or comma separated) | `""` |
99
+ | `luals-version` | Version of `lua-language-server` to use | `latest` |
100
+ | `fail-on-error` | Fail the workflow step if diagnostics are found | `true` |
101
+ | `quiet` | Suppress progress messages | `false` |
102
+
103
+ When running inside GitHub Actions, `nanos-lint` automatically outputs **workflow annotations** (`::error` / `::warning`) that appear inline on PR diffs.
104
+
105
+ ---
106
+
107
+ ## CLI Reference
108
+
109
+ ```
110
+ nanos-lint [command] [options] [path]
111
+
112
+ COMMANDS:
113
+ check [path] Check a workspace or Lua file (default)
114
+ init [path] Scaffold a .luarc.json configuration in the workspace (copies definitions to .nanos-lint/)
115
+ download-luals [version] Download and cache the LuaLS binary
116
+ help, --help, -h Show help message
117
+ version, --version, -v Show version information
118
+
119
+ OPTIONS:
120
+ -i, --ignore <pattern> Files or directories to ignore (supports globs, repeatable, comma/newline-separated)
121
+ --checklevel=<level> Minimum diagnostic level: Error, Warning, Information, Hint (default: Warning)
122
+ --config=<path> Path to custom .luarc.json configuration file
123
+ --format=<format> Output format: pretty, json, github (default: pretty)
124
+ --github Output in GitHub Actions format (shortcut for --format=github)
125
+ --luals-version=<ver> Version of LuaLS to use (default: latest)
126
+ --no-fail Do not exit with code 1 if diagnostics are found
127
+ --quiet Suppress progress output
128
+ -f, --force (init command only) Overwrite existing .luarc.json
129
+ ```
130
+
131
+ ### Environment Variables
132
+
133
+ | Variable | Description |
134
+ | :--- | :--- |
135
+ | `LUALS_BIN` | Explicit path to a pre-installed `lua-language-server` binary |
136
+ | `NO_COLOR` | Disables ANSI color output when set to any non-empty value |
137
+ | `FORCE_COLOR` | Forces ANSI color output even in non-TTY environments |
138
+
139
+ ---
140
+
141
+ ## Workspace Configuration (`.luarc.json`)
142
+
143
+ If your project already has a `.luarc.json`, `nanos-lint` automatically merges it. Your custom settings (e.g., custom globals, disabled diagnostics, additional libraries) are retained, while nanos world definitions are injected in `workspace.library`:
144
+
145
+ ```json
146
+ {
147
+ "$schema": "https://raw.githubusercontent.com/LuaLS/lua-language-server/master/setting/schema.json",
148
+ "diagnostics": {
149
+ "disable": [
150
+ "lowercase-global"
151
+ ],
152
+ "globals": [
153
+ "MyCustomGlobal"
154
+ ]
155
+ }
156
+ }
157
+ ```
158
+
159
+ To scaffold a portable `.luarc.json` with vendored type annotations in your project, run:
160
+ ```bash
161
+ npx nanos-lint init
162
+ # Or overwrite an existing configuration:
163
+ npx nanos-lint init --force
164
+ ```
165
+
166
+ ---
167
+
168
+ ## Standalone Binary Distributions (Offline / CD)
169
+
170
+ For environments without Node.js, pre-packaged release bundles containing the compiled `lua-language-server` binary and nanos-lint wrapper are available on the [Releases](https://github.com/vugi99/nanos-lint/releases) page:
171
+
172
+ - `nanos-lint-<version>-windows-x64.zip`
173
+ - `nanos-lint-<version>-linux-x64.tar.gz`
174
+
175
+ Simply extract the archive and run `./nanos-lint` (Linux) or `nanos-lint.cmd` (Windows).
176
+
177
+ ---
178
+
179
+ ## Development
180
+
181
+ ```bash
182
+ # Clone with submodules
183
+ git clone --recursive https://github.com/vugi99/nanos-lint.git
184
+ cd nanos-lint
185
+
186
+ # Install dependencies
187
+ npm install
188
+
189
+ # Update annotations submodule from upstream
190
+ git submodule update --remote --merge
191
+
192
+ # Run ESLint
193
+ npm run lint
194
+
195
+ # Run type check
196
+ npm run typecheck
197
+
198
+ # Run Vitest test suite (unit + live LuaLS integration tests)
199
+ npm test
200
+
201
+ # Build distribution bundle
202
+ npm run build
203
+ ```
204
+
205
+ See [AGENTS.md](AGENTS.md) for development philosophy and quality gate requirements.
206
+
207
+ ---
208
+
209
+ ## License
210
+
211
+ [MIT](LICENSE)
package/action.yml ADDED
@@ -0,0 +1,87 @@
1
+ name: 'nanos-world Lua Linter'
2
+ description: 'Fast, accurate linter and type-checker for nanos world Lua scripts powered by LuaLS'
3
+ author: 'nanos-world'
4
+ branding:
5
+ icon: 'check-circle'
6
+ color: 'yellow'
7
+
8
+ inputs:
9
+ path:
10
+ description: 'Path to workspace directory or Lua file to check'
11
+ required: false
12
+ default: '.'
13
+ checklevel:
14
+ description: 'Minimum diagnostic severity level to report (Error, Warning, Information, Hint)'
15
+ required: false
16
+ default: 'Warning'
17
+ config:
18
+ description: 'Path to a custom .luarc.json configuration file'
19
+ required: false
20
+ default: ''
21
+ luals-version:
22
+ description: 'Version of LuaLS to use (or "latest")'
23
+ required: false
24
+ default: 'latest'
25
+ fail-on-error:
26
+ description: 'Whether to fail the action step if diagnostic errors/warnings are found'
27
+ required: false
28
+ default: 'true'
29
+ quiet:
30
+ description: 'Suppress progress output'
31
+ required: false
32
+ default: 'false'
33
+ ignore:
34
+ description: 'Files or directories to ignore (supports glob patterns, multiple entries can be newline or comma separated)'
35
+ required: false
36
+ default: ''
37
+
38
+ runs:
39
+ using: 'composite'
40
+ steps:
41
+ - name: Setup Node.js
42
+ uses: actions/setup-node@v7
43
+ with:
44
+ node-version: '24'
45
+
46
+ - name: Run nanos-lint
47
+ shell: bash
48
+ env:
49
+ INPUT_PATH: ${{ inputs.path }}
50
+ INPUT_CHECKLEVEL: ${{ inputs.checklevel }}
51
+ INPUT_CONFIG: ${{ inputs.config }}
52
+ INPUT_LUALS_VERSION: ${{ inputs.luals-version }}
53
+ INPUT_FAIL_ON_ERROR: ${{ inputs.fail-on-error }}
54
+ INPUT_QUIET: ${{ inputs.quiet }}
55
+ INPUT_IGNORE: ${{ inputs.ignore }}
56
+ ACTION_PATH: ${{ github.action_path }}
57
+ run: |
58
+ ARGS=("check" "$INPUT_PATH" "--checklevel=$INPUT_CHECKLEVEL" "--luals-version=$INPUT_LUALS_VERSION" "--format=github")
59
+
60
+ if [ -n "$INPUT_CONFIG" ]; then
61
+ ARGS+=("--config=$INPUT_CONFIG")
62
+ fi
63
+
64
+ if [ -n "$INPUT_IGNORE" ]; then
65
+ while IFS= read -r line || [ -n "$line" ]; do
66
+ trimmed=$(echo "$line" | xargs)
67
+ if [ -n "$trimmed" ]; then
68
+ ARGS+=("--ignore=$trimmed")
69
+ fi
70
+ done <<< "$INPUT_IGNORE"
71
+ fi
72
+
73
+ if [ "$INPUT_FAIL_ON_ERROR" = "false" ]; then
74
+ ARGS+=("--no-fail")
75
+ fi
76
+
77
+ if [ "$INPUT_QUIET" = "true" ]; then
78
+ ARGS+=("--quiet")
79
+ fi
80
+
81
+ if [ -f "$ACTION_PATH/dist/cli.js" ]; then
82
+ node "$ACTION_PATH/dist/cli.js" "${ARGS[@]}"
83
+ else
84
+ npx --yes nanos-lint@^2.1.0 "${ARGS[@]}"
85
+ fi
86
+
87
+
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import { runCLI } from "../dist/cli.js";
3
+
4
+ runCLI()
5
+ .then((code) => {
6
+ process.exit(code);
7
+ })
8
+ .catch((err) => {
9
+ const message = err instanceof Error ? err.message : String(err);
10
+ console.error(`error: ${message}`);
11
+ if (process.env.DEBUG && err instanceof Error && err.stack) {
12
+ console.error(err.stack);
13
+ }
14
+ process.exit(1);
15
+ });
16
+
17
+