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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Default 80
Should we use 140?
Prettier strives to fit the most code into every line. With the print width set to 120, prettier may produce overly compact, or otherwise undesirable code.
Tab Width
Default 2
Use Tabs
Default False
Use Semicolons
Default True
Quotes
Default double
We're mostly using single, so let's just stick with it
Trailing Commas
Default none
For diffing (and because we're using node 8), we should use them everywhere
Bracket Spacing
Default { foo: bar }
Optional {foo: bar}
Default feels more readable to me
JSX Brackets
Default
<buttonclassName="prettier-class"id="prettier-id"onClick={this.handleClick}>
Click Here
</button>
Optional
<buttonclassName="prettier-class"id="prettier-id"onClick={this.handleClick}>
Click Here
</button>
I don't have an opinion here. Which one is more readable?
Arrow Function Parentheses (for parameters)
Default - Avoid - x => x
Optional - Always - (x) => x
The argument for always is that diffs become more readable. I don't have an opinion.
Change which appears the most
Removing spaces before colons in types
Type definitions used to look like this:
Why? Having multiple lines that import from the same path can make code harder to maintain.
// badimportfoofrom'foo';// … some other imports … //import{named1,named2}from'foo';// goodimportfoo,{named1,named2}from'foo';// goodimportfoo,{named1,named2,}from'foo';
No else after return - The else here is unnecessary. Does this improve code readability?
if (!userUri) {
throw new Error('Missing auth token');
}
return buildContext(userUri, teamUri);
I also think else if is more readable than if ... if ... This is configurable in the rule.
The name of the imported module must match the name of the thing being imported. (under the category maintainability)
importServicefrom'x/y/z/Service'// goodimportMyCoolServicefrom'x/y/z/Service'// bad
Causes problems when importing from files with the same name in different places
import sharedEpics, { SharedEpicContext } from '../../../../common_data_components/redux/epics';
import sbapi, { SbapiEpicContext } from '../../sbapi/epics';
What to do here?
8.1 When you must use an anonymous function (as when passing an inline callback), use arrow function notation. eslint: prefer-arrow-callback, arrow-spacing
Why? It creates a version of the function that executes in the context of this, which is usually what you want, and is a more concise syntax.
Why not? If you have a fairly complicated function, you might move that logic out into its own named function expression.
Applies a naming convention to function names and method names. You can configure the naming convention by passing parameters. Please note, the private-method-regex does take precedence over the static-method-regex, so a private static method must match the private-method-regex. The default values are:
"check-format": allows only lowerCamelCased or UPPER_CASED variable names
"allow-leading-underscore" allows underscores at the beginning (only has an effect if “check-format” specified)
"allow-trailing-underscore" allows underscores at the end. (only has an effect if “check-format” specified)
"allow-pascal-case" allows PascalCase in addition to lowerCamelCase.
"allow-snake-case" allows snake_case in addition to lowerCamelCase.
"ban-keywords": disallows the use of certain TypeScript keywords as variable or parameter names.
These are: any, Number, number, String, string, Boolean, boolean, Undefined, undefined
By default, this only allows lowerCamelCase or UPPER_CASE. We probably want to modify this to just ban-keywords.
Prefer array literal
Use array literal syntax when declaring or instantiating array types. For example, prefer the Javascript form of string[] to the TypeScript form Array. Prefer '[]' to 'new Array()'. Prefer '[4, 5]' to 'new Array(4, 5)'. Prefer '[undefined, undefined]' to 'new Array(4)'.