You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The goal is to create an eslint file that roughly matches the existing code base conventions.
It's ok to loosen the rules to allow the codebase to pass with as few changes as possible. Or we can make these tricky rules simply emit warnings for now. If any of these rules cannot be applied to the current code base without major changes or refactoring, we'll remove it for now.
Rules
General
Use tabs
No max line length for now
All lines must end with ";" except on JSX where they are optional (not sure if can be done)
Spacing between parenthesis should be as in the code example below
Variables should be either "const" (prefered) or "let" if it has to mutate. No "var".
If statements can be on one line
If an if statement is on more than one line, the line(s) below must be wrapped in {}
Classes and modules
Exported modules must have the same name as the filename. eg. "MyComponent.jsx" would export a component named "MyComponent"
If it can be done: Private class variables end with trailing underscore
Files must end with a trailing new line (mostly because most editors add one)
Case
Function names camelCase, but underscores are allowed so that instanceName_eventName() is possible
Local variables camelCase
Component names as PascalCase
Strings
Strings must not be split over several lines (to make them more easily searchable), except in ES6 string templates
Strings must be wrapped in single quotes.
React
No anonymous functions in React event handlers
All React components should be PureComponent
Only strict equality or inequality is allowed
Example code
This is an example of code that is considered as valid:
class MyClass {
constructor() {
super();
}
render() {
return <div>Hello</div>;
}
}
function doSomething(one, two) {
}
if (something === '1') {
doSomething(123, 456);
}
if (!something) doSomethingElse();
Implementation
Use eslint for the linter config. Use a pre-commit hook with husky to format the code before commit.
The text was updated successfully, but these errors were encountered:
The goal is to create an eslint file that roughly matches the existing code base conventions.
It's ok to loosen the rules to allow the codebase to pass with as few changes as possible. Or we can make these tricky rules simply emit warnings for now. If any of these rules cannot be applied to the current code base without major changes or refactoring, we'll remove it for now.
Rules
General
{}
Classes and modules
Case
instanceName_eventName()
is possibleStrings
React
Example code
This is an example of code that is considered as valid:
Implementation
Use eslint for the linter config. Use a pre-commit hook with husky to format the code before commit.
The text was updated successfully, but these errors were encountered: