Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fluent-chaining allows chained functions after multi-line class instantiation #62

Open
onebytegone opened this issue Feb 20, 2024 · 0 comments
Assignees

Comments

@onebytegone
Copy link
Contributor

Currently, this passes linting:

// passes
new Class({
   prop: true,
})
   .run();

However, the use of a builder function does not pass linting:

// fails with "Call expression should be on a new line and indented eslint(@silvermine/silvermine/fluent-chaining)"
makeInstance({
   prop: true,
})
   .run();

The case with new Class should also likely fail.

Failing test case:

diff --git a/tests/lib/rules/fluent-chaining.test.js b/tests/lib/rules/fluent-chaining.test.js
index 7639a0b..5900a29 100644
--- a/tests/lib/rules/fluent-chaining.test.js
+++ b/tests/lib/rules/fluent-chaining.test.js
@@ -221,6 +221,20 @@ function checkChainingIndentationError1() {
    };
 }

+function checkChainingIndentationWithConstructorError() {
+   return {
+      code: formatCode(
+         'new Class({',
+         '   prop: true',
+         '})',
+         '   .run();'
+      ),
+      errors: [
+         chainingIndentationMatchErrorMessage(),
+      ],
+   };
+}
+
 // wrong indentation
 function checkChainingIndentationError2() {
    return {
@@ -299,6 +313,11 @@ ruleTester.run('fluent-chaining - checkChainingIndentationError1', fluentChainin
    invalid: [ checkChainingIndentationError1() ],
 });

+ruleTester.run('fluent-chaining - checkChainingIndentationWithConstructorError', fluentChaining, {
+   valid: [],
+   invalid: [ checkChainingIndentationWithConstructorError() ],
+});
+
 ruleTester.run('fluent-chaining - checkChainingIndentationError2', fluentChaining, {
    valid: [],
    invalid: [ checkChainingIndentationError2() ],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants