Dataset Viewer
Auto-converted to Parquet Duplicate
instance_id
string
repo
string
pull_number
int64
issue_numbers
list
base_commit
string
patch
string
test_patch
string
problem_statement
string
hints_text
string
created_at
string
version
string
updated_at
string
environment_setup_commit
string
FAIL_TO_PASS
list
PASS_TO_PASS
list
FAIL_TO_FAIL
list
PASS_TO_FAIL
list
source_dir
null
sharkdp__bat-1440
sharkdp/bat
1,440
[ "1438", "1438" ]
60e00d49a99f33eb90397c6932c770d82fd481ec
diff --git a/src/preprocessor.rs b/src/preprocessor.rs --- a/src/preprocessor.rs +++ b/src/preprocessor.rs @@ -72,7 +72,7 @@ pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String { } } // line feed - '\x0A' => output.push('␊'), + '\x0A' => output.push_str("␊\x0A"), // carriage return '\x0D' => output.push('␍'), // null diff --git a/src/printer.rs b/src/printer.rs --- a/src/printer.rs +++ b/src/printer.rs @@ -91,9 +91,6 @@ impl<'a> Printer for SimplePrinter<'a> { if self.config.show_nonprintable { let line = replace_nonprintable(line_buffer, self.config.tab_width); write!(handle, "{}", line)?; - if line_buffer.last() == Some(&b'\n') { - writeln!(handle)?; - } } else { handle.write_all(line_buffer)? }; diff --git a/src/printer.rs b/src/printer.rs --- a/src/printer.rs +++ b/src/printer.rs @@ -463,7 +460,7 @@ impl<'a> Printer for InteractivePrinter<'a> { } } - if line.bytes().next_back() != Some(b'\n') { + if !self.config.style_components.plain() && line.bytes().next_back() != Some(b'\n') { writeln!(handle)?; } } else {
diff --git a/CHANGELOG.md b/CHANGELOG.md --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ ## Bugfixes -- only print themes hint in interactive mode (`bat --list-themes`), see #1439 (@rsteube) +- If the last line doesn't end with a newline character, don't add it if `--style=plain`, see #1438 (@Enselic) +- Only print themes hint in interactive mode (`bat --list-themes`), see #1439 (@rsteube) - Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic) ## Other diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -813,3 +813,17 @@ fn show_all_mode() { .stdout("hello·world␊\n├──┤␍␀␇␈␛") .stderr(""); } + +#[test] +fn plain_mode_does_not_add_nonexisting_newline() { + bat() + .arg("--paging=never") + .arg("--color=never") + .arg("--decorations=always") + .arg("--style=plain") + .arg("single-line.txt") + .assert() + .success() + .stdout("Single Line"); +} + diff --git a/tests/syntax-tests/highlighted/Plaintext/plaintext.txt b/tests/syntax-tests/highlighted/Plaintext/plaintext.txt --- a/tests/syntax-tests/highlighted/Plaintext/plaintext.txt +++ b/tests/syntax-tests/highlighted/Plaintext/plaintext.txt @@ -175,4 +175,4 @@ \u{ad}␊ \u{ae}␊ ␊ -Here's·a·line·with·multiple·characters. +Here's·a·line·with·multiple·characters.␊ diff --git a/tests/syntax-tests/source/ActionScript/test.as b/tests/syntax-tests/source/ActionScript/test.as --- a/tests/syntax-tests/source/ActionScript/test.as +++ b/tests/syntax-tests/source/ActionScript/test.as @@ -72,4 +72,4 @@ package TestSyntax { var sndChannel:SoundChannel = mySound.play(); } } -} \ No newline at end of file +} diff --git a/tests/syntax-tests/source/Batch/build.bat b/tests/syntax-tests/source/Batch/build.bat --- a/tests/syntax-tests/source/Batch/build.bat +++ b/tests/syntax-tests/source/Batch/build.bat @@ -56,4 +56,4 @@ set LDLIBS= ^ @set "LINK_FILES=%LINK_FILES% %%~f" ) -lld-link.exe %LINK_FILES% -out:"%OUTPUT%" %LDFLAGS% %LDLIBS% \ No newline at end of file +lld-link.exe %LINK_FILES% -out:"%OUTPUT%" %LDFLAGS% %LDLIBS% diff --git a/tests/syntax-tests/source/Clojure/test.clj b/tests/syntax-tests/source/Clojure/test.clj --- a/tests/syntax-tests/source/Clojure/test.clj +++ b/tests/syntax-tests/source/Clojure/test.clj @@ -55,4 +55,4 @@ (println (factorial 5)) (log) (log "Message")) - \ No newline at end of file + diff --git a/tests/syntax-tests/source/Dockerfile/Dockerfile b/tests/syntax-tests/source/Dockerfile/Dockerfile --- a/tests/syntax-tests/source/Dockerfile/Dockerfile +++ b/tests/syntax-tests/source/Dockerfile/Dockerfile @@ -16,4 +16,4 @@ EXPOSE 80/tcp VOLUME [/var/lib/mysql/data] -ENTRYPOINT ["/usr/bin/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/entrypoint.sh"] diff --git a/tests/syntax-tests/source/Git Attributes/example.gitattributes b/tests/syntax-tests/source/Git Attributes/example.gitattributes --- a/tests/syntax-tests/source/Git Attributes/example.gitattributes +++ b/tests/syntax-tests/source/Git Attributes/example.gitattributes @@ -13,4 +13,4 @@ *.patch -text .gitattributes linguist-language=gitattributes -.gitkeep export-ignore \ No newline at end of file +.gitkeep export-ignore diff --git a/tests/syntax-tests/source/Git Config/text.gitconfig b/tests/syntax-tests/source/Git Config/text.gitconfig --- a/tests/syntax-tests/source/Git Config/text.gitconfig +++ b/tests/syntax-tests/source/Git Config/text.gitconfig @@ -104,4 +104,4 @@ [user] email = f.nord@example.com name = Frank Nord - signingkey = AAAAAAAAAAAAAAAA \ No newline at end of file + signingkey = AAAAAAAAAAAAAAAA diff --git a/tests/syntax-tests/source/Hosts/hosts b/tests/syntax-tests/source/Hosts/hosts --- a/tests/syntax-tests/source/Hosts/hosts +++ b/tests/syntax-tests/source/Hosts/hosts @@ -5,4 +5,4 @@ 192.160.0.200 try.sample.test try #another comment 216.58.223.238 google.com -::1 localhost.try ip6-localhost \ No newline at end of file +::1 localhost.try ip6-localhost diff --git a/tests/syntax-tests/source/Makefile/Makefile b/tests/syntax-tests/source/Makefile/Makefile --- a/tests/syntax-tests/source/Makefile/Makefile +++ b/tests/syntax-tests/source/Makefile/Makefile @@ -382,4 +382,4 @@ install: all @ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_SENTINEL_NAME) uninstall: - rm -f $(INSTALL_BIN)/{$(REDIS_SERVER_NAME),$(REDIS_BENCHMARK_NAME),$(REDIS_CLI_NAME),$(REDIS_CHECK_RDB_NAME),$(REDIS_CHECK_AOF_NAME),$(REDIS_SENTINEL_NAME)} \ No newline at end of file + rm -f $(INSTALL_BIN)/{$(REDIS_SERVER_NAME),$(REDIS_BENCHMARK_NAME),$(REDIS_CLI_NAME),$(REDIS_CHECK_RDB_NAME),$(REDIS_CHECK_AOF_NAME),$(REDIS_SENTINEL_NAME)} diff --git a/tests/syntax-tests/source/PHP/test.php b/tests/syntax-tests/source/PHP/test.php --- a/tests/syntax-tests/source/PHP/test.php +++ b/tests/syntax-tests/source/PHP/test.php @@ -108,4 +108,4 @@ function setName($name) { $ending = 2 > 3 ? "yep" : "nah"; -?> \ No newline at end of file +?> diff --git a/tests/syntax-tests/source/RequirementsTXT/requirements.txt b/tests/syntax-tests/source/RequirementsTXT/requirements.txt --- a/tests/syntax-tests/source/RequirementsTXT/requirements.txt +++ b/tests/syntax-tests/source/RequirementsTXT/requirements.txt @@ -5,4 +5,4 @@ pywheels>=12.4 #a whitespace followed by comments Nuitka<0.6.8.4 wxPython>=1.0, <=2.1 -#this is another comment \ No newline at end of file +#this is another comment diff --git a/tests/syntax-tests/source/YAML/example.yaml b/tests/syntax-tests/source/YAML/example.yaml --- a/tests/syntax-tests/source/YAML/example.yaml +++ b/tests/syntax-tests/source/YAML/example.yaml @@ -31,4 +31,4 @@ emails: - bob@example.com - bill@example.com supervisors: - - george@example.com \ No newline at end of file + - george@example.com diff --git a/tests/syntax-tests/source/reStructuredText/reference.rst b/tests/syntax-tests/source/reStructuredText/reference.rst --- a/tests/syntax-tests/source/reStructuredText/reference.rst +++ b/tests/syntax-tests/source/reStructuredText/reference.rst @@ -317,4 +317,4 @@ blank lines before and after.) .. So this block is not "lost", - despite its indentation. \ No newline at end of file + despite its indentation.
Newline can be added even if --style=plain In #975 @sharkdp said this: > The fact that bat -p prints a trailing newline (even if there is no newline at the end of the file) should be considered a bug, I believe (but we should check older tickets, if there was a reason for this behavior). And I completely agree. The reason the artificial newline was added in the first place was to fix #299, but there should be no risk of regressions since --style=plain excludes any kind of decorations that bug was about. Note that a pager such as `less` will add an artificial newline too, so one either has to disable paging or use a "pager" that does not add a newline to get the benefit of fixing this bug. **Step-by-step:** 1. echo -n nonewline > nonewline.txt 2. bat --style=plain --paging=never nonewline.txt 3. bat --style=plain --pager=cat nonewline.txt **Expected result:** After 2. and 3. the line shall not contain a newline. I personally use `zsh` to check this since by default `zsh` will print e.g. `%` as the last char if there is a missing newline. **Actual result:** A newline is printed with `bat 0.17.1`. (I will soon open a PR with a proposed fix) Newline can be added even if --style=plain In #975 @sharkdp said this: > The fact that bat -p prints a trailing newline (even if there is no newline at the end of the file) should be considered a bug, I believe (but we should check older tickets, if there was a reason for this behavior). And I completely agree. The reason the artificial newline was added in the first place was to fix #299, but there should be no risk of regressions since --style=plain excludes any kind of decorations that bug was about. Note that a pager such as `less` will add an artificial newline too, so one either has to disable paging or use a "pager" that does not add a newline to get the benefit of fixing this bug. **Step-by-step:** 1. echo -n nonewline > nonewline.txt 2. bat --style=plain --paging=never nonewline.txt 3. bat --style=plain --pager=cat nonewline.txt **Expected result:** After 2. and 3. the line shall not contain a newline. I personally use `zsh` to check this since by default `zsh` will print e.g. `%` as the last char if there is a missing newline. **Actual result:** A newline is printed with `bat 0.17.1`. (I will soon open a PR with a proposed fix)
Thank you for taking the time to write this down in detail! Thank you for taking the time to write this down in detail!
2020-12-16T19:47:12Z
0.17
2021-01-06T21:41:06Z
c569774e1a8528fab91225dabdadf53fde3916ea
[ "plain_mode_does_not_add_nonexisting_newline" ]
[ "config::default_config_should_highlight_no_lines", "config::default_config_should_include_all_lines", "input::basic", "less::test_parse_less_version_487", "input::utf16le", "less::test_parse_less_version_529", "less::test_parse_less_version_wrong_program", "less::test_parse_less_version_551", "line_range::test_parse_fail", "line_range::test_parse_full", "line_range::test_parse_partial_max", "line_range::test_parse_partial_min", "line_range::test_parse_single", "line_range::test_ranges_advanced", "line_range::test_ranges_all", "line_range::test_ranges_none", "line_range::test_ranges_open_high", "line_range::test_ranges_open_low", "line_range::test_ranges_simple", "preprocessor::test_try_parse_utf8_char", "syntax_mapping::basic", "syntax_mapping::builtin_mappings", "syntax_mapping::user_can_override_builtin_mappings", "assets::tests::syntax_detection_is_case_sensitive", "assets::tests::syntax_detection_for_symlinked_file", "assets::tests::syntax_detection_basic", "assets::tests::syntax_detection_with_custom_mapping", "assets::tests::syntax_detection_invalid_utf8", "assets::tests::syntax_detection_first_line", "assets::tests::syntax_detection_well_defined_mapping_for_duplicate_extensions", "assets::tests::syntax_detection_stdin_filename", "assets::tests::syntax_detection_same_for_inputkinds", "config::multi_line", "config::comments", "config::empty", "config::multiple", "config::quotes", "config::single", "filename_multiple_err", "config_location_test", "concatenate_empty_last", "concatenate_empty_first", "line_range_last_3", "line_range_multiple", "tabs_passthrough_wrapped", "does_not_print_unwanted_file_named_cache", "concatenate", "concatenate_empty_first_and_last", "config_read_arguments_from_file", "grid_overrides_rule", "concatenate_empty_both", "tabs_8", "pager_value_bat", "filename_basic", "do_not_exit_directory", "tabs_numbers", "filename_stdin_binary", "concatenate_single_line", "can_print_file_named_cache", "basic", "can_print_file_starting_with_cache", "pager_overwrite", "pager_basic", "tabs_4", "can_print_file_named_cache_with_additional_argument", "filename_stdin", "alias_pager_disable_long_overrides_short", "concatenate_empty_between", "concatenate_single_line_empty", "fail_non_existing", "line_numbers", "tabs_4_wrapped", "filename_binary", "empty_file_leads_to_empty_output_with_rule_enabled", "utf16", "alias_pager_disable", "tabs_passthrough", "pager_disable", "stdin", "empty_file_leads_to_empty_output_with_grid_enabled", "snip", "unicode_wrap", "header_padding_rule", "file_with_invalid_utf8_filename", "show_all_mode", "header_padding", "concatenate_stdin", "tabs_8_wrapped", "filename_multiple_ok", "line_range_first_two", "fail_directory", "line_range_2_3", "do_not_detect_different_syntax_for_stdin_and_files", "do_not_panic_regression_tests", "no_duplicate_extensions", "changes_grid_header_rule", "rule", "full", "changes_grid_numbers", "changes_grid_rule", "changes_grid", "grid_rule", "grid_header_rule", "header_numbers", "changes_header", "changes_rule", "changes_header_numbers", "changes_numbers", "grid_numbers", "grid_header_numbers", "numbers", "grid", "changes_grid_header_numbers_rule", "changes_grid_header", "changes", "changes_header_rule", "grid_header", "header_rule", "header_numbers_rule", "plain", "changes_grid_header_numbers", "header", "src/lib.rs - (line 12)" ]
[]
[]
null
rinja-rs__askama-486
rinja-rs/askama
486
[ "245" ]
92df4d1fe49e8fde5ca13f13b8236102bc16b969
diff --git a/askama_escape/src/lib.rs b/askama_escape/src/lib.rs --- a/askama_escape/src/lib.rs +++ b/askama_escape/src/lib.rs @@ -129,7 +129,6 @@ impl Escaper for Html { b'&' => escaping_body!(start, i, fmt, bytes, "&amp;"), b'"' => escaping_body!(start, i, fmt, bytes, "&quot;"), b'\'' => escaping_body!(start, i, fmt, bytes, "&#x27;"), - b'/' => escaping_body!(start, i, fmt, bytes, "&#x2f;"), _ => (), } }
diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs --- a/testing/tests/filters.rs +++ b/testing/tests/filters.rs @@ -21,7 +21,7 @@ fn filter_escape() { }; assert_eq!( s.render().unwrap(), - "&#x2f;&#x2f; my &lt;html&gt; is &quot;unsafe&quot; &amp; \ + "// my &lt;html&gt; is &quot;unsafe&quot; &amp; \ should be &#x27;escaped&#x27;" ); } diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -40,12 +40,9 @@ struct EscapeTemplate<'a> { #[test] fn test_escape() { - let s = EscapeTemplate { name: "<>&\"'/" }; + let s = EscapeTemplate { name: "<>&\"'" }; - assert_eq!( - s.render().unwrap(), - "Hello, &lt;&gt;&amp;&quot;&#x27;&#x2f;!" - ); + assert_eq!(s.render().unwrap(), "Hello, &lt;&gt;&amp;&quot;&#x27;!"); } #[derive(Template)]
askama_escape Why escape slashes? Sorry, I just don't seem to understand what harm slashes can do in html. [Why does it escape slashes?](https://github.com/djc/askama/blob/467f4ade19fa34983de7e6f6d81c6b4d5ff140fe/askama_escape/src/lib.rs#L134)
Because the OWASP recommends doing so. https://security.stackexchange.com/questions/49852/why-should-xss-filters-escape-forward-slash [OWASP Cross Site Scripting Prevention Cheat Sheet](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.md#rule-1---html-escape-before-inserting-untrusted-data-into-html-element-content) Yes they do indeed. But not in there [XSS Experimental Minimal Encoding Rules](https://www.owasp.org/index.php/XSS_Experimental_Minimal_Encoding_Rules). Furthermore I don't see anyone provide an actual attack on Security Stack Exchange that was enabled due to unescaped `/`. So I don't agree. If I agree or not doesn't matter though since the OWASP recommends doing so. It would still be nice to have a minimal escape version of that function. The reason for this is that I simply don't want my slashes inside of `src` and `href` to be escaped. It's simply useless. You could write your own filter that does more minimal escaping and returns the result as a `MarkupDisplay::Safe`, I think.
2021-05-16T20:39:00Z
0.10
2021-05-17T19:33:59Z
49252d2457f280026c020d0df46733578eb959a5
[ "filter_escape" ]
[ "filter_format", "filter_fmt", "into_numbers_fmt", "test_filter_let_filter", "test_filter_truncate", "test_join", "test_my_filter", "test_nested_filter_ref", "test_vec_join", "test_attr", "test_comment", "test_composition", "test_constants", "test_define_string_var", "test_else", "test_else_if", "test_empty", "test_escape", "test_func_ref_call", "test_generics", "test_if", "test_index", "test_literals", "test_minus", "test_literals_escape", "test_negation", "test_nested_attr", "test_option", "test_option_none_some", "test_path_compare", "test_path_func_call", "test_raw_complex", "test_raw_simple", "test_root_path_func_call", "test_slice_literal", "test_tuple_attr", "test_variables", "test_variables_no_escape", "without_import_on_derive::test_without_import" ]
[]
[]
null
tracel-ai__burn-572
tracel-ai/burn
572
[ "541" ]
597eab524d7232a9798487f094c51ffc2c81f545
diff --git a/burn-autodiff/src/ops/module.rs b/burn-autodiff/src/ops/module.rs --- a/burn-autodiff/src/ops/module.rs +++ b/burn-autodiff/src/ops/module.rs @@ -38,12 +38,11 @@ impl<B: Backend> ModuleOps<ADBackendDecorator<B>> for ADBackendDecorator<B> { } fn embedding_backward( - weights: ADTensor<B, 2>, - output: ADTensor<B, 3>, - indices: IntTensor<B, 2>, + _weights: ADTensor<B, 2>, + _output: ADTensor<B, 3>, + _indices: IntTensor<B, 2>, ) -> ADTensor<B, 2> { - let tensor = B::embedding_backward(weights.primitive, output.primitive, indices); - ADTensor::new(tensor) + panic!("Can't differentiate embedding backward."); } fn conv2d( diff --git a/burn-autodiff/src/ops/module.rs b/burn-autodiff/src/ops/module.rs --- a/burn-autodiff/src/ops/module.rs +++ b/burn-autodiff/src/ops/module.rs @@ -446,16 +445,15 @@ impl<B: Backend> ModuleOps<ADBackendDecorator<B>> for ADBackendDecorator<B> { } } } + fn avg_pool2d_backward( - x: ADTensor<B, 4>, - grad: ADTensor<B, 4>, - kernel_size: [usize; 2], - stride: [usize; 2], - padding: [usize; 2], + _x: ADTensor<B, 4>, + _grad: ADTensor<B, 4>, + _kernel_size: [usize; 2], + _stride: [usize; 2], + _padding: [usize; 2], ) -> ADTensor<B, 4> { - let tensor = - B::avg_pool2d_backward(x.primitive, grad.primitive, kernel_size, stride, padding); - ADTensor::new(tensor) + panic!("Can't differentiate avg pool 2d backward."); } fn max_pool2d( diff --git a/burn-autodiff/src/ops/module.rs b/burn-autodiff/src/ops/module.rs --- a/burn-autodiff/src/ops/module.rs +++ b/burn-autodiff/src/ops/module.rs @@ -513,22 +511,50 @@ impl<B: Backend> ModuleOps<ADBackendDecorator<B>> for ADBackendDecorator<B> { } fn max_pool2d_with_indices_backward( - x: ADTensor<B, 4>, - kernel_size: [usize; 2], - stride: [usize; 2], - padding: [usize; 2], - output_grad: ADTensor<B, 4>, - indices: IntTensor<B, 4>, + _x: ADTensor<B, 4>, + _kernel_size: [usize; 2], + _stride: [usize; 2], + _padding: [usize; 2], + _output_grad: ADTensor<B, 4>, + _indices: IntTensor<B, 4>, ) -> MaxPool2dBackward<ADBackendDecorator<B>> { - let output = B::max_pool2d_with_indices_backward( - x.primitive, - kernel_size, - stride, - padding, - output_grad.primitive, - indices, - ); - MaxPool2dBackward::new(ADTensor::new(output.x_grad)) + panic!("Can't differentiate max pool2d with indices backward."); + } + + fn adaptive_avg_pool2d(x: ADTensor<B, 4>, output_size: [usize; 2]) -> ADTensor<B, 4> { + #[derive(Debug)] + struct AdaptiveAvgPool2D; + + impl<B: Backend> Backward<B, 4, 1> for AdaptiveAvgPool2D { + type State = B::TensorPrimitive<4>; + + fn backward(self, ops: Ops<Self::State, 1>, grads: &mut Gradients) { + let [node_parent] = ops.parents; + let grad = grads.consume::<B, 4>(&ops.node); + + if let Some(node) = node_parent { + let grad = B::adaptive_avg_pool2d_backward(ops.state, grad); + grads.register::<B, 4>(node, grad); + } + } + } + + match AdaptiveAvgPool2D.prepare([x.node], [x.graph]).statefull() { + OpsKind::Tracked(prep) => prep.finish( + x.primitive.clone(), + B::adaptive_avg_pool2d(x.primitive, output_size), + ), + OpsKind::UnTracked(prep) => { + prep.finish(B::adaptive_avg_pool2d(x.primitive, output_size)) + } + } + } + + fn adaptive_avg_pool2d_backward( + _x: ADTensor<B, 4>, + _grad: ADTensor<B, 4>, + ) -> <ADBackendDecorator<B> as Backend>::TensorPrimitive<4> { + panic!("Can't differentiate adaptive avg pool2d backward."); } } diff --git /dev/null b/burn-core/src/nn/pool/adaptive_avg_pool2d.rs new file mode 100644 --- /dev/null +++ b/burn-core/src/nn/pool/adaptive_avg_pool2d.rs @@ -0,0 +1,41 @@ +use crate as burn; + +use crate::config::Config; +use crate::module::Module; +use crate::tensor::backend::Backend; +use crate::tensor::Tensor; +use burn_tensor::module::adaptive_avg_pool2d; + +/// Configuration to create a [2D adaptive avg pooling](AdaptiveAvgPool2d) layer. +#[derive(Config)] +pub struct AdaptiveAvgPool2dConfig { + /// The size of the output. + pub output_size: [usize; 2], +} + +/// Applies a 2D adaptive avg pooling over input tensors. +#[derive(Module, Debug, Clone)] +pub struct AdaptiveAvgPool2d { + output_size: [usize; 2], +} + +impl AdaptiveAvgPool2dConfig { + /// Initialize a new [adaptive avg pool 2d](AdaptiveAvgPool2d) module. + pub fn init(&self) -> AdaptiveAvgPool2d { + AdaptiveAvgPool2d { + output_size: self.output_size, + } + } +} + +impl AdaptiveAvgPool2d { + /// Applies the forward pass on the input tensor. + /// + /// # Shapes + /// + /// - input: [batch_size, channels, height_in, width_in], + /// - output: [batch_size, channels, height_out, width_out], + pub fn forward<B: Backend>(&self, input: Tensor<B, 4>) -> Tensor<B, 4> { + adaptive_avg_pool2d(input, self.output_size) + } +} diff --git a/burn-core/src/nn/pool/avg_pool1d.rs b/burn-core/src/nn/pool/avg_pool1d.rs --- a/burn-core/src/nn/pool/avg_pool1d.rs +++ b/burn-core/src/nn/pool/avg_pool1d.rs @@ -10,8 +10,6 @@ use burn_tensor::module::avg_pool1d; /// Configuration to create a [1D avg pooling](AvgPool1d) layer. #[derive(Config)] pub struct AvgPool1dConfig { - /// The number of channels. - pub channels: usize, /// The size of the kernel. pub kernel_size: usize, /// The stride. diff --git a/burn-core/src/nn/pool/avg_pool2d.rs b/burn-core/src/nn/pool/avg_pool2d.rs --- a/burn-core/src/nn/pool/avg_pool2d.rs +++ b/burn-core/src/nn/pool/avg_pool2d.rs @@ -10,8 +10,6 @@ use burn_tensor::module::avg_pool2d; /// Configuration to create a [2D avg pooling](AvgPool2d) layer. #[derive(Config)] pub struct AvgPool2dConfig { - /// The number of channels. - pub channels: usize, /// The size of the kernel. pub kernel_size: [usize; 2], /// The strides. diff --git a/burn-core/src/nn/pool/max_pool2d.rs b/burn-core/src/nn/pool/max_pool2d.rs --- a/burn-core/src/nn/pool/max_pool2d.rs +++ b/burn-core/src/nn/pool/max_pool2d.rs @@ -10,8 +10,6 @@ use burn_tensor::module::max_pool2d; /// Configuration to create an [2D max pooling](MaxPool2d) layer. #[derive(Debug, Config)] pub struct MaxPool2dConfig { - /// The number of channels. - pub channels: usize, /// The size of the kernel. pub kernel_size: [usize; 2], /// The strides. diff --git a/burn-core/src/nn/pool/mod.rs b/burn-core/src/nn/pool/mod.rs --- a/burn-core/src/nn/pool/mod.rs +++ b/burn-core/src/nn/pool/mod.rs @@ -1,7 +1,9 @@ +mod adaptive_avg_pool2d; mod avg_pool1d; mod avg_pool2d; mod max_pool2d; +pub use adaptive_avg_pool2d::*; pub use avg_pool1d::*; pub use avg_pool2d::*; pub use max_pool2d::*; diff --git a/burn-import/src/burn/node/max_pool2d.rs b/burn-import/src/burn/node/max_pool2d.rs --- a/burn-import/src/burn/node/max_pool2d.rs +++ b/burn-import/src/burn/node/max_pool2d.rs @@ -48,7 +48,6 @@ impl<PS: PrecisionSettings> NodeCodegen<PS> for MaxPool2dNode { fn field_init(&self, _with_record: bool) -> Option<TokenStream> { let name = &self.field.name; - let channels = self.config.channels.to_tokens(); let kernel_size = self.config.kernel_size.to_tokens(); let strides = self.config.strides.to_tokens(); let padding = self.config.padding.to_tokens(); diff --git a/burn-import/src/burn/node/max_pool2d.rs b/burn-import/src/burn/node/max_pool2d.rs --- a/burn-import/src/burn/node/max_pool2d.rs +++ b/burn-import/src/burn/node/max_pool2d.rs @@ -58,7 +57,7 @@ impl<PS: PrecisionSettings> NodeCodegen<PS> for MaxPool2dNode { }; let tokens = quote! { - let #name = MaxPool2dConfig::new(#channels, #kernel_size) + let #name = MaxPool2dConfig::new(#kernel_size) .with_strides(#strides) .with_padding(#padding) .#init_line diff --git a/burn-import/src/onnx/op_configuration.rs b/burn-import/src/onnx/op_configuration.rs --- a/burn-import/src/onnx/op_configuration.rs +++ b/burn-import/src/onnx/op_configuration.rs @@ -69,14 +69,12 @@ pub fn conv2d_config(curr: &Node) -> Conv2dConfig { /// Create a MaxPool2dConfig from the attributes of the node pub fn max_pool2d_config(curr: &Node) -> MaxPool2dConfig { - let mut channels: i64 = 1; let mut kernel_shape = Vec::new(); let mut strides = Vec::new(); let mut pads = Vec::new(); for (key, value) in curr.attrs.iter() { match key.as_str() { - "channels" => attr_value_i64(value, &mut channels), "kernel_shape" => attr_value_vec_i64(value, &mut kernel_shape), "strides" => attr_value_vec_i64(value, &mut strides), "pads" => attr_value_vec_i64(value, &mut pads), diff --git a/burn-import/src/onnx/op_configuration.rs b/burn-import/src/onnx/op_configuration.rs --- a/burn-import/src/onnx/op_configuration.rs +++ b/burn-import/src/onnx/op_configuration.rs @@ -86,12 +84,9 @@ pub fn max_pool2d_config(curr: &Node) -> MaxPool2dConfig { let padding = padding_config(&pads); - MaxPool2dConfig::new( - channels as usize, - [kernel_shape[0] as usize, kernel_shape[1] as usize], - ) - .with_strides([strides[0] as usize, strides[1] as usize]) - .with_padding(padding) + MaxPool2dConfig::new([kernel_shape[0] as usize, kernel_shape[1] as usize]) + .with_strides([strides[0] as usize, strides[1] as usize]) + .with_padding(padding) } /// Create a FlattenConfig from the attributes of the node diff --git /dev/null b/burn-ndarray/src/ops/adaptive_avgpool.rs new file mode 100644 --- /dev/null +++ b/burn-ndarray/src/ops/adaptive_avgpool.rs @@ -0,0 +1,103 @@ +use crate::{ + element::FloatNdArrayElement, iter_par, run_par, sharing::UnsafeSharedRef, + tensor::NdArrayTensor, +}; +use burn_tensor::ElementConversion; +use ndarray::Array4; + +pub(crate) fn adaptive_avg_pool2d<E: FloatNdArrayElement>( + x: NdArrayTensor<E, 4>, + output_size: [usize; 2], +) -> NdArrayTensor<E, 4> { + let [batch_size, channels, input_height, input_width] = x.shape().dims; + + let x = x.array; + let mut output = Array4::from_elem( + (batch_size, channels, output_size[0], output_size[1]), + 0.elem(), + ); + let unsafe_shared_out = UnsafeSharedRef::new(&mut output); + + run_par!(|| { + iter_par!(0, batch_size * channels).for_each(|k| unsafe { + let b = k / channels; + let c = k % channels; + + let output = unsafe_shared_out.get(); + for h in 0..output_size[0] { + for w in 0..output_size[1] { + let ih_start = start_index(h, output_size[0], input_height); + let ih_end = end_index(h, output_size[0], input_height); + let iw_start = start_index(w, output_size[1], input_width); + let iw_end = end_index(w, output_size[1], input_width); + + let mut sum_val: E = 0.elem(); + + for ih in ih_start..ih_end { + for iw in iw_start..iw_end { + sum_val += x[[b, c, ih, iw]]; + } + } + + let count: E = (((ih_end - ih_start) * (iw_end - iw_start)) as i32).elem(); + output[[b, c, h, w]] = sum_val / count.elem(); + } + } + }) + }); + + NdArrayTensor::new(output.into_dyn().into_shared()) +} + +pub(crate) fn adaptive_avg_pool2d_backward<E: FloatNdArrayElement>( + x: NdArrayTensor<E, 4>, + grad: NdArrayTensor<E, 4>, +) -> NdArrayTensor<E, 4> { + let [_, _, input_height, input_width] = x.shape().dims; + let [batch_size, channels, output_height, output_width] = grad.shape().dims; + + let mut output_grad = + Array4::from_elem((batch_size, channels, input_height, input_width), 0.elem()); + let unsafe_shared_out = UnsafeSharedRef::new(&mut output_grad); + + run_par!(|| { + iter_par!(0, batch_size * channels).for_each(|k| unsafe { + let b = k / channels; + let c = k % channels; + + let output_grad = unsafe_shared_out.get(); + for oh in 0..output_height { + for ow in 0..output_width { + let ih_start = start_index(oh, output_height, input_height); + let ih_end = end_index(oh, output_height, input_height); + + let iw_start = start_index(ow, output_width, input_width); + let iw_end = end_index(ow, output_width, input_width); + + let count: E = (((ih_end - ih_start) * (iw_end - iw_start)) as i32).elem(); + + for ih in ih_start..ih_end { + for iw in iw_start..iw_end { + output_grad[[b, c, ih, iw]] += + grad.array[[b, c, oh, ow]] / count.elem(); + } + } + } + } + }) + }); + + NdArrayTensor::new(output_grad.into_dyn().into_shared()) +} + +fn start_index(output_size_index: usize, output_size: usize, input_size: usize) -> usize { + libm::floorf((output_size_index as f32 * input_size as f32) / output_size as f32) as usize +} + +fn end_index(output_size_index: usize, output_size: usize, input_size: usize) -> usize { + let index = + libm::ceilf(((output_size_index + 1) as f32 * input_size as f32) / output_size as f32) + as usize; + + usize::min(index, input_size) +} diff --git a/burn-ndarray/src/ops/mod.rs b/burn-ndarray/src/ops/mod.rs --- a/burn-ndarray/src/ops/mod.rs +++ b/burn-ndarray/src/ops/mod.rs @@ -5,6 +5,7 @@ mod int_tensor; mod module; mod tensor; +pub(crate) mod adaptive_avgpool; pub(crate) mod avgpool; pub(crate) mod conv; pub(crate) mod macros; diff --git a/burn-ndarray/src/ops/module.rs b/burn-ndarray/src/ops/module.rs --- a/burn-ndarray/src/ops/module.rs +++ b/burn-ndarray/src/ops/module.rs @@ -1,4 +1,5 @@ use super::{ + adaptive_avgpool::{adaptive_avg_pool2d, adaptive_avg_pool2d_backward}, avgpool::{avg_pool2d, avg_pool2d_backward}, conv::{conv2d, conv_transpose2d}, maxpool::{max_pool2d, max_pool2d_backward, max_pool2d_with_indices}, diff --git a/burn-ndarray/src/ops/module.rs b/burn-ndarray/src/ops/module.rs --- a/burn-ndarray/src/ops/module.rs +++ b/burn-ndarray/src/ops/module.rs @@ -81,4 +82,15 @@ impl<E: FloatNdArrayElement> ModuleOps<NdArrayBackend<E>> for NdArrayBackend<E> indices, )) } + + fn adaptive_avg_pool2d(x: NdArrayTensor<E, 4>, output_size: [usize; 2]) -> NdArrayTensor<E, 4> { + adaptive_avg_pool2d(x, output_size) + } + + fn adaptive_avg_pool2d_backward( + x: NdArrayTensor<E, 4>, + grad: NdArrayTensor<E, 4>, + ) -> NdArrayTensor<E, 4> { + adaptive_avg_pool2d_backward(x, grad) + } } diff --git a/burn-tch/src/ops/module.rs b/burn-tch/src/ops/module.rs --- a/burn-tch/src/ops/module.rs +++ b/burn-tch/src/ops/module.rs @@ -220,4 +220,16 @@ impl<E: TchElement> ModuleOps<TchBackend<E>> for TchBackend<E> { MaxPool2dBackward::new(TchTensor::new(grad)) } + + fn adaptive_avg_pool2d(x: TchTensor<E, 4>, output_size: [usize; 2]) -> TchTensor<E, 4> { + let tensor = tch::Tensor::adaptive_avg_pool2d(&x.tensor, output_size.map(|e| e as i64)); + + TchTensor::new(tensor) + } + + fn adaptive_avg_pool2d_backward(x: TchTensor<E, 4>, grad: TchTensor<E, 4>) -> TchTensor<E, 4> { + let tensor = tch::Tensor::internal_adaptive_avg_pool2d_backward(&x.tensor, &grad.tensor); + + TchTensor::new(tensor) + } } diff --git a/burn-tensor/src/tensor/module.rs b/burn-tensor/src/tensor/module.rs --- a/burn-tensor/src/tensor/module.rs +++ b/burn-tensor/src/tensor/module.rs @@ -137,3 +137,11 @@ where (Tensor::new(output.output), Tensor::new(output.indices)) } + +/// Applies a [2D adaptive avg pooling](crate::ops::ModuleOps::adaptive_avg_pool2d). +pub fn adaptive_avg_pool2d<B>(x: Tensor<B, 4>, output_size: [usize; 2]) -> Tensor<B, 4> +where + B: Backend, +{ + Tensor::new(B::adaptive_avg_pool2d(x.primitive, output_size)) +} diff --git a/burn-tensor/src/tensor/ops/modules/base.rs b/burn-tensor/src/tensor/ops/modules/base.rs --- a/burn-tensor/src/tensor/ops/modules/base.rs +++ b/burn-tensor/src/tensor/ops/modules/base.rs @@ -262,6 +262,22 @@ pub trait ModuleOps<B: Backend> { padding: [usize; 2], ) -> B::TensorPrimitive<4>; + /// Two dimensional adaptive avg pooling. + /// + /// # Shapes + /// + /// x: [batch_size, channels, height, width], + fn adaptive_avg_pool2d( + x: B::TensorPrimitive<4>, + output_size: [usize; 2], + ) -> B::TensorPrimitive<4>; + + /// Backward pass for the [adaptive avg pooling 2d](ModuleOps::adaptive_avg_pool2d) operation. + fn adaptive_avg_pool2d_backward( + x: B::TensorPrimitive<4>, + grad: B::TensorPrimitive<4>, + ) -> B::TensorPrimitive<4>; + /// Two dimensional max pooling. /// /// # Shapes diff --git /dev/null b/burn-wgpu/src/kernel/pool/adaptive_avg_pool2d.rs new file mode 100644 --- /dev/null +++ b/burn-wgpu/src/kernel/pool/adaptive_avg_pool2d.rs @@ -0,0 +1,108 @@ +use std::sync::Arc; + +use burn_tensor::Shape; +use wgpu::Buffer; + +use crate::{ + element::WgpuElement, + kernel::{elemwise_workgroup, KernelSettings}, + kernel_wgsl, + tensor::WgpuTensor, +}; + +kernel_wgsl!( + AdaptiveAvgPool2d, + "../../template/pool/adaptive_avg_pool2d.wgsl" +); +kernel_wgsl!( + AdaptiveAvgPool2dBackward, + "../../template/pool/adaptive_avg_pool2d_backward.wgsl" +); + +pub(crate) fn adaptive_avg_pool2d<E: WgpuElement>( + x: WgpuTensor<E, 4>, + output_size: [usize; 2], +) -> WgpuTensor<E, 4> { + const WORKGROUP: usize = 32; + + let [batch_size, channels, _, _] = x.shape.dims; + + let output_shape = Shape::new([batch_size, channels, output_size[0], output_size[1]]); + let num_elems = output_shape.num_elements(); + let output_buffer = x + .context + .create_buffer(num_elems * core::mem::size_of::<E>()); + let output = WgpuTensor::new(x.context.clone(), output_shape, output_buffer); + + let kernel = x + .context + .compile_static::<KernelSettings<AdaptiveAvgPool2d, E, i32, WORKGROUP, WORKGROUP, 1>>(); + + let info_buffer = build_info(&x, &output); + + x.context.execute( + elemwise_workgroup(output.shape.num_elements(), WORKGROUP), + kernel, + &[&x.buffer, &output.buffer, &info_buffer], + ); + + output +} + +pub(crate) fn adaptive_avg_pool2d_backward<E: WgpuElement>( + x: WgpuTensor<E, 4>, + out_grad: WgpuTensor<E, 4>, +) -> WgpuTensor<E, 4> { + const WORKGROUP: usize = 32; + + let output_shape = x.shape.clone(); + let num_elems = output_shape.num_elements(); + let output_buffer = x + .context + .create_buffer(num_elems * core::mem::size_of::<E>()); + let output = WgpuTensor::new(x.context.clone(), output_shape, output_buffer); + + let kernel = x.context.compile_static::<KernelSettings< + AdaptiveAvgPool2dBackward, + E, + i32, + WORKGROUP, + WORKGROUP, + 1, + >>(); + + let info_buffer = build_info(&x, &out_grad); + + x.context.execute( + elemwise_workgroup(output.shape.num_elements(), WORKGROUP), + kernel, + &[&out_grad.buffer, &output.buffer, &info_buffer], + ); + + output +} + +fn build_info<E: WgpuElement>(x: &WgpuTensor<E, 4>, output: &WgpuTensor<E, 4>) -> Arc<Buffer> { + let mut info: [u32; 16] = [0; 16]; + info[0] = x.strides[0] as u32; + info[1] = x.strides[1] as u32; + info[2] = x.strides[2] as u32; + info[3] = x.strides[3] as u32; + info[4] = x.shape.dims[0] as u32; + info[5] = x.shape.dims[1] as u32; + info[6] = x.shape.dims[2] as u32; + info[7] = x.shape.dims[3] as u32; + + info[8] = output.strides[0] as u32; + info[9] = output.strides[1] as u32; + info[10] = output.strides[2] as u32; + info[11] = output.strides[3] as u32; + info[12] = output.shape.dims[0] as u32; + info[13] = output.shape.dims[1] as u32; + info[14] = output.shape.dims[2] as u32; + info[15] = output.shape.dims[3] as u32; + + output + .context + .create_buffer_with_data(bytemuck::cast_slice(&info)) +} diff --git a/burn-wgpu/src/kernel/pool/mod.rs b/burn-wgpu/src/kernel/pool/mod.rs --- a/burn-wgpu/src/kernel/pool/mod.rs +++ b/burn-wgpu/src/kernel/pool/mod.rs @@ -1,7 +1,9 @@ +mod adaptive_avg_pool2d; mod avg_pool2d; mod base; mod max_pool2d; +pub(crate) use adaptive_avg_pool2d::*; pub use avg_pool2d::*; pub(super) use base::*; pub use max_pool2d::*; diff --git a/burn-wgpu/src/ops/module_ops.rs b/burn-wgpu/src/ops/module_ops.rs --- a/burn-wgpu/src/ops/module_ops.rs +++ b/burn-wgpu/src/ops/module_ops.rs @@ -90,4 +90,18 @@ where padding, )) } + + fn adaptive_avg_pool2d( + x: FloatTensor<Self, 4>, + output_size: [usize; 2], + ) -> FloatTensor<Self, 4> { + kernel::pool::adaptive_avg_pool2d(x, output_size) + } + + fn adaptive_avg_pool2d_backward( + x: FloatTensor<Self, 4>, + grad: FloatTensor<Self, 4>, + ) -> FloatTensor<Self, 4> { + kernel::pool::adaptive_avg_pool2d_backward(x, grad) + } } diff --git /dev/null b/burn-wgpu/src/template/pool/adaptive_avg_pool2d.wgsl new file mode 100644 --- /dev/null +++ b/burn-wgpu/src/template/pool/adaptive_avg_pool2d.wgsl @@ -0,0 +1,74 @@ +@group(0) +@binding(0) +var<storage, read> x: array<{{ elem }}>; + +@group(0) +@binding(1) +var<storage, read_write> output: array<{{ elem }}>; + +@group(0) +@binding(2) +var<storage, read> info: array<u32, 16>; + +const WORKGROUP_SIZE_X = {{ workgroup_size_x }}u; + +@compute +@workgroup_size({{ workgroup_size_x }}, {{ workgroup_size_y }}, 1) +fn main( + @builtin(global_invocation_id) global_id: vec3<u32>, + @builtin(num_workgroups) num_workgroups: vec3<u32>, +) { + let id = global_id.y * (num_workgroups.x * WORKGROUP_SIZE_X) + global_id.x; + + let input_stride_0 = info[0]; + let input_stride_1 = info[1]; + let input_stride_2 = info[2]; + let input_stride_3 = info[3]; + let input_shape_0 = info[4]; + let input_shape_1 = info[5]; + let input_shape_2 = info[6]; + let input_shape_3 = info[7]; + + let output_stride_0 = info[8]; + let output_stride_1 = info[9]; + let output_stride_2 = info[10]; + let output_stride_3 = info[11]; + let output_shape_0 = info[12]; + let output_shape_1 = info[13]; + let output_shape_2 = info[14]; + let output_shape_3 = info[15]; + + let b = id / output_stride_0 % output_shape_0; + let c = id / output_stride_1 % output_shape_1; + let oh = id / output_stride_2 % output_shape_2; + let ow = id / output_stride_3 % output_shape_3; + + let ih_start = start_index(oh, output_shape_2, input_shape_2); + let ih_end = end_index(oh, output_shape_2, input_shape_2); + + let iw_start = start_index(ow, output_shape_3, input_shape_3); + let iw_end = end_index(ow, output_shape_3, input_shape_3); + + var sum = 0.0; + + for (var ih = ih_start; ih < ih_end; ih++) { + for (var iw = iw_start; iw < iw_end; iw++) { + let index_input = b * input_stride_0 + c * input_stride_1 + ih * input_stride_2 + iw * input_stride_3; + sum += x[index_input]; + } + } + + let count = {{ elem }}((ih_end - ih_start) * (iw_end - iw_start)); + output[id] = sum / count; +} + +fn start_index(output_size_index: u32, output_size: u32, input_size: u32) -> u32 { + return u32(floor((f32(output_size_index) * f32(input_size)) / f32(output_size))); +} + +fn end_index(output_size_index: u32, output_size: u32, input_size: u32) -> u32 { + let index = u32(ceil((f32(output_size_index + 1u) * f32(input_size)) / f32(output_size))); + + return min(index, input_size); +} + diff --git /dev/null b/burn-wgpu/src/template/pool/adaptive_avg_pool2d_backward.wgsl new file mode 100644 --- /dev/null +++ b/burn-wgpu/src/template/pool/adaptive_avg_pool2d_backward.wgsl @@ -0,0 +1,88 @@ +@group(0) +@binding(0) +var<storage, read> grad: array<{{ elem }}>; + +@group(0) +@binding(1) +var<storage, read_write> output: array<{{ elem }}>; + +@group(0) +@binding(2) +var<storage, read> info: array<u32, 16>; + +const WORKGROUP_SIZE_X = {{ workgroup_size_x }}u; + +@compute +@workgroup_size({{ workgroup_size_x }}, {{ workgroup_size_y }}, 1) +fn main( + @builtin(global_invocation_id) global_id: vec3<u32>, + @builtin(num_workgroups) num_workgroups: vec3<u32>, +) { + let id = global_id.y * (num_workgroups.x * WORKGROUP_SIZE_X) + global_id.x; + + let input_stride_0 = info[0]; + let input_stride_1 = info[1]; + let input_stride_2 = info[2]; + let input_stride_3 = info[3]; + let input_shape_0 = info[4]; + let input_shape_1 = info[5]; + let input_shape_2 = info[6]; + let input_shape_3 = info[7]; + + let grad_stride_0 = info[8]; + let grad_stride_1 = info[9]; + let grad_stride_2 = info[10]; + let grad_stride_3 = info[11]; + let grad_shape_0 = info[12]; + let grad_shape_1 = info[13]; + let grad_shape_2 = info[14]; + let grad_shape_3 = info[15]; + + let b = id / input_stride_0 % input_shape_0; + let c = id / input_stride_1 % input_shape_1; + let ih = id / input_stride_2 % input_shape_2; + let iw = id / input_stride_3 % input_shape_3; + + let oh_start = start_index(ih, input_shape_2, grad_shape_2); + let oh_end = end_index(ih, input_shape_2, grad_shape_2); + + let ow_start = start_index(iw, input_shape_3, grad_shape_3); + let ow_end = end_index(iw, input_shape_3, grad_shape_3); + + var grad_acc = 0.0; + + for (var oh = oh_start; oh < oh_end; oh++) { + for (var ow = ow_start; ow < ow_end; ow++) { + let ih_start = start_index(oh, grad_shape_2, input_shape_2); + let ih_end = end_index(oh, grad_shape_2, input_shape_2); + + let iw_start = start_index(ow, grad_shape_3, input_shape_3); + let iw_end = end_index(ow, grad_shape_3, input_shape_3); + + let contributed_h = ih >= ih_start && ih < ih_end; + let contributed_w = iw >= iw_start && iw < iw_end; + + // If no contribution skip + if !contributed_h || !contributed_w { + continue; + } + + let index = b * grad_stride_0 + c * grad_stride_1 + oh * grad_stride_2 + ow * grad_stride_3; + let count = {{ elem }}((ih_end - ih_start) * (iw_end - iw_start)); + + grad_acc += grad[index] / count; + } + } + + output[id] = grad_acc; +} + +fn start_index(output_size_index: u32, output_size: u32, input_size: u32) -> u32 { + return u32(floor((f32(output_size_index) * f32(input_size)) / f32(output_size))); +} + +fn end_index(output_size_index: u32, output_size: u32, input_size: u32) -> u32 { + let index = u32(ceil((f32(output_size_index + 1u) * f32(input_size)) / f32(output_size))); + + return min(index, input_size); +}
diff --git /dev/null b/burn-autodiff/src/tests/adaptive_avgpool2d.rs new file mode 100644 --- /dev/null +++ b/burn-autodiff/src/tests/adaptive_avgpool2d.rs @@ -0,0 +1,64 @@ +#[burn_tensor_testgen::testgen(ad_adaptive_avg_pool2d)] +mod tests { + use super::*; + use burn_tensor::module::adaptive_avg_pool2d; + use burn_tensor::{Data, Shape, Tensor}; + + #[test] + fn test_avg_pool2d_simple() { + let test = AdaptiveAvgPool2dTestCase { + batch_size: 1, + channels: 2, + height: 5, + width: 3, + output_size_1: 3, + output_size_2: 2, + }; + + test.assert_output(TestTensor::from_floats([[ + [ + [0.2500, 0.5000, 0.2500], + [0.4167, 0.8333, 0.4167], + [0.1667, 0.3333, 0.1667], + [0.4167, 0.8333, 0.4167], + [0.2500, 0.5000, 0.2500], + ], + [ + [0.2500, 0.5000, 0.2500], + [0.4167, 0.8333, 0.4167], + [0.1667, 0.3333, 0.1667], + [0.4167, 0.8333, 0.4167], + [0.2500, 0.5000, 0.2500], + ], + ]])); + } + + struct AdaptiveAvgPool2dTestCase { + batch_size: usize, + channels: usize, + height: usize, + width: usize, + output_size_1: usize, + output_size_2: usize, + } + + impl AdaptiveAvgPool2dTestCase { + fn assert_output(self, x_grad: TestTensor<4>) { + let shape_x = Shape::new([self.batch_size, self.channels, self.height, self.width]); + let x = TestADTensor::from_data( + TestTensorInt::arange(0..shape_x.num_elements()) + .reshape(shape_x) + .into_data() + .convert(), + ) + .require_grad(); + let output = adaptive_avg_pool2d(x.clone(), [self.output_size_1, self.output_size_2]); + let grads = output.backward(); + let x_grad_actual = x.grad(&grads).unwrap(); + + x_grad + .to_data() + .assert_approx_eq(&x_grad_actual.into_data(), 3); + } + } +} diff --git a/burn-autodiff/src/tests/mod.rs b/burn-autodiff/src/tests/mod.rs --- a/burn-autodiff/src/tests/mod.rs +++ b/burn-autodiff/src/tests/mod.rs @@ -1,6 +1,7 @@ #![allow(missing_docs)] mod abs; +mod adaptive_avgpool2d; mod add; mod aggregation; mod avgpool1d; diff --git a/burn-autodiff/src/tests/mod.rs b/burn-autodiff/src/tests/mod.rs --- a/burn-autodiff/src/tests/mod.rs +++ b/burn-autodiff/src/tests/mod.rs @@ -60,6 +61,7 @@ macro_rules! testgen_all { burn_autodiff::testgen_ad_max_pool2d!(); burn_autodiff::testgen_ad_avg_pool1d!(); burn_autodiff::testgen_ad_avg_pool2d!(); + burn_autodiff::testgen_ad_adaptive_avg_pool2d!(); burn_autodiff::testgen_module_backward!(); // Tensor diff --git a/burn-import/src/burn/node/max_pool2d.rs b/burn-import/src/burn/node/max_pool2d.rs --- a/burn-import/src/burn/node/max_pool2d.rs +++ b/burn-import/src/burn/node/max_pool2d.rs @@ -105,7 +104,7 @@ mod tests { "max_pool2d", TensorType::new_float("input", 4), TensorType::new_float("output", 4), - MaxPool2dConfig::new(1, [3, 3]) + MaxPool2dConfig::new([3, 3]) .with_strides([1, 1]) .with_padding(PaddingConfig2d::Valid), )); diff --git a/burn-import/src/burn/node/max_pool2d.rs b/burn-import/src/burn/node/max_pool2d.rs --- a/burn-import/src/burn/node/max_pool2d.rs +++ b/burn-import/src/burn/node/max_pool2d.rs @@ -126,7 +125,7 @@ mod tests { impl<B: Backend> Model <B> { pub fn new_with(record: ModelRecord<B>) -> Self { - let max_pool2d = MaxPool2dConfig::new(1, [3, 3]) + let max_pool2d = MaxPool2dConfig::new([3, 3]) .with_strides([1, 1]) .with_padding(PaddingConfig2d::Valid) .init(); diff --git a/burn-no-std-tests/src/conv.rs b/burn-no-std-tests/src/conv.rs --- a/burn-no-std-tests/src/conv.rs +++ b/burn-no-std-tests/src/conv.rs @@ -26,7 +26,7 @@ impl<B: Backend> ConvBlock<B> { let conv = nn::conv::Conv2dConfig::new(config.channels, config.kernel_size) .with_padding(nn::PaddingConfig2d::Same) .init(); - let pool = nn::pool::MaxPool2dConfig::new(config.channels[1], config.kernel_size) + let pool = nn::pool::MaxPool2dConfig::new(config.kernel_size) .with_padding(nn::PaddingConfig2d::Same) .init(); let activation = nn::GELU::new(); diff --git a/burn-tensor/src/tests/mod.rs b/burn-tensor/src/tests/mod.rs --- a/burn-tensor/src/tests/mod.rs +++ b/burn-tensor/src/tests/mod.rs @@ -23,6 +23,7 @@ macro_rules! testgen_all { burn_tensor::testgen_module_max_pool2d!(); burn_tensor::testgen_module_avg_pool1d!(); burn_tensor::testgen_module_avg_pool2d!(); + burn_tensor::testgen_module_adaptive_avg_pool2d!(); // test ops burn_tensor::testgen_add!(); diff --git /dev/null b/burn-tensor/src/tests/module/adaptive_avgpool2d.rs new file mode 100644 --- /dev/null +++ b/burn-tensor/src/tests/module/adaptive_avgpool2d.rs @@ -0,0 +1,103 @@ +#[burn_tensor_testgen::testgen(module_adaptive_avg_pool2d)] +mod tests { + use super::*; + use burn_tensor::module::adaptive_avg_pool2d; + use burn_tensor::{Data, Shape, Tensor}; + + #[test] + fn test_adaptive_avg_pool2d_simple() { + let test = AdaptiveAvgPool2dTestCase { + batch_size: 1, + channels: 2, + height: 8, + width: 6, + height_out: 4, + width_out: 4, + }; + + test.assert_output(TestTensor::from_floats([[ + [ + [3.5000, 4.5000, 6.5000, 7.5000], + [15.5000, 16.5000, 18.5000, 19.5000], + [27.5000, 28.5000, 30.5000, 31.5000], + [39.5000, 40.5000, 42.5000, 43.5000], + ], + [ + [51.5000, 52.5000, 54.5000, 55.5000], + [63.5000, 64.5000, 66.5000, 67.5000], + [75.5000, 76.5000, 78.5000, 79.5000], + [87.5000, 88.5000, 90.5000, 91.5000], + ], + ]])); + } + + #[test] + fn test_adaptive_avg_pool2d_dyn_filter_size() { + let test = AdaptiveAvgPool2dTestCase { + batch_size: 1, + channels: 2, + height: 5, + width: 7, + height_out: 3, + width_out: 2, + }; + + test.assert_output(TestTensor::from_floats([[ + [[5.0000, 8.0000], [15.5000, 18.5000], [26.0000, 29.0000]], + [[40.0000, 43.0000], [50.5000, 53.5000], [61.0000, 64.0000]], + ]])); + } + + #[test] + fn test_adaptive_avg_pool2d_bigger_output() { + let test = AdaptiveAvgPool2dTestCase { + batch_size: 1, + channels: 2, + height: 4, + width: 3, + height_out: 5, + width_out: 4, + }; + + test.assert_output(TestTensor::from_floats([[ + [ + [0.0000, 0.5000, 1.5000, 2.0000], + [1.5000, 2.0000, 3.0000, 3.5000], + [4.5000, 5.0000, 6.0000, 6.5000], + [7.5000, 8.0000, 9.0000, 9.5000], + [9.0000, 9.5000, 10.5000, 11.0000], + ], + [ + [12.0000, 12.5000, 13.5000, 14.0000], + [13.5000, 14.0000, 15.0000, 15.5000], + [16.5000, 17.0000, 18.0000, 18.5000], + [19.5000, 20.0000, 21.0000, 21.5000], + [21.0000, 21.5000, 22.5000, 23.0000], + ], + ]])); + } + + struct AdaptiveAvgPool2dTestCase { + batch_size: usize, + channels: usize, + height: usize, + width: usize, + height_out: usize, + width_out: usize, + } + + impl AdaptiveAvgPool2dTestCase { + fn assert_output(self, y: TestTensor<4>) { + let shape_x = Shape::new([self.batch_size, self.channels, self.height, self.width]); + let x = TestTensor::from_data( + TestTensorInt::arange(0..shape_x.num_elements()) + .reshape(shape_x) + .into_data() + .convert(), + ); + let output = adaptive_avg_pool2d(x, [self.height_out, self.width_out]); + + y.to_data().assert_approx_eq(&output.into_data(), 3); + } + } +} diff --git a/burn-tensor/src/tests/module/mod.rs b/burn-tensor/src/tests/module/mod.rs --- a/burn-tensor/src/tests/module/mod.rs +++ b/burn-tensor/src/tests/module/mod.rs @@ -1,3 +1,4 @@ +mod adaptive_avgpool2d; mod avgpool1d; mod avgpool2d; mod conv1d;
Adaptive average pooling Implement adaptive average pooling in all backends. - [ ] ndarray - [ ] tch - [ ] wgpu - [ ] autodiff
2023-08-01T15:30:16Z
7.0
2023-08-04T14:24:02Z
8808ee265ed366b0e263ec7221854df0c956993f
[ "burn::node::unary::tests::test_unary_codegen_sigmoid", "burn::node::concat::tests::test_codegen_concat", "burn::node::reshape::tests::test_codegen_nodes", "burn::node::batch_norm::tests::test_codegen", "burn::node::unary::tests::test_unary_codegen_transpose", "burn::node::unary::tests::test_unary_codegen_flatten", "burn::node::base::tests::test_codegen_two_nodes", "burn::node::unary::tests::test_unary_codegen_log_softmax", "burn::node::base::tests::test_codegen_clone_tensor", "burn::node::binary::tests::test_binary_codegen_div", "burn::node::binary::tests::test_binary_codegen_sub", "burn::node::binary::tests::test_binary_codegen_equal", "burn::node::linear::tests::test_codegen", "burn::node::binary::tests::test_binary_codegen_add", "burn::node::binary::tests::test_binary_codegen_mul", "burn::node::unary::tests::test_unary_codegen_relu", "burn::node::matmul::tests::test_codegen_two_nodes", "burn::node::max_pool2d::tests::test_codegen", "burn::node::conv2d::tests::test_codegen", "tests::test_codegen::case_3_concat", "tests::test_codegen::case_2_conv2d", "tests::test_codegen::case_1_mixed", "test_mnist_model_with_random_input" ]
[ "tensor::api::check::tests::binary_ops_devices - should panic", "tensor::api::check::tests::binary_ops_shapes_no_broadcast - should panic", "tensor::api::check::tests::binary_ops_shapes_with_broadcast", "tensor::api::check::tests::index_range_exceed_number_of_dimensions - should panic", "tensor::api::check::tests::index_range_exceed_dimension - should panic", "tensor::api::check::tests::reshape_invalid_shape - should panic", "tensor::api::check::tests::reshape_valid_shape", "tensor::data::tests::should_assert_appox_eq_above_limit - should panic", "tensor::data::tests::should_assert_appox_eq_check_shape - should panic", "tensor::data::tests::should_have_right_shape", "tensor::data::tests::should_have_right_num_elements", "tensor::data::tests::should_assert_appox_eq_limit", "tensor::ops::modules::conv::tests::test_calculate_output_padding_1", "tensor::ops::modules::conv::tests::test_calculate_output_size_1", "tensor::ops::modules::conv::tests::test_calculate_output_size_2", "tensor::ops::modules::conv::tests::test_calculate_output_size_3", "tensor::ops::modules::conv::tests::test_calculate_same_padding_1", "tensor::ops::modules::conv::tests::test_calculate_same_padding_2", "tensor::shape::tests::num_elements", "src/tensor/api/numeric.rs - tensor::api::numeric::Tensor<B,D,K>::argmax (line 319)", "src/tensor/api/float.rs - tensor::api::float::Tensor<B,D>::int (line 112)", "src/tensor/api/base.rs - tensor::api::base::Tensor<B,D,K>::slice (line 208)", "src/tensor/api/float.rs - tensor::api::float::Tensor<B,D>::from_floats (line 94)", "src/tensor/api/float.rs - tensor::api::float::Tensor<B,D>::one_hot (line 145)", "src/tensor/api/int.rs - tensor::api::int::Tensor<B,D,Int>::float (line 74)", "src/tensor/api/base.rs - tensor::api::base::T (line 409)", "src/tensor/api/int.rs - tensor::api::int::Tensor<B,D,Int>::from_ints (line 56)", "src/tensor/api/numeric.rs - tensor::api::numeric::Tensor<B,D,K>::argmin (line 364)", "src/tensor/api/base.rs - tensor::api::base::Tensor<B,D,K>::slice_assign (line 234)", "src/tensor/api/base.rs - tensor::api::base::Tensor<B,D,K>::squeeze (line 141)", "src/tensor/api/base.rs - tensor::api::base::Tensor<B,D,K>::flatten (line 90)", "src/tensor/api/base.rs - tensor::api::base::Tensor<B,D,K>::unsqueeze (line 176)" ]
[]
[]
null
biomejs__biome-1527
biomejs/biome
1,527
[ "1524" ]
57f454976a02d34581291e6f06a10caa34953745
diff --git a/CHANGELOG.md b/CHANGELOG.md --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,8 +39,35 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom - Add an unsafe code fix for [noConsoleLog](https://biomejs.dev/linter/rules/no-console-log/). Contributed by @vasucp1207 +- [useArrowFunction](https://biomejs.dev/rules/) no longer reports function in `extends` clauses or in a `new` expression. COntributed by @Conaclos + + This cases requires the presence of a prototype. + #### Bug fixes +- The fix of [useArrowFunction](https://biomejs.dev/rules/) now adds parentheses around the arrow function in more cases where it is needed ([#1524](https://github.com/biomejs/biome/issues/1524)). + + A function expression doesn't need parentheses in most expressions where it can appear. + This is not the case with the arrow function. + We previously added parentheses when the function appears in a call or member expression. + We now add parentheses in binary-like expressions and other cases where they are needed, hopefully covering all cases. + + Previously: + + ```diff + - f = f ?? function() {}; + + f = f ?? () => {}; + ``` + + Now: + + ```diff + - f = f ?? function() {}; + + f = f ?? (() => {}); + ``` + + Contributed by @Conaclos + ### Parser diff --git a/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs b/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs --- a/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs +++ b/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs @@ -15,7 +15,7 @@ use biome_js_syntax::{ }; use biome_rowan::{ declare_node_union, AstNode, AstNodeList, AstSeparatedList, BatchMutationExt, Language, - SyntaxNode, SyntaxNodeOptionExt, TextRange, TriviaPieceKind, WalkEvent, + SyntaxNode, TextRange, TriviaPieceKind, WalkEvent, }; declare_rule! { diff --git a/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs b/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs --- a/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs +++ b/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs @@ -104,6 +104,21 @@ impl Rule for UseArrowFunction { // Ignore functions that explicitly declare a `this` type. return None; } + let requires_prototype = function_expression + .syntax() + .ancestors() + .skip(1) + .find(|ancestor| ancestor.kind() != JsSyntaxKind::JS_PARENTHESIZED_EXPRESSION) + .is_some_and(|ancestor| { + matches!( + ancestor.kind(), + JsSyntaxKind::JS_NEW_EXPRESSION | JsSyntaxKind::JS_EXTENDS_CLAUSE + ) + }); + if requires_prototype { + // Ignore cases where a prototype is required + return None; + } Some(()) } diff --git a/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs b/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs --- a/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs +++ b/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs @@ -144,7 +159,7 @@ impl Rule for UseArrowFunction { } let arrow_function = arrow_function_builder.build(); let arrow_function = if needs_parentheses(function_expression) { - AnyJsExpression::from(make::parenthesized(arrow_function)) + AnyJsExpression::from(make::parenthesized(arrow_function.trim_trailing_trivia()?)) } else { AnyJsExpression::from(arrow_function) }; diff --git a/website/src/content/docs/internals/changelog.mdx b/website/src/content/docs/internals/changelog.mdx --- a/website/src/content/docs/internals/changelog.mdx +++ b/website/src/content/docs/internals/changelog.mdx @@ -45,8 +45,35 @@ Read our [guidelines for writing a good changelog entry](https://github.com/biom - Add an unsafe code fix for [noConsoleLog](https://biomejs.dev/linter/rules/no-console-log/). Contributed by @vasucp1207 +- [useArrowFunction](https://biomejs.dev/rules/) no longer reports function in `extends` clauses or in a `new` expression. COntributed by @Conaclos + + This cases requires the presence of a prototype. + #### Bug fixes +- The fix of [useArrowFunction](https://biomejs.dev/rules/) now adds parentheses around the arrow function in more cases where it is needed ([#1524](https://github.com/biomejs/biome/issues/1524)). + + A function expression doesn't need parentheses in most expressions where it can appear. + This is not the case with the arrow function. + We previously added parentheses when the function appears in a call or member expression. + We now add parentheses in binary-like expressions and other cases where they are needed, hopefully covering all cases. + + Previously: + + ```diff + - f = f ?? function() {}; + + f = f ?? () => {}; + ``` + + Now: + + ```diff + - f = f ?? function() {}; + + f = f ?? (() => {}); + ``` + + Contributed by @Conaclos + ### Parser
diff --git a/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs b/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs --- a/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs +++ b/crates/biome_js_analyze/src/analyzers/complexity/use_arrow_function.rs @@ -165,20 +180,41 @@ impl Rule for UseArrowFunction { /// Returns `true` if `function_expr` needs parenthesis when turned into an arrow function. fn needs_parentheses(function_expression: &JsFunctionExpression) -> bool { - function_expression - .syntax() - .parent() - .kind() - .is_some_and(|parent_kind| { - matches!( - parent_kind, - JsSyntaxKind::JS_CALL_EXPRESSION + function_expression.syntax().parent().is_some_and(|parent| { + // Copied from the implementation of `NeedsParentheses` for `JsArrowFunctionExpression` + // in the `biome_js_formatter` crate. + // TODO: Should `NeedsParentheses` be moved in `biome_js_syntax`? + matches!( + parent.kind(), + JsSyntaxKind::TS_AS_EXPRESSION + | JsSyntaxKind::TS_SATISFIES_EXPRESSION + | JsSyntaxKind::JS_UNARY_EXPRESSION + | JsSyntaxKind::JS_AWAIT_EXPRESSION + | JsSyntaxKind::TS_TYPE_ASSERTION_EXPRESSION + // Conditional expression + // NOTE: parens are only needed when the arrow function appears in the test. + // To simplify we always add parens. + | JsSyntaxKind::JS_CONDITIONAL_EXPRESSION + // Lower expression + | JsSyntaxKind::JS_EXTENDS_CLAUSE + | JsSyntaxKind::TS_NON_NULL_ASSERTION_EXPRESSION + // Callee + | JsSyntaxKind::JS_CALL_EXPRESSION + | JsSyntaxKind::JS_NEW_EXPRESSION + // Member-like | JsSyntaxKind::JS_STATIC_MEMBER_ASSIGNMENT | JsSyntaxKind::JS_STATIC_MEMBER_EXPRESSION | JsSyntaxKind::JS_COMPUTED_MEMBER_ASSIGNMENT | JsSyntaxKind::JS_COMPUTED_MEMBER_EXPRESSION - ) - }) + // Template tag + | JsSyntaxKind::JS_TEMPLATE_EXPRESSION + // Binary-like + | JsSyntaxKind::JS_LOGICAL_EXPRESSION + | JsSyntaxKind::JS_BINARY_EXPRESSION + | JsSyntaxKind::JS_INSTANCEOF_EXPRESSION + | JsSyntaxKind::JS_IN_EXPRESSION + ) + }) } declare_node_union! { diff --git a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts --- a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts +++ b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts @@ -36,12 +36,18 @@ function f7() { }; } -const f8 = function(a) {}.bind(null, 0); - -const f9 = function(a) {}["bind"](null, 0); - -const called = function () {}(); - const f10 = function(x) { return 0, 1; } + +const as = function () {} as () => void; +const satisfies = function () {} satisfies () => void; +const unary = +function () {}; +const conditionalTest = function () {} ? true : false; +class ExtendsClause extends function() {} {}; +const non_null_assertion = function () {}!; +const call = function () {}(); +const staticMember = function(a) {}.bind(null, 0); +const computedMember = function(a) {}["bind"](null, 0); +const logical = false || function () {}; +const binary = false + function () {}; \ No newline at end of file diff --git a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap --- a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap @@ -42,16 +42,21 @@ function f7() { }; } -const f8 = function(a) {}.bind(null, 0); - -const f9 = function(a) {}["bind"](null, 0); - -const called = function () {}(); - const f10 = function(x) { return 0, 1; } +const as = function () {} as () => void; +const satisfies = function () {} satisfies () => void; +const unary = +function () {}; +const conditionalTest = function () {} ? true : false; +class ExtendsClause extends function() {} {}; +const non_null_assertion = function () {}!; +const call = function () {}(); +const staticMember = function(a) {}.bind(null, 0); +const computedMember = function(a) {}["bind"](null, 0); +const logical = false || function () {}; +const binary = false + function () {}; ``` # Diagnostics diff --git a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap --- a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap @@ -268,16 +273,19 @@ invalid.ts:30:12 lint/complexity/useArrowFunction FIXABLE ━━━━━━ ``` ``` -invalid.ts:39:12 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.ts:39:13 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function expression can be turned into an arrow function. 37 │ } 38 │ - > 39 │ const f8 = function(a) {}.bind(null, 0); - │ ^^^^^^^^^^^^^^ - 40 │ - 41 │ const f9 = function(a) {}["bind"](null, 0); + > 39 │ const f10 = function(x) { + │ ^^^^^^^^^^^^^ + > 40 │ return 0, 1; + > 41 │ } + │ ^ + 42 │ + 43 │ const as = function () {} as () => void; i Function expressions that don't use this can be turned into arrow functions. diff --git a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap --- a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/invalid.ts.snap @@ -285,91 +293,265 @@ invalid.ts:39:12 lint/complexity/useArrowFunction FIXABLE ━━━━━━ 37 37 │ } 38 38 │ - 39 │ - const·f8·=·function(a)·{}.bind(null,·0); - 39 │ + const·f8·=·((a)·=>·{}).bind(null,·0); - 40 40 │ - 41 41 │ const f9 = function(a) {}["bind"](null, 0); + 39 │ - const·f10·=·function(x)·{ + 40 │ - ····return·0,·1; + 41 │ - } + 39 │ + const·f10·=·(x)·=>·(0,·1) + 42 40 │ + 43 41 │ const as = function () {} as () => void; ``` ``` -invalid.ts:41:12 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.ts:43:12 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function expression can be turned into an arrow function. - 39 │ const f8 = function(a) {}.bind(null, 0); - 40 │ - > 41 │ const f9 = function(a) {}["bind"](null, 0); - │ ^^^^^^^^^^^^^^ + 41 │ } 42 │ - 43 │ const called = function () {}(); + > 43 │ const as = function () {} as () => void; + │ ^^^^^^^^^^^^^^ + 44 │ const satisfies = function () {} satisfies () => void; + 45 │ const unary = +function () {}; i Function expressions that don't use this can be turned into arrow functions. i Safe fix: Use an arrow function instead. - 39 39 │ const f8 = function(a) {}.bind(null, 0); - 40 40 │ - 41 │ - const·f9·=·function(a)·{}["bind"](null,·0); - 41 │ + const·f9·=·((a)·=>·{})["bind"](null,·0); + 41 41 │ } 42 42 │ - 43 43 │ const called = function () {}(); + 43 │ - const·as·=·function·()·{}·as·()·=>·void; + 43 │ + const·as·=·(()·=>·{})·as·()·=>·void; + 44 44 │ const satisfies = function () {} satisfies () => void; + 45 45 │ const unary = +function () {}; ``` ``` -invalid.ts:43:16 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.ts:44:19 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function expression can be turned into an arrow function. - 41 │ const f9 = function(a) {}["bind"](null, 0); - 42 │ - > 43 │ const called = function () {}(); - │ ^^^^^^^^^^^^^^ - 44 │ - 45 │ const f10 = function(x) { + 43 │ const as = function () {} as () => void; + > 44 │ const satisfies = function () {} satisfies () => void; + │ ^^^^^^^^^^^^^^ + 45 │ const unary = +function () {}; + 46 │ const conditionalTest = function () {} ? true : false; i Function expressions that don't use this can be turned into arrow functions. i Safe fix: Use an arrow function instead. - 41 41 │ const f9 = function(a) {}["bind"](null, 0); 42 42 │ - 43 │ - const·called·=·function·()·{}(); - 43 │ + const·called·=·(()·=>·{})(); - 44 44 │ - 45 45 │ const f10 = function(x) { + 43 43 │ const as = function () {} as () => void; + 44 │ - const·satisfies·=·function·()·{}·satisfies·()·=>·void; + 44 │ + const·satisfies·=·(()·=>·{})·satisfies·()·=>·void; + 45 45 │ const unary = +function () {}; + 46 46 │ const conditionalTest = function () {} ? true : false; ``` ``` -invalid.ts:45:13 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.ts:45:16 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! This function expression can be turned into an arrow function. - 43 │ const called = function () {}(); - 44 │ - > 45 │ const f10 = function(x) { - │ ^^^^^^^^^^^^^ - > 46 │ return 0, 1; - > 47 │ } - │ ^ - 48 │ + 43 │ const as = function () {} as () => void; + 44 │ const satisfies = function () {} satisfies () => void; + > 45 │ const unary = +function () {}; + │ ^^^^^^^^^^^^^^ + 46 │ const conditionalTest = function () {} ? true : false; + 47 │ class ExtendsClause extends function() {} {}; + + i Function expressions that don't use this can be turned into arrow functions. + + i Safe fix: Use an arrow function instead. + + 43 43 │ const as = function () {} as () => void; + 44 44 │ const satisfies = function () {} satisfies () => void; + 45 │ - const·unary·=·+function·()·{}; + 45 │ + const·unary·=·+(()·=>·{}); + 46 46 │ const conditionalTest = function () {} ? true : false; + 47 47 │ class ExtendsClause extends function() {} {}; + + +``` + +``` +invalid.ts:46:25 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! This function expression can be turned into an arrow function. + + 44 │ const satisfies = function () {} satisfies () => void; + 45 │ const unary = +function () {}; + > 46 │ const conditionalTest = function () {} ? true : false; + │ ^^^^^^^^^^^^^^ + 47 │ class ExtendsClause extends function() {} {}; + 48 │ const non_null_assertion = function () {}!; + + i Function expressions that don't use this can be turned into arrow functions. + + i Safe fix: Use an arrow function instead. + + 44 44 │ const satisfies = function () {} satisfies () => void; + 45 45 │ const unary = +function () {}; + 46 │ - const·conditionalTest·=·function·()·{}·?·true·:·false; + 46 │ + const·conditionalTest·=·(()·=>·{})·?·true·:·false; + 47 47 │ class ExtendsClause extends function() {} {}; + 48 48 │ const non_null_assertion = function () {}!; + + +``` + +``` +invalid.ts:48:28 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! This function expression can be turned into an arrow function. + + 46 │ const conditionalTest = function () {} ? true : false; + 47 │ class ExtendsClause extends function() {} {}; + > 48 │ const non_null_assertion = function () {}!; + │ ^^^^^^^^^^^^^^ + 49 │ const call = function () {}(); + 50 │ const staticMember = function(a) {}.bind(null, 0); + + i Function expressions that don't use this can be turned into arrow functions. + + i Safe fix: Use an arrow function instead. + + 46 46 │ const conditionalTest = function () {} ? true : false; + 47 47 │ class ExtendsClause extends function() {} {}; + 48 │ - const·non_null_assertion·=·function·()·{}!; + 48 │ + const·non_null_assertion·=·(()·=>·{})!; + 49 49 │ const call = function () {}(); + 50 50 │ const staticMember = function(a) {}.bind(null, 0); + + +``` + +``` +invalid.ts:49:14 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! This function expression can be turned into an arrow function. + + 47 │ class ExtendsClause extends function() {} {}; + 48 │ const non_null_assertion = function () {}!; + > 49 │ const call = function () {}(); + │ ^^^^^^^^^^^^^^ + 50 │ const staticMember = function(a) {}.bind(null, 0); + 51 │ const computedMember = function(a) {}["bind"](null, 0); + + i Function expressions that don't use this can be turned into arrow functions. + + i Safe fix: Use an arrow function instead. + + 47 47 │ class ExtendsClause extends function() {} {}; + 48 48 │ const non_null_assertion = function () {}!; + 49 │ - const·call·=·function·()·{}(); + 49 │ + const·call·=·(()·=>·{})(); + 50 50 │ const staticMember = function(a) {}.bind(null, 0); + 51 51 │ const computedMember = function(a) {}["bind"](null, 0); + + +``` + +``` +invalid.ts:50:22 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! This function expression can be turned into an arrow function. + + 48 │ const non_null_assertion = function () {}!; + 49 │ const call = function () {}(); + > 50 │ const staticMember = function(a) {}.bind(null, 0); + │ ^^^^^^^^^^^^^^ + 51 │ const computedMember = function(a) {}["bind"](null, 0); + 52 │ const logical = false || function () {}; + + i Function expressions that don't use this can be turned into arrow functions. + + i Safe fix: Use an arrow function instead. + + 48 48 │ const non_null_assertion = function () {}!; + 49 49 │ const call = function () {}(); + 50 │ - const·staticMember·=·function(a)·{}.bind(null,·0); + 50 │ + const·staticMember·=·((a)·=>·{}).bind(null,·0); + 51 51 │ const computedMember = function(a) {}["bind"](null, 0); + 52 52 │ const logical = false || function () {}; + + +``` + +``` +invalid.ts:51:24 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! This function expression can be turned into an arrow function. + + 49 │ const call = function () {}(); + 50 │ const staticMember = function(a) {}.bind(null, 0); + > 51 │ const computedMember = function(a) {}["bind"](null, 0); + │ ^^^^^^^^^^^^^^ + 52 │ const logical = false || function () {}; + 53 │ const binary = false + function () {}; + + i Function expressions that don't use this can be turned into arrow functions. + + i Safe fix: Use an arrow function instead. + + 49 49 │ const call = function () {}(); + 50 50 │ const staticMember = function(a) {}.bind(null, 0); + 51 │ - const·computedMember·=·function(a)·{}["bind"](null,·0); + 51 │ + const·computedMember·=·((a)·=>·{})["bind"](null,·0); + 52 52 │ const logical = false || function () {}; + 53 53 │ const binary = false + function () {}; + + +``` + +``` +invalid.ts:52:26 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! This function expression can be turned into an arrow function. + + 50 │ const staticMember = function(a) {}.bind(null, 0); + 51 │ const computedMember = function(a) {}["bind"](null, 0); + > 52 │ const logical = false || function () {}; + │ ^^^^^^^^^^^^^^ + 53 │ const binary = false + function () {}; + + i Function expressions that don't use this can be turned into arrow functions. + + i Safe fix: Use an arrow function instead. + + 50 50 │ const staticMember = function(a) {}.bind(null, 0); + 51 51 │ const computedMember = function(a) {}["bind"](null, 0); + 52 │ - const·logical·=·false·||·function·()·{}; + 52 │ + const·logical·=·false·||·(()·=>·{}); + 53 53 │ const binary = false + function () {}; + + +``` + +``` +invalid.ts:53:24 lint/complexity/useArrowFunction FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + ! This function expression can be turned into an arrow function. + + 51 │ const computedMember = function(a) {}["bind"](null, 0); + 52 │ const logical = false || function () {}; + > 53 │ const binary = false + function () {}; + │ ^^^^^^^^^^^^^^ i Function expressions that don't use this can be turned into arrow functions. i Safe fix: Use an arrow function instead. - 43 43 │ const called = function () {}(); - 44 44 │ - 45 │ - const·f10·=·function(x)·{ - 46 │ - ····return·0,·1; - 47 │ - } - 45 │ + const·f10·=·(x)·=>·(0,·1) - 48 46 │ + 51 51 │ const computedMember = function(a) {}["bind"](null, 0); + 52 52 │ const logical = false || function () {}; + 53 │ - const·binary·=·false·+·function·()·{}; + 53 │ + const·binary·=·false·+·(()·=>·{}); ``` diff --git a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/valid.ts b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/valid.ts --- a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/valid.ts +++ b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/valid.ts @@ -84,3 +84,5 @@ export default function() { const usingNewTarget = function () { return new.target; } + +class ExtendsClause extends (function() {}) {} diff --git a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/valid.ts.snap b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/valid.ts.snap --- a/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/valid.ts.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/useArrowFunction/valid.ts.snap @@ -91,6 +91,8 @@ const usingNewTarget = function () { return new.target; } +class ExtendsClause extends (function() {}) {} + ```
🐛 useArrowFunction exception in operator expression ? ### Environment information ```block CLI: Version: 1.5.1 Color support: true Platform: CPU Architecture: x86_64 OS: macos Environment: BIOME_LOG_DIR: unset NO_COLOR: unset TERM: "xterm-256color" JS_RUNTIME_VERSION: "v20.9.0" JS_RUNTIME_NAME: "node" NODE_PACKAGE_MANAGER: "npm/10.1.0" Biome Configuration: Status: unset Workspace: Open Documents: 0 ``` ### What happened? ```js const _setImmediate = (typeof setImmediate === 'function' && function (fn) { setImmediate(fn); }) || function (fn) { setTimeout(fn, 0); }; ``` after `check --apply` ```js const _setImmediate = (typeof setImmediate === 'function' && (fn) => { setImmediate(fn); }) || (fn) => { setTimeout(fn, 0); }; ``` > Uncaught SyntaxError: Malformed arrow function parameter list ### Expected result ```js const _setImmediate = (typeof setImmediate === 'function' && ((fn) => { setImmediate(fn); })) || ((fn) => { setTimeout(fn, 0); }); ``` Arrow functions should be wrapped with `()` ? ### Code of Conduct - [X] I agree to follow Biome's Code of Conduct
2024-01-11T12:29:29Z
0.4
2024-01-11T17:23:34Z
b8cf046560376b8b19042b95a518e45bdcbbac22
[ "analyzers::correctness::no_nonoctal_decimal_escape::tests::test_get_unicode_escape", "analyzers::correctness::no_nonoctal_decimal_escape::tests::test_is_octal_escape_sequence", "analyzers::correctness::no_nonoctal_decimal_escape::tests::test_parse_escape_sequences", "analyzers::suspicious::no_control_characters_in_regex::tests::test_collect_control_characters", "assists::correctness::organize_imports::test_order", "globals::browser::test_order", "globals::node::test_order", "globals::runtime::test_order", "aria_services::tests::test_extract_attributes", "globals::typescript::test_order", "semantic_analyzers::nursery::no_misleading_character_class::tests::test_replace_escaped_unicode", "react::hooks::test::test_is_react_hook_call", "react::hooks::test::ok_react_stable_captures_with_default_import", "react::hooks::test::ok_react_stable_captures", "utils::batch::tests::ok_remove_formal_parameter_first", "semantic_analyzers::correctness::no_constant_condition::tests::test_get_boolean_value", "utils::batch::tests::ok_remove_formal_parameter_from_class_constructor_second", "utils::batch::tests::ok_remove_first_member", "utils::batch::tests::ok_remove_formal_parameter_from_class_constructor_middle", "utils::batch::tests::ok_remove_formal_parameter_from_class_constructor_single", "utils::batch::tests::ok_remove_formal_parameter_from_class_constructor_second_trailing_comma", "utils::batch::tests::ok_remove_formal_parameter_from_class_constructor_first", "utils::batch::tests::ok_remove_formal_parameter_middle", "tests::suppression_syntax", "utils::batch::tests::ok_remove_formal_parameter_second_trailing_comma", "utils::batch::tests::ok_remove_formal_parameter_single", "utils::batch::tests::ok_remove_formal_parameter_second", "utils::batch::tests::ok_remove_variable_declarator_fist", "utils::batch::tests::ok_remove_last_member", "utils::case::tests::test_case_convert", "utils::batch::tests::ok_remove_only_member", "utils::batch::tests::ok_remove_middle_member", "utils::batch::tests::ok_remove_last_member_trailing_comma", "utils::batch::tests::ok_remove_variable_declarator_second", "utils::batch::tests::ok_remove_variable_declarator_second_trailling_comma", "utils::batch::tests::ok_remove_variable_declarator_single", "utils::batch::tests::ok_remove_variable_declarator_middle", "tests::quick_test", "utils::rename::tests::nok_rename_declaration_conflict_after", "utils::rename::tests::nok_rename_function_conflict", "utils::rename::tests::nok_rename_declaration_conflict_before", "utils::rename::tests::nok_rename_read_reference", "utils::rename::tests::nok_rename_read_reference_conflict_hoisting_same_scope", "utils::rename::tests::ok_rename_declaration", "utils::rename::tests::nok_rename_read_reference_conflict_hoisting_outer_scope", "utils::rename::tests::nok_rename_write_reference", "utils::rename::tests::ok_rename_declaration_with_multiple_declarators", "utils::rename::tests::ok_rename_declaration_inner_scope", "utils::rename::tests::nok_rename_read_reference_parent_scope_conflict", "utils::rename::tests::ok_rename_read_reference", "utils::rename::tests::ok_rename_read_before_initit", "utils::test::find_variable_position_matches_on_right", "utils::test::find_variable_position_matches_on_left", "utils::test::find_variable_position_not_match", "utils::tests::ok_find_attributes_by_name", "utils::rename::tests::ok_rename_function_same_name", "utils::rename::tests::ok_rename_write_before_init", "utils::rename::tests::ok_rename_trivia_is_kept", "utils::rename::tests::ok_rename_write_reference", "tests::suppression", "utils::rename::tests::cannot_find_declaration", "utils::rename::tests::cannot_be_renamed", "specs::complexity::no_excessive_cognitive_complexity::boolean_operators2_options_json", "specs::complexity::no_excessive_cognitive_complexity::boolean_operators_options_json", "specs::a11y::no_autofocus::valid_jsx", "specs::a11y::no_aria_unsupported_elements::valid_jsx", "specs::a11y::no_redundant_roles::valid_jsx", "specs::a11y::no_access_key::valid_jsx", "specs::a11y::no_noninteractive_tabindex::valid_jsx", "specs::a11y::no_aria_hidden_on_focusable::valid_jsx", "no_double_equals_jsx", "specs::a11y::use_anchor_content::valid_jsx", "simple_js", "specs::a11y::use_aria_activedescendant_with_tabindex::invalid_js", "specs::a11y::use_aria_activedescendant_with_tabindex::valid_js", "specs::a11y::use_button_type::with_binding_valid_js", "specs::a11y::use_key_with_click_events::invalid_jsx", "specs::a11y::no_blank_target::valid_jsx", "invalid_jsx", "specs::a11y::use_button_type::with_default_namespace_invalid_js", "specs::a11y::use_valid_lang::valid_jsx", "specs::a11y::use_valid_aria_props::valid_jsx", "specs::a11y::no_positive_tabindex::valid_jsx_jsx", "specs::a11y::use_valid_aria_role::valid_jsx", "specs::a11y::use_aria_props_for_role::valid_jsx", "specs::a11y::use_valid_aria_values::valid_jsx", "specs::a11y::use_button_type::with_renamed_import_invalid_js", "specs::a11y::use_valid_anchor::valid_jsx", "specs::complexity::no_banned_types::valid_ts", "specs::a11y::use_iframe_title::valid_jsx", "specs::a11y::no_distracting_elements::invalid_jsx", "specs::a11y::use_key_with_mouse_events::valid_jsx", "specs::a11y::no_redundant_alt::valid_jsx", "specs::a11y::no_header_scope::valid_jsx", "specs::a11y::use_html_lang::valid_jsx", "specs::a11y::use_valid_lang::invalid_jsx", "specs::a11y::use_key_with_click_events::valid_jsx", "specs::a11y::no_svg_without_title::valid_jsx", "no_undeclared_variables_ts", "specs::a11y::no_svg_without_title::invalid_jsx", "specs::complexity::no_excessive_cognitive_complexity::complex_event_handler_ts", "specs::a11y::no_noninteractive_element_to_interactive_role::valid_jsx", "specs::a11y::use_heading_content::valid_jsx", "specs::a11y::no_positive_tabindex::react_create_element_valid_js", "specs::a11y::use_button_type::in_jsx_jsx", "specs::a11y::use_button_type::with_binding_invalid_js", "specs::a11y::use_media_caption::valid_jsx", "specs::complexity::no_excessive_cognitive_complexity::boolean_operators2_js", "specs::complexity::no_excessive_cognitive_complexity::boolean_operators_js", "specs::a11y::use_media_caption::invalid_jsx", "specs::complexity::no_excessive_cognitive_complexity::get_words_options_json", "specs::a11y::no_interactive_element_to_noninteractive_role::valid_jsx", "specs::a11y::use_anchor_content::invalid_jsx", "specs::complexity::no_excessive_cognitive_complexity::functional_chain_options_json", "specs::complexity::no_excessive_cognitive_complexity::invalid_config_options_json", "specs::complexity::no_excessive_cognitive_complexity::lambdas_options_json", "specs::a11y::no_noninteractive_tabindex::invalid_jsx", "specs::a11y::no_positive_tabindex::react_create_element_invalid_js", "no_double_equals_js", "specs::complexity::no_excessive_cognitive_complexity::excessive_nesting_js", "specs::a11y::use_alt_text::area_jsx", "specs::a11y::use_alt_text::object_jsx", "specs::a11y::no_blank_target::invalid_jsx", "specs::a11y::no_header_scope::invalid_jsx", "specs::a11y::no_aria_hidden_on_focusable::invalid_jsx", "specs::a11y::use_valid_aria_props::invalid_jsx", "specs::a11y::no_aria_unsupported_elements::invalid_jsx", "specs::complexity::no_excessive_cognitive_complexity::sum_of_primes_options_json", "specs::a11y::no_access_key::invalid_jsx", "specs::complexity::no_excessive_cognitive_complexity::functional_chain_js", "specs::a11y::use_key_with_mouse_events::invalid_jsx", "specs::a11y::use_iframe_title::invalid_jsx", "specs::complexity::no_excessive_cognitive_complexity::nested_control_flow_structures_options_json", "specs::a11y::use_html_lang::invalid_jsx", "specs::complexity::no_excessive_cognitive_complexity::simple_branches2_options_json", "specs::complexity::no_useless_constructor::valid_decorator_options_json", "specs::complexity::no_excessive_cognitive_complexity::simple_branches_options_json", "specs::a11y::no_autofocus::invalid_jsx", "specs::a11y::use_button_type::in_object_js", "specs::a11y::use_valid_aria_role::invalid_jsx", "specs::a11y::use_alt_text::input_jsx", "specs::a11y::use_heading_content::invalid_jsx", "specs::a11y::use_valid_anchor::invalid_jsx", "specs::a11y::no_positive_tabindex::invalid_jsx", "specs::a11y::use_valid_aria_values::invalid_jsx", "specs::a11y::no_redundant_alt::invalid_jsx", "specs::a11y::use_alt_text::img_jsx", "specs::a11y::use_aria_props_for_role::invalid_jsx", "specs::complexity::no_useless_empty_export::valid_export_js", "specs::complexity::no_useless_empty_export::valid_empty_export_js", "specs::complexity::no_excessive_cognitive_complexity::valid_js", "specs::complexity::no_extra_boolean_cast::valid_js", "specs::complexity::no_useless_catch::valid_js", "specs::complexity::no_useless_type_constraint::valid_ts", "specs::complexity::no_multiple_spaces_in_regular_expression_literals::valid_jsonc", "specs::complexity::no_useless_fragments::user_defined_valid_jsx", "specs::complexity::no_useless_fragments::valid_jsx", "specs::complexity::no_this_in_static::valid_js", "specs::complexity::no_useless_fragments::not_fragment_valid_jsx", "specs::complexity::no_useless_constructor::valid_ts", "specs::complexity::no_useless_fragments::from_import_rename_valid_jsx", "specs::complexity::no_useless_empty_export::invalid_with_empty_export_js", "specs::complexity::no_useless_fragments::with_jsx_element_invalid_jsx", "specs::complexity::no_useless_fragments::from_import_namespace_invalid_jsx", "specs::complexity::no_useless_catch::invalid_js", "specs::complexity::use_flat_map::valid_jsonc", "specs::complexity::no_useless_fragments::with_jsx_expression_child_invalid_jsx", "specs::complexity::no_useless_empty_export::invalid_with_export_js", "specs::complexity::no_useless_empty_export::invalid_with_default_export_js", "specs::complexity::no_useless_fragments::assigments_jsx", "specs::complexity::no_useless_constructor::invalid_ts", "specs::complexity::no_useless_empty_export::invalid_with_export_from_js", "specs::complexity::no_for_each::valid_js", "specs::complexity::no_useless_constructor::valid_decorator_js", "specs::complexity::no_useless_empty_export::invalid_with_sideeffect_import_js", "specs::complexity::no_useless_fragments::from_import_valid_jsx", "specs::complexity::no_static_only_class::valid_ts", "specs::complexity::no_excessive_cognitive_complexity::nested_control_flow_structures_js", "specs::complexity::no_useless_switch_case::valid_js", "specs::complexity::no_void::valid_js", "specs::complexity::no_excessive_cognitive_complexity::simple_branches_js", "specs::complexity::no_with::invalid_cjs", "specs::complexity::no_useless_fragments::issue_4639_jsx", "specs::complexity::use_literal_keys::valid_ts", "specs::complexity::no_useless_fragments::issue_3668_jsx", "specs::complexity::no_excessive_cognitive_complexity::get_words_js", "specs::complexity::no_static_only_class::invalid_ts", "specs::complexity::no_useless_empty_export::invalid_with_import_js", "specs::complexity::no_useless_fragments::with_jsx_text_invalid_jsx", "specs::complexity::no_useless_constructor::invalid_js", "specs::complexity::no_useless_fragments::issue_459_jsx", "specs::correctness::no_initializer_with_definite::valid_ts", "specs::complexity::no_excessive_cognitive_complexity::simple_branches2_js", "specs::correctness::no_global_object_calls::valid_import_js", "specs::complexity::use_literal_keys::valid_js", "specs::complexity::no_excessive_cognitive_complexity::invalid_config_js", "specs::complexity::no_void::invalid_js", "specs::correctness::no_duplicate_private_class_members::valid_js", "specs::complexity::use_simple_number_keys::valid_js", "specs::complexity::no_useless_this_alias::valid_js", "specs::complexity::no_excessive_cognitive_complexity::sum_of_primes_js", "specs::correctness::no_inner_declarations::invalid_module_cjs", "specs::complexity::no_for_each::invalid_js", "specs::complexity::use_arrow_function::valid_ts", "specs::complexity::no_useless_label::valid_jsonc", "specs::correctness::no_children_prop::no_children_prop_invalid_jsx", "specs::correctness::no_inner_declarations::valid_moduke_ts", "specs::complexity::no_useless_constructor::valid_jsonc", "specs::complexity::no_useless_fragments::component_fragment_jsx", "specs::complexity::no_excessive_cognitive_complexity::lambdas_js", "specs::complexity::no_useless_fragments::from_import_invalid_jsx", "specs::complexity::use_simplified_logic_expression::valid_jsonc", "specs::correctness::no_initializer_with_definite::invalid_ts", "specs::correctness::no_constructor_return::valid_js", "specs::correctness::no_empty_pattern::valid_jsonc", "specs::correctness::no_children_prop::no_children_prop_valid_jsx", "specs::correctness::no_empty_character_class_in_regex::valid_js", "specs::complexity::no_useless_rename::valid_js", "specs::complexity::no_useless_fragments::with_children_jsx", "specs::correctness::no_inner_declarations::valid_block_scoped_func_decl_js", "specs::correctness::no_nonoctal_decimal_escape::valid_js", "specs::correctness::no_inner_declarations::valid_module_js", "specs::complexity::no_useless_fragments::with_comments_invalid_jsx", "specs::correctness::no_new_symbol::valid_js", "specs::correctness::no_self_assign::issue548_js", "specs::correctness::no_setter_return::valid_js", "specs::complexity::no_useless_fragments::from_import_rename_invalid_jsx", "specs::correctness::no_constructor_return::invalid_js", "specs::correctness::no_invalid_new_builtin::valid_js", "specs::correctness::no_string_case_mismatch::valid_jsonc", "specs::complexity::no_useless_fragments::no_children_jsx", "specs::correctness::no_undeclared_variables::infer_ts", "specs::correctness::no_undeclared_variables::invalid_ts_in_js_js", "specs::correctness::no_undeclared_variables::type_parameters_ts", "specs::complexity::no_useless_type_constraint::invalid_tsx", "specs::correctness::no_render_return_value::valid_import_tsx", "specs::correctness::no_empty_pattern::invalid_jsonc", "specs::complexity::use_simplified_logic_expression::invalid_jsonc", "specs::correctness::no_undeclared_variables::no_undeclared_variables_js", "specs::complexity::no_useless_switch_case::invalid_js", "specs::correctness::no_invalid_constructor_super::valid_ts", "specs::correctness::no_switch_declarations::valid_jsonc", "specs::correctness::no_undeclared_variables::infer_incorrect_ts", "specs::correctness::no_undeclared_variables::no_undeclared_variables_ts", "specs::correctness::no_unreachable::js_continue_statement_js", "specs::correctness::no_undeclared_variables::invalid_type_value_with_same_name_ts", "specs::correctness::no_super_without_extends::invalid_js", "specs::correctness::no_render_return_value::valid_global_tsx", "specs::correctness::no_render_return_value::valid_local_tsx", "specs::correctness::no_undeclared_variables::valid_ts_globals_ts", "specs::correctness::no_unreachable::js_return_statement_js", "specs::correctness::no_unreachable::js_break_statement_js", "specs::correctness::no_precision_loss::valid_js", "specs::complexity::no_useless_constructor::invalid_jsonc", "specs::correctness::no_unreachable::js_do_while_statement_js", "specs::correctness::no_empty_character_class_in_regex::invalid_js", "specs::correctness::no_inner_declarations::valid_jsonc", "specs::complexity::use_flat_map::invalid_jsonc", "specs::correctness::no_unreachable::js_for_statement_js", "specs::correctness::no_self_assign::valid_js", "specs::correctness::no_render_return_value::invalid_global_tsx", "specs::correctness::no_unreachable::issue_3654_js", "specs::correctness::no_unreachable::js_while_statement_js", "specs::correctness::no_unreachable::js_for_of_statement_js", "specs::correctness::no_unreachable::js_try_statement_js", "specs::complexity::use_optional_chain::complex_logical_and_cases_ts", "specs::correctness::no_unreachable::js_for_in_statement_js", "specs::correctness::no_unsafe_optional_chaining::invalid_cjs", "specs::correctness::no_unreachable::js_throw_statement_js", "specs::correctness::no_unreachable::js_if_statement_js", "specs::correctness::no_unused_labels::valid_js", "specs::correctness::no_unreachable::js_switch_statement_js", "specs::correctness::no_unreachable::js_labeled_statement_js", "specs::correctness::no_duplicate_private_class_members::invalid_js", "specs::correctness::no_new_symbol::invalid_jsonc", "specs::correctness::no_unreachable::js_try_finally_statement_js", "specs::correctness::no_unreachable::js_variable_statement_js", "specs::correctness::no_global_object_calls::valid_js", "specs::correctness::no_unreachable::nested_functions_js", "specs::correctness::no_unused_variables::invalid_class_ts", "specs::correctness::no_unused_variables::invalid_enum_ts", "specs::correctness::no_unreachable::nested_blocks_js", "specs::correctness::no_unused_variables::invalid_type_ts", "specs::correctness::no_unreachable_super::valid_js", "specs::complexity::no_useless_this_alias::invalid_js", "specs::correctness::no_unused_variables::invalid_interface_ts", "specs::correctness::no_unused_variables::valid_class_and_interface_export_ts", "specs::correctness::no_unused_variables::invalidtypeof_ts", "specs::correctness::no_unreachable::terminators_plurals_js", "specs::correctness::no_unused_variables::valid_for_statement_js", "specs::correctness::no_invalid_new_builtin::invalid_js", "specs::correctness::no_unused_variables::issue104_ts", "specs::correctness::no_unused_variables::valid_enum_ts", "specs::correctness::no_switch_declarations::invalid_jsonc", "specs::correctness::no_unused_variables::valid_issue861_js", "specs::complexity::no_multiple_spaces_in_regular_expression_literals::invalid_jsonc", "specs::correctness::no_invalid_constructor_super::invalid_js", "specs::correctness::no_unused_variables::valid_value_export_type_ts", "specs::correctness::no_render_return_value::invalid_import_tsx", "specs::correctness::no_unused_variables::valid_import_ts", "specs::correctness::no_unused_variables::valid_variable_and_export_ts", "specs::correctness::no_unused_variables::invalid_import_ts", "specs::correctness::no_unused_variables::valid_declare_ts", "specs::correctness::no_unused_variables::valid_export_ts", "specs::correctness::no_unused_variables::valid_abstract_class_ts", "specs::correctness::no_unused_variables::definitionfile_d_ts", "specs::correctness::no_unused_variables::valid_functions_ts", "specs::correctness::no_unused_variables::valid_interface_ts", "specs::correctness::no_unreachable::suppression_comments_js", "specs::correctness::no_unused_variables::valid_class_ts", "specs::correctness::no_unreachable_super::this_before_super_js", "specs::correctness::no_unused_variables::valid_function_type_ts", "specs::correctness::no_unsafe_finally::valid_js", "specs::correctness::no_unsafe_optional_chaining::valid_js", "specs::complexity::use_regex_literals::valid_jsonc", "specs::correctness::no_unreachable_super::duplicate_super_js", "specs::correctness::no_unused_variables::valid_inner_used_js", "specs::correctness::no_unused_variables::invalid_type_value_same_names_ts", "specs::correctness::use_exhaustive_dependencies::custom_hook_options_json", "specs::complexity::use_optional_chain::valid_cases_ts", "specs::correctness::no_unnecessary_continue::valid_js", "specs::correctness::no_unreachable::high_complexity_js", "specs::correctness::use_exhaustive_dependencies::malformed_options_options_json", "specs::correctness::use_hook_at_top_level::deprecated_config_options_json", "specs::correctness::no_unused_variables::invalid_recursive_functions_js", "specs::correctness::organize_imports::empty_line_js", "specs::correctness::no_unused_variables::valid_variables_tsx", "specs::correctness::no_inner_declarations::invalid_jsonc", "specs::correctness::no_unsafe_optional_chaining::valid_arithmetic_js", "specs::correctness::organize_imports::directives_js", "specs::correctness::no_unreachable_super::missing_super_js", "specs::correctness::use_hook_at_top_level::custom_hook_js", "specs::correctness::no_void_type_return::valid_ts", "specs::correctness::organize_imports::sorted_js", "specs::correctness::no_unused_variables::valid_with_self_assign_js", "specs::correctness::no_unused_variables::invalid_method_parameters_ts", "specs::complexity::no_useless_label::invalid_jsonc", "specs::correctness::no_unused_variables::valid_type_param_ts", "specs::correctness::no_switch_declarations::invalid_ts", "specs::correctness::organize_imports::empty_line_whitespace_js", "specs::correctness::organize_imports::duplicate_js", "specs::correctness::organize_imports::interpreter_js", "specs::correctness::organize_imports::comments_js", "specs::correctness::organize_imports::non_import_newline_js", "specs::correctness::organize_imports::group_comment_js", "specs::correctness::organize_imports::non_import_js", "specs::correctness::organize_imports::natural_sort_js", "specs::correctness::no_unused_variables::invalid_type_param_ts", "specs::nursery::no_empty_type_parameters::valid_ts", "specs::correctness::organize_imports::remaining_content_js", "specs::nursery::no_global_assign::valid_js", "specs::correctness::no_void_type_return::invalid_ts", "specs::correctness::use_exhaustive_dependencies::newline_js", "specs::correctness::use_hook_at_top_level::valid_ts", "specs::correctness::use_exhaustive_dependencies::check_hooks_imported_from_react_js", "specs::correctness::use_exhaustive_dependencies::malformed_options_js", "specs::correctness::no_self_assign::invalid_js", "specs::correctness::use_hook_at_top_level::invalid_ts", "specs::correctness::use_hook_at_top_level::deprecated_config_js", "specs::correctness::use_yield::valid_js", "specs::correctness::no_void_elements_with_children::create_element_js", "specs::correctness::use_hook_at_top_level::invalid_jsx", "specs::nursery::no_empty_block_statements::valid_js", "specs::nursery::no_empty_block_statements::valid_ts", "specs::correctness::organize_imports::groups_js", "specs::nursery::no_unused_imports::issue557_ts", "specs::correctness::use_exhaustive_dependencies::extra_dependencies_invalid_js", "specs::nursery::no_type_only_import_attributes::valid_js", "specs::nursery::no_nodejs_modules::invalid_cjs_cjs", "specs::nursery::no_type_only_import_attributes::valid_ts", "specs::nursery::no_empty_type_parameters::invalid_ts", "specs::nursery::no_invalid_use_before_declaration::invalid_ts", "specs::nursery::no_empty_block_statements::valid_cjs", "specs::correctness::use_yield::invalid_js", "specs::correctness::use_exhaustive_dependencies::valid_ts", "specs::nursery::no_invalid_use_before_declaration::valid_ts", "specs::nursery::no_invalid_use_before_declaration::valid_js", "specs::correctness::no_unsafe_finally::invalid_js", "specs::nursery::no_global_eval::validtest_cjs", "specs::correctness::no_setter_return::invalid_js", "specs::nursery::use_consistent_array_type::valid_generic_options_json", "specs::nursery::use_consistent_array_type::invalid_shorthand_options_json", "specs::correctness::use_valid_for_direction::invalid_jsonc", "specs::correctness::use_exhaustive_dependencies::custom_hook_js", "specs::correctness::no_constant_condition::valid_jsonc", "specs::complexity::no_extra_boolean_cast::invalid_js", "specs::nursery::no_global_assign::invalid_js", "specs::nursery::no_unused_imports::valid_js", "specs::nursery::no_misleading_character_class::valid_js", "specs::nursery::no_invalid_use_before_declaration::invalid_js", "specs::nursery::no_useless_ternary::valid_js", "specs::correctness::use_hook_at_top_level::valid_js", "specs::complexity::no_useless_type_constraint::invalid_ts", "specs::correctness::use_valid_for_direction::valid_jsonc", "specs::nursery::no_empty_block_statements::invalid_js", "specs::nursery::no_type_only_import_attributes::invalid_ts", "specs::nursery::use_filenaming_convention::invalid_camel_case_options_json", "specs::nursery::use_filenaming_convention::invalid_kebab_case_options_json", "specs::nursery::no_global_eval::valid_js", "specs::correctness::use_is_nan::valid_js", "specs::nursery::use_filenaming_convention::invalid_snake_case_options_json", "specs::nursery::use_filenaming_convention::__u_n_d_e_r_s_c_o_r_e_i_n_v_a_l_i_d_js", "specs::nursery::use_filenaming_convention::malformed_options_empty_filename_cases_options_json", "specs::nursery::no_empty_block_statements::invalid_ts", "specs::nursery::use_filenaming_convention::malformed_options_options_json", "specs::nursery::use_filenaming_convention::valid_exported_const_options_json", "specs::nursery::use_filenaming_convention::_underscorevalid_js", "specs::correctness::no_precision_loss::invalid_js", "specs::nursery::use_filenaming_convention::valid_camel_case_js", "specs::nursery::use_filenaming_convention::_valid_js", "specs::nursery::use_filenaming_convention::filename_invalid_extension_js", "specs::correctness::no_unused_variables::inavlid_self_write_js", "specs::nursery::use_filenaming_convention::filename_test_invalid_extension_ts", "specs::nursery::no_useless_lone_block_statements::valid_module_js", "specs::nursery::use_filenaming_convention::i_n_v_a_l_i_d_js", "specs::nursery::use_filenaming_convention::valid_pascal_case_options_json", "specs::nursery::use_filenaming_convention::valid_s_trict_case_options_json", "specs::nursery::use_filenaming_convention::invalid_pascal_case_js", "specs::nursery::use_filenaming_convention::invalid_camel_case_js", "specs::nursery::use_filenaming_convention::invalid_s_trict_case_js", "specs::nursery::use_filenaming_convention::invalid_snake_case_js", "specs::nursery::no_useless_lone_block_statements::valid_cjs", "specs::nursery::use_filenaming_convention::malformed_options_empty_filename_cases_js", "specs::nursery::use_filenaming_convention::valid_my_class_js", "specs::nursery::use_consistent_array_type::valid_generic_ts", "specs::nursery::no_useless_ternary::invalid_js", "specs::correctness::no_string_case_mismatch::invalid_jsonc", "specs::nursery::no_useless_lone_block_statements::invalid_cjs", "specs::nursery::use_filenaming_convention::valid_s_trict_case_js", "specs::nursery::use_consistent_array_type::valid_ts", "specs::nursery::use_filenaming_convention::valid_exported_const_js", "specs::nursery::use_await::valid_js", "specs::nursery::use_grouped_type_import::valid_ts", "specs::nursery::use_filenaming_convention::invalid_kebab_case_js", "specs::nursery::use_filenaming_convention::valid_js", "specs::correctness::organize_imports::named_specifiers_js", "specs::nursery::use_filenaming_convention::malformed_options_js", "specs::nursery::use_filenaming_convention::valid_kebab_case_js", "specs::nursery::use_await::invalid_js", "specs::nursery::use_export_type::valid_ts", "specs::correctness::no_unreachable::merge_ranges_js", "specs::nursery::use_filenaming_convention::valid_snake_case_js", "specs::nursery::no_global_eval::invalid_js", "specs::nursery::use_import_type::invalid_namesapce_imports_ts", "specs::nursery::use_nodejs_import_protocol::valid_js", "specs::nursery::use_import_type::valid_combined_ts", "specs::nursery::use_import_type::valid_named_imports_ts", "specs::nursery::use_filenaming_convention::valid_pascal_case_js", "specs::nursery::use_import_type::valid_default_imports_ts", "specs::nursery::use_import_restrictions::valid_package_private_imports_js", "specs::security::no_dangerously_set_inner_html::create_element_binding_valid_js", "specs::nursery::use_import_type::valid_namespace_imports_ts", "specs::nursery::use_number_namespace::valid_js", "specs::nursery::no_unused_private_class_members::valid_js", "specs::nursery::use_import_type::valid_unused_ts", "specs::nursery::use_number_namespace::invalid_properties_value_shorthand_js", "specs::security::no_dangerously_set_inner_html::react_create_element_js", "specs::nursery::use_import_restrictions::invalid_package_private_imports_js", "specs::style::no_default_export::valid_js", "specs::style::no_implicit_boolean::valid_jsx", "specs::security::no_dangerously_set_inner_html::create_element_binding_invalid_js", "specs::style::no_namespace::invalid_ts", "specs::security::no_dangerously_set_inner_html::inside_jsx_jsx", "specs::nursery::use_import_type::invalid_default_imports_ts", "specs::nursery::use_shorthand_function_type::valid_ts", "specs::nursery::no_then_property::valid_js", "specs::style::no_default_export::valid_cjs", "specs::style::no_namespace::valid_ts", "specs::style::no_parameter_properties::valid_ts", "specs::performance::no_delete::valid_jsonc", "specs::performance::no_accumulating_spread::valid_jsonc", "specs::style::no_comma_operator::valid_jsonc", "specs::style::no_restricted_globals::additional_global_options_json", "specs::style::no_arguments::invalid_cjs", "specs::style::no_negation_else::valid_js", "specs::style::no_restricted_globals::invalid_jsonc", "specs::style::no_restricted_globals::valid_js", "specs::security::no_dangerously_set_inner_html_with_children::create_element_js", "specs::style::no_shouty_constants::valid_js", "specs::style::no_non_null_assertion::valid_ts", "specs::style::no_restricted_globals::additional_global_js", "specs::style::no_unused_template_literal::valid_js", "specs::style::no_var::invalid_module_js", "specs::style::no_var::valid_jsonc", "specs::style::no_default_export::invalid_json", "specs::correctness::no_unnecessary_continue::invalid_js", "specs::style::no_implicit_boolean::invalid_jsx", "specs::style::no_parameter_properties::invalid_ts", "specs::style::no_inferrable_types::valid_ts", "specs::nursery::no_useless_lone_block_statements::invalid_module_js", "specs::security::no_dangerously_set_inner_html_with_children::in_jsx_jsx", "specs::correctness::no_void_elements_with_children::in_jsx_jsx", "specs::performance::no_delete::invalid_jsonc", "specs::performance::no_accumulating_spread::invalid_jsonc", "specs::style::no_comma_operator::invalid_jsonc", "specs::style::no_useless_else::missed_js", "specs::style::use_as_const_assertion::valid_ts", "specs::style::no_useless_else::valid_js", "specs::style::use_default_parameter_last::valid_ts", "specs::nursery::use_import_type::invalid_named_imports_ts", "specs::style::use_enum_initializers::valid_ts", "specs::style::use_collapsed_else_if::valid_js", "specs::style::use_const::valid_partial_js", "specs::nursery::use_grouped_type_import::invalid_ts", "specs::complexity::no_useless_rename::invalid_js", "specs::style::no_var::invalid_functions_js", "specs::nursery::use_for_of::valid_js", "specs::complexity::no_banned_types::invalid_ts", "specs::nursery::use_for_of::invalid_js", "specs::correctness::no_unused_variables::invalid_variables_ts", "specs::style::use_default_parameter_last::valid_js", "specs::style::use_exponentiation_operator::valid_local_math_js", "specs::correctness::use_exhaustive_dependencies::valid_js", "specs::style::use_fragment_syntax::valid_jsx", "specs::style::no_parameter_assign::invalid_jsonc", "specs::nursery::no_unused_private_class_members::invalid_ts", "specs::style::use_exponentiation_operator::valid_js", "specs::complexity::use_simple_number_keys::invalid_js", "specs::style::use_exponentiation_operator::invalid_without_autofix_js", "specs::style::use_naming_convention::invalid_enum_member_ts", "specs::complexity::use_literal_keys::invalid_ts", "specs::style::use_naming_convention::invalid_class_static_getter_js", "specs::style::use_naming_convention::invalid_class_method_js", "specs::style::use_literal_enum_members::valid_ts", "specs::correctness::use_exhaustive_dependencies::missing_dependencies_invalid_js", "specs::style::use_naming_convention::invalid_enum_ts", "specs::style::no_var::invalid_script_jsonc", "specs::style::use_naming_convention::invalid_export_alias_js", "specs::correctness::use_hook_at_top_level::invalid_js", "specs::style::no_shouty_constants::invalid_js", "specs::nursery::no_unused_imports::invalid_ts", "specs::style::use_naming_convention::invalid_class_setter_js", "specs::style::use_naming_convention::invalid_class_static_setter_js", "specs::style::use_naming_convention::invalid_class_getter_js", "specs::style::use_naming_convention::invalid_class_static_method_js", "specs::style::use_naming_convention::invalid_export_namespace_js", "specs::correctness::no_constant_condition::invalid_jsonc", "specs::correctness::no_unused_variables::invalid_function_ts", "specs::style::use_naming_convention::invalid_class_property_js", "specs::style::use_naming_convention::invalid_class_js", "specs::style::use_fragment_syntax::invalid_jsx", "specs::style::use_naming_convention::invalid_object_getter_js", "specs::style::use_naming_convention::invalid_object_setter_js", "specs::style::use_naming_convention::invalid_parameter_property_ts", "specs::style::use_naming_convention::invalid_object_property_js", "specs::style::use_naming_convention::invalid_catch_parameter_js", "specs::style::use_naming_convention::invalid_type_getter_ts", "specs::correctness::no_global_object_calls::invalid_js", "specs::style::no_negation_else::invalid_js", "specs::correctness::no_unused_labels::invalid_js", "specs::style::use_naming_convention::invalid_import_namespace_js", "specs::style::use_naming_convention::invalid_object_method_js", "specs::style::use_default_parameter_last::invalid_js", "specs::style::use_naming_convention::invalid_index_parameter_ts", "specs::style::use_literal_enum_members::invalid_ts", "specs::style::use_naming_convention::malformed_options_options_json", "specs::style::use_naming_convention::valid_class_non_strict_pascal_case_options_json", "specs::style::use_naming_convention::invalid_type_property_ts", "specs::nursery::use_export_type::invalid_ts", "specs::style::no_parameter_assign::valid_jsonc", "specs::style::use_naming_convention::invalid_function_js", "specs::style::use_naming_convention::invalid_top_level_variable_ts", "specs::style::use_exponentiation_operator::invalid_with_comments_js", "specs::style::use_naming_convention::invalid_function_parameter_js", "specs::style::use_naming_convention::valid_enum_member_camel_case_options_json", "specs::style::use_naming_convention::valid_class_getter_js", "specs::style::use_naming_convention::invalid_type_method_ts", "specs::style::use_naming_convention::valid_class_js", "specs::style::use_naming_convention::valid_class_method_js", "specs::style::use_naming_convention::valid_enum_member_constant_case_options_json", "specs::style::use_collapsed_else_if::invalid_js", "specs::style::use_naming_convention::valid_export_source_js", "specs::style::use_naming_convention::valid_enum_ts", "specs::style::use_naming_convention::valid_class_static_getter_js", "specs::style::use_naming_convention::valid_class_non_strict_pascal_case_js", "specs::style::use_naming_convention::malformed_options_js", "specs::style::use_naming_convention::invalid_type_parameter_ts", "specs::style::use_naming_convention::valid_catch_parameter_js", "specs::style::use_naming_convention::valid_function_parameter_js", "specs::style::use_naming_convention::valid_export_alias_js", "specs::style::use_naming_convention::invalid_type_readonly_property_ts", "specs::style::use_naming_convention::valid_class_setter_js", "specs::style::use_naming_convention::valid_import_alias_js", "specs::nursery::use_import_type::invalid_combined_ts", "specs::style::use_naming_convention::valid_import_source_js", "specs::style::use_naming_convention::valid_enum_member_camel_case_ts", "specs::style::use_naming_convention::valid_enum_member_ts", "specs::style::use_naming_convention::valid_index_parameter_ts", "specs::style::use_naming_convention::valid_namespace_ts", "specs::style::use_naming_convention::valid_object_getter_js", "specs::style::use_naming_convention::valid_export_namespace_js", "specs::style::use_naming_convention::valid_import_namespace_js", "specs::style::use_naming_convention::valid_class_static_method_js", "specs::style::use_naming_convention::valid_function_js", "specs::style::use_naming_convention::valid_interface_ts", "specs::style::use_naming_convention::valid_enum_member_constant_case_ts", "specs::style::use_naming_convention::valid_class_static_property_js", "specs::style::use_naming_convention::valid_class_property_js", "specs::style::use_naming_convention::valid_object_setter_js", "specs::style::use_naming_convention::valid_class_static_setter_js", "specs::style::use_exponentiation_operator::invalid_class_ts", "specs::style::use_naming_convention::invalid_namespace_ts", "specs::style::use_naming_convention::valid_type_property_ts", "specs::nursery::no_unused_private_class_members::invalid_js", "specs::style::use_naming_convention::valid_type_getter_ts", "specs::style::use_naming_convention::invalid_type_setter_ts", "specs::style::use_numeric_literals::overriden_js", "specs::style::use_naming_convention::valid_type_readonly_property_ts", "specs::style::use_single_var_declarator::valid_js", "specs::style::use_shorthand_assign::valid_js", "specs::style::use_naming_convention::valid_local_variable_js", "specs::style::use_naming_convention::valid_object_property_js", "specs::style::use_self_closing_elements::valid_tsx", "specs::style::use_naming_convention::valid_object_method_js", "specs::style::use_naming_convention::valid_type_alias_ts", "specs::style::use_naming_convention::valid_type_setter_ts", "specs::style::use_naming_convention::valid_type_parameter_ts", "specs::style::use_naming_convention::valid_type_method_ts", "specs::complexity::no_this_in_static::invalid_js", "specs::nursery::no_unused_imports::invalid_jsx", "specs::style::use_naming_convention::valid_top_level_variable_ts", "specs::style::use_template::valid_js", "specs::style::use_single_case_statement::valid_js", "specs::style::use_naming_convention::invalid_type_alias_ts", "specs::style::use_shorthand_array_type::valid_ts", "specs::suspicious::no_approximative_numeric_constant::valid_js", "specs::style::use_naming_convention::valid_parameter_property_ts", "specs::suspicious::no_assign_in_expressions::valid_js", "specs::style::use_exponentiation_operator::invalid_unary_expression_js", "specs::style::use_naming_convention::invalid_import_alias_js", "specs::suspicious::no_catch_assign::invalid_js", "specs::style::use_while::valid_js", "specs::style::use_numeric_literals::valid_js", "specs::suspicious::no_async_promise_executor::invalid_jsonc", "specs::style::use_default_parameter_last::invalid_ts", "specs::style::use_naming_convention::invalid_interface_ts", "specs::nursery::use_shorthand_function_type::invalid_ts", "specs::correctness::no_unsafe_optional_chaining::invalid_js", "specs::suspicious::no_confusing_labels::valid_jsonc", "specs::nursery::no_then_property::invalid_js", "specs::suspicious::no_console_log::invalid_js", "specs::suspicious::no_comment_text::valid_tsx", "specs::suspicious::no_console_log::valid_js", "specs::style::use_while::invalid_js", "specs::suspicious::no_double_equals::valid_jsonc", "specs::suspicious::no_async_promise_executor::valid_jsonc", "specs::suspicious::no_double_equals::invalid_jsonc", "specs::suspicious::no_control_characters_in_regex::valid_js", "specs::suspicious::no_empty_interface::valid_d_ts", "specs::suspicious::no_confusing_void_type::valid_ts", "specs::suspicious::no_compare_neg_zero::valid_jsonc", "specs::suspicious::no_confusing_labels::invalid_jsonc", "specs::suspicious::no_class_assign::valid_js", "specs::suspicious::no_compare_neg_zero::invalid_comments_js", "specs::suspicious::no_double_equals::invalid_jsx", "specs::suspicious::no_const_enum::invalid_ts", "specs::suspicious::no_empty_interface::valid_ts", "specs::suspicious::no_approximative_numeric_constant::invalid_js", "specs::nursery::no_unused_imports::invalid_js", "specs::suspicious::no_duplicate_parameters::valid_jsonc", "specs::suspicious::no_duplicate_case::valid_js", "specs::suspicious::no_class_assign::invalid_js", "specs::style::use_enum_initializers::invalid_ts", "specs::style::use_naming_convention::invalid_local_variable_js", "specs::suspicious::no_duplicate_jsx_props::valid_jsx", "specs::suspicious::no_empty_interface::invalid_ts", "specs::suspicious::no_comment_text::invalid_tsx", "specs::suspicious::no_duplicate_jsx_props::invalid_jsx", "specs::suspicious::no_duplicate_class_members::valid_js", "specs::suspicious::no_explicit_any::valid_type_constraints_ts", "specs::suspicious::no_debugger::invalid_js", "specs::style::use_self_closing_elements::invalid_tsx", "specs::suspicious::no_array_index_key::valid_jsx", "specs::style::use_single_var_declarator::invalid_js", "specs::suspicious::no_global_is_finite::valid_js", "specs::style::no_unused_template_literal::invalid_js", "specs::suspicious::no_global_is_nan::valid_js", "specs::suspicious::no_explicit_any::valid_ts", "specs::suspicious::no_import_assign::valid_js", "specs::suspicious::no_explicit_any::invalid_variable_ts", "specs::style::use_exponentiation_operator::invalid_base_expoent_higher_precedence_js", "specs::suspicious::no_extra_non_null_assertion::valid_ts", "specs::style::use_const::valid_jsonc", "specs::suspicious::no_implicit_any_let::valid_ts", "specs::suspicious::no_implicit_any_let::invalid_ts", "specs::suspicious::no_fallthrough_switch_clause::valid_js", "specs::suspicious::no_duplicate_object_keys::valid_jsonc", "specs::suspicious::no_label_var::valid_js", "specs::suspicious::no_function_assign::valid_jsonc", "specs::suspicious::no_double_equals::invalid_js", "specs::suspicious::no_control_characters_in_regex::invalid_js", "specs::suspicious::no_redeclare::valid_mapped_types_ts", "specs::suspicious::no_misleading_instantiator::valid_ts", "specs::suspicious::no_redeclare::invalid_ts", "specs::suspicious::no_redeclare::invalid_declaration_merging_ts", "specs::suspicious::no_assign_in_expressions::invalid_js", "specs::suspicious::no_redundant_use_strict::valid_cjs", "specs::suspicious::no_redeclare::valid_index_signatures_ts", "specs::suspicious::no_label_var::invalid_js", "specs::suspicious::no_compare_neg_zero::invalid_jsonc", "specs::suspicious::no_redeclare::valid_modules_ts", "specs::suspicious::no_redundant_use_strict::valid_react_directives_tsx", "specs::suspicious::no_misrefactored_shorthand_assign::valid_js", "specs::suspicious::no_duplicate_parameters::invalid_ts", "specs::suspicious::no_redeclare::valid_duplicate_ts", "specs::suspicious::no_redeclare::valid_method_type_param_ts", "specs::suspicious::no_redundant_use_strict::invalid_function_cjs", "specs::suspicious::no_function_assign::invalid_jsonc", "specs::suspicious::no_redundant_use_strict::invalid_function_js", "specs::suspicious::no_explicit_any::invalid_type_and_interface_ts", "specs::suspicious::no_redeclare::valid_jsonc", "specs::suspicious::no_explicit_any::invalid_class_ts", "specs::suspicious::no_redundant_use_strict::invalid_ts", "specs::suspicious::no_prototype_builtins::invalid_js", "specs::suspicious::no_import_assign::invalid_js", "specs::suspicious::no_misleading_instantiator::invalid_ts", "specs::suspicious::no_prototype_builtins::valid_js", "specs::suspicious::no_unsafe_negation::valid_jsonc", "specs::suspicious::use_namespace_keyword::valid_ts", "specs::style::no_non_null_assertion::invalid_ts", "specs::suspicious::no_shadow_restricted_names::invalid_jsonc", "specs::suspicious::no_confusing_void_type::invalid_ts", "specs::suspicious::no_duplicate_class_members::invalid_js", "specs::suspicious::no_explicit_any::invalid_function_ts", "specs::suspicious::no_unsafe_declaration_merging::invalid_ts", "specs::suspicious::no_unsafe_declaration_merging::valid_ts", "specs::suspicious::no_sparse_array::valid_js", "ts_module_export_ts", "specs::suspicious::use_valid_typeof::valid_jsonc", "specs::suspicious::no_redundant_use_strict::invalid_class_cjs", "specs::style::use_single_case_statement::invalid_js", "specs::suspicious::use_default_switch_clause_last::valid_js", "specs::suspicious::use_is_array::valid_js", "specs::suspicious::no_redundant_use_strict::invalid_cjs", "specs::suspicious::use_is_array::valid_shadowing_js", "specs::suspicious::no_unsafe_negation::invalid_jsonc", "specs::suspicious::no_self_compare::valid_jsonc", "specs::suspicious::no_redeclare::invalid_jsonc", "specs::suspicious::no_sparse_array::invalid_jsonc", "specs::suspicious::no_redundant_use_strict::invalid_js", "specs::suspicious::use_default_switch_clause_last::invalid_js", "specs::suspicious::use_namespace_keyword::invalid_ts", "specs::suspicious::use_valid_typeof::invalid_jsonc", "specs::suspicious::use_getter_return::valid_js", "specs::suspicious::no_redeclare::valid_declaration_merging_ts", "specs::suspicious::use_is_array::invalid_js", "specs::suspicious::no_fallthrough_switch_clause::invalid_js", "specs::nursery::use_consistent_array_type::invalid_shorthand_ts", "specs::suspicious::no_self_compare::invalid_jsonc", "specs::suspicious::use_getter_return::invalid_js", "specs::suspicious::no_duplicate_case::invalid_js", "specs::suspicious::no_array_index_key::invalid_jsx", "specs::suspicious::no_global_is_finite::invalid_js", "specs::suspicious::no_duplicate_object_keys::invalid_jsonc", "specs::style::use_exponentiation_operator::invalid_base_expoent_lower_precedence_js", "specs::correctness::no_const_assign::invalid_js", "specs::suspicious::no_global_is_nan::invalid_js", "specs::style::use_const::invalid_jsonc", "specs::style::use_exponentiation_operator::invalid_parents_with_lower_precedence_js", "specs::nursery::use_consistent_array_type::invalid_ts", "specs::style::no_useless_else::invalid_js", "specs::style::use_shorthand_array_type::invalid_ts", "specs::style::use_as_const_assertion::invalid_ts", "specs::suspicious::no_misrefactored_shorthand_assign::invalid_js", "specs::style::use_block_statements::invalid_js", "specs::complexity::use_regex_literals::invalid_jsonc", "specs::style::use_exponentiation_operator::invalid_parents_with_higher_precedence_js", "specs::style::use_exponentiation_operator::invalid_adjacent_tokens_js", "specs::complexity::use_arrow_function::invalid_ts", "specs::suspicious::no_extra_non_null_assertion::invalid_ts", "specs::style::use_shorthand_assign::invalid_js", "specs::a11y::no_redundant_roles::invalid_jsx", "specs::complexity::use_literal_keys::invalid_js", "specs::nursery::no_nodejs_modules::invalid_esm_js", "specs::style::no_inferrable_types::invalid_ts", "specs::correctness::no_nonoctal_decimal_escape::invalid_js", "specs::complexity::use_optional_chain::logical_and_cases1_js", "specs::style::use_exponentiation_operator::invalid_js", "specs::nursery::use_nodejs_import_protocol::invalid_js", "specs::correctness::use_is_nan::invalid_js", "specs::nursery::use_number_namespace::invalid_js", "specs::complexity::use_optional_chain::logical_and_cases2_js", "no_array_index_key_jsx", "specs::complexity::use_optional_chain::logical_and_cases6_js", "specs::nursery::no_misleading_character_class::invalid_js", "specs::complexity::use_optional_chain::logical_and_cases3_js", "specs::style::use_template::invalid_js", "specs::complexity::use_optional_chain::logical_and_cases5_js", "specs::complexity::use_optional_chain::logical_and_cases4_js", "specs::complexity::use_optional_chain::nullish_and_logical_or1_ts", "specs::a11y::no_interactive_element_to_noninteractive_role::invalid_jsx", "specs::complexity::use_optional_chain::nullish_and_logical_or2_ts", "specs::style::use_numeric_literals::invalid_js", "specs::a11y::no_noninteractive_element_to_interactive_role::invalid_jsx", "crates/biome_js_analyze/src/utils/case.rs - utils::case::Case::identify (line 41)", "crates/biome_js_analyze/src/globals/node.rs - globals::node::is_node_builtin_module (line 238)", "crates/biome_js_analyze/src/utils/case.rs - utils::case::Case::convert (line 185)", "crates/biome_js_analyze/src/utils/case.rs - utils::case::Case::is_compatible_with (line 134)" ]
[]
[]
[]
null
nushell__nushell-13357
nushell/nushell
13,357
[ "13137" ]
5417c89387b67c3192ae9043473b556cd669ee15
"diff --git a/crates/nu-cli/src/syntax_highlight.rs b/crates/nu-cli/src/syntax_highlight.rs\n--- a/c(...TRUNCATED)
"diff --git a/crates/nu-cmd-lang/src/example_support.rs b/crates/nu-cmd-lang/src/example_support.rs\(...TRUNCATED)
"Inconsistent `$in` behavior in `each` closure\n### Describe the bug\n\n```ls | each {$in.name; $in.(...TRUNCATED)
"I don't see the inconsistency but maybe I'm missing the point. I think it's the semicolon that's th(...TRUNCATED)
2024-07-12T01:31:40Z
1.77
2024-07-22T07:20:53Z
5417c89387b67c3192ae9043473b556cd669ee15
["core_commands::const_::test::test_command_type","core_commands::let_::test::test_command_type","co(...TRUNCATED)
["input_types::call_with_list_test","input_types::test_type_annotations::case_05_input_output","inpu(...TRUNCATED)
[]
[]
null
BurntSushi__ripgrep-2626
BurntSushi/ripgrep
2,626
[ "1966", "2635" ]
7099e174acbcbd940f57e4ab4913fee4040c826e
"diff --git a/.cargo/config.toml b/.cargo/config.toml\n--- a/.cargo/config.toml\n+++ b/.cargo/config(...TRUNCATED)
"diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml\n--- a/.github/workflows/ci.yml\n+(...TRUNCATED)
"`rg --unknown-switch` panics on broken pipe error\n#### What version of ripgrep are you using?\r\n\(...TRUNCATED)
"I discovered this in my own project after trying to match ripgrep's panic free printing of `--help`(...TRUNCATED)
2023-10-12T15:22:03Z
13.0
2024-06-23T17:16:03Z
7099e174acbcbd940f57e4ab4913fee4040c826e
[ "gitignore::tests::parse_excludes_file4" ]
["default_types::tests::default_types_are_sorted","gitignore::tests::cs1","gitignore::tests::cs2","g(...TRUNCATED)
[]
[]
null
BurntSushi__ripgrep-2610
BurntSushi/ripgrep
2,610
[ "2483" ]
86ef6833085428c21ef1fb7f2de8e5e7f54f1f72
"diff --git a/.gitignore b/.gitignore\n--- a/.gitignore\n+++ b/.gitignore\n@@ -7,6 +7,7 @@ target\n (...TRUNCATED)
"diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml\n--- a/.github/workflows/ci.yml\n+(...TRUNCATED)
"Add configurable hyperlinks\nThis PR adds hyperlinks to search results in terminals which support t(...TRUNCATED)
"Works well for me. One minor thing I noticed, is that the last colon ist embedded in the link label(...TRUNCATED)
2023-09-21T17:18:23Z
13.0
2023-09-26T21:13:54Z
7099e174acbcbd940f57e4ab4913fee4040c826e
["escape::tests::backslash","escape::tests::carriage","escape::tests::empty","escape::tests::nl","es(...TRUNCATED)
[]
[]
[]
null
clap-rs__clap-3732
clap-rs/clap
3,732
[ "3621" ]
740bb39f50883b5af97b62e041618d5433220245
"diff --git a/.clippy.toml b/.clippy.toml\n--- a/.clippy.toml\n+++ b/.clippy.toml\n@@ -1,1 +1,1 @@\n(...TRUNCATED)
"diff --git a/.github/workflows/rust-next.yml b/.github/workflows/rust-next.yml\n--- a/.github/workf(...TRUNCATED)
"Add an option to not panic on value*of() of non valid arguments\n### Please complete the following (...TRUNCATED)
"It'd help if you explained why you don't want arguments validated.\r\n\r\n> Make so the cargo featu(...TRUNCATED)
2022-05-17T21:47:36Z
3.1
2022-05-18T00:25:21Z
20ed49a535d14afac1972dd3cc3003c97bcc744f
["generator::utils::tests::test_flags","generator::utils::tests::test_all_subcommands","generator::u(...TRUNCATED)
[]
[]
[]
null
clap-rs__clap-3684
clap-rs/clap
3,684
[ "2861" ]
17ec7757891a38965e8492f7a0a48e674a9536eb
"diff --git a/Cargo.toml b/Cargo.toml\n--- a/Cargo.toml\n+++ b/Cargo.toml\n@@ -64,7 +64,7 @@ default(...TRUNCATED)
"diff --git a/tests/builder/subcommands.rs b/tests/builder/subcommands.rs\n--- a/tests/builder/subco(...TRUNCATED)
"Stabilise `AppSettings::Multicall` Tracking Issue\nOriginal request: https://github.com/clap-rs/cla(...TRUNCATED)
"Can you please fill up the known issues that are unresolved from the pr?\n> Can you please fill up (...TRUNCATED)
2022-05-03T21:54:09Z
3.1
2022-05-20T17:42:56Z
20ed49a535d14afac1972dd3cc3003c97bcc744f
["app_settings::missing_positional_no_hyphen","default_vals::default_if_arg_present_no_default_user_(...TRUNCATED)
["builder::arg::test::option_display_multiple_occurrences","builder::arg::test::flag_display_multipl(...TRUNCATED)
["app_settings::require_eq","cargo::crate_authors","cargo::crate_name","command::command","conflicts(...TRUNCATED)
[]
null
clap-rs__clap-3453
clap-rs/clap
3,453
[ "3335" ]
cb06496a0d4adbd1b328ad790777de2345da5e51
"diff --git a/clap_complete/src/shells/zsh.rs b/clap_complete/src/shells/zsh.rs\n--- a/clap_complete(...TRUNCATED)
"diff --git a/tests/builder/help.rs b/tests/builder/help.rs\n--- a/tests/builder/help.rs\n+++ b/test(...TRUNCATED)
"`name` implies a user-facing meaning, causing confusion\nMaintainer's notes:\r\n- The root cause wa(...TRUNCATED)
"```rust\r\nuse clap::Parser;\r\n\r\n#[derive(Debug, Parser)]\r\npub struct Example {\r\n #[clap((...TRUNCATED)
2022-02-11T20:13:32Z
3.0
2022-02-11T20:28:43Z
cb06496a0d4adbd1b328ad790777de2345da5e51
["build::app_tests::app_send_sync","build::app_tests::global_setting","build::app_tests::propagate_v(...TRUNCATED)
[]
[]
[]
null
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
1