Skip to content

Conversation

@waximabbax
Copy link
Contributor

@waximabbax waximabbax commented Nov 18, 2024

For: https://coda.io/d/_dW9bnkUghpB/Coding-Conventions_supcbaNC#_lucUnu9p

Since we are going this route where we should define a function like function foo() {} instead of const foo = () => {}.

Most of the AI-generated code uses the arrow function in these scenarios it might help to warn developers while testing.

This will still allow arrow functions in callbacks and loops as you can see in the screenshot:

image

Perhaps we can create a ticket for formatting older code, --fix won't fix the entire app, we can either perhaps use IDE to format all files to manually reformat. Anyway, it's only a warning, not an error so older code can still go through.

@malberts
Copy link
Collaborator

The problem I've noticed with using warn rules is they get ignored and they spam CI, and then eventually we disable the rule.

I think we should just set this to error. I don't see any case where it would be better/preferred to use an arrow function declaration, so we might as well disallow it. It's going to be a bit of work to update the code, though.

And just to confirm what @waximabbax mentioned, this applies to declarations only, so anonymous arrow functions are still allowed.

@JeroenDeDauw
Copy link
Member

Agree that warn causes spam

I don't think it is a good time investment for us to go change the syntax everywhere

@waximabbax
Copy link
Contributor Author

There is a bit of code inconsistency we can avoid, we can also make this run only for new code. Other than code inconsistency, I don't think there are any other technical concerns.

@waximabbax
Copy link
Contributor Author

I am not sure what should we do with this PR, I've added code to include only files that have changes but it will still include the entire file but fixing one file shouldn't be any trouble at all.

@JeroenDeDauw Please feel free to close this PR if it is not worth it.

sourceType: 'module'
},
rules: {
'func-style': [ 'error', 'declaration', { allowArrowFunctions: false } ],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neojs doesn't have code like const foo = () => {} so it doesn't hurt to keep it.

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

Successfully merging this pull request may close these issues.

4 participants