Skip to content

Commit b2088b9

Browse files
committed
linting
1 parent 7eb7926 commit b2088b9

File tree

12 files changed

+649
-43
lines changed

12 files changed

+649
-43
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.vscode/
2+
build/
3+
coverage/
4+
node_modules/

.eslintrc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"parser": "babel-eslint",
3+
"env": {
4+
"browser": true,
5+
"es6": true,
6+
"node": true,
7+
"jest": true
8+
},
9+
"extends": [ "xo", "plugin:unicorn/recommended" ],
10+
"plugins": [ "import", "unicorn" ],
11+
"rules": {
12+
// omit semicolons. there's only a few cases where automatic
13+
// semicolon insertion is problematic - most of which can be
14+
// mitigated by other linting rules such as func-call-spacing
15+
// or no-unexpected-multiline
16+
"semi": [ 2, "never" ],
17+
// enforce 2-space indentation
18+
"indent": [ 2, 2 ],
19+
// enforce arrow parens, regardless of argument count
20+
"arrow-parens": [ 2, "always" ],
21+
// enforce dangling commas for multiline statements
22+
"comma-dangle": [ 2, "always-multiline" ],
23+
// enforce consistent spacing inside braces and brackets
24+
"array-bracket-spacing": [ 2, "always", {
25+
"arraysInArrays": false,
26+
"objectsInArrays": false
27+
}],
28+
"object-curly-spacing": [ 2, "always", {
29+
"arraysInObjects": false,
30+
"objectsInObjects": false
31+
}],
32+
// enforce consistent linebreak style for operators, with an
33+
// exception being made for multi-line-ternaries so those are
34+
// easier to spot
35+
"operator-linebreak": [ 2, "after", {
36+
"overrides": { "?": "before", ":": "before" }
37+
}]
38+
}
39+
}

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@
1818
],
1919
"scripts": {
2020
"build": "babel src --out-dir build",
21+
"lint": "eslint src",
2122
"test": "jest --coverage"
2223
},
2324
"dependencies": {},
2425
"devDependencies": {
2526
"babel-cli": "^6.18.0",
27+
"babel-eslint": "^7.1.1",
2628
"babel-plugin-transform-object-rest-spread": "^6.22.0",
2729
"babel-preset-es2015": "^6.18.0",
2830
"coveralls": "^2.11.15",
31+
"eslint": "^3.14.1",
32+
"eslint-config-xo": "^0.17.0",
33+
"eslint-plugin-import": "^2.2.0",
34+
"eslint-plugin-unicorn": "^1.0.0",
2935
"jest": "^18.1.0"
3036
},
3137
"jest": {

src/__tests__/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('css-spring', () => {
3030
spring(
3131
{
3232
'padding-left': '-50rem',
33-
'opacity': true,
33+
opacity: true,
3434
'margin-right': '0em',
3535
},
3636
{

src/__tests__/to-string.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('format', () => {
1616
expect(
1717
reduceProperties({
1818
'padding-right': '12px',
19-
'padding-left': '12px'
19+
'padding-left': '12px',
2020
})
2121
).toEqual(
2222
'padding-right:12px;padding-left:12px;'

src/__tests__/util.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('utilities', () => {
1414
})
1515

1616
test('maps each value', () => {
17-
const mapped = mapValues({ foo: 1, bar: 2 }, (v) => 'wat')
17+
const mapped = mapValues({ foo: 1, bar: 2 }, () => 'wat')
1818
expect(mapped).toEqual({ foo: 'wat', bar: 'wat' })
1919
})
2020
})

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const spring = (startProps, endProps, options = {}) => {
5151
const percent = `${i}%`
5252
keyframes[percent] = Object.assign(
5353
keyframes[percent] || {},
54-
{ [key]: `${+value.toFixed(precision)}${animatableProps[key].unit}` }
54+
{ [key]: `${Number(value.toFixed(precision))}${animatableProps[key].unit}` }
5555
)
5656
}
5757
})

src/props.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export const getAnimatableProps = (startProps, endProps) => {
2222
if (startMatches && endMatches && startMatches[2] === endMatches[2]) {
2323
result[key] = {
2424
unit: startMatches[2],
25-
start: +startMatches[1],
26-
end: +endMatches[1]
25+
start: Number(startMatches[1]),
26+
end: Number(endMatches[1]),
2727
}
2828
}
2929
}

src/stepper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Taken from react-motion
22
// @see https://github.com/chenglou/react-motion/blob/master/src/stepper.js
3-
const reusedTuple = [0, 0]
3+
const reusedTuple = [ 0, 0 ]
44

5+
// eslint-disable-next-line max-params
56
export default (secondPerFrame, x, v, destX, k, b, precision = 0.01) => {
67
// Spring stiffness, in kg / s^2
78

src/to-string.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ export const toString = (keyframes, formatter = defaultFormatter) => {
1313
}, '')
1414
}
1515

16-
1716
export default toString

0 commit comments

Comments
 (0)