|
| 1 | +--- |
| 2 | +title: Oxlint v0.10 Migration Guide |
| 3 | +outline: deep |
| 4 | +authors: |
| 5 | + - don |
| 6 | +editLink: false |
| 7 | +--- |
| 8 | + |
| 9 | +<AppBlogPostHeader /> |
| 10 | + |
| 11 | +Oxlint v0.10.0 is here! This release includes several exciting features, |
| 12 | +including many improvements to configuration files. |
| 13 | + |
| 14 | +## New Features |
| 15 | + |
| 16 | +<!-- todo: other features --> |
| 17 | +### New Rules |
| 18 | + |
| 19 | +This release includes the following new rules: |
| 20 | +- `promise/no-callback-in-promise` |
| 21 | +- `react/iframe-missing-sandbox` |
| 22 | +- `node/no-new-require` |
| 23 | + |
| 24 | +And adds auto fixes/suggestions for: |
| 25 | +- `eslint/no-plusplus` |
| 26 | + |
| 27 | +### Enable/Disable Rules by Category |
| 28 | + |
| 29 | +You can now enable or disable entire categories of rules with the `categories` |
| 30 | +field inside of your configuration file. |
| 31 | + |
| 32 | +Now, instead of running this command: |
| 33 | + |
| 34 | +```sh |
| 35 | +oxlint -D correctness -W suspicious -c oxlint.json |
| 36 | +``` |
| 37 | + |
| 38 | +You can add a `categories` field to your `oxlint.json`: |
| 39 | + |
| 40 | +::: code-group |
| 41 | + |
| 42 | +```jsonc [oxlintrc.json] |
| 43 | +{ |
| 44 | + "categories": { // [!code ++] |
| 45 | + "correctness": "deny", // [!code ++] |
| 46 | + "suspicious": "warn", // [!code ++] |
| 47 | + }, // [!code ++] |
| 48 | + "rules": { |
| 49 | + "no-const-assign": "error", |
| 50 | + "import/no-cycle": "error", |
| 51 | + }, |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +::: |
| 56 | + |
| 57 | +and drop the `-D` and `-W` flags. |
| 58 | + |
| 59 | +### `plugins` Are Now Supported in Configuration Files |
| 60 | + |
| 61 | +Configuration files now support the `plugins` array from ESLint v8 configs. |
| 62 | +This allows you to enable plugins without CLI arguments, making it possible to |
| 63 | +use plugins in VSCode. |
| 64 | + |
| 65 | +::: code-group |
| 66 | + |
| 67 | +```jsonc [oxlintrc.json] |
| 68 | +{ |
| 69 | + "plugins": ["import"], // [!code ++] |
| 70 | + "categories": { |
| 71 | + "correctness": "deny", |
| 72 | + "suspicious": "warn", |
| 73 | + }, |
| 74 | + "rules": { |
| 75 | + "react/jsx-uses-react": "off", |
| 76 | + "react/react-in-jsx-scope": "off", |
| 77 | + }, |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +::: |
| 82 | + |
| 83 | +This plays nicely with `categories`, as enabled/disabled categories affect plugins as well. |
| 84 | + |
| 85 | +::: code-group |
| 86 | + |
| 87 | +```jsonc [oxlintrc.json] |
| 88 | +{ |
| 89 | + "plugins": ["import"], |
| 90 | + // `categories` affects all enabled plugins |
| 91 | + "categories": { |
| 92 | + "correctness": "allow", |
| 93 | + "suspicious": "warn", |
| 94 | + }, |
| 95 | + "rules": { |
| 96 | + "no-const-assign": "error", |
| 97 | + "import/no-cycle": "error", |
| 98 | + }, |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +::: |
| 103 | + |
| 104 | +## Breaking Changes and Migration Guide |
| 105 | + |
| 106 | +### CLI vs Config File Rule Priority |
| 107 | + |
| 108 | +Before, config files would override rules set in CLI arguments. For example, running this command: |
| 109 | + |
| 110 | +```sh |
| 111 | +oxlint -A correctness -c oxlintrc.json |
| 112 | +``` |
| 113 | + |
| 114 | +With this config file |
| 115 | + |
| 116 | +::: code-group |
| 117 | + |
| 118 | +```jsonc [oxlintrc.json] |
| 119 | +{ |
| 120 | + "rules": { |
| 121 | + "no-const-assign": "error", |
| 122 | + }, |
| 123 | +} |
| 124 | +``` |
| 125 | + |
| 126 | +::: |
| 127 | + |
| 128 | +Would result in a single rule, `no-const-assign` being turned on at an error level with all other rules disabled (i.e. set to "allow"). |
| 129 | + |
| 130 | +Now, **CLI arguments will override config files**. That same command with the |
| 131 | +same config file will result with **all rules being disabled**. To get the same |
| 132 | +behavior as before, enable and disable categories in your config file instead of |
| 133 | +with CLI arguments. |
| 134 | + |
| 135 | +```sh |
| 136 | +oxlint -c oxlint.json |
| 137 | +``` |
| 138 | + |
| 139 | +::: code-group |
| 140 | + |
| 141 | +```jsonc [oxlintrc.json] |
| 142 | +{ |
| 143 | + "categories": { // [!code ++] |
| 144 | + "correctness": "allow", // [!code ++] |
| 145 | + }, // [!code ++] |
| 146 | + "rules": { |
| 147 | + "no-const-assign": "error", |
| 148 | + }, |
| 149 | +} |
| 150 | +``` |
| 151 | + |
| 152 | +::: |
0 commit comments