javascript icon indicating copy to clipboard operation
javascript copied to clipboard

max-classes-per-file enabled in code but not in docs

Open SeanOfTheHillPeople opened this issue 5 years ago • 9 comments

The max-classes-per-file rule is enabled in rules/best-practices.js but there is no mention of this requirement in the docs. If this is a best practice, I'd like to know why.

SeanOfTheHillPeople avatar Dec 09 '19 20:12 SeanOfTheHillPeople

The same rationale that applies to https://github.com/airbnb/javascript/tree/master/react#basic-rules (but also appears not to be documented): the whole point of modules is to make them as small and atomic and reusable as possible, which means splitting things up as much as possible.

Is there a specific use case where you think this rule shouldn't apply?

ljharb avatar Dec 09 '19 20:12 ljharb

Thanks! I'll have a look at our offending modules with the team to see if there's a case for keeping them together.

SeanOfTheHillPeople avatar Dec 09 '19 21:12 SeanOfTheHillPeople

I would advocate for the use of a single module for model and controller classes for the same 'component' (in non-React ES6)

SteveThorpe avatar Dec 09 '19 21:12 SteveThorpe

@SteveThorpe that presumes the MVC pattern is an ideal one to be following for the frontend, react or otherwise :-)

ljharb avatar Dec 09 '19 21:12 ljharb

@ljharb MVC is far from ideal (IMO), even for our codebase. But if you are starting out with a codebase that is 'sort-of' MVC and, have a directive to impose AirBnb style on it, then the max-classes-per-file rule makes things worse (again, IMO)

SteveThorpe avatar Dec 09 '19 22:12 SteveThorpe

@ljharb So would you agree that if you are stuck with the MVC pattern then you could be justified in turning off the max-classes-per-file rule? ;)

SteveThorpe avatar Dec 09 '19 22:12 SteveThorpe

You can always turn off any rules that aren't a good fit for your use case - the Airbnb config assumes you're using Babel, targeting both web and node, using React, etc.

ljharb avatar Dec 09 '19 22:12 ljharb

i rendered a repository from json after reciving a web token from releasing my notes curious to know what all it is. can anyone help?

ghost avatar Feb 18 '20 23:02 ghost

@clout4sad this seems pretty unrelated to this repo, which is a javascript style guide. I'd suggest IRC or stack overflow.

ljharb avatar Feb 19 '20 00:02 ljharb