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

Commit 56cb31c

Browse files
author
Marlow Payne
authored
Merge pull request #133 from mobify/release-2.6.0
πŸ”– Release 2.6.0
2 parents fd72b1d + 9fee0fa commit 56cb31c

File tree

7 files changed

+183
-162
lines changed

7 files changed

+183
-162
lines changed

β€Ž.gitignoreβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
*.sw[a-z]
12
.idea/

β€ŽCHANGELOGβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Pending Release
2+
-
3+
2.6.0
4+
- Remove `variable-for-property` rule from sass-lint [#126](https://github.com/mobify/mobify-code-style/pull/126)
5+
- Add the eslint jsx-a11y plugin through a new `mobify-es6-react-a11y` configuration [#129](https://github.com/mobify/mobify-code-style/pull/129)
16
2.5.3
27
- Fix #123 by using react/jsx-wrap-multilines rule
38
- Migrate CSSComb documentation from Confluence to code style repo

β€Žcss/.sass-lint.ymlβ€Ž

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,7 @@ rules:
323323
trailing-semicolon: 2
324324
url-quotes: 1 # Only warn here, since sass-lint doesn't understand helpers in urls
325325
variable-for-property:
326-
- 2
327-
- properties:
328-
- font
326+
- 0
329327
variable-name-format:
330328
- 2
331329
- allow-leading-underscore: true

β€Žes6/README.mdβ€Ž

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,44 @@ Included is a default ESLint configuration, `mobify-es6.yml` written for ESLint
55
- `eslint-plugin-import`
66
- `eslint-import-resolver-webpack`
77

8-
The lint configuration is the definitive source for rules; this document explains the most notable ones. `eslint <source-files> --fix` will fix most formatting issues, such as spacing.
8+
The lint configuration is the definitive source for rules; this document explains the most notable ones. `eslint <source-files> --fix` will fix most formatting issues, such as spacing.
99

1010
If React/JSX is in use, use the React default configuration `mobify-es6-react.yml`, which also requires the `eslint-plugin-react` module.
1111

12+
JSX accessibility linting is available with the `mobify-es6-react-a11y.yml` configuration. It requires the additional modules:
13+
14+
- `eslint-plugin-react`
15+
- `eslint-plugin-jsx-a11y`
16+
17+
## Global Names and Environments
18+
19+
By default, the lint configuration only assumes the standard set of
20+
global names in the browser environment are defined. If writing a
21+
script that runs in a different environment, such as a worker or Node,
22+
add an `eslint-env` directive at the top of the file, e.g.:
23+
```javascript
24+
/* eslint-env node */
25+
```
26+
27+
If you have defined or are using a global that is not associated with
28+
any environment, you can define it for the linter in one of two
29+
ways. If the global is only used in a single file or single place,
30+
define it in that file by inserting a `global` directive at the top of
31+
the file:
32+
```javascript
33+
/* global myGlobal anotherGlobal Mobify */
34+
```
35+
36+
If, instead, it is used throughout your project, add it to the
37+
`.eslintrc.yml` file for that project, with
38+
```yaml
39+
globals:
40+
myGlobal: true
41+
anotherGlobal: false
42+
```
43+
The boolean value indicates whether the global is to be treated as
44+
read-only (`false`) or read-write (`true`).
45+
1246
## Overriding Lint Rules
1347

1448
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.
@@ -35,21 +69,21 @@ if (x > y)
3569
return x - y
3670
else
3771
return y - x
38-
39-
for (let item of cartItems)
72+
73+
for (let item of cartItems)
4074
console.log(item)
41-
75+
4276
//good!
4377
if (x > y) {
4478
return x - y
4579
} else {
4680
return y - x
4781
}
48-
82+
4983
for (let item of cartItems) {
5084
console.log(item)
5185
}
52-
86+
5387
```
5488

5589
## Avoid 'Yoda' conditions
@@ -91,12 +125,12 @@ return {
91125
It is clearer to use dot notation instead of bracket notation when it is available (i.e. when the property name is a constant, identifier-legal string).
92126

93127
```javascript
94-
// Bad
128+
// Bad
95129
console.log(myObj['prop'])
96130
97131
// Good
98132
console.log(myObj.prop)
99-
```
133+
```
100134

101135
## Use ES6 `import` rather than `require`
102136

@@ -138,7 +172,7 @@ export const func3 = () => { console.log(3) }
138172

139173
## Don't use semicolons
140174

141-
With ES6 (and the current lint rules!) we have finally arrived at an environment where automatic semicolon insertion won't cause problems. So don't use them.
175+
With ES6 (and the current lint rules!) we have finally arrived at an environment where automatic semicolon insertion won't cause problems. So don't use them.
142176

143177
## Prefer template strings to string concatenation
144178

@@ -159,9 +193,9 @@ Ternary expressions can be helpful, but can also lead to unclear code. If multip
159193

160194
```javascript
161195
// Bad
162-
let name = (item
163-
? item.name
164-
: (defaultItem
196+
let name = (item
197+
? item.name
198+
: (defaultItem
165199
? defaultItem.name
166200
: defaultName
167201
)
@@ -222,7 +256,7 @@ return fetch('http://mysite.com/api')
222256
.then(function(response) {
223257
return response.json()
224258
})
225-
259+
226260
// Good
227261
return fetch('http://mysite.com/api')
228262
.then((response) => {
@@ -232,7 +266,7 @@ return fetch('http://mysite.com/api')
232266
// Also good
233267
return fetch('http://mysite.com/api')
234268
.then((response) => response.json())
235-
269+
236270
// Still fine
237271
element.addEventListener('click', function(event) {
238272
console.log(this.id)
@@ -270,7 +304,7 @@ This is more readable and prevents unexpected results when commenting out lines.
270304
let x = 5,
271305
y = 10,
272306
z = 100
273-
307+
274308
// Good
275309
let x = 5
276310
let y = 10
@@ -354,11 +388,11 @@ class MyComponent extends React.Component {
354388
componentDidMount() {
355389
this.props.sendAnalytics()
356390
}
357-
391+
358392
render() {
359393
return <div>{this.props.content}</div>
360394
}
361-
}
395+
}
362396
```
363397
364398
## Use plain functions for stateless components
@@ -370,7 +404,7 @@ React now allows stateless components to be implemented as pure functions rather
370404
class MyComponent extends React.Component {
371405
render() {
372406
return (
373-
<ul>
407+
<ul>
374408
{this.props.items.map((item) => <li>{item.content}</li>}
375409
</ul>
376410
)
@@ -390,7 +424,7 @@ const MyComponent = ({items}) => {
390424
391425
# JSX
392426
393-
## Self-close component elements if possible
427+
## Self-close component elements if possible
394428
395429
```javascript
396430
// Bad
@@ -400,4 +434,3 @@ const MyComponent = ({items}) => {
400434
// Good
401435
<MyComponent prop1="test" prop2={10+2} />
402436
```
403-
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extends:
2+
- './mobify-es6-react.yml'
3+
- 'plugin:jsx-a11y/recommended'
4+
plugins:
5+
- jsx-a11y
6+
rules:
7+
# JSX A11y rules
8+
jsx-a11y/href-no-hash: [1, 'Link']
9+
jsx-a11y/img-has-alt: [1, 'Image']

β€Ž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.5.3",
3+
"version": "2.6.0",
44
"description": "Code style guide and linting tools for Mobify",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
Β (0)