Skip to content

Commit

Permalink
chore: add vscode color highlight support to test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Rel1cx committed Jul 8, 2024
1 parent f09c4cc commit ea94363
Show file tree
Hide file tree
Showing 66 changed files with 1,169 additions and 1,242 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"dprint.dprint",
"dbaeumer.vscode-eslint"
"dbaeumer.vscode-eslint",
"bierner.comment-tagged-templates"
]
}
18 changes: 17 additions & 1 deletion eslint.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,23 @@ const config: FlatConfig[] = [
},
],
// Part: unicorn rules
"unicorn/template-indent": "warn",
"unicorn/template-indent": [
"warn",
{
comments: [
"outdent",
"dedent",
"html",
"tsx",
],
tags: [
"outdent",
"dedent",
"html",
"tsx",
],
},
],
// Part: eslint-comments rules
"eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
"eslint-comments/no-aggregating-enable": "error",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import dedent from "dedent";

import { allValid, ruleTester } from "../../../../../test";
import rule, { RULE_NAME } from "./class-component";

ruleTester.run(RULE_NAME, rule, {
invalid: [
{
code: dedent`
code: /* tsx */ `
class ParentComponent extends React.Component {
render() {
return <div />;
Expand All @@ -16,7 +14,7 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: "CLASS_COMPONENT" }],
},
{
code: dedent`
code: /* tsx */ `
const ClassComponent = class extends React.Component {
render() {
return <div />;
Expand All @@ -26,7 +24,7 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: "CLASS_COMPONENT" }],
},
{
code: dedent`
code: /* tsx */ `
function ParentComponent() {
class UnstableNestedClassComponent extends React.Component {
render() {
Expand All @@ -44,7 +42,7 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: "CLASS_COMPONENT" }],
},
{
code: dedent`
code: /* tsx */ `
class ParentComponent extends React.Component {
render() {
class UnstableNestedClassComponent extends React.Component {
Expand All @@ -67,7 +65,7 @@ ruleTester.run(RULE_NAME, rule, {
],
},
{
code: dedent`
code: /* tsx */ `
class ParentComponent extends React.Component {
render() {
class UnstableNestedClassComponent extends React.Component {
Expand All @@ -90,7 +88,7 @@ ruleTester.run(RULE_NAME, rule, {
],
},
{
code: dedent`
code: /* tsx */ `
class ParentComponent extends React.Component {
render() {
function UnstableNestedFunctionComponent() {
Expand All @@ -108,7 +106,7 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: "CLASS_COMPONENT" }],
},
{
code: dedent`
code: /* tsx */ `
class ParentComponent extends React.Component {
render() {
function UnstableNestedClassComponent() {
Expand All @@ -126,7 +124,7 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: "CLASS_COMPONENT" }],
},
{
code: dedent`
code: /* tsx */ `
class ParentComponent extends React.Component {
render() {
const UnstableNestedVariableComponent = () => {
Expand All @@ -144,25 +142,25 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: "CLASS_COMPONENT" }],
},
{
code: `
class ParentComponent extends React.Component {
render() {
const UnstableNestedClassComponent = () => {
return React.createElement("div", null);
}
return React.createElement(
"div",
null,
React.createElement(UnstableNestedClassComponent, null)
);
}
code: /* tsx */ `
class ParentComponent extends React.Component {
render() {
const UnstableNestedClassComponent = () => {
return React.createElement("div", null);
}
`,
return React.createElement(
"div",
null,
React.createElement(UnstableNestedClassComponent, null)
);
}
}
`,
errors: [{ messageId: "CLASS_COMPONENT" }],
},
{
code: dedent`
code: /* tsx */ `
class ParentComponent extends React.Component {
render() {
const List = () => {
Expand All @@ -176,7 +174,7 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: "CLASS_COMPONENT" }],
},
{
code: dedent`
code: /* tsx */ `
class ParentComponent extends React.Component {
render() {
const List = (props) => {
Expand Down
Loading

0 comments on commit ea94363

Please sign in to comment.