Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit bf0064f

Browse files
authored
Merge release-v2.8.4 into master
2 parents 0f28653 + 11d78e3 commit bf0064f

File tree

8 files changed

+389
-1
lines changed

8 files changed

+389
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v2.8.4 (October 31, 2017)
2+
- Add support to copyright tooling for TypeScript files (.ts, .tsx) [#164](https://github.com/mobify/mobify-code-style/pull/164)
3+
14
## v2.8.3 (May 31, 2017)
25
- Set sass linting rules to un-ignore base styles
36

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * */
2+
/* Copyright (c) year Mobify Research & Development Inc. All rights reserved. */
3+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * */
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * */
2+
/* Copyright (c) year Mobify Research & Development Inc. All rights reserved. */
3+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * */

es6/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,71 @@ globals:
5151
The boolean value indicates whether the global is to be treated as
5252
read-only (`false`) or read-write (`true`).
5353

54+
## Naming
55+
56+
Classes and constructor functions should be `TitleCased`
57+
58+
```javascript
59+
// GOOD
60+
class DatePicker { }
61+
62+
var LinkLabel = function() { }
63+
64+
// BAD
65+
class linkLabel { }
66+
```
67+
68+
Constant values that appear outside of a method scope and truly represent "data"
69+
that is constant (ie. it isn't something that is expected to be mutated during
70+
the app lifecycle), should be in `ALL_CAPS`. This means that things like global
71+
functions would still be `camelCased`. See examples below.
72+
73+
```javascript
74+
// GOOD: constant data
75+
export const DEFAULT_NAME = 'Element'
76+
77+
const STATE_CALLBACKS = {
78+
pending: sendPendingResponse,
79+
completed: sendCompletedResponse,
80+
archived: sendArchivedResponse
81+
}
82+
83+
// BAD: constant data should be ALL_CAPS
84+
export const defaultName = 'Element'
85+
86+
class DatePicker {
87+
render() {
88+
// BAD: constant is within a method and should be camelCased
89+
const DEFAULT_VALUE = 0
90+
}
91+
}
92+
```
93+
94+
All other symbols (methods, variables, and constants within a method) should be `camelCased`!
95+
96+
```javascript
97+
// BAD - functions aren't "data" or a "class" and so shouldn't be TitleCase
98+
export const ReceiveProductData = createAction('Receive Product Data')
99+
100+
// GOOD - exporting a function with camelCase name
101+
export const receiveProductData = createAction('Receive Product Data')
102+
103+
104+
// BAD - `const` outside of a method should be ALL_CAPS
105+
const defaultName = 'Element'
106+
107+
// BAD - Not a constructor function and so should be camelCase
108+
const AddToCart = () => { console.log('Adding to cart') }
109+
110+
// GOOD - local constants within class or function
111+
class MyClass {
112+
const name = 'Button'
113+
render() {
114+
const button = <Button name={name} />
115+
}
116+
}
117+
```
118+
54119
## Overriding Lint Rules
55120

56121
Some of the lint rules disallow uncommon but valid behaviour that is easily confused with/typoed from much more common behaviour. If you need to use the disallowed behaviour on purpose, use an explicit lint override in the source.

es6/mobify-es6.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ rules:
7676
func-style:
7777
- error
7878
- expression
79+
new-cap:
80+
- error
81+
-
82+
newIsCap: true
83+
capIsNew: true
84+
properties: false
7985
new-parens: error
8086
no-alert: error
8187
no-labels: error

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mobify-code-style",
3-
"version": "2.8.3",
3+
"version": "2.8.4",
44
"description": "Code style guide and linting tools for Mobify",
55
"repository": {
66
"type": "git",

python/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,14 @@ Message codes can be found [here](http://pylint-messages.wikidot.com/all-codes).
148148
Disable works for the block in which they are found, so include it at the module
149149
level to disable a message for a module or file.
150150

151+
## Docstrings
152+
153+
We don't have a company-wide standard for Docstrings, but if you're
154+
starting a new project, a good choice is the [Google style](https://google.github.io/styleguide/pyguide.html#Comments).
155+
The official Google documentation isn't always easy to follow, but there
156+
is an example file in [`example_google.py`](./example_google.py), in this repository.
157+
158+
Using correct `Args` and `Returns` descriptions in your code will make it
159+
easier for you (or others) to work with many IDEs and code-aware editors
160+
that can infer the types of parameters and return values for you.
161+

0 commit comments

Comments
 (0)