oxc/crates
DonIsaac f7da22da18 perf(linter): disable lint rules by file type (#4380)
### TL;DR

Added a `should_run` function to multiple lint rules to determine if a rule should be executed based on the source type. This change optimizes the linting process by avoiding unnecessary rule checks.

### What changed?

1. **New Method**: Introduced the `should_run` method in the `Rule` trait.
2. **Implementation**: Implemented the `should_run` method for various lint rules, particularly those related to React and TypeScript.
3. **Usage**: Updated the `Linter` to use the `should_run` method to filter rules before execution.
4. **Macro Update**: Modified the `declare_all_lint_rules` macro to incorporate the `should_run` method.

### How to test?

1. Run the linter on a project containing React and TypeScript files.
2. Verify that only relevant rules are executed based on the file type (e.g., JSX rules for React files).

### Why make this change?

This change improves the performance of the linter by ensuring that only applicable rules are run for a given file type, reducing unnecessary computation and potential false positives.

---
2024-07-21 15:22:54 +00:00
..
oxc Release crates v0.21.0 (#4344) 2024-07-18 14:39:07 +08:00
oxc_allocator Release crates v0.21.0 (#4344) 2024-07-18 14:39:07 +08:00
oxc_ast perf: replace some CompactStr usages with Cows (#4377) 2024-07-20 19:19:55 +00:00
oxc_ast_macros refactor(ast): reduce #[cfg_attr] boilerplate in AST type defs (#4375) 2024-07-20 16:41:16 +00:00
oxc_cfg Release crates v0.21.0 (#4344) 2024-07-18 14:39:07 +08:00
oxc_codegen fix(codegen): object shorthand with parens ({x: (x)}) -> ({ x }) (#4391) 2024-07-21 14:04:17 +00:00
oxc_diagnostics refactor(linter): use diagnostic codes in lint rules (#4349) 2024-07-20 03:35:00 +00:00
oxc_index Release crates v0.21.0 (#4344) 2024-07-18 14:39:07 +08:00
oxc_isolated_declarations fix(codegen): print shorthand for all { x } variants (#4374) 2024-07-21 19:54:21 +08:00
oxc_js_regex
oxc_language_server refactor(linter): use diagnostic codes in lint rules (#4349) 2024-07-20 03:35:00 +00:00
oxc_linter perf(linter): disable lint rules by file type (#4380) 2024-07-21 15:22:54 +00:00
oxc_macros perf(linter): disable lint rules by file type (#4380) 2024-07-21 15:22:54 +00:00
oxc_mangler fix(codegen): print shorthand for all { x } variants (#4374) 2024-07-21 19:54:21 +08:00
oxc_minifier Release crates v0.21.0 (#4344) 2024-07-18 14:39:07 +08:00
oxc_module_lexer Release crates v0.21.0 (#4344) 2024-07-18 14:39:07 +08:00
oxc_parser fix(ast): visit Programs hashbang field first (#4368) 2024-07-19 16:27:51 +00:00
oxc_prettier chore: remove unsafe_code = "warn" rust lint 2024-07-15 10:39:08 +08:00
oxc_semantic perf(semantic): remove a branch from add_scope (#4384) 2024-07-21 12:43:34 +00:00
oxc_sourcemap fix(sourcemap): avoid negative line if token_chunks has same prev_dst_line (#4348) 2024-07-19 18:14:35 +08:00
oxc_span perf: replace some CompactStr usages with Cows (#4377) 2024-07-20 19:19:55 +00:00
oxc_syntax fix(transformer/typescript): unexpectedly removed class binding from ExportNamedDeclaration (#4351) 2024-07-18 16:44:38 +00:00
oxc_transformer Release crates v0.21.0 (#4344) 2024-07-18 14:39:07 +08:00
oxc_traverse perf(semantic): remove a branch from add_scope (#4384) 2024-07-21 12:43:34 +00:00
oxc_wasm refactor(linter): use diagnostic codes in lint rules (#4349) 2024-07-20 03:35:00 +00:00