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
16 changes: 8 additions & 8 deletions src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub mod ban_unknown_rule_code;
pub mod ban_untagged_ignore;
pub mod ban_untagged_todo;
pub mod ban_unused_ignore;
pub mod button_has_type;
pub mod camelcase;
pub mod constructor_super;
pub mod default_param_last;
Expand All @@ -28,11 +27,11 @@ pub mod fresh_server_event_handlers;
pub mod getter_return;
pub mod guard_for_in;
pub mod jsx_boolean_value;
pub mod jsx_button_has_type;
pub mod jsx_curly_braces;
pub mod jsx_key;
pub mod jsx_no_children_prop;
pub mod jsx_no_comment_text_nodes;
pub mod jsx_no_danger_with_children;
pub mod jsx_no_duplicate_props;
pub mod jsx_no_unescaped_entities;
pub mod jsx_no_useless_fragment;
Expand All @@ -51,7 +50,6 @@ pub mod no_console;
pub mod no_const_assign;
pub mod no_constant_condition;
pub mod no_control_regex;
pub mod no_danger;
pub mod no_debugger;
pub mod no_delete_var;
pub mod no_deprecated_deno_api;
Expand Down Expand Up @@ -120,9 +118,11 @@ pub mod prefer_ascii;
pub mod prefer_const;
pub mod prefer_namespace_keyword;
pub mod prefer_primordials;
pub mod react_no_danger;
pub mod react_no_danger_with_children;
pub mod react_rules_of_hooks;
pub mod require_await;
pub mod require_yield;
pub mod rules_of_hooks;
pub mod single_var_declarator;
pub mod triple_slash_reference;
pub mod use_isnan;
Expand Down Expand Up @@ -256,7 +256,6 @@ fn get_all_rules_raw() -> Vec<Box<dyn LintRule>> {
Box::new(ban_untagged_ignore::BanUntaggedIgnore),
Box::new(ban_untagged_todo::BanUntaggedTodo),
Box::new(ban_unused_ignore::BanUnusedIgnore),
Box::new(button_has_type::ButtonHasType),
Box::new(camelcase::Camelcase),
Box::new(constructor_super::ConstructorSuper),
Box::new(default_param_last::DefaultParamLast),
Expand All @@ -269,11 +268,11 @@ fn get_all_rules_raw() -> Vec<Box<dyn LintRule>> {
Box::new(getter_return::GetterReturn),
Box::new(guard_for_in::GuardForIn),
Box::new(jsx_boolean_value::JSXBooleanValue),
Box::new(jsx_button_has_type::JSXButtonHasType),
Box::new(jsx_curly_braces::JSXCurlyBraces),
Box::new(jsx_key::JSXKey),
Box::new(jsx_no_children_prop::JSXNoChildrenProp),
Box::new(jsx_no_comment_text_nodes::JSXNoCommentTextNodes),
Box::new(jsx_no_danger_with_children::JSXNoDangerWithChildren),
Box::new(jsx_no_duplicate_props::JSXNoDuplicateProps),
Box::new(jsx_no_unescaped_entities::JSXNoUnescapedEntities),
Box::new(jsx_no_useless_fragment::JSXNoUselessFragment),
Expand All @@ -292,7 +291,6 @@ fn get_all_rules_raw() -> Vec<Box<dyn LintRule>> {
Box::new(no_const_assign::NoConstAssign),
Box::new(no_constant_condition::NoConstantCondition),
Box::new(no_control_regex::NoControlRegex),
Box::new(no_danger::NoDanger),
Box::new(no_debugger::NoDebugger),
Box::new(no_delete_var::NoDeleteVar),
Box::new(no_deprecated_deno_api::NoDeprecatedDenoApi),
Expand Down Expand Up @@ -365,9 +363,11 @@ fn get_all_rules_raw() -> Vec<Box<dyn LintRule>> {
Box::new(prefer_const::PreferConst),
Box::new(prefer_namespace_keyword::PreferNamespaceKeyword),
Box::new(prefer_primordials::PreferPrimordials),
Box::new(react_no_danger::ReactNoDanger),
Box::new(react_no_danger_with_children::ReactNoDangerWithChildren),
Box::new(react_rules_of_hooks::ReactRulesOfHooks),
Box::new(require_await::RequireAwait),
Box::new(require_yield::RequireYield),
Box::new(rules_of_hooks::RulesOfHooks),
Box::new(single_var_declarator::SingleVarDeclarator),
Box::new(triple_slash_reference::TripleSlashReference),
Box::new(use_isnan::UseIsNaN),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use deno_ast::view::{
use deno_ast::{view as ast_view, SourceRanged};

#[derive(Debug)]
pub struct ButtonHasType;
pub struct JSXButtonHasType;

const CODE: &str = "button-has-type";
const CODE: &str = "jsx-button-has-type";

impl LintRule for ButtonHasType {
impl LintRule for JSXButtonHasType {
fn tags(&self) -> Tags {
&[tags::RECOMMENDED, tags::REACT, tags::JSX, tags::FRESH]
}
Expand Down Expand Up @@ -255,7 +255,7 @@ mod tests {
#[test]
fn button_has_type_valid() {
assert_lint_ok! {
ButtonHasType,
JSXButtonHasType,
filename: "file:///foo.jsx",
// non derived classes.
r#"<button type="button" />"#,
Expand Down Expand Up @@ -284,7 +284,7 @@ mod tests {
DiagnosticKind::MissingValue.message_and_hint();

assert_lint_err! {
ButtonHasType,
JSXButtonHasType,
filename: "file:///foo.jsx",
"<button />": [
{
Expand Down
12 changes: 6 additions & 6 deletions src/rules/no_danger.rs → src/rules/react_no_danger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use deno_ast::view::{JSXAttr, JSXAttrName};
use deno_ast::SourceRanged;

#[derive(Debug)]
pub struct NoDanger;
pub struct ReactNoDanger;

const CODE: &str = "no-danger";
const CODE: &str = "react-no-danger";

impl LintRule for NoDanger {
impl LintRule for ReactNoDanger {
fn tags(&self) -> Tags {
&[tags::RECOMMENDED, tags::REACT, tags::JSX]
&[tags::REACT, tags::FRESH]
}

fn code(&self) -> &'static str {
Expand Down Expand Up @@ -54,7 +54,7 @@ mod tests {
#[test]
fn no_danger_valid() {
assert_lint_ok! {
NoDanger,
ReactNoDanger,
filename: "file:///foo.jsx",
// non derived classes.
r#"<div />"#,
Expand All @@ -64,7 +64,7 @@ mod tests {
#[test]
fn no_danger_invalid() {
assert_lint_err! {
NoDanger,
ReactNoDanger,
filename: "file:///foo.jsx",
"<div dangerouslySetInnerHTML />": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ use deno_ast::SourceRanged;
use once_cell::sync::Lazy;

#[derive(Debug)]
pub struct JSXNoDangerWithChildren;
pub struct ReactNoDangerWithChildren;

const CODE: &str = "jsx-no-danger-with-children";
const CODE: &str = "react-no-danger-with-children";

impl LintRule for JSXNoDangerWithChildren {
impl LintRule for ReactNoDangerWithChildren {
fn tags(&self) -> Tags {
&[tags::RECOMMENDED, tags::REACT, tags::JSX, tags::FRESH]
&[tags::REACT, tags::FRESH]
}

fn code(&self) -> &'static str {
Expand Down Expand Up @@ -79,7 +79,7 @@ mod tests {
#[test]
fn jsx_no_danger_with_children_valid() {
assert_lint_ok! {
JSXNoDangerWithChildren,
ReactNoDangerWithChildren,
filename: "file:///foo.jsx",
r#"<div dangerouslySetInnerHTML={{ __html: "foo" }} />"#,
r#"<div dangerouslySetInnerHTML={{ __html: "foo" }}></div>"#,
Expand All @@ -91,7 +91,7 @@ mod tests {
#[test]
fn jsx_no_danger_with_children_invalid() {
assert_lint_err! {
JSXNoDangerWithChildren,
ReactNoDangerWithChildren,
filename: "file:///foo.jsx",
r#"<div dangerouslySetInnerHTML={{ __html: "foo" }}>foo</div>"#: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use deno_ast::SourceRanged;
use once_cell::sync::Lazy;

#[derive(Debug)]
pub struct RulesOfHooks;
pub struct ReactRulesOfHooks;

const CODE: &str = "rules-of-hooks";
const CODE: &str = "react-rules-of-hooks";

impl LintRule for RulesOfHooks {
impl LintRule for ReactRulesOfHooks {
fn tags(&self) -> Tags {
&[tags::RECOMMENDED, tags::REACT, tags::JSX, tags::FRESH]
&[tags::REACT, tags::FRESH]
}

fn code(&self) -> &'static str {
Expand Down Expand Up @@ -279,7 +279,7 @@ mod tests {
#[test]
fn rules_of_hooks_valid() {
assert_lint_ok! {
RulesOfHooks,
ReactRulesOfHooks,
filename: "file:///foo.jsx",
r#"function Foo() { useState(0) }"#,
r#"function useFoo() { useState(0) }"#,
Expand All @@ -302,7 +302,7 @@ function doAThing() {
#[test]
fn rules_of_hooks_invalid() {
assert_lint_err! {
RulesOfHooks,
ReactRulesOfHooks,
filename: "file:///foo.jsx",
r#"function foo() { useState(0) }"#: [
{
Expand Down
Loading