Skip to content

Commit

Permalink
chore: add blank line eslint rule (#36369)
Browse files Browse the repository at this point in the history
## Description
Added ESLint rule to force blank lines between statements. 


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags="@tag.All"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]
> 🔴 🔴 🔴 Some tests have failed.
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/10924926728>
> Commit: 34f5771
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10924926728&attempt=1&selectiontype=test&testsstatus=failed&specsstatus=fail"
target="_blank">Cypress dashboard</a>.
> Tags: @tag.All
> Spec: 
> The following are new failures, please fix them before merging the PR:
<ol>
> <li>cypress/e2e/Regression/ClientSide/Anvil/AnvilModal_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilButtonWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilCheckboxGroupWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilCurrencyInputWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilIconButtonWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilInlineButtonWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilInputWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilParagraphWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilPhoneInputWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilStatsWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilSwitchGroupWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilSwitchWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilTableWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilToolbarButtonWidgetSnapshot_spec.ts
>
<li>cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilZoneSectionWidgetSnapshot_spec.ts</ol>
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master"
target="_blank">List of identified flaky tests</a>.
> <hr>Wed, 18 Sep 2024 16:33:36 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No

---------

Co-authored-by: Valera Melnikov <[email protected]>
  • Loading branch information
znamenskii-ilia and KelvinOm authored Sep 18, 2024
1 parent 9f7e624 commit d6f249b
Show file tree
Hide file tree
Showing 1,948 changed files with 13,051 additions and 2 deletions.
24 changes: 23 additions & 1 deletion app/client/.eslintrc.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@
"project": "./tsconfig.json"
},
"rules": {
"padding-line-between-statements": [
"error",
{ "blankLine": "always", "prev": "*", "next": "return" },
{
"blankLine": "always",
"prev": "*",
"next": ["if", "for", "while"]
},
{
"blankLine": "always",
"prev": ["if", "for", "while"],
"next": "*"
},
{ "blankLine": "always", "prev": ["const", "let"], "next": "*" },
{
"blankLine": "any",
"prev": ["const", "let"],
"next": ["const", "let"]
},
{ "blankLine": "always", "prev": "*", "next": "function" },
{ "blankLine": "always", "prev": "function", "next": "*" }
],
"testing-library/consistent-data-testid": [
"warn",
{
Expand Down Expand Up @@ -72,7 +94,7 @@
"react-perf/jsx-no-new-array-as-prop": "warn",
"react-perf/jsx-no-new-function-as-prop": "warn",
"react-perf/jsx-no-jsx-as-prop": "warn",
"react-perf/jsx-no-new-object-as-prop": [
"react-perf/jsx-no-new-object-as-prop": [
"warn",
{
// we are disabling this rule here for native component since it won't make much difference in performance
Expand Down
3 changes: 2 additions & 1 deletion app/client/cypress/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@typescript-eslint/adjacent-overload-signatures": "off",
"jest/no-disabled-tests": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off"
"@typescript-eslint/no-var-requires": "off",
"padding-line-between-statements": "off"
}
}
8 changes: 8 additions & 0 deletions app/client/packages/ast/src/actionCreator/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ describe("getActionBlocks", () => {
"Api1.run(() => setAlert('Success'), () => {});showModal('Modal1')",
2,
);

expect(result).toEqual([
"Api1.run(() => setAlert('Success'), () => {});",
"showModal('Modal1');",
Expand All @@ -162,6 +163,7 @@ describe("getActionBlocks", () => {
it("should return an array of action blocks", () => {
const value = "Api1.run(() => {\n (() => {});\n}, () => {}, {});";
const result = getActionBlocks(value, 2);

expect(result).toEqual([
"Api1.run(() => {\n (() => {});\n}, () => {}, {});",
]);
Expand Down Expand Up @@ -285,6 +287,7 @@ describe("getThenCatchBlocksFromQuery", () => {
it("should return then/catch callbacks appropriately", () => {
const value = "Api1.run().catch(() => { a() }).then(() => { b() });";
const result = getThenCatchBlocksFromQuery(value, 2);

expect(result).toEqual({
then: `() => {\n b();\n}`,
catch: `() => {\n a();\n}`,
Expand Down Expand Up @@ -362,13 +365,16 @@ describe("Tests AST methods around function arguments", function () {
it("Sets argument at 0th index", function () {
const code1 = 'showAlert("", "")';
const modified1 = setTextArgumentAtPosition(code1, "Hello", 0, 2);

expect(modified1).toEqual(`{{showAlert("Hello", "");}}`);

const code2 = 'showAlert("", 2).then(() => "Hello")';
const modified2 = setTextArgumentAtPosition(code2, "Hello", 0, 2);

expect(modified2).toEqual(`{{showAlert("Hello", 2).then(() => "Hello");}}`);

const arg1 = getEnumArgumentAtPosition(code2, 1, "", 2);

expect(arg1).toBe("2");
});
});
Expand Down Expand Up @@ -407,10 +413,12 @@ describe("Test canTranslateToUI methoda", () => {
expected: false,
},
];

test.each(cases.map((x) => [x.index, x.input, x.expected]))(
"test case %d",
(_, input, expected) => {
const result = canTranslateToUI(input as string, 2);

expect(result).toEqual(expected);
},
);
Expand Down
Loading

0 comments on commit d6f249b

Please sign in to comment.