Skip to content

Conversation

@camchenry
Copy link
Member

@camchenry camchenry commented Nov 5, 2025

This depends on the next version of tsgolint (after 0.6.0) to be released in order to work, otherwise not all options will not be accepted.

This implements rule configuration for rules that run in tsgolint. This is achieved by serializing the rule configuration as JSON and sending it as part of the payload, which is now supported by tsgolint. This is implemented by adding a new to_configuration method, which does the opposite of from_configuration. This is only implemented and used for tsgolint rules, so that there's no additional performance cost unless you are using type-aware linting.

Unfortunately, this does mean that we sort of have to maintain config parsing in two separate codebases, but I think we can improve this in the future with more tooling.


Generated rule documentation:


## Configuration

This rule accepts a configuration object with the following properties:

### allowForKnownSafeCalls

type: `array`

default: `[]`

Allows specific calls to be ignored, specified as type or value specifiers.


#### allowForKnownSafeCalls[n]



Type or value specifier for matching specific declarations

Supports four types of specifiers:

1. **String specifier** (deprecated): Universal match by name
```json
"Promise"
```

2. **File specifier**: Match types/values declared in local files
```json
{ "from": "file", "name": "MyType" }
{ "from": "file", "name": ["Type1", "Type2"] }
{ "from": "file", "name": "MyType", "path": "./types.ts" }
```

3. **Lib specifier**: Match TypeScript built-in lib types
```json
{ "from": "lib", "name": "Promise" }
{ "from": "lib", "name": ["Promise", "PromiseLike"] }
```

4. **Package specifier**: Match types/values from npm packages
```json
{ "from": "package", "name": "Observable", "package": "rxjs" }
{ "from": "package", "name": ["Observable", "Subject"], "package": "rxjs" }
```


### allowForKnownSafePromises

type: `array`

default: `[]`

Allows specific Promise types to be ignored, specified as type or value specifiers.


#### allowForKnownSafePromises[n]



Type or value specifier for matching specific declarations

Supports four types of specifiers:

1. **String specifier** (deprecated): Universal match by name
```json
"Promise"
```

2. **File specifier**: Match types/values declared in local files
```json
{ "from": "file", "name": "MyType" }
{ "from": "file", "name": ["Type1", "Type2"] }
{ "from": "file", "name": "MyType", "path": "./types.ts" }
```

3. **Lib specifier**: Match TypeScript built-in lib types
```json
{ "from": "lib", "name": "Promise" }
{ "from": "lib", "name": ["Promise", "PromiseLike"] }
```

4. **Package specifier**: Match types/values from npm packages
```json
{ "from": "package", "name": "Observable", "package": "rxjs" }
{ "from": "package", "name": ["Observable", "Subject"], "package": "rxjs" }
```


### checkThenables

type: `boolean`

default: `false`

Check for thenable objects that are not necessarily Promises.


### ignoreIIFE

type: `boolean`

default: `false`

Ignore immediately invoked function expressions (IIFEs).


### ignoreVoid

type: `boolean`

default: `true`

Ignore Promises that are void expressions.


@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI C-enhancement Category - New feature or request labels Nov 5, 2025
Copy link
Member Author

camchenry commented Nov 5, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 5, 2025

CodSpeed Performance Report

Merging #15286 will not alter performance

Comparing 11-04-feat_linter_allow_configuring_tsgolint_rules (5d935a9) with main (ba76081)1

Summary

✅ 4 untouched
⏩ 33 skipped2

Footnotes

  1. No successful run was found on main (7b29f21) during the generation of this report, so ba76081 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 33 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@camchenry camchenry force-pushed the 11-04-feat_linter_allow_configuring_tsgolint_rules branch 3 times, most recently from beb3883 to 07e377e Compare November 13, 2025 00:52
@camchenry camchenry marked this pull request as ready for review November 13, 2025 02:56
@camchenry camchenry requested a review from camc314 as a code owner November 13, 2025 02:56
Copilot AI review requested due to automatic review settings November 13, 2025 02:56
Copilot finished reviewing on behalf of camchenry November 13, 2025 02:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements rule configuration support for tsgolint by adding a to_configuration method that serializes rule configurations to JSON. This enables oxlint to pass rule-specific options to the tsgolint type-aware linter.

  • Adds to_configuration() trait method to serialize rule configurations
  • Implements configuration structs and serialization for no-floating-promises rule
  • Updates tsgolint integration to include rule options in the payload (version 2 format)

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
crates/oxc_macros/src/declare_all_lint_rules.rs Adds generated to_configuration method that delegates to individual rule implementations
crates/oxc_linter/src/rule.rs Defines the to_configuration trait method with clear documentation about its usage for tsgolint rules
crates/oxc_linter/src/tsgolint.rs Extends Rule struct with options field and implements Ord/PartialOrd; updates payload construction to include serialized rule configurations
crates/oxc_linter/src/rules/typescript/no_floating_promises.rs Implements complete configuration support including config structs, type specifiers, serialization, and comprehensive tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@camchenry camchenry force-pushed the 11-04-feat_linter_allow_configuring_tsgolint_rules branch from 07e377e to 5d935a9 Compare November 13, 2025 03:13
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Nov 14, 2025
Copy link
Contributor

camc314 commented Nov 14, 2025

Merge activity

This depends on the next version of `tsgolint` (after 0.6.0) to be released in order to work, otherwise not all `options` will not be accepted.

This implements rule configuration for rules that run in tsgolint. This is achieved by serializing the rule configuration as JSON and sending it as part of the payload, which is now supported by tsgolint. This is implemented by adding a new `to_configuration` method, which does the opposite of `from_configuration`. This is only implemented and used for tsgolint rules, so that there's no additional performance cost unless you are using type-aware linting.

Unfortunately, this does mean that we sort of have to maintain config parsing in two separate codebases, but I think we can improve this in the future with more tooling.

---

Generated rule documentation:

````

## Configuration

This rule accepts a configuration object with the following properties:

### allowForKnownSafeCalls

type: `array`

default: `[]`

Allows specific calls to be ignored, specified as type or value specifiers.

#### allowForKnownSafeCalls[n]

Type or value specifier for matching specific declarations

Supports four types of specifiers:

1. **String specifier** (deprecated): Universal match by name
```json
"Promise"
```

2. **File specifier**: Match types/values declared in local files
```json
{ "from": "file", "name": "MyType" }
{ "from": "file", "name": ["Type1", "Type2"] }
{ "from": "file", "name": "MyType", "path": "./types.ts" }
```

3. **Lib specifier**: Match TypeScript built-in lib types
```json
{ "from": "lib", "name": "Promise" }
{ "from": "lib", "name": ["Promise", "PromiseLike"] }
```

4. **Package specifier**: Match types/values from npm packages
```json
{ "from": "package", "name": "Observable", "package": "rxjs" }
{ "from": "package", "name": ["Observable", "Subject"], "package": "rxjs" }
```

### allowForKnownSafePromises

type: `array`

default: `[]`

Allows specific Promise types to be ignored, specified as type or value specifiers.

#### allowForKnownSafePromises[n]

Type or value specifier for matching specific declarations

Supports four types of specifiers:

1. **String specifier** (deprecated): Universal match by name
```json
"Promise"
```

2. **File specifier**: Match types/values declared in local files
```json
{ "from": "file", "name": "MyType" }
{ "from": "file", "name": ["Type1", "Type2"] }
{ "from": "file", "name": "MyType", "path": "./types.ts" }
```

3. **Lib specifier**: Match TypeScript built-in lib types
```json
{ "from": "lib", "name": "Promise" }
{ "from": "lib", "name": ["Promise", "PromiseLike"] }
```

4. **Package specifier**: Match types/values from npm packages
```json
{ "from": "package", "name": "Observable", "package": "rxjs" }
{ "from": "package", "name": ["Observable", "Subject"], "package": "rxjs" }
```

### checkThenables

type: `boolean`

default: `false`

Check for thenable objects that are not necessarily Promises.

### ignoreIIFE

type: `boolean`

default: `false`

Ignore immediately invoked function expressions (IIFEs).

### ignoreVoid

type: `boolean`

default: `true`

Ignore Promises that are void expressions.

````
@graphite-app graphite-app bot force-pushed the 11-04-feat_linter_allow_configuring_tsgolint_rules branch from 5d935a9 to 7598b3e Compare November 14, 2025 22:22
@graphite-app graphite-app bot merged commit 7598b3e into main Nov 14, 2025
20 checks passed
@graphite-app graphite-app bot deleted the 11-04-feat_linter_allow_configuring_tsgolint_rules branch November 14, 2025 22:28
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 14, 2025
overlookmotel pushed a commit that referenced this pull request Nov 17, 2025
# Oxlint
### 🚀 Features

- c199e38 linter: Implement config for all tsgolint rules supporting
options (#15659) (camchenry)
- 7598b3e linter: Allow configuring tsgolint rules (#15286) (camchenry)
- e77f2ce vscode: Support `oxlint --lsp` (#15680) (Sysix)
- e01c551 oxlint: Add `--lsp` flag to run the language server (#15611)
(Sysix)
- ac5c2ab lsp/fmt: Support ignore files & patterns (#15647) (Sysix)
- e50a9bf linter: Add unicorn/prefer-response-static-json rule (#15692)
(Mikhail Baev)
- f5d9abb oxlint: Add enabled? column to --rules cli output (#15213)
(Wren)
- 6b5205c linter/plugins: Implement deprecated
`SourceCode#getJSDocComment` method (#15653) (overlookmotel)
- 5eccff1 linter/plugins: Implement deprecated `SourceCode` tokens
methods (#15645) (overlookmotel)
- 4c62ffa language_server: Add `run_server` helper for CLI tools
(#15609) (Sysix)
- 0d52a5e linter/plugins: Implement `Context#parserOptions` getter
(#15632) (overlookmotel)
- 287a538 linter/plugins: Implement `Context#get*` deprecated methods
(#15606) (overlookmotel)
- 84de1ca oxlint,oxfmt: Allow comments and also commas for
vscode-json-ls (#15612) (leaysgur)
- e763919 linter: Add test to enforce schema documentation for rules
with configuration options (#15234) (Connor Shea)
- 6cd0b5f linter/no-callback-in-promise: Add support for `timeoutsErr`
option (#15507) (Li Wei)

### 🐛 Bug Fixes

- 1decd57 linter/no-empty-named-blocks: Only search within node for
comma token (#15751) (camc314)
- 17c3d6d linter: Improve docs, diagnostic message, and implementation
of typescript/consistent-indexed-object-style rule. (#15750)
(connorshea)
- 78a6df2 linter/no-empty-named-blocks: Skip comments when searching for
token (#15735) (camc314)
- 042befd linter/require-await: Skip comments when searching for token
(#15734) (camc314)
- 7a78220 linter/no-async-await: Skip comments when searching for token
(#15733) (camc314)
- 23b9ad1 linter/consistent-type-specifier-style: Skip comments when
searching for token (#15732) (camc314)
- 440a977 ast: Include rest properties when using
`get_binding_identifiers` (#15710) (camc314)
- 516d14e linter/no-namespace: Skip comments when searching for token
(#15716) (camc314)
- b5aaace linter/prefer-namespace-keyword: Skip comments when searching
for token (#15715) (camc314)
- 4eb9fa6 editor: Execute `oxc.path.server` in win32 with shell (#14203)
(Sysix)
- 9f991a4 linter: Reverse extends overrides priority (#14939) (Peter
Wagenet)
- 7c4a916 linter: Restores `oxlint --rules -f=json` functionality.
(#15689) (Wren)
- 24d00f4 linter/plugins: Add types for suggested fixes (#15636)
(overlookmotel)
- 257360f linter/plugins: Fill in TS type def for `RuleMeta` (#15629)
(overlookmotel)
- 81e179c linter: Allow file extensions without a dot in
react/jsx-filename-extension rule (#15574) (Connor Shea)
- 7a0e931 linter: Update the unicorn/prefer-add-event-listener rule with
new JavaScript APIs (#15581) (connorshea)
- bb5f8ca oxlint: Fix type annotation for big-endian (#15561) (Sysix)

### ⚡ Performance

- e2a0997 linter/plugins: Recycle empty visitor object in ESLint compat
mode (#15693) (overlookmotel)
- 7528db4 language_server: Pass file content as a referenced `String`
(#15568) (Sysix)
- 54061e9 linter/plugins: Avoid implicit boolean coercion in `initLines`
(#15641) (overlookmotel)
- ccfd935 language_server: Avoid `Mutex` in `ServerLinter` (#15516)
(Sysix)

### 📚 Documentation

- 3ab750a linter: Clarify react-in-jsx-scope rule docs. (#15749)
(connorshea)
- a5feebc linter: `oxlint-disable` not `eslint-disable` (#15672)
(overlookmotel)
- 3d15805 linter: Reformat doc comments (#15670) (overlookmotel)
- 16fcba6 linter: Remove "experimental" from description of stable
features (#15669) (overlookmotel)
- e62fd98 linter: Correct comment on what `EnablePlugins` does (#15668)
(overlookmotel)
- a25d31e linter: Fix grammar (#15666) (overlookmotel)
- f5f452f linter: Add missing `perf` category (#15667) (overlookmotel)
- 2c58952 linter: Add config docs for no-restricted-globals rule.
(#15662) (connorshea)
- a210b12 linter/plugins: Improve JSDoc comment for `RuleOptionsSchema`
(#15642) (overlookmotel)
- 3aabfac linter/plugins: Alter comments on `FILE_CONTEXT` used in
ESLint-compat `Context` shim (#15605) (overlookmotel)
- fd58aea linter: Fix a typo in the docs for react/no-is-mounted.
(#15575) (Connor Shea)
# Oxfmt
### 🚀 Features

- 84de1ca oxlint,oxfmt: Allow comments and also commas for
vscode-json-ls (#15612) (leaysgur)
- 99823ad oxfmt: Print nothing for default(write) mode (#15583)
(leaysgur)
- 25a0163 formatter/sort_imports: Sort imports by `Array<Array<string>>`
groups (#15578) (leaysgur)

### 🐛 Bug Fixes

- bf20cf5 formatter: `CRLF` issue in the member chain (#15764) (Dunqing)
- 5d688a0 formatter: Measuring multiline text in `fits_text` is
incorrect (#15762) (Dunqing)
- e306958 formatter: Regression case for test call (#15760) (Dunqing)
- c42d983 formatter: Re-fix all cases that fail after
`AstNode::Argument` was removed (#15676) (Dunqing)

### ⚡ Performance

- d99a83f oxfmt: Use simdutf8 based read_to_string (#15614) (leaysgur)
- 128e186 formatter/sort_imports: Precompute import metadata (#15580)
(leaysgur)
- cd31cc1 formatter/sort_imports: Use `Vec::with_capacity` for
`next_elements` (#15579) (leaysgur)

### 📚 Documentation

- 3d15805 linter: Reformat doc comments (#15670) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants