[WIP] first draft of client directory and overall coding style docs#145
[WIP] first draft of client directory and overall coding style docs#145the-vampiire wants to merge 1 commit intodevelopmentfrom
Conversation
| - intuitive navigation of grouped components | ||
|
|
||
| # Guidelines | ||
| - always use absolute imports from `./src/path/to/import` |
There was a problem hiding this comment.
Add jsconfig.json to root
{
"compilerOptions": {
"target": "ES6",
"baseUrl": "."
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
But I think target should be ./src. Nothing outside src/ should be imported.
| - maximum column length of 100 characters | ||
| - new lines at the ends of each file | ||
|
|
||
| # Trailing Commas |
There was a problem hiding this comment.
JSX closing tags in new line
Same reasons as trailing commas in multi-line lists
| - styles/ | ||
| - App.jsx | ||
| - index.js | ||
|
|
There was a problem hiding this comment.
config/
- keys
- apollo
- ...
|
module.exports = {
"plugins": ["jest"],
"extends": "airbnb-base",
"env": {
"jest/globals": true
},
"rules": {
"no-console": 0,
"camelcase": 0,
+ "no-param-reassign": 0,
"import/no-dynamic-require": 0,
"import/no-unresolved": [
2,
{ caseSensitive: false }
]
}
};im conflicted over this one cases:
downsides:
const arr = [{ one: 1 }];
const mapped = arr.map(el => { el.one = 2; return el; });
arr // [{ one: 2 }]
mapped // [{ one: 2}]alternatives:
@TheSabby @thinktwice13 @serpient (and your husband if he has an opinion on it!) |
|
here is another example when using Sequelize hooks that would trigger by the eslint rule ProjectMember.beforeBulkDestroy((options) => {
options.individualHooks = true;
}); |
|
@the-vampiire This is AirBnB config It already ignores express |
Rules to consider/discuss
|
casingso sabby came up with this pattern because he didnt know js used camelcase lol. but i really like it and use it across all my projects:
it makes it really easy to distinguish what you are working with at any given time. and its easier to avoid spelling mistakes due to capitalization for the most common declarations - variables. the only place it isntt happy with it seems to be on props. but im fine with overriding that for consistency linebreaks
return methodName(some_argument, and_another, one_more)
? a_true_bit
: a_false_bit
if (
this_long_thing &&
one_more_long_part &&
aThirdOne(called_here)
) {
// do some things
}
return (
<SomeTag
prop_one = {some_value}
prop_two = {some_other}
prop_three = {() => someMethod(stuff)}
/>
);nasty onecompletely agree. we need to write semantic html. at the very least going forward and refactor when you come across previous code |
|
But I like the idea. |
|
Ah good point. Actually I like bringing the naming pattern to props as well. Variables snake, methods camel, classes (components) pascal. What do you think? Sent with GitHawk |
|
I can see a case for caps in enums. But not for consts. On that note think const should be used for everything that won’t be reassigned. 90% of cases are suitable for const. Only use lets during switches or a conditional chain where reassignment is part of the flow. Sent with GitHawk |
|
Const over let is default in airbnb Sent with GitHawk |
|
I did not meant local variables, but globally defined app constants, like different options
or query/mutation definitions. Redux actions were like that, too. We use those to define filter options and table headers, for example.
…On Sun, Nov 25, 2018, 04:37 Vamp ***@***.***> wrote:
Const over let is default in airbnb
Sent with GitHawk <http://githawk.com>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#145 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGTp4eLYiIZG2YawR1IjhrAHUG9RHjPWks5uyhBzgaJpZM4YPxik>
.
|
|
About bringing the casing patterns to JSX props, I'm good with that if we can enforce it with ESLint. Otherwise I'd rather just stick to one type. I don't care which one (but prefer camel). |
have a look and lets develop this PR into a committable first draft