forked from oxc-project/oxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
executable file
·195 lines (150 loc) · 5.19 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/usr/bin/env -S just --justfile
set windows-shell := ["powershell"]
set shell := ["bash", "-cu"]
_default:
@just --list -u
alias r := ready
alias c := conformance
alias f := fix
alias new-typescript-rule := new-ts-rule
# Make sure you have cargo-binstall installed.
# You can download the pre-compiled binary from <https://github.com/cargo-bins/cargo-binstall#installation>
# or install via `cargo install cargo-binstall`
# Initialize the project by installing all the necessary tools.
init:
cargo binstall cargo-watch cargo-insta typos-cli cargo-shear dprint -y
# When ready, run the same CI commands
ready:
git diff --exit-code --quiet
typos
just fmt
just check
just test
just lint
just doc
just ast
git status
# Clone or update submodules
submodules:
just clone-submodule tasks/coverage/test262 [email protected]:tc39/test262.git d62fa93c8f9ce5e687c0bbaa5d2b59670ab2ff60
just clone-submodule tasks/coverage/babel [email protected]:babel/babel.git 3bcfee232506a4cebe410f02042fb0f0adeeb0b1
just clone-submodule tasks/coverage/typescript [email protected]:microsoft/TypeScript.git a709f9899c2a544b6de65a0f2623ecbbe1394eab
just clone-submodule tasks/prettier_conformance/prettier [email protected]:prettier/prettier.git 52829385bcc4d785e58ae2602c0b098a643523c9
# Install git pre-commit to format files
install-hook:
echo -e "#!/bin/sh\njust fmt" > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
# --no-vcs-ignores: cargo-watch has a bug loading all .gitignores, including the ones listed in .gitignore
# use .ignore file getting the ignore list
# Run `cargo watch`
watch command:
cargo watch --no-vcs-ignores -i '*snap*' -x '{{command}}'
# Run the example in `parser`, `formatter`, `linter`
example tool *args='':
just watch 'run -p oxc_{{tool}} --example {{tool}} -- {{args}}'
# Generate AST related boilerplate code.
# Run this when AST definition is changed.
ast:
cargo run -p oxc_ast_tools
just check
# Format all files
fmt:
cargo shear --fix # remove all unused dependencies
cargo fmt --all
dprint fmt
# Run cargo check
check:
cargo ck
# Run all the tests
test:
cargo test
# Lint the whole project
lint:
cargo lint -- --deny warnings
[unix]
doc:
RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items
[windows]
doc:
$Env:RUSTDOCFLAGS='-D warnings'; cargo doc --no-deps --document-private-items
# Fix all auto-fixable format and lint issues. Make sure your working tree is clean first.
fix:
cargo clippy --fix --allow-staged --no-deps
just fmt
typos -w
git status
# Run all the conformance tests. See `tasks/coverage`, `tasks/transform_conformance`, `tasks/minsize`
coverage:
cargo coverage
cargo run -p oxc_transform_conformance -- --exec
cargo run -p oxc_prettier_conformance
cargo minsize
conformance *args='':
cargo coverage -- {{args}}
# Watch oxlint
watch-oxlint *args='':
just watch 'run -p oxlint -- {{args}}'
# Build oxlint in release build
oxlint:
cargo oxlint
# Get code coverage
codecov:
cargo codecov --html
# Run the benchmarks. See `tasks/benchmark`
benchmark:
cargo benchmark
# Automatically DRY up Cargo.toml manifests in a workspace.
autoinherit:
cargo binstall cargo-autoinherit
cargo autoinherit
# Test Transform
test-transform *args='':
cargo run -p oxc_transform_conformance -- {{args}}
cargo run -p oxc_transform_conformance -- --exec {{args}}
# Install wasm-pack
install-wasm:
cargo binstall wasm-pack
watch-wasm:
cargo watch --no-vcs-ignores -i 'npm/oxc-wasm/**' -- just build-wasm dev
build-wasm mode="release":
wasm-pack build --out-dir ../../npm/oxc-wasm --target web --{{mode}} --scope oxc crates/oxc_wasm
# Generate the JavaScript global variables. See `tasks/javascript_globals`
javascript-globals:
cargo run -p javascript_globals
# Create a new lint rule by providing the ESLint name. See `tasks/rulegen`
new-rule name:
cargo run -p rulegen {{name}}
new-jest-rule name:
cargo run -p rulegen {{name}} jest
new-ts-rule name:
cargo run -p rulegen {{name}} typescript
new-unicorn-rule name:
cargo run -p rulegen {{name}} unicorn
new-react-rule name:
cargo run -p rulegen {{name}} react
new-jsx-a11y-rule name:
cargo run -p rulegen {{name}} jsx-a11y
new-oxc-rule name:
cargo run -p rulegen {{name}} oxc
new-nextjs-rule name:
cargo run -p rulegen {{name}} nextjs
new-jsdoc-rule name:
cargo run -p rulegen {{name}} jsdoc
new-react-perf-rule name:
cargo run -p rulegen {{name}} react-perf
new-n-rule name:
cargo run -p rulegen {{name}} n
new-promise-rule name:
cargo run -p rulegen {{name}} promise
new-vitest-rule name:
cargo run -p rulegen {{name}} vitest
new-security-rule name:
cargo run -p rulegen {{name}} security
clone-submodule dir url sha:
cd {{dir}} || git init {{dir}}
cd {{dir}} && git remote add origin {{url}} || true
cd {{dir}} && git fetch --depth=1 origin {{sha}} && git reset --hard {{sha}}
website path:
cargo run -p website -- linter-rules --table {{path}}/src/docs/guide/usage/linter/generated-rules.md --rule-docs {{path}}/src/docs/guide/usage/linter/rules
cargo run -p website -- linter-cli > {{path}}/src/docs/guide/usage/linter/generated-cli.md
cargo run -p website -- linter-schema-markdown > {{path}}/src/docs/guide/usage/linter/generated-config.md