Skip to content

Commit cc8dd48

Browse files
baevmshulaoda
andauthored
feat(linter): add unicorn/no-invalid-fetch-options rule (#9212)
This PR implements [unicorn/no-invalid-fetch-options](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v56.0.1/docs/rules/no-invalid-fetch-options.md) rule issue: #684 --------- Co-authored-by: shulaoda <laipichan@qq.com>
1 parent d2ab0fe commit cc8dd48

File tree

38 files changed

+352
-37
lines changed

38 files changed

+352
-37
lines changed

apps/oxlint/src/snapshots/_--ignore-path fixtures__linter__.customignore --no-ignore fixtures__linter__nan.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ working directory:
1414
help: Use the isNaN function to compare with NaN.
1515
1616
Found 1 warning and 0 errors.
17-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
17+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1818
----------
1919
CLI result: LintSucceeded
2020
----------

apps/oxlint/src/snapshots/_--ignore-pattern _____.js --ignore-pattern _____.vue fixtures__linter@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ arguments: --ignore-pattern **/*.js --ignore-pattern **/*.vue fixtures/linter
66
working directory:
77
----------
88
Found 0 warnings and 0 errors.
9-
Finished in <variable>ms on 0 files with 98 rules using 1 threads.
9+
Finished in <variable>ms on 0 files with 99 rules using 1 threads.
1010
----------
1111
CLI result: LintSucceeded
1212
----------

apps/oxlint/src/snapshots/_--import-plugin -A all -D no-cycle fixtures__flow__@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ arguments: --import-plugin -A all -D no-cycle fixtures/flow/
66
working directory:
77
----------
88
Found 0 warnings and 0 errors.
9-
Finished in <variable>ms on 2 files with 100 rules using 1 threads.
9+
Finished in <variable>ms on 2 files with 101 rules using 1 threads.
1010
----------
1111
CLI result: LintSucceeded
1212
----------

apps/oxlint/src/snapshots/_--import-plugin fixtures__flow__index.mjs@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ arguments: --import-plugin fixtures/flow/index.mjs
66
working directory:
77
----------
88
Found 0 warnings and 0 errors.
9-
Finished in <variable>ms on 1 file with 100 rules using 1 threads.
9+
Finished in <variable>ms on 1 file with 101 rules using 1 threads.
1010
----------
1111
CLI result: LintSucceeded
1212
----------

apps/oxlint/src/snapshots/_--vitest-plugin -c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ working directory:
2323
help: Remove the appending `.skip`
2424
2525
Found 1 warning and 1 error.
26-
Finished in <variable>ms on 1 file with 110 rules using 1 threads.
26+
Finished in <variable>ms on 1 file with 111 rules using 1 threads.
2727
----------
2828
CLI result: LintFoundErrors
2929
----------

apps/oxlint/src/snapshots/_-D correctness fixtures__linter__debugger.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ working directory:
1414
help: Delete this code.
1515
1616
Found 0 warnings and 1 error.
17-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
17+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1818
----------
1919
CLI result: LintFoundErrors
2020
----------

apps/oxlint/src/snapshots/_-W correctness -A no-debugger fixtures__linter__debugger.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ arguments: -W correctness -A no-debugger fixtures/linter/debugger.js
66
working directory:
77
----------
88
Found 0 warnings and 0 errors.
9-
Finished in <variable>ms on 1 file with 97 rules using 1 threads.
9+
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
1010
----------
1111
CLI result: LintSucceeded
1212
----------

apps/oxlint/src/snapshots/_-W no-undef -c fixtures__eslintrc_env__eslintrc_no_env.json fixtures__eslintrc_env__test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ working directory:
1313
`----
1414
1515
Found 1 warning and 0 errors.
16-
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
16+
Finished in <variable>ms on 1 file with 100 rules using 1 threads.
1717
----------
1818
CLI result: LintSucceeded
1919
----------

apps/oxlint/src/snapshots/_-W no-undef -c fixtures__no_undef__eslintrc.json fixtures__no_undef__test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ working directory:
1313
`----
1414
1515
Found 1 warning and 0 errors.
16-
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
16+
Finished in <variable>ms on 1 file with 100 rules using 1 threads.
1717
----------
1818
CLI result: LintSucceeded
1919
----------

apps/oxlint/src/snapshots/_-c fixtures__config_ignore_patterns__ignore_extension__eslintrc.json fixtures__config_ignore_patterns__ignore_extension@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ working directory:
1212
help: Delete this file or add some code to it.
1313
1414
Found 1 warning and 0 errors.
15-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
15+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1616
----------
1717
CLI result: LintSucceeded
1818
----------

apps/oxlint/src/snapshots/_-c fixtures__eslintrc_env__eslintrc_env_browser.json fixtures__eslintrc_env__test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ arguments: -c fixtures/eslintrc_env/eslintrc_env_browser.json fixtures/eslintrc_
66
working directory:
77
----------
88
Found 0 warnings and 0 errors.
9-
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
9+
Finished in <variable>ms on 1 file with 100 rules using 1 threads.
1010
----------
1111
CLI result: LintSucceeded
1212
----------

apps/oxlint/src/snapshots/_-c fixtures__eslintrc_off__eslintrc.json fixtures__eslintrc_off__test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ working directory:
1212
help: Delete this file or add some code to it.
1313
1414
Found 1 warning and 0 errors.
15-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
15+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1616
----------
1717
CLI result: LintSucceeded
1818
----------

apps/oxlint/src/snapshots/_-c fixtures__eslintrc_vitest_replace__eslintrc.json fixtures__eslintrc_vitest_replace__foo.test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ arguments: -c fixtures/eslintrc_vitest_replace/eslintrc.json fixtures/eslintrc_v
66
working directory:
77
----------
88
Found 0 warnings and 0 errors.
9-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
9+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1010
----------
1111
CLI result: LintSucceeded
1212
----------

apps/oxlint/src/snapshots/_-c fixtures__linter__eslintrc.json fixtures__linter__debugger.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ working directory:
1414
help: Delete this code.
1515
1616
Found 0 warnings and 1 error.
17-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
17+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1818
----------
1919
CLI result: LintFoundErrors
2020
----------

apps/oxlint/src/snapshots/_-c fixtures__no_console_off__eslintrc.json fixtures__no_console_off__test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ arguments: -c fixtures/no_console_off/eslintrc.json fixtures/no_console_off/test
66
working directory:
77
----------
88
Found 0 warnings and 0 errors.
9-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
9+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1010
----------
1111
CLI result: LintSucceeded
1212
----------

apps/oxlint/src/snapshots/_-c fixtures__no_empty_allow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_allow_empty_catch__test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ arguments: -c fixtures/no_empty_allow_empty_catch/eslintrc.json -W no-empty fixt
66
working directory:
77
----------
88
Found 0 warnings and 0 errors.
9-
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
9+
Finished in <variable>ms on 1 file with 100 rules using 1 threads.
1010
----------
1111
CLI result: LintSucceeded
1212
----------

apps/oxlint/src/snapshots/_-c fixtures__no_empty_disallow_empty_catch__eslintrc.json -W no-empty fixtures__no_empty_disallow_empty_catch__test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ working directory:
1414
help: Remove this block or add a comment inside it
1515
1616
Found 1 warning and 0 errors.
17-
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
17+
Finished in <variable>ms on 1 file with 100 rules using 1 threads.
1818
----------
1919
CLI result: LintSucceeded
2020
----------

apps/oxlint/src/snapshots/_-c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.js -c fixtures__overrides__.oxlintrc.json fixtures__overrides__test.ts -c fixtures__overrides__.oxlintrc.json fixtures__overrides__other.jsx@oxlint.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ working directory:
1515
help: Replace var with let or const
1616
1717
Found 0 warnings and 1 error.
18-
Finished in <variable>ms on 1 file with 100 rules using 1 threads.
18+
Finished in <variable>ms on 1 file with 101 rules using 1 threads.
1919
----------
2020
CLI result: LintFoundErrors
2121
----------
@@ -42,7 +42,7 @@ working directory:
4242
help: Delete this console statement.
4343
4444
Found 1 warning and 1 error.
45-
Finished in <variable>ms on 1 file with 100 rules using 1 threads.
45+
Finished in <variable>ms on 1 file with 101 rules using 1 threads.
4646
----------
4747
CLI result: LintFoundErrors
4848
----------
@@ -61,7 +61,7 @@ working directory:
6161
help: Replace var with let or const
6262
6363
Found 0 warnings and 1 error.
64-
Finished in <variable>ms on 1 file with 100 rules using 1 threads.
64+
Finished in <variable>ms on 1 file with 101 rules using 1 threads.
6565
----------
6666
CLI result: LintFoundErrors
6767
----------

apps/oxlint/src/snapshots/_-c fixtures__overrides__directories-config.json fixtures__overrides@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ working directory:
3535
help: Delete this code.
3636

3737
Found 2 warnings and 2 errors.
38-
Finished in <variable>ms on 7 files with 97 rules using 1 threads.
38+
Finished in <variable>ms on 7 files with 98 rules using 1 threads.
3939
----------
4040
CLI result: LintFoundErrors
4141
----------

apps/oxlint/src/snapshots/_fixtures__astro__debugger.astro@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ working directory:
3939
help: Delete this code.
4040

4141
Found 4 warnings and 0 errors.
42-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
42+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
4343
----------
4444
CLI result: LintSucceeded
4545
----------

apps/oxlint/src/snapshots/_fixtures__linter@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ working directory:
2828
help: Use the isNaN function to compare with NaN.
2929
3030
Found 3 warnings and 0 errors.
31-
Finished in <variable>ms on 3 files with 98 rules using 1 threads.
31+
Finished in <variable>ms on 3 files with 99 rules using 1 threads.
3232
----------
3333
CLI result: LintSucceeded
3434
----------

apps/oxlint/src/snapshots/_fixtures__linter__debugger.js fixtures__linter__nan.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ working directory:
2121
help: Use the isNaN function to compare with NaN.
2222

2323
Found 2 warnings and 0 errors.
24-
Finished in <variable>ms on 2 files with 98 rules using 1 threads.
24+
Finished in <variable>ms on 2 files with 99 rules using 1 threads.
2525
----------
2626
CLI result: LintSucceeded
2727
----------

apps/oxlint/src/snapshots/_fixtures__linter__debugger.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ working directory:
1414
help: Delete this code.
1515
1616
Found 1 warning and 0 errors.
17-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
17+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1818
----------
1919
CLI result: LintSucceeded
2020
----------

apps/oxlint/src/snapshots/_fixtures__svelte__debugger.svelte@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ working directory:
1616
help: Delete this code.
1717
1818
Found 1 warning and 0 errors.
19-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
19+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
2020
----------
2121
CLI result: LintSucceeded
2222
----------

apps/oxlint/src/snapshots/_fixtures__vue__debugger.vue@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ working directory:
2323
help: Delete this code.
2424

2525
Found 2 warnings and 0 errors.
26-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
26+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
2727
----------
2828
CLI result: LintSucceeded
2929
----------

apps/oxlint/src/snapshots/_fixtures__vue__empty.vue@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ arguments: fixtures/vue/empty.vue
66
working directory:
77
----------
88
Found 0 warnings and 0 errors.
9-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
9+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1010
----------
1111
CLI result: LintSucceeded
1212
----------

apps/oxlint/src/snapshots/_foo.asdf@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ arguments: foo.asdf
66
working directory:
77
----------
88
Found 0 warnings and 0 errors.
9-
Finished in <variable>ms on 0 files with 98 rules using 1 threads.
9+
Finished in <variable>ms on 0 files with 99 rules using 1 threads.
1010
----------
1111
CLI result: LintSucceeded
1212
----------

apps/oxlint/src/snapshots/fixtures__auto_config_detection_debugger.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ working directory: fixtures/auto_config_detection
1414
help: Delete this code.
1515
1616
Found 0 warnings and 1 error.
17-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
17+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1818
----------
1919
CLI result: LintFoundErrors
2020
----------

apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__ignore_directory_-c eslintrc.json@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ working directory: fixtures/config_ignore_patterns/ignore_directory
1414
help: Delete this file or add some code to it.
1515
1616
Found 1 warning and 0 errors.
17-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
17+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1818
----------
1919
CLI result: LintSucceeded
2020
----------

apps/oxlint/src/snapshots/fixtures__config_ignore_patterns__with_oxlintrc_-c .__test__eslintrc.json --ignore-pattern _.ts .@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ working directory: fixtures/config_ignore_patterns/with_oxlintrc
1212
help: Delete this file or add some code to it.
1313
1414
Found 1 warning and 0 errors.
15-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
15+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1616
----------
1717
CLI result: LintSucceeded
1818
----------

apps/oxlint/src/snapshots/fixtures__disable_eslint_and_unicorn_alias_rules_-c .oxlintrc-eslint.json test.js -c .oxlintrc-unicorn.json test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ arguments: -c .oxlintrc-unicorn.json test.js
1616
working directory: fixtures/disable_eslint_and_unicorn_alias_rules
1717
----------
1818
Found 0 warnings and 0 errors.
19-
Finished in <variable>ms on 1 file with 62 rules using 1 threads.
19+
Finished in <variable>ms on 1 file with 63 rules using 1 threads.
2020
----------
2121
CLI result: LintSucceeded
2222
----------

apps/oxlint/src/snapshots/fixtures__linter_debugger.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ working directory: fixtures/linter
1414
help: Delete this code.
1515
1616
Found 1 warning and 0 errors.
17-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
17+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
1818
----------
1919
CLI result: LintSucceeded
2020
----------

apps/oxlint/src/snapshots/fixtures__output_formatter_diagnostic_--format=default test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ working directory: fixtures/output_formatter_diagnostic
3333
help: Delete this code.
3434
3535
Found 2 warnings and 1 error.
36-
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
36+
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
3737
----------
3838
CLI result: LintFoundErrors
3939
----------

apps/oxlint/src/snapshots/fixtures__overrides_env_globals_-c .oxlintrc.json .@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ working directory: fixtures/overrides_env_globals
5151
`----
5252

5353
Found 5 warnings and 0 errors.
54-
Finished in <variable>ms on 3 files with 98 rules using 1 threads.
54+
Finished in <variable>ms on 3 files with 99 rules using 1 threads.
5555
----------
5656
CLI result: LintSucceeded
5757
----------

apps/oxlint/src/snapshots/fixtures__two_rules_with_same_rule_name_-c .oxlintrc.json test.js@oxlint.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ arguments: -c .oxlintrc.json test.js
66
working directory: fixtures/two_rules_with_same_rule_name
77
----------
88
Found 0 warnings and 0 errors.
9-
Finished in <variable>ms on 1 file with 62 rules using 1 threads.
9+
Finished in <variable>ms on 1 file with 63 rules using 1 threads.
1010
----------
1111
CLI result: LintSucceeded
1212
----------

crates/oxc_linter/src/rules.rs

+2
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ mod unicorn {
332332
pub mod no_empty_file;
333333
pub mod no_hex_escape;
334334
pub mod no_instanceof_array;
335+
pub mod no_invalid_fetch_options;
335336
pub mod no_invalid_remove_event_listener;
336337
pub mod no_length_as_slice_end;
337338
pub mod no_lonely_if;
@@ -936,6 +937,7 @@ oxc_macros::declare_all_lint_rules! {
936937
unicorn::explicit_length_check,
937938
unicorn::filename_case,
938939
unicorn::new_for_builtins,
940+
unicorn::no_invalid_fetch_options,
939941
unicorn::no_abusive_eslint_disable,
940942
unicorn::no_anonymous_default_export,
941943
unicorn::no_array_for_each,

0 commit comments

Comments
 (0)