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

Update eslint rules #2870

Closed
wants to merge 3 commits into from
Closed

Conversation

onEXHovia
Copy link

Disable rule for properties.

@onEXHovia onEXHovia changed the title Add lines-between-class-members rule Update eslint rules Dec 9, 2024
@VincentLanglet
Copy link
Member

VincentLanglet commented Dec 10, 2024

Hi,

For such coding standard decision, it would be great to explain:

  • Why disable arrow-body-style
  • Why disable lines-between-class-members on properties

Cause I assume the airbnb standard was used to minimize such debate. It's not a big deal to have a new line between properties no ?

@onEXHovia
Copy link
Author

The default configuration works, because code base use jquery.

I don't see the point in a rule that forces you to write

export default class extends Controller {
  static targets = ['counter', 'field'];

  static outlets = ['filter'];
                                                        
  static classes = ['active'];
}

instead, right?

export default class extends Controller {
  static targets = ['counter', 'field'];
  static outlets = ['filter'];               
  static classes = ['active'];
}

There should be a new line between methods, its good behavior. Same for the rule arrow-body-style
Disabling these rules will not create chaos in the code style, but they will remove annoying checks

@onEXHovia
Copy link
Author

Looking at checks https://github.com/sonata-project/SonataAdminBundle/actions/runs/12253259625/job/34181578909?pr=8230 we need to set up a rule yoda

because the package is supported by backend developers and code null !== this.advancedTargets.find((advanced) => !advanced.hidden) is normal for backend

@VincentLanglet
Copy link
Member

I'm ok for lines-between-class-members

I agree for yoda which need to be updated to be consistent with php-cs checks.

For arrow-body-style I'm not sure about the loss of forcing using arrow functions they have benefits I think.

@VincentLanglet
Copy link
Member

I dunno why I cannot give approval
image

I'll force the merge when the PR will be updated with all the needed rules.

@onEXHovia
Copy link
Author

yoda rule in next pr becauce affects another files
no-param-reassign for update property objects function params
allow behavior
https://github.com/sonata-project/SonataAdminBundle/pull/8230/files#diff-3a0b638bf958bb528c0a5318ef50022634d2199a23a204e6ce7e7ea3e44f9bd2R24
https://github.com/sonata-project/SonataAdminBundle/blob/4.x/webpack.config.js#L29

left the rule arrow-body-style for enable the use of braces around arrow function body
allow behavior
https://github.com/sonata-project/SonataAdminBundle/pull/8230/files#diff-9e471847050b0de785c04717ed47442f05b48c99ba2b4bf9347d5d79819e9c86R43

there is no reason to write

  get enabledFields() {
    return this.fieldTargets.filter((field) => field.classList.contains(this.activeClass));
  }

instead

  get enabledFields() {
    return this.fieldTargets.filter((field) => {
      return field.classList.contains(this.activeClass);
    });
  }

the rule doesn't affect anything, but it's always useful to make a block with return when the line is too long.

@VincentLanglet
Copy link
Member

Ok, and why you totally disable line between class members ? I thought it was ok to keep it for methods

@onEXHovia
Copy link
Author

Ok, and why you totally disable line between class members ? I thought it was ok to keep it for methods

because admin bundle use 8.x branch eslint and localy failed to configure behavior, flexible settings is possible in 9.x far as I understand

@VincentLanglet
Copy link
Member

Ok, please order the rules alphabetically if possible.

And so far, I cannot merge this... because of github
image

@VincentLanglet
Copy link
Member

I successfully merged this manually, instead 5f40bd4

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.

2 participants