Skip to content

Commit d609087

Browse files
authored
Merge pull request #290 from realityking/eslint
Switch eslint to use airbnb config
2 parents 110a7d4 + 636dbb4 commit d609087

14 files changed

+260
-202
lines changed

.eslintrc.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
module.exports = {
2-
'extends': 'eslint-config-brigade/react',
2+
'extends': 'eslint-config-airbnb',
33
'parserOptions': {
4-
'ecmaVersion': 6,
5-
'sourceType': 'module'
4+
'ecmaVersion': 2018,
5+
'sourceType': 'module',
6+
'ecmaFeatures': {
7+
'jsx': true,
8+
},
9+
},
10+
'rules': {
11+
'no-restricted-globals': 'off',
12+
'no-plusplus': 'off',
13+
'no-underscore-dangle': 'off'
14+
},
15+
'env': {
16+
'browser': true,
617
},
718
};

karma.conf.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* global process */
22
// Karma configuration
33

4-
module.exports = function(config) {
4+
module.exports = (config) => {
55
config.set({
66

77
// base path that will be used to resolve all patterns (eg. files, exclude)
@@ -13,7 +13,7 @@ module.exports = function(config) {
1313

1414
// list of files / patterns to load in the browser
1515
files: [
16-
'tests.webpack.js'
16+
'tests.webpack.js',
1717
],
1818

1919
// list of files to exclude
@@ -24,7 +24,7 @@ module.exports = function(config) {
2424
// available preprocessors:
2525
// https://npmjs.org/browse/keyword/karma-preprocessor
2626
preprocessors: {
27-
'tests.webpack.js': ['webpack']
27+
'tests.webpack.js': ['webpack'],
2828
},
2929

3030
webpack: {
@@ -33,14 +33,17 @@ module.exports = function(config) {
3333
{
3434
test: /\.jsx?$/,
3535
loaders: ['babel-loader?cacheDirectory=true'],
36-
exclude: /node_modules/
37-
}
38-
]
39-
}
36+
exclude: /node_modules/,
37+
},
38+
],
39+
},
40+
resolve: {
41+
extensions: ['.js', '.jsx', '.json'],
42+
},
4043
},
4144

4245
webpackMiddleware: {
43-
noInfo: true
46+
noInfo: true,
4447
},
4548

4649
// test results reporter to use
@@ -66,8 +69,8 @@ module.exports = function(config) {
6669
// start these browsers
6770
// available browser launchers:
6871
// https://npmjs.org/browse/keyword/karma-launcher
69-
browsers: process.env.CONTINUOUS_INTEGRATION === 'true' ?
70-
['Firefox'] : ['Chrome'],
72+
browsers: process.env.CONTINUOUS_INTEGRATION === 'true'
73+
? ['Firefox'] : ['Chrome'],
7174

7275
// if true, Karma captures browsers, runs the tests and exits
7376
singleRun: true,

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@
4343
"babel-core": "^6.26.3",
4444
"babel-loader": "^6.4.0",
4545
"babel-preset-airbnb": "^2.5.1",
46-
"eslint": "^3.17.1",
47-
"eslint-config-brigade": "^3.2.1",
48-
"eslint-plugin-react": "^6.10.0",
46+
"eslint": "^4.19.1",
47+
"eslint-config-airbnb": "^17.1.0",
48+
"eslint-plugin-import": "^2.15.0",
49+
"eslint-plugin-jsx-a11y": "^6.1.2",
50+
"eslint-plugin-react": "^7.12.4",
4951
"in-publish": "^2.0.0",
5052
"jasmine-core": "2.6.4",
5153
"karma": "^1.5.0",

rollup.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ export default [
1010
],
1111
output: [
1212
{ file: pkg.main, format: 'cjs' },
13-
{ file: pkg.module, format: 'es' }
13+
{ file: pkg.module, format: 'es' },
1414
],
1515
plugins: [
1616
babel({
17-
exclude: ['node_modules/**']
18-
})
19-
]
20-
}
17+
exclude: ['node_modules/**'],
18+
}),
19+
],
20+
},
2121
];

src/computeOffsetPixels.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ export default function computeOffsetPixels(offset, contextHeight) {
1717
if (typeof percentOffset === 'number') {
1818
return percentOffset * contextHeight;
1919
}
20+
21+
return undefined;
2022
}

src/debugLog.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export default function debugLog() {
1+
export default function debugLog(...args) {
22
if (process.env.NODE_ENV !== 'production') {
3-
console.log(arguments); // eslint-disable-line no-console
3+
console.log(...args); // eslint-disable-line no-console
44
}
55
}

src/ensureChildrenIsValid.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from 'react';
22

3-
export const errorMessage =
4-
'<Waypoint> expected to receive a single React element child.\n\n' +
5-
'See https://goo.gl/LrBNgw for more info.';
3+
export const errorMessage = '<Waypoint> expected to receive a single React element child.\n\n'
4+
+ 'See https://goo.gl/LrBNgw for more info.';
65

76
/**
87
* Raise an error if more that one child was provided to "children"

src/ensureRefIsUsedByChild.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import isDOMElement from './isDOMElement';
22

3-
export const errorMessage =
4-
'<Waypoint> needs a DOM element to compute boundaries. The child you passed is neither a ' +
5-
'DOM element (e.g. <div>) nor does it use the innerRef prop.\n\n' +
6-
'See https://goo.gl/LrBNgw for more info.';
3+
export const errorMessage = '<Waypoint> needs a DOM element to compute boundaries. The child you passed is neither a '
4+
+ 'DOM element (e.g. <div>) nor does it use the innerRef prop.\n\n'
5+
+ 'See https://goo.gl/LrBNgw for more info.';
76

87
/**
98
* Raise an error if "children" is not a DOM Element and there is no ref provided to Waypoint

src/getCurrentPosition.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { INVISIBLE, INSIDE, BELOW, ABOVE } from './constants';
1+
import {
2+
INVISIBLE, INSIDE, BELOW, ABOVE,
3+
} from './constants';
24

35
/**
46
* @param {object} bounds An object with bounds data for the waypoint and
@@ -13,20 +15,20 @@ export default function getCurrentPosition(bounds) {
1315
}
1416

1517
// top is within the viewport
16-
if (bounds.viewportTop <= bounds.waypointTop &&
17-
bounds.waypointTop <= bounds.viewportBottom) {
18+
if (bounds.viewportTop <= bounds.waypointTop
19+
&& bounds.waypointTop <= bounds.viewportBottom) {
1820
return INSIDE;
1921
}
2022

2123
// bottom is within the viewport
22-
if (bounds.viewportTop <= bounds.waypointBottom &&
23-
bounds.waypointBottom <= bounds.viewportBottom) {
24+
if (bounds.viewportTop <= bounds.waypointBottom
25+
&& bounds.waypointBottom <= bounds.viewportBottom) {
2426
return INSIDE;
2527
}
2628

2729
// top is above the viewport and bottom is below the viewport
28-
if (bounds.waypointTop <= bounds.viewportTop &&
29-
bounds.viewportBottom <= bounds.waypointBottom) {
30+
if (bounds.waypointTop <= bounds.viewportTop
31+
&& bounds.viewportBottom <= bounds.waypointBottom) {
3032
return INSIDE;
3133
}
3234

src/parseOffsetAsPercentage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ export default function parseOffsetAsPercentage(str) {
1414
if (str.slice(-1) === '%') {
1515
return parseFloat(str.slice(0, -1)) / 100;
1616
}
17+
18+
return undefined;
1719
}

0 commit comments

Comments
 (0)