Skip to content

Commit 09657ad

Browse files
connorsheaSysix
andauthored
feat: Migrate the settings field from ESLint configs (#361)
* Add basic support for migrating settings field for oxlint plugins. * Add an integration test for the settings migration. * Add special logic for handling the react.version field, as `detect` is commonly used and we should make sure not to output an invalid oxlint config. * Resolve feedback, remove runtime value from types.ts. * Resolve feedback, simplify code for skipping unsupported settings keys. * Update the nextjs config snapshot. * Simplify deepMerge. * Simplify the assignment logic further. * Use type-only imports. * Update the settings migration to include settings for JS Plugins. When the `--js-plugins` option is passed, we should migrate all settings (other than import-related settings, as they are not supported by the native plugin). * Update readme. * Drop a few unsupported settings keys. And genericize the code a bit so we can easily add more in the future. --------- Co-authored-by: Alexander S. <sysix@sysix-coding.de>
1 parent f070ec4 commit 09657ad

12 files changed

+1151
-10
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ The migration tool has been tested to work quite well for simple ESLint flat con
6363

6464
Here are some known caveats to be aware of:
6565

66-
**`settings` field not migrated**
66+
**`settings` field migration**
6767

68-
The `settings` field (e.g. for setting the React version) is not migrated to the oxlint config yet. You may need to copy it over manually if you have any settings specified.
68+
The `settings` field (e.g. for setting the React version) is migrated for known oxlint-supported plugins: `jsx-a11y`, `next`, `react`, `jsdoc`, and `vitest`. By default, other settings keys are skipped since they aren't supported by oxlint. If using the `--js-plugins` flag, other settings keys will also be migrated in order to support JS Plugins.
69+
70+
Note: Oxlint does not support `settings` in override configs. If your ESLint config has settings in configs with `files` patterns, those settings will be skipped and a warning will be shown.
6971

7072
Not all `settings` options are supported by oxlint, and so rule behavior in certain edge-cases may differ. See [the Settings docs](https://oxc.rs/docs/guide/usage/linter/config-file-reference.html#settings) for more info.
7173

integration_test/__snapshots__/many-extends.spec.ts.snap

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,11 @@ exports[`many-extends.spec.ts > many-extends.spec.ts 1`] = `
335335
"react/function-component-definition",
336336
],
337337
},
338-
"warnings": [],
338+
"warnings": [
339+
"Settings not migrated (not supported by oxlint): import/extensions.",
340+
"Settings found in config with 'files' pattern (import/extensions). Oxlint does not support settings in overrides, these settings will be skipped.",
341+
"Settings found in config with 'files' pattern (import/extensions, import/external-module-folders, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
342+
],
339343
}
340344
`;
341345

@@ -674,7 +678,11 @@ exports[`many-extends.spec.ts --js-plugins > many-extends.spec.ts--js-plugins 1`
674678
"react/function-component-definition",
675679
],
676680
},
677-
"warnings": [],
681+
"warnings": [
682+
"Settings not migrated (not supported by oxlint): import/extensions.",
683+
"Settings found in config with 'files' pattern (import/extensions). Oxlint does not support settings in overrides, these settings will be skipped.",
684+
"Settings found in config with 'files' pattern (import/extensions, import/external-module-folders, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
685+
],
678686
}
679687
`;
680688

@@ -1034,7 +1042,11 @@ exports[`many-extends.spec.ts --type-aware > many-extends.spec.ts--type-aware 1`
10341042
"react/function-component-definition",
10351043
],
10361044
},
1037-
"warnings": [],
1045+
"warnings": [
1046+
"Settings not migrated (not supported by oxlint): import/extensions.",
1047+
"Settings found in config with 'files' pattern (import/extensions). Oxlint does not support settings in overrides, these settings will be skipped.",
1048+
"Settings found in config with 'files' pattern (import/extensions, import/external-module-folders, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
1049+
],
10381050
}
10391051
`;
10401052

@@ -1328,6 +1340,10 @@ exports[`many-extends.spec.ts merge > many-extends.spec.ts--merge 1`] = `
13281340
"react/function-component-definition",
13291341
],
13301342
},
1331-
"warnings": [],
1343+
"warnings": [
1344+
"Settings not migrated (not supported by oxlint): import/extensions.",
1345+
"Settings found in config with 'files' pattern (import/extensions). Oxlint does not support settings in overrides, these settings will be skipped.",
1346+
"Settings found in config with 'files' pattern (import/extensions, import/external-module-folders, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
1347+
],
13321348
}
13331349
`;

integration_test/__snapshots__/next-core-web-vitals.spec.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ exports[`next-core-web-vitals > next-core-web-vitals 1`] = `
137137
},
138138
"warnings": [
139139
"special parser detected: eslint-config-next/parser",
140+
"Settings found in config with 'files' pattern (react, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
140141
],
141142
}
142143
`;
@@ -278,6 +279,7 @@ exports[`next-core-web-vitals --js-plugins > next-core-web-vitals--js-plugins 1`
278279
},
279280
"warnings": [
280281
"special parser detected: eslint-config-next/parser",
282+
"Settings found in config with 'files' pattern (react, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
281283
],
282284
}
283285
`;
@@ -419,6 +421,7 @@ exports[`next-core-web-vitals --type-aware > next-core-web-vitals--type-aware 1`
419421
},
420422
"warnings": [
421423
"special parser detected: eslint-config-next/parser",
424+
"Settings found in config with 'files' pattern (react, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
422425
],
423426
}
424427
`;
@@ -559,6 +562,7 @@ exports[`next-core-web-vitals merge > next-core-web-vitals--merge 1`] = `
559562
},
560563
"warnings": [
561564
"special parser detected: eslint-config-next/parser",
565+
"Settings found in config with 'files' pattern (react, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
562566
],
563567
}
564568
`;

integration_test/__snapshots__/next-eslint-config-project.spec.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ exports[`next-eslint-config-project > next-eslint-config-project 1`] = `
133133
},
134134
"warnings": [
135135
"special parser detected: eslint-config-next/parser",
136+
"Settings found in config with 'files' pattern (react, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
136137
],
137138
}
138139
`;
@@ -270,6 +271,7 @@ exports[`next-eslint-config-project --js-plugins > next-eslint-config-project--j
270271
},
271272
"warnings": [
272273
"special parser detected: eslint-config-next/parser",
274+
"Settings found in config with 'files' pattern (react, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
273275
],
274276
}
275277
`;
@@ -407,6 +409,7 @@ exports[`next-eslint-config-project --type-aware > next-eslint-config-project--t
407409
},
408410
"warnings": [
409411
"special parser detected: eslint-config-next/parser",
412+
"Settings found in config with 'files' pattern (react, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
410413
],
411414
}
412415
`;
@@ -545,6 +548,7 @@ exports[`next-eslint-config-project merge > next-eslint-config-project--merge 1`
545548
},
546549
"warnings": [
547550
"special parser detected: eslint-config-next/parser",
551+
"Settings found in config with 'files' pattern (react, import/parsers, import/resolver). Oxlint does not support settings in overrides, these settings will be skipped.",
548552
],
549553
}
550554
`;

integration_test/__snapshots__/pupeeteer.spec.ts.snap

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,10 @@ exports[`puppeteer > puppeteer 1`] = `
283283
"@typescript-eslint/consistent-type-exports",
284284
],
285285
},
286-
"warnings": [],
286+
"warnings": [
287+
"Settings not migrated (not supported by oxlint): import/extensions, import/external-module-folders, import/parsers, import/resolver.",
288+
"Settings not migrated (not supported by oxlint): import/resolver.",
289+
],
287290
}
288291
`;
289292

@@ -600,7 +603,10 @@ exports[`puppeteer --js-plugins > puppeteer--js-plugins 1`] = `
600603
"@typescript-eslint/consistent-type-exports",
601604
],
602605
},
603-
"warnings": [],
606+
"warnings": [
607+
"Settings not migrated (not supported by oxlint): import/extensions, import/external-module-folders, import/parsers, import/resolver.",
608+
"Settings not migrated (not supported by oxlint): import/resolver.",
609+
],
604610
}
605611
`;
606612

@@ -907,7 +913,10 @@ exports[`puppeteer --type-aware > puppeteer--type-aware 1`] = `
907913
"@typescript-eslint/consistent-type-exports",
908914
],
909915
},
910-
"warnings": [],
916+
"warnings": [
917+
"Settings not migrated (not supported by oxlint): import/extensions, import/external-module-folders, import/parsers, import/resolver.",
918+
"Settings not migrated (not supported by oxlint): import/resolver.",
919+
],
911920
}
912921
`;
913922

@@ -1176,6 +1185,9 @@ exports[`puppeteer merge > puppeteer--merge 1`] = `
11761185
"@typescript-eslint/consistent-type-exports",
11771186
],
11781187
},
1179-
"warnings": [],
1188+
"warnings": [
1189+
"Settings not migrated (not supported by oxlint): import/extensions, import/external-module-folders, import/parsers, import/resolver.",
1190+
"Settings not migrated (not supported by oxlint): import/resolver.",
1191+
],
11801192
}
11811193
`;

0 commit comments

Comments
 (0)