Skip to content

Commit 90734f3

Browse files
Merge remote-tracking branch 'origin/main' into arewerslintyet
2 parents d622d7e + 0d24667 commit 90734f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4507
-798
lines changed

.github/actions/setup-go/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ runs:
2121

2222
- name: Clean Go module cache dir
2323
shell: bash
24+
if: runner.os == 'linux'
2425
run: sudo rm -rf ~/go/pkg/mod/golang.org/toolchain*
2526

2627
- name: Go cache

.github/workflows/ci.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ env:
1919
jobs:
2020
test-go:
2121
name: Test Go
22-
runs-on: rspack-ubuntu-22.04-large
22+
runs-on: ${{ matrix.runner }}
2323
strategy:
2424
matrix:
25+
runner:
26+
[
27+
rspack-ubuntu-22.04-large,
28+
rspack-windows-2022-large,
29+
rspack-darwin-14-medium,
30+
]
2531
go-version: ['1.24.1']
2632
steps:
2733
- name: Checkout code
@@ -39,23 +45,27 @@ jobs:
3945
go-version: ${{ matrix.go-version }}
4046
cache-name: test-go
4147
- name: golangci-lint
48+
if: runner.os == 'Linux'
4249
uses: golangci/golangci-lint-action@v8
4350
with:
4451
version: v2.3.0
4552
args: --timeout=5m ./cmd/... ./internal/...
4653
- name: go vet
54+
if: runner.os == 'Linux'
4755
run: npm run lint:go
4856
- name: go fmt
57+
if: runner.os == 'Linux'
4958
run: npm run format:go
5059
- name: Unit Test
5160
run: |
5261
go test -parallel 4 ./internal/...
5362
5463
test-node:
5564
name: Test npm packages
56-
runs-on: rspack-ubuntu-22.04-large
65+
runs-on: ${{ matrix.os }}
5766
strategy:
5867
matrix:
68+
os: [rspack-ubuntu-22.04-large, windows-latest]
5969
go-version: ['1.24.1']
6070
steps:
6171
- name: Checkout code
@@ -73,16 +83,18 @@ jobs:
7383
uses: ./.github/actions/setup-node
7484

7585
- name: Format
86+
if: runner.os == 'Linux'
7687
run: pnpm format:check
7788

7889
- name: Build
7990
run: pnpm build
8091

8192
- name: TypeCheck
93+
if: runner.os == 'Linux'
8294
run: pnpm typecheck
8395

84-
- name: Install xvfb and dependencies
85-
if: ${{ runner.os == 'Linux' && runner.environment == 'self-hosted' }}
96+
- name: Install xvfb and dependencies (Linux only)
97+
if: runner.os == 'Linux'
8698
run: |
8799
sudo apt update
88100
sudo apt install -y libasound2 libgbm1 libgtk-3-0 libnss3 xvfb
@@ -91,9 +103,9 @@ jobs:
91103
uses: lynx-infra/cache@5c6160a6a4c7fca80a2f3057bb9dfc9513fcb732
92104
with:
93105
path: packages/vscode-extension/.vscode-test
94-
key: 'vscode-test'
106+
key: vscode-test-${{ matrix.os }}
95107
restore-keys: |
96-
- 'vscode-test-'
108+
vscode-test-${{ matrix.os }}-
97109
98110
- name: Test on Linux
99111
if: runner.os == 'Linux'
@@ -104,17 +116,19 @@ jobs:
104116
run: pnpm -r test
105117

106118
- name: Check Spell
119+
if: runner.os == 'Linux'
107120
run: pnpm check-spell
108121

109122
- name: Lint
123+
if: runner.os == 'Linux'
110124
run: pnpm run lint
111125

112126
done:
113127
needs:
114128
- test-go
115129
- test-node
116130
if: always()
117-
runs-on: rspack-ubuntu-22.04-large
131+
runs-on: ubuntu-latest
118132
name: CI Done
119133
steps:
120134
- run: exit 1

.github/workflows/release.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ on:
4141
- npm
4242
- extension
4343
permissions:
44-
# Provenance generation in GitHub Actions requires "write" access to the "id-token"
45-
id-token: write
4644
contents: read
4745
env:
4846
GO_VERSION: '1.24.1'
@@ -54,6 +52,11 @@ jobs:
5452
needs: [build]
5553
runs-on: ubuntu-22.04
5654
environment: npm
55+
permissions:
56+
# For push git tags
57+
contents: write
58+
# For Trusted Publish
59+
id-token: write
5760
steps:
5861
- name: Show dry-run status
5962
run: |
@@ -95,13 +98,15 @@ jobs:
9598

9699
- name: Move binaries
97100
uses: ./.github/actions/move-artifacts
98-
99101
- name: Publish npm packages
100102
if: ${{ inputs.dry_run == false }}
101-
env:
102-
NPM_TOKEN: ${{ secrets.RSLINT_NPM_TOKEN }}
103103
run: |
104104
pnpm -r publish --no-git-checks --tag ${{ github.event.inputs.npm_tag }} --publish-branch ${{ github.event.inputs.branch }}
105+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
106+
git config --global user.name "github-actions"
107+
echo git tag v$(jq -r .version package.json)
108+
git tag v$(jq -r .version package.json)
109+
git push origin --follow-tags
105110
106111
publish-extension-vscode:
107112
if: ${{ inputs.to_release == 'all' || inputs.to_release == 'extension' }}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Update Rule Manifest
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
update-rule-manifest:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
22+
- name: Check for rule changes
23+
id: diff
24+
run: |
25+
git fetch origin main
26+
git diff --name-only HEAD~10 HEAD | grep '^internal/rules/' || echo '' > changed_rules.txt
27+
git diff --name-status HEAD~10 HEAD | grep '^internal/rules/' || echo '' > changed_rules_status.txt
28+
29+
- name: Generate rule-manifest.json if rules changed
30+
if: ${{ hashFiles('changed_rules.txt') != '' }}
31+
run: |
32+
node scripts/gen-rule-manifest.js
33+
34+
- name: Create Pull Request if rule-manifest.json changed
35+
uses: peter-evans/create-pull-request@v5
36+
with:
37+
commit-message: 'chore: update rule-manifest.json [auto]'
38+
title: 'chore: update rule-manifest.json [auto]'
39+
body: 'Auto-generated PR to update rule-manifest.json when rules change.'
40+
branch: auto/update-rule-manifest
41+
add-paths: packages/rslint-test-tools/rule-manifest.json
42+
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ packages/vscode-extension/.vscode-test
1313
packages/rslint-test-tools/tests/typescript-eslint/fixtures
1414
packages/rslint-test-tools/tests/typescript-eslint/rules
1515
packages/rslint/pkg/
16+
website/doc_build
1617
pnpm-lock.yaml

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<picture>
2+
<img alt="Rslint Banner" src="https://assets.rspack.rs/rslint/rslint-banner.png">
3+
</picture>
4+
15
# Rslint
26

37
<p>
@@ -32,7 +36,7 @@ Rslint is a fork of [tsgolint](https://github.com/typescript-eslint/tsgolint), b
3236

3337
## 🚀 Getting Started
3438

35-
See [Guide](./GUIDE.md).
39+
See [Guide](./website/docs/guide/index.md).
3640

3741
## 📖 Architecture Overview
3842

architecture.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,51 +43,51 @@ Rslint is a high-performance JavaScript and TypeScript linter written in Go, des
4343

4444
```
4545
┌─────────────────────────────────────────────────────────────────┐
46-
│ RSLINT SYSTEM │
46+
│ RSLINT SYSTEM
4747
├─────────────────────────────────────────────────────────────────┤
4848
│ │
4949
│ ┌─────────────┐ ┌──────────────┐ ┌─────────────────────────┐ │
5050
│ │ CLI │ │ API │ │ LSP Server │ │
51-
│ │ (cmd/rslint)│ │ (internal/ │ │ (internal/lsp) │ │
51+
│ │ (cmd/rslint)│ │ (internal/ │ │ (internal/lsp) │ │
5252
│ │ │ │ api) │ │ │ │
5353
│ └─────┬───────┘ └──────┬───────┘ └──────────┬──────────────┘ │
5454
│ │ │ │ │
5555
│ └─────────────────┼─────────────────────┘ │
5656
│ │ │
57-
│ ┌─────────────────────┬─▼──────────────────────────────────────┐ │
58-
│ │ │ LINTER CORE │ │
59-
│ │ ┌─────────────────┐│ (internal/linter) │ │
60-
│ │ CONFIG ││ │ │
61-
│ │ LOADER ││ ┌──────────────┐ ┌─────────────────┐│ │
62-
│ │ │(internal/config)││ │ PROJECT │ │ RULE ENGINE ││ │
63-
│ │ │ ││ │ DISCOVERY │ │ (internal/rule) ││ │
64-
│ │ └─────────────────┘│ │ │ │ ││ │
57+
│ ┌─────────────────────┬─▼────────────────────────────────────┐ │
58+
│ │ │ LINTER CORE │ │
59+
│ │ ┌─────────────────┐ │ (internal/linter) │ │
60+
│ │ │ CONFIG │ │ │
61+
│ │ │ LOADER │ ┌──────────────┐ ┌─────────────────┐│ │
62+
│ │ │(internal/config)│ │ │ PROJECT │ │ RULE ENGINE ││ │
63+
│ │ │ │ │ │ DISCOVERY │ │ (internal/rule) ││ │
64+
│ │ └─────────────────┘ │ │ │ │ ││ │
6565
│ │ │ └──────────────┘ └─────────────────┘│ │
66-
│ └─────────────────────┴──────────────────────────────────────┘ │
66+
│ └─────────────────────┴──────────────────────────────────────┘ │
6767
│ │ │
68-
│ ┌─────────────────────┬─▼──────────────────────────────────────┐ │
68+
│ ┌─────────────────────┬─▼────────────────────────────────────┐ │
6969
│ │ │ TYPESCRIPT-GO │ │
70-
│ │ ┌─────────────────┐│ (typescript-go submodule) │ │
71-
│ │ │ RULES ││ │ │
72-
│ │ │ (internal/rules)│ ┌──────────┐ ┌──────────┐ ┌─────────┐│ │
73-
│ │ │ │ │ LEXER │ │ PARSER │ │ CHECKER ││ │
74-
│ │ │ - no_unused_vars│ │ │ │ │ │ ││ │
75-
│ │ │ - array_type │ │ │ │ │ │ ││ │
76-
│ │ │ - await_thenable│ │ │ │ │ │ ││ │
77-
│ │ │ - ... │ └──────────┘ └──────────┘ └─────────┘│ │
78-
│ │ └─────────────────┘│ │ │
79-
│ └─────────────────────┴──────────────────────────────────────┘ │
70+
│ │ ┌─────────────────┐ │ (typescript-go submodule) │ │
71+
│ │ │ RULES │ │ │ │
72+
│ │ │ (internal/rules)│ ┌──────────┐ ┌──────────┐ ┌─────────┐│ │
73+
│ │ │ │ │ LEXER │ │ PARSER │ │ CHECKER ││ │
74+
│ │ │ - no_unused_vars│ │ │ │ │ │ ││ │
75+
│ │ │ - array_type │ │ │ │ │ │ ││ │
76+
│ │ │ - await_thenable│ │ │ │ │ │ ││ │
77+
│ │ │ - ... │ └──────────┘ └──────────┘ └─────────┘│ │
78+
│ │ └─────────────────┘ │ │ │
79+
│ └─────────────────────┴──────────────────────────────────────┘ │
8080
│ │
81-
│ ┌────────────────────────────────────────────────────────────┐ │
81+
│ ┌────────────────────────────────────────────────────────────┐ │
8282
│ │ NODE.JS PACKAGES │ │
83-
│ │ │ │
84-
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │ │
85-
│ │ │ @rslint │ │ VS Code │ │ Testing Tools │ │ │
86-
│ │ │ /core │ │ Extension │ │ │ │ │
87-
│ │ │ │ │ │ │ - rslint-test-tools │ │ │
88-
│ │ │ │ │ │ │ - rule-tester │ │ │
89-
│ │ └─────────────┘ └─────────────┘ └─────────────────────────┘ │ │
90-
│ └────────────────────────────────────────────────────────────┘ │
83+
│ │ │ │
84+
│ │┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │ │
85+
│ ││ @rslint │ │ VS Code │ │ Testing Tools │ │ │
86+
│ ││ /core │ │ Extension │ │ │ │ │
87+
│ ││ │ │ │ │ - rslint-test-tools │ │ │
88+
│ ││ │ │ │ │ - rule-tester │ │ │
89+
│ │└─────────────┘ └─────────────┘ └─────────────────────────┘ │ │
90+
│ └────────────────────────────────────────────────────────────┘ │
9191
└─────────────────────────────────────────────────────────────────┘
9292
```
9393

cmd/rslint/api.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ func (h *IPCHandler) HandleLint(req api.LintRequest) (*api.LintResponse, error)
4848
allowedFiles := []string{}
4949
// Apply file contents if provided
5050
if len(req.FileContents) > 0 {
51-
fs = utils.NewOverlayVFS(fs, req.FileContents)
52-
for file := range req.FileContents {
53-
54-
allowedFiles = append(allowedFiles, file) // Collect allowed files from request
51+
fileContents := make(map[string]string, len(req.FileContents))
52+
for k, v := range req.FileContents {
53+
normalizePath := tspath.NormalizePath(k)
54+
fileContents[normalizePath] = v
55+
allowedFiles = append(allowedFiles, normalizePath)
5556
}
57+
fs = utils.NewOverlayVFS(fs, fileContents)
58+
5659
}
5760

5861
// Initialize rule registry with all available rules

cmd/rslint/cmd.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ Usage:
314314
rslint [OPTIONS]
315315
316316
Options:
317+
--init Initialize a default config in the current directory.
317318
--config PATH Which rslint config file to use. Defaults to rslint.json.
318319
--format FORMAT Output format: default | jsonline
319320
--fix Automatically fix problems
@@ -328,6 +329,7 @@ func runCMD() int {
328329
flag.Usage = func() { fmt.Fprint(os.Stderr, usage) }
329330

330331
var (
332+
init bool
331333
help bool
332334
config string
333335
fix bool
@@ -343,6 +345,7 @@ func runCMD() int {
343345
)
344346
flag.StringVar(&format, "format", "default", "output format")
345347
flag.StringVar(&config, "config", "", "which rslint config to use")
348+
flag.BoolVar(&init, "init", false, "initialize a default config in the current directory")
346349
flag.BoolVar(&fix, "fix", false, "automatically fix problems")
347350
flag.BoolVar(&help, "help", false, "show help")
348351
flag.BoolVar(&help, "h", false, "show help")
@@ -405,6 +408,14 @@ func runCMD() int {
405408
}
406409
currentDirectory = tspath.NormalizePath(currentDirectory)
407410

411+
if init {
412+
if err := rslintconfig.InitDefaultConfig(currentDirectory); err != nil {
413+
fmt.Fprintf(os.Stderr, "error initializing config: %v\n", err)
414+
return 1
415+
}
416+
return 0
417+
}
418+
408419
fs := bundled.WrapFS(cachedvfs.From(osvfs.FS()))
409420

410421
// Initialize rule registry with all available rules

0 commit comments

Comments
 (0)