|
| 1 | +# Oxlint Migration Gaps |
| 2 | + |
| 3 | +This document tracks the ESLint rules that are not natively supported in Oxlint, or have different behavior. |
| 4 | + |
| 5 | +## Migration Summary |
| 6 | + |
| 7 | +| Metric | Value | |
| 8 | +| ----------------------- | ----------------------------------------- | |
| 9 | +| ESLint Version | 8.57.0 | |
| 10 | +| Oxlint Version | 1.43.0 | |
| 11 | +| Performance Improvement | ~330x faster (24ms vs ~8s for same files) | |
| 12 | +| Total Files Linted | 1953 | |
| 13 | +| Rules Active | 93+ | |
| 14 | + |
| 15 | +## Unsupported ESLint Plugins/Rules |
| 16 | + |
| 17 | +### @typescript-eslint Rules Not Supported |
| 18 | + |
| 19 | +| Rule | Status | Notes | |
| 20 | +| -------------------------------------------------- | ---------- | ------------------------------------------ | |
| 21 | +| `@typescript-eslint/no-inferrable-types` | Not needed | Was disabled in ESLint config | |
| 22 | +| `@typescript-eslint/typedef` | **Gap** | Enforces type annotations on variables | |
| 23 | +| `@typescript-eslint/member-ordering` | **Gap** | Class member ordering enforcement | |
| 24 | +| `@typescript-eslint/naming-convention` | **Gap** | Private/protected member underscore prefix | |
| 25 | +| `@typescript-eslint/unified-signatures` | **Gap** | Prevent unnecessary overloads | |
| 26 | +| `@typescript-eslint/explicit-member-accessibility` | **Gap** | public/private/protected keywords | |
| 27 | + |
| 28 | +### eslint-plugin-deprecation |
| 29 | + |
| 30 | +| Rule | Status | Notes | |
| 31 | +| ------------------------- | ------- | --------------------------------------------------- | |
| 32 | +| `deprecation/deprecation` | Partial | Use `typescript/no-deprecated` with type-aware mode | |
| 33 | + |
| 34 | +### eslint-plugin-import |
| 35 | + |
| 36 | +| Rule | Status | Notes | |
| 37 | +| ----------------------------------- | ------- | --------------------------------- | |
| 38 | +| `import/no-extraneous-dependencies` | **Gap** | Check for undeclared dependencies | |
| 39 | +| `import/first` | **Gap** | Imports should come first | |
| 40 | +| `import/newline-after-import` | **Gap** | Newline after import block | |
| 41 | + |
| 42 | +### eslint-plugin-simple-import-sort |
| 43 | + |
| 44 | +| Rule | Status | Notes | |
| 45 | +| ---------------------------- | ------- | -------------------------------------------------- | |
| 46 | +| `simple-import-sort/imports` | **Gap** | Import sorting - consider using Prettier or dprint | |
| 47 | + |
| 48 | +### eslint-plugin-jsdoc |
| 49 | + |
| 50 | +| Rule | Status | Notes | |
| 51 | +| --------------------- | ------- | ----------------------------- | |
| 52 | +| `jsdoc/require-jsdoc` | **Gap** | Require JSDoc for public APIs | |
| 53 | + |
| 54 | +### ESLint Core Rules |
| 55 | + |
| 56 | +| Rule | Status | Notes | |
| 57 | +| ----------------------- | ------- | ------------------------------------------- | |
| 58 | +| `max-lines` | **Gap** | File size limit (300 lines) | |
| 59 | +| `spaced-comment` | **Gap** | Whitespace in comments | |
| 60 | +| `no-restricted-globals` | **Gap** | Restrict window/document/location/navigator | |
| 61 | + |
| 62 | +## Custom Sentry Plugin Rules |
| 63 | + |
| 64 | +The `@sentry-internal/eslint-plugin-sdk` contains 6 custom rules. These can be loaded via Oxlint's JS plugins feature. |
| 65 | + |
| 66 | +| Rule | Status | Notes | |
| 67 | +| ----------------------------- | ----------- | ----------------------------------------------- | |
| 68 | +| `no-eq-empty` | **Gap** | Disallow `=== []` or `=== {}` | |
| 69 | +| `no-class-field-initializers` | **Gap** | Disallow class field initializers (bundle size) | |
| 70 | +| `no-regexp-constructor` | **Gap** | Warn about `new RegExp()` usage | |
| 71 | +| `no-unsafe-random-apis` | **Gap** | Disallow `Math.random()` etc | |
| 72 | +| `no-focused-tests` | **Covered** | Use `jest/no-focused-tests` | |
| 73 | +| `no-skipped-tests` | **Covered** | Use `jest/no-disabled-tests` | |
| 74 | + |
| 75 | +## Type-Aware Linting |
| 76 | + |
| 77 | +Type-aware rules require the `--type-aware` flag and `oxlint-tsgolint` package: |
| 78 | + |
| 79 | +```bash |
| 80 | +# Install type-aware package |
| 81 | +yarn add -D oxlint-tsgolint |
| 82 | + |
| 83 | +# Run with type-aware rules |
| 84 | +yarn lint:oxlint:type-aware |
| 85 | +``` |
| 86 | + |
| 87 | +Type-aware mode enables additional checks like: |
| 88 | + |
| 89 | +- `typescript/no-floating-promises` (enhanced) |
| 90 | +- `typescript/no-unsafe-member-access` (enhanced) |
| 91 | +- `typescript/unbound-method` (enhanced) |
| 92 | +- `typescript/no-deprecated` |
| 93 | +- `typescript/no-base-to-string` |
| 94 | +- `typescript/restrict-template-expressions` |
| 95 | + |
| 96 | +**Note**: Type-aware linting requires TypeScript 7+ and may need tsconfig adjustments. |
| 97 | + |
| 98 | +## Current Errors Found by Oxlint |
| 99 | + |
| 100 | +As of migration, Oxlint identifies the following issues that ESLint may not have caught: |
| 101 | + |
| 102 | +### Complexity Issues (21 functions) |
| 103 | + |
| 104 | +Functions exceeding cyclomatic complexity of 20: |
| 105 | + |
| 106 | +- `getNotificationAttributes` (31) |
| 107 | +- `constructor` in replay integration (32) |
| 108 | +- `xhrCallback` (27) |
| 109 | +- `_INTERNAL_captureLog` (28) |
| 110 | +- And others... |
| 111 | + |
| 112 | +### Unused Variables |
| 113 | + |
| 114 | +- Unused catch parameters not prefixed with `_` |
| 115 | +- Unused function declarations |
| 116 | + |
| 117 | +### Code Quality |
| 118 | + |
| 119 | +- Bitwise operations (intentionally used in replay packages) |
| 120 | +- Missing return types on some callback functions |
| 121 | + |
| 122 | +## Recommendations |
| 123 | + |
| 124 | +1. **JS Plugins**: Load the custom Sentry plugin via `jsPlugins` config option |
| 125 | +2. **Prettier Integration**: Use Prettier for import sorting since `simple-import-sort` is not supported |
| 126 | +3. **Type-Aware**: Enable type-aware linting in CI for enhanced TypeScript checks |
| 127 | +4. **Fix Incrementally**: Address the 71+ errors found by Oxlint over time |
| 128 | + |
| 129 | +## Performance Comparison |
| 130 | + |
| 131 | +``` |
| 132 | +ESLint (packages/core + packages/browser): |
| 133 | + Time: ~8 seconds |
| 134 | +
|
| 135 | +Oxlint (same files): |
| 136 | + Time: 24ms |
| 137 | + Speedup: ~330x |
| 138 | +``` |
| 139 | + |
| 140 | +## References |
| 141 | + |
| 142 | +- [Oxlint Documentation](https://oxc.rs/docs/guide/usage/linter/) |
| 143 | +- [Migrate from ESLint](https://oxc.rs/docs/guide/usage/linter/migrate-from-eslint.html) |
| 144 | +- [Type-Aware Linting](https://oxc.rs/docs/guide/usage/linter/type-aware.html) |
| 145 | +- [JS Plugins](https://oxc.rs/docs/guide/usage/linter/js-plugins.html) |
0 commit comments