Skip to content

Commit b629940

Browse files
committed
Merge branch 'main' into linter/issue-20465-vue-js-plugin-ranges
2 parents 4ee8fae + 067da8c commit b629940

6,398 files changed

Lines changed: 499975 additions & 87096 deletions

File tree

Some content is hidden

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

.agents/skills/migrate-oxfmt/SKILL.md

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ An automated migration tool is built into oxfmt, supporting both Prettier and Bi
1313

1414
## Step 1: Run Automated Migration
1515

16+
First, decide whether the automated tool fits:
17+
18+
- **Static root config** (JSON/YAML, or a JS/TS config that just exports a plain object): use `--migrate` below.
19+
- **Dynamic JS/TS config** (logic such as environment branches or computed values): `--migrate` writes only a resolved snapshot of the values — the logic does not survive. Migrate manually instead, porting the logic to `oxfmt.config.ts` with the option mappings in this guide.
20+
- **Nested per-directory configs**: `--migrate` only handles the config found from the current directory. Migrate the nested ones manually (see "Nested Config" in Step 2).
21+
1622
### From Prettier
1723

1824
```bash
@@ -25,6 +31,7 @@ This will:
2531
- Create `.oxfmtrc.json` with migrated options
2632
- Migrate `.prettierignore` patterns to `ignorePatterns`
2733
- Migrate `prettier-plugin-tailwindcss` options to `sortTailwindcss`
34+
- Migrate `prettier-plugin-svelte` options to `svelte` (`svelteSortOrder``sortOrder`, `svelteAllowShorthand``allowShorthand`, `svelteIndentScriptAndStyle``indentScriptAndStyle`)
2835
- Detect `prettier-plugin-packagejson` and enable `sortPackageJson`
2936

3037
### From Biome
@@ -53,15 +60,20 @@ Biome option mapping:
5360
| `javascript.formatter.trailingCommas` | `trailingComma` |
5461
| `javascript.formatter.semicolons` (`"always"`/`"asNeeded"`) | `semi` (`true`/`false`) |
5562
| `javascript.formatter.arrowParentheses` (`"asNeeded"`) | `arrowParens` (`"avoid"`) |
56-
| `formatter.bracketSameLine` | `bracketSameLine` |
63+
| `javascript.formatter.bracketSameLine` | `bracketSameLine` |
5764
| `formatter.bracketSpacing` | `bracketSpacing` |
5865
| `formatter.attributePosition` (`"multiline"`) | `singleAttributePerLine` (`true`) |
5966

67+
Notes (Biome):
68+
69+
- For `formatter.*` options in the table, a `javascript.formatter.*` value of the same name takes precedence when present. `bracketSameLine` is read only from `javascript.formatter.bracketSameLine`.
70+
- Options not set in `biome.json` are written to `.oxfmtrc.json` with Biome's default values explicitly (e.g. `printWidth: 80`, `useTabs: true`), so the output preserves Biome's formatting behavior.
71+
6072
Notes (both sources):
6173

62-
- Fails if `.oxfmtrc.json` already exists. Delete it first if you want to re-run.
74+
- Fails if `.oxfmtrc.json` or `.oxfmtrc.jsonc` already exists. Delete it first if you want to re-run.
6375
- If no source config is found, creates a blank `.oxfmtrc.json` instead.
64-
- `overrides` cannot be auto-migrated for either source and must be converted manually.
76+
- `overrides` cannot be auto-migrated for either source and must be converted manually (a warning is printed if detected).
6577

6678
## Step 2: Review Generated Config
6779

@@ -75,11 +87,15 @@ Prettier and Biome default is 80, oxfmt default is 100. The migration tool sets
7587

7688
These Prettier options are skipped during migration:
7789

78-
| Option | Status |
79-
| ------------------------------ | ------------------------------------------------ |
80-
| `endOfLine: "auto"` | Not supported. Use `"lf"` or `"crlf"` explicitly |
81-
| `experimentalTernaries` | Not supported in JS/TS files yet |
82-
| `experimentalOperatorPosition` | Not supported in JS/TS files yet |
90+
| Option | Status |
91+
| ------------------------------- | ------------------------------------------------ |
92+
| `endOfLine: "auto"` | Not supported. Use `"lf"` or `"crlf"` explicitly |
93+
| `experimentalTernaries` | Not supported in JS/TS files yet |
94+
| `experimentalOperatorPosition` | Not supported in JS/TS files yet |
95+
| `requirePragma`, `insertPragma` | Not supported |
96+
| `parser`, `filepath` | Not applicable to oxfmt |
97+
98+
Regex values (e.g. `"/^my-/"`) in `tailwindFunctions` / `tailwindAttributes` are also skipped with a warning — oxfmt only supports literal strings there.
8399

84100
### sortPackageJson (Prettier only)
85101

@@ -100,20 +116,25 @@ The `overrides` field cannot be auto-migrated from either Prettier or Biome. Con
100116
"overrides": [
101117
{
102118
"files": ["*.md"],
119+
"excludeFiles": ["CHANGELOG.md"],
103120
"options": { "tabWidth": 4 }
104121
}
105122
]
106123
}
107124
```
108125

126+
(`excludeFiles` is optional.)
127+
109128
### Nested Config
110129

111-
Oxfmt does not support nested configuration files (e.g., a separate `.oxfmtrc.json` in a subdirectory). If your project used per-directory Prettier or Biome configs, consolidate them using `overrides` with file glob patterns, or run oxfmt separately per directory with different working directories.
130+
Oxfmt supports nested configuration files: a `.oxfmtrc.json` in a subdirectory applies to files under that directory. Pass `--disable-nested-config` to opt out and use only the root config.
131+
132+
However, `--migrate` only migrates the config found from the current directory — it does not walk subdirectories. If the project has per-directory Prettier or Biome configs, you must migrate each one yourself: convert each nested config to a `.oxfmtrc.json` in the same directory manually (using the option mappings in this guide).
112133

113134
### Prettier-Compatible Options
114135

115136
These options transfer directly with the same behavior:
116-
`tabWidth`, `useTabs`, `semi`, `singleQuote`, `jsxSingleQuote`, `quoteProps`, `trailingComma`, `arrowParens`, `bracketSpacing`, `bracketSameLine`, `endOfLine`, `proseWrap`, `htmlWhitespaceSensitivity`, `singleAttributePerLine`, `vueIndentScriptAndStyle`
137+
`printWidth`, `tabWidth`, `useTabs`, `semi`, `singleQuote`, `jsxSingleQuote`, `quoteProps`, `trailingComma`, `arrowParens`, `bracketSpacing`, `bracketSameLine`, `objectWrap`, `endOfLine`, `proseWrap`, `htmlWhitespaceSensitivity`, `singleAttributePerLine`, `vueIndentScriptAndStyle`, `embeddedLanguageFormatting`
117138

118139
## Step 3: Configure Oxfmt Extensions
119140

@@ -132,6 +153,8 @@ Sort import statements, inspired by `eslint-plugin-perfectionist/sort-imports` (
132153
}
133154
```
134155

156+
Other options: `partitionByComment`, `sortSideEffects`, `order`, `ignoreCase`, `internalPattern`, `groups`, `customGroups`.
157+
135158
### sortTailwindcss
136159

137160
Replaces `prettier-plugin-tailwindcss`. Auto-migrated with renamed options:
@@ -147,10 +170,12 @@ Replaces `prettier-plugin-tailwindcss`. Auto-migrated with renamed options:
147170

148171
### Other Extensions
149172

150-
| Option | Default | Description |
151-
| -------------------- | ------- | ---------------------------------------------------------------------------- |
152-
| `insertFinalNewline` | `true` | Whether to add a final newline at end of file |
153-
| `sortPackageJson` | `true` | Sort `package.json` keys. Set `{ "sortScripts": true }` to also sort scripts |
173+
| Option | Default | Description |
174+
| -------------------- | -------- | ------------------------------------------------------------------------------- |
175+
| `insertFinalNewline` | `true` | Whether to add a final newline at end of file |
176+
| `sortPackageJson` | `true` | Sort `package.json` keys. Set `{ "sortScripts": true }` to also sort scripts |
177+
| `jsdoc` | disabled | Format JSDoc comments. Set `true` or an options object for fine-grained control |
178+
| `svelte` | disabled | Svelte formatting options, replacing `prettier-plugin-svelte` (auto-migrated) |
154179

155180
## Step 4: Update CI and Scripts
156181

@@ -183,13 +208,14 @@ npx oxfmt@latest --check
183208

184209
### File Type Coverage
185210

186-
- JS/TS: Formatted natively by oxfmt
211+
- JS/TS, JSON/JSONC/JSON5, CSS/SCSS/Less, GraphQL: Formatted natively by oxfmt
187212
- TOML: Formatted natively (via taplo)
188-
- CSS, HTML, YAML, Markdown, GraphQL, etc.: Delegated to Prettier internally (when using `npx oxfmt`)
213+
- HTML, YAML, Markdown, Vue, Svelte, etc.: Delegated to Prettier internally (when using `npx oxfmt`)
189214

190215
## Tips
191216

192-
- EditorConfig: Oxfmt reads `.editorconfig` automatically for `useTabs`, `tabWidth`, `endOfLine`, `insertFinalNewline`, and `printWidth`. Options in `.oxfmtrc.json` take precedence.
217+
- Config file: `.oxfmtrc.jsonc` and `oxfmt.config.ts` are also supported as auto-discovered config file names, in addition to `.oxfmtrc.json`. `--migrate` and `--init` only generate `.oxfmtrc.json`; keep it as-is unless the user explicitly asks for another format or the source config had logic to preserve (see Step 1).
218+
- EditorConfig: Oxfmt reads `.editorconfig` automatically for `useTabs`, `tabWidth`, `endOfLine`, `insertFinalNewline`, `printWidth`, and `singleQuote`. Options in `.oxfmtrc.json` take precedence.
193219
- CI: Use `npx oxfmt@latest --check` to enforce formatting in CI.
194220
- LSP: Run `oxfmt --lsp` for editor integration via Language Server Protocol.
195221
- Schema support: Add `"$schema": "./node_modules/oxfmt/configuration_schema.json"` to `.oxfmtrc.json` for editor autocompletion.
Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
11
---
22
name: performance-lint-rules
3-
description: Tips for writing performant Oxc linter rules. Use only when editing Rust rule implementations under crates/oxc_linter/src/rules/.
3+
description: Performance review guidance for Oxc linter rule implementations. Use only when reviewing Rust rule code under crates/oxc_linter/src/rules/ or when explicitly auditing those rules for performance improvements.
44
---
55

6-
This skill gives performance guidance for Oxc linter rule implementations.
7-
8-
## Scope
9-
10-
Use this skill **only** for Rust code under `crates/oxc_linter/src/rules/`.
11-
12-
Do not use this skill for linter infrastructure, parser code, semantic analysis, formatter code, tests outside the rules directory, or unrelated crates.
13-
146
## Performance Guidelines
157

168
### Prefer top-level node kind checks
179

18-
Put node kind checks at the top level of the rule when possible. Rule runner implementations generated by lintgen can recognize implemented node types, which helps avoid invoking rules on unrelated AST nodes.
10+
Put node kind checks at the rule entry point. If a rule only handles a few syntactic forms, start `run` with an `AstKind` match and return for all other nodes, even when a helper filters again internally. This lets lintgen derive narrower `NODE_TYPES` and avoids dispatching the rule on unrelated AST nodes.
11+
12+
After changing the relevant node kinds for a rule, regenerate the rule runner with `cargo lintgen` and consider adding or updating `assert_rule_runs_on_node_types` coverage in `crates/oxc_linter/src/rule.rs`.
13+
14+
Implement only the needed entry point. If a rule is a whole-file pass over semantic indexes, use `run_once` by itself. Implementing both `run` and `run_once` prevents useful node-type narrowing.
1915

2016
### Do cheaper checks first
2117

22-
Order checks from cheapest and most selective to most expensive. Simple equality checks, early returns, and fast paths such as ASCII-only checks should come before semantic lookups, allocations, or deeper AST traversal.
18+
Order checks from cheapest and most selective to most expensive. Return quickly for common non-matches before doing semantic lookups, allocations, or deeper traversal.
2319

24-
Most rules trigger on only a small set of nodes, so quickly return for the common non-matching cases.
20+
- Matching a small fixed string set with `matches!` before semantic checks.
21+
- Rejecting lowercase identifiers before global-object checks when only constructors can match.
22+
- Checking whether a JSX attribute starts with `aria-` before lowercasing it.
23+
- Checking for required syntax such as a `key` prop before looking up callback parameter symbols.
24+
- Checking `source_range(span).contains("this")` before running a visitor that only finds `this`.
2525

26-
### Optimize for success
26+
### Delay expensive context
2727

28-
Most files do not contain lint errors. Avoid preparing diagnostics, labels, help text, fix data, or other extra context until the rule knows it needs to report an issue.
28+
Most files do not contain lint errors. Do not prepare diagnostics, labels, help text, fix data, ancestors, symbols, JSX element types, or replacement strings until the rule has found a syntactic candidate that could actually report.
2929

3030
### Iterate over the smallest set possible
3131

32-
Avoid walking more syntax than necessary.
33-
3432
- Use `run_once` when the rule only needs a whole-file pass and does not need to run on every node.
3533
- Iterate over symbols instead of AST nodes when looking for references to specific names.
3634
- Prefer targeted lists or semantic data over broad AST traversal when available.
35+
- For name-based binding checks, use `ctx.scoping().get_binding(scope_id, name)` instead of scanning every binding in `get_bindings(scope_id)`.
36+
- For global or unresolved identifier checks, start from `ctx.scoping().root_unresolved_references().get(name)` for the small set of relevant names instead of visiting every `IdentifierReference`.
37+
- When iterating unresolved references, still verify the reference is the right kind: skip references with a symbol, type-only references, and nodes whose `AstKind` is not the expected identifier or member access.
38+
- When checking imported specifiers or exported names, iterate the concrete specifiers or precomputed export set rather than scanning all root bindings for every item.
39+
40+
Use precomputed `FxHashSet`s only when many symbols need the same membership test. Prefer keyed semantic lookup when each lookup already has an exact name.
3741

3842
### Avoid unnecessary regular expressions
3943

40-
Do not construct regular expressions internally when byte or string checks are enough. Prefer simple operations such as checking whether a string contains a character, starts with a prefix, ends with a suffix, or matches a small fixed set of values.
44+
Avoid regular expressions when byte or string checks are enough: `contains`, `starts_with`, `ends_with`, or matching a small fixed set.
4145

42-
### Avoid heap allocations
46+
For hot comment or string scanning paths, prefer a cheap `memchr` or byte search to reject most inputs, then parse only candidates. Preserve regex semantics when replacing one, especially identifier boundaries, optional prefixes, and multiline whitespace.
4347

44-
Minimize allocations in hot lint paths.
48+
### Avoid heap allocations
4549

4650
- Use copy-on-write utilities when a value usually does not need to change.
4751
- Avoid intermediate `Vec`s and `String`s when iteration or borrowed data is enough.
4852
- Keep temporary data on the stack when practical.
4953
- Delay allocation until a diagnostic, fix, or transformed value is actually needed.
54+
- Use allocation-free ASCII comparisons such as `starts_with_ignore_case` before calling `cow_to_ascii_lowercase`.
55+
- Use byte scans such as `as_bytes().array_windows()` for simple ASCII patterns like escape sequences.
56+
- Reserve hash maps or sets when the final size is known.
57+
- Avoid building a `HashSet` just to check names that can be looked up directly in scoping data.

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ coverage = "run -p oxc_coverage --profile coverage --"
88
benchmark = "bench -p oxc_benchmark"
99
minsize = "run -p oxc_minsize --profile coverage --"
1010
allocs = "run -p oxc_track_memory_allocations --profile coverage --"
11+
lint-timings = "run -p oxc_track_linter_timings --profile coverage --"
1112
rule = "run -p rulegen"
1213
lintgen = "run -p oxc_linter_codegen"
1314

.gitattributes

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
crates/oxc_formatter/tests/fixtures/** text=auto eol=lf
2-
crates/oxc_formatter/tests/fixtures/js/crlf text=auto eol=crlf
2+
crates/oxc_formatter/tests/fixtures/js/crlf/** text=auto eol=crlf
3+
crates/oxc_formatter_json/tests/fixtures/** text=auto eol=lf
4+
crates/oxc_formatter_json/tests/fixtures/jsonc/crlf/** text=auto eol=crlf
5+
crates/oxc_formatter_graphql/tests/fixtures/** text=auto eol=lf
6+
crates/oxc_formatter_graphql/tests/fixtures/graphql/crlf/** text=auto eol=crlf
7+
crates/oxc_formatter_yaml/tests/fixtures/** text=auto eol=lf
8+
crates/oxc_formatter_yaml/tests/fixtures/yaml/crlf/** text=auto eol=crlf
39
apps/oxfmt/test/**/fixtures/** text=auto eol=lf
410
apps/oxlint/test/fixtures/** text=auto eol=lf
511

.github/CODEOWNERS

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,87 @@
77
Cargo.lock
88
pnpm-lock.yaml
99

10-
/apps/oxfmt @leaysgur
10+
# Linter (@camc314)
11+
12+
/crates/oxc_linter @camc314
13+
/oxlintrc.json @camc314
1114
/apps/oxlint @camc314
1215
/apps/oxlint/conformance @camc314 @overlookmotel
1316
/apps/oxlint/src-js @camc314 @overlookmotel
17+
/apps/oxlint/src-js/package/config.generated.ts @camc314
1418
/apps/oxlint/test @camc314 @overlookmotel
1519
/apps/oxlint/tsdown_plugins @camc314 @overlookmotel
20+
/npm/oxlint @camc314
21+
/npm/oxlint-plugin-eslint @camc314
22+
/npm/oxlint-plugins @camc314
23+
/tasks/lint_rules @camc314
24+
/tasks/linter_codegen @camc314
25+
/tasks/rulegen @camc314
26+
/tasks/website_linter @camc314
1627

17-
/crates/oxc_allocator @overlookmotel
18-
/crates/oxc_data_structures @overlookmotel
19-
/crates/oxc_formatter @dunqing @leaysgur
20-
/crates/oxc_isolated_declarations @dunqing
21-
/crates/oxc_language_server @camc314 @sysix
22-
/crates/oxc_linter @camc314
28+
# Formatter (@leaysgur)
29+
30+
/crates/oxc_formatter @leaysgur
31+
/crates/oxc_formatter_core @leaysgur
32+
/crates/oxc_formatter_json @leaysgur
33+
/crates/oxc_formatter_graphql @leaysgur
34+
/crates/oxc_formatter_css @leaysgur
35+
/crates/oxc_formatter_yaml @leaysgur
36+
/crates/oxc_jsdoc @leaysgur
2337
/crates/oxc_regular_expression @leaysgur
38+
/oxfmtrc.jsonc @leaysgur
39+
/apps/oxfmt @leaysgur
40+
/npm/oxfmt @leaysgur
41+
/tasks/prettier_conformance @leaysgur
42+
/tasks/website_formatter @leaysgur
43+
44+
# Shared application tooling (@camc314 @leaysgur)
45+
46+
/crates/oxc_language_server @camc314 @leaysgur @sysix
47+
/crates/oxc_config @camc314 @leaysgur
48+
/apps/shared @camc314 @leaysgur
49+
50+
# Transformer / Minifier / Semantic (@dunqing)
51+
52+
/crates/oxc_transformer @dunqing
53+
/crates/oxc_transformer_plugins @dunqing
54+
/crates/oxc_minifier @dunqing
55+
/crates/oxc_mangler @dunqing
2456
/crates/oxc_semantic @dunqing
25-
/crates/oxc_transformer @overlookmotel @dunqing
26-
/crates/oxc_transformer_plugins @overlookmotel @dunqing
27-
/crates/oxc_traverse @overlookmotel
57+
/crates/oxc_isolated_declarations @dunqing
58+
/crates/oxc_ecmascript @dunqing
59+
/crates/oxc_cfg @dunqing
60+
/crates/oxc_compat @dunqing
61+
/crates/oxc_codegen @dunqing
62+
/crates/oxc_napi @dunqing
63+
/napi/transform @dunqing
64+
/napi/transform-react @dunqing
65+
/napi/minify @dunqing
66+
/npm/runtime @dunqing
67+
/tasks/transform_conformance @dunqing
68+
/tasks/transform_checker @dunqing
69+
/tasks/minsize @dunqing
70+
/tasks/compat_data @dunqing
2871

72+
# Core infrastructure crates (@overlookmotel)
73+
74+
/crates/oxc_allocator @overlookmotel
75+
/crates/oxc_data_structures @overlookmotel
76+
/crates/oxc_traverse @overlookmotel
77+
/crates/oxc_ast @overlookmotel
78+
/crates/oxc_ast_macros @overlookmotel
79+
/crates/oxc_ast_visit @overlookmotel
80+
/crates/oxc_macros @overlookmotel
81+
/crates/oxc_span @overlookmotel
82+
/crates/oxc_str @overlookmotel
83+
/crates/oxc_syntax @overlookmotel
84+
/crates/oxc_estree @overlookmotel
85+
/crates/oxc_estree_tokens @overlookmotel
86+
/npm/oxc-types @overlookmotel
2987
/tasks/ast_tools @overlookmotel
88+
/tasks/track_memory_allocations @overlookmotel
89+
90+
# Everything else falls through to the default owner @Boshen, including:
91+
# parser (crates/oxc_parser, napi/parser), umbrella crates (crates/oxc,
92+
# crates/oxc_react_compiler), crates/oxc_diagnostics, CI/release config,
93+
# .github, build/dev toolchain configs, and project documentation.

.github/FUNDING.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
github: [Boshen, Dunqing, camc314, leaysgur]
21
open_collective: oxc

.github/generated/ast_changes_watch_list.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ src:
2020
- 'crates/oxc_allocator/src/**/*.rs'
2121
- 'crates/oxc_ast/src/**/*.rs'
2222
- 'crates/oxc_ast_macros/src/generated/derived_traits.rs'
23+
- 'crates/oxc_ast_macros/src/generated/enums.rs'
2324
- 'crates/oxc_ast_macros/src/generated/structs.rs'
2425
- 'crates/oxc_ast_macros/src/lib.rs'
2526
- 'crates/oxc_ast_visit/src/**/*.rs'

0 commit comments

Comments
 (0)