Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions crates/oxc_linter/src/generated/rule_runner_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1478,12 +1478,14 @@ impl RuleRunner for crate::rules::jsdoc::empty_tags::EmptyTags {
}

impl RuleRunner for crate::rules::jsdoc::implements_on_classes::ImplementsOnClasses {
const NODE_TYPES: Option<&AstTypesBitset> = None;
const NODE_TYPES: Option<&AstTypesBitset> =
Some(&AstTypesBitset::from_types(&[AstType::ArrowFunctionExpression, AstType::Function]));
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
}

impl RuleRunner for crate::rules::jsdoc::no_defaults::NoDefaults {
const NODE_TYPES: Option<&AstTypesBitset> = None;
const NODE_TYPES: Option<&AstTypesBitset> =
Some(&AstTypesBitset::from_types(&[AstType::ArrowFunctionExpression, AstType::Function]));
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
}

Expand All @@ -1500,7 +1502,8 @@ impl RuleRunner for crate::rules::jsdoc::require_param_description::RequireParam
}

impl RuleRunner for crate::rules::jsdoc::require_param_name::RequireParamName {
const NODE_TYPES: Option<&AstTypesBitset> = None;
const NODE_TYPES: Option<&AstTypesBitset> =
Some(&AstTypesBitset::from_types(&[AstType::ArrowFunctionExpression, AstType::Function]));
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
}

Expand Down Expand Up @@ -1536,12 +1539,14 @@ impl RuleRunner for crate::rules::jsdoc::require_returns::RequireReturns {
}

impl RuleRunner for crate::rules::jsdoc::require_returns_description::RequireReturnsDescription {
const NODE_TYPES: Option<&AstTypesBitset> = None;
const NODE_TYPES: Option<&AstTypesBitset> =
Some(&AstTypesBitset::from_types(&[AstType::ArrowFunctionExpression, AstType::Function]));
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
}

impl RuleRunner for crate::rules::jsdoc::require_returns_type::RequireReturnsType {
const NODE_TYPES: Option<&AstTypesBitset> = None;
const NODE_TYPES: Option<&AstTypesBitset> =
Some(&AstTypesBitset::from_types(&[AstType::ArrowFunctionExpression, AstType::Function]));
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
}

Expand Down
27 changes: 14 additions & 13 deletions crates/oxc_linter/src/rules/jsdoc/implements_on_classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use oxc_span::Span;

use crate::{
AstNode,
ast_util::is_function_node,
context::LintContext,
rule::Rule,
utils::{get_function_nearest_jsdoc_node, should_ignore_as_internal, should_ignore_as_private},
Expand Down Expand Up @@ -76,8 +75,10 @@ fn is_function_inside_of_class<'a, 'b>(node: &'b AstNode<'a>, ctx: &'b LintConte

impl Rule for ImplementsOnClasses {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
if !is_function_node(node) {
return;
match node.kind() {
AstKind::Function(f) if f.is_function_declaration() || f.is_expression() => {}
AstKind::ArrowFunctionExpression(_) => {}
_ => return,
}

// Filter plain declared (arrow) function.
Expand Down Expand Up @@ -136,7 +137,7 @@ fn test() {
* @class
*/
function quux () {

}
",
None,
Expand All @@ -149,7 +150,7 @@ fn test() {
* @constructor
*/
function quux () {

}
",
None,
Expand All @@ -162,7 +163,7 @@ fn test() {
* @constructor
*/
const quux = () => {

}
",
None,
Expand All @@ -178,7 +179,7 @@ fn test() {
* @implements {SomeClass}
*/
constructor () {

}
}
",
Expand All @@ -195,7 +196,7 @@ fn test() {
* @implements {SomeClass}
*/
constructor () {

}
}
",
Expand All @@ -212,7 +213,7 @@ fn test() {
* @implements {SomeClass}
*/
foo() {

}
}
",
Expand All @@ -225,7 +226,7 @@ fn test() {
*
*/
function quux () {

}
",
None,
Expand Down Expand Up @@ -260,7 +261,7 @@ fn test() {
* @implements {SomeClass}
*/
function quux () {

}
",
None,
Expand All @@ -272,7 +273,7 @@ fn test() {
* @implements {SomeClass}
*/
const quux = () => {

}
",
None,
Expand All @@ -285,7 +286,7 @@ fn test() {
* @implements {SomeClass}
*/
const quux = function() {

}
",
None,
Expand Down
8 changes: 5 additions & 3 deletions crates/oxc_linter/src/rules/jsdoc/no_defaults.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use serde::Deserialize;

use crate::{
AstNode,
ast_util::is_function_node,
context::LintContext,
rule::Rule,
utils::{get_function_nearest_jsdoc_node, should_ignore_as_internal, should_ignore_as_private},
Expand Down Expand Up @@ -66,8 +66,10 @@ impl Rule for NoDefaults {
}

fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
if !is_function_node(node) {
return;
match node.kind() {
AstKind::Function(f) if f.is_function_declaration() || f.is_expression() => {}
AstKind::ArrowFunctionExpression(_) => {}
_ => return,
}

let Some(jsdocs) = get_function_nearest_jsdoc_node(node, ctx)
Expand Down
16 changes: 9 additions & 7 deletions crates/oxc_linter/src/rules/jsdoc/require_param_name.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;

use crate::{
AstNode,
ast_util::is_function_node,
context::LintContext,
rule::Rule,
utils::{get_function_nearest_jsdoc_node, should_ignore_as_internal, should_ignore_as_private},
Expand Down Expand Up @@ -48,8 +48,10 @@ declare_oxc_lint!(

impl Rule for RequireParamName {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
if !is_function_node(node) {
return;
match node.kind() {
AstKind::Function(f) if f.is_function_declaration() || f.is_expression() => {}
AstKind::ArrowFunctionExpression(_) => {}
_ => return,
}

// If no JSDoc is found, skip
Expand Down Expand Up @@ -96,7 +98,7 @@ fn test() {
* @param foo
*/
function quux (foo) {

}
",
None,
Expand All @@ -108,7 +110,7 @@ fn test() {
* @param {string} foo
*/
function quux (foo) {

}
",
None,
Expand Down Expand Up @@ -170,7 +172,7 @@ fn test() {
* @param
*/
function quux (foo) {

}
",
None,
Expand All @@ -182,7 +184,7 @@ fn test() {
* @param {string}
*/
function quux (foo) {

}
",
None,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;

use crate::{
AstNode,
ast_util::is_function_node,
context::LintContext,
rule::Rule,
utils::{get_function_nearest_jsdoc_node, should_ignore_as_internal, should_ignore_as_private},
Expand Down Expand Up @@ -49,8 +49,10 @@ declare_oxc_lint!(

impl Rule for RequireReturnsDescription {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
if !is_function_node(node) {
return;
match node.kind() {
AstKind::Function(f) if f.is_function_declaration() || f.is_expression() => {}
AstKind::ArrowFunctionExpression(_) => {}
_ => return,
}

// If no JSDoc is found, skip
Expand Down
8 changes: 5 additions & 3 deletions crates/oxc_linter/src/rules/jsdoc/require_returns_type.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;

use crate::{
AstNode,
ast_util::is_function_node,
context::LintContext,
rule::Rule,
utils::{get_function_nearest_jsdoc_node, should_ignore_as_internal, should_ignore_as_private},
Expand Down Expand Up @@ -48,8 +48,10 @@ declare_oxc_lint!(

impl Rule for RequireReturnsType {
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
if !is_function_node(node) {
return;
match node.kind() {
AstKind::Function(f) if f.is_function_declaration() || f.is_expression() => {}
AstKind::ArrowFunctionExpression(_) => {}
_ => return,
}

// If no JSDoc is found, skip
Expand Down
Loading