Skip to content

Commit

Permalink
Merge pull request #290 from realityking/eslint
Browse files Browse the repository at this point in the history
Switch eslint to use airbnb config
  • Loading branch information
lencioni authored Feb 19, 2019
2 parents 110a7d4 + 636dbb4 commit d609087
Show file tree
Hide file tree
Showing 14 changed files with 260 additions and 202 deletions.
17 changes: 14 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
module.exports = {
'extends': 'eslint-config-brigade/react',
'extends': 'eslint-config-airbnb',
'parserOptions': {
'ecmaVersion': 6,
'sourceType': 'module'
'ecmaVersion': 2018,
'sourceType': 'module',
'ecmaFeatures': {
'jsx': true,
},
},
'rules': {
'no-restricted-globals': 'off',
'no-plusplus': 'off',
'no-underscore-dangle': 'off'
},
'env': {
'browser': true,
},
};
23 changes: 13 additions & 10 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global process */
// Karma configuration

module.exports = function(config) {
module.exports = (config) => {
config.set({

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

// list of files / patterns to load in the browser
files: [
'tests.webpack.js'
'tests.webpack.js',
],

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

webpack: {
Expand All @@ -33,14 +33,17 @@ module.exports = function(config) {
{
test: /\.jsx?$/,
loaders: ['babel-loader?cacheDirectory=true'],
exclude: /node_modules/
}
]
}
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.json'],
},
},

webpackMiddleware: {
noInfo: true
noInfo: true,
},

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

// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@
"babel-core": "^6.26.3",
"babel-loader": "^6.4.0",
"babel-preset-airbnb": "^2.5.1",
"eslint": "^3.17.1",
"eslint-config-brigade": "^3.2.1",
"eslint-plugin-react": "^6.10.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.15.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.12.4",
"in-publish": "^2.0.0",
"jasmine-core": "2.6.4",
"karma": "^1.5.0",
Expand Down
10 changes: 5 additions & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export default [
],
output: [
{ file: pkg.main, format: 'cjs' },
{ file: pkg.module, format: 'es' }
{ file: pkg.module, format: 'es' },
],
plugins: [
babel({
exclude: ['node_modules/**']
})
]
}
exclude: ['node_modules/**'],
}),
],
},
];
2 changes: 2 additions & 0 deletions src/computeOffsetPixels.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ export default function computeOffsetPixels(offset, contextHeight) {
if (typeof percentOffset === 'number') {
return percentOffset * contextHeight;
}

return undefined;
}
4 changes: 2 additions & 2 deletions src/debugLog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default function debugLog() {
export default function debugLog(...args) {
if (process.env.NODE_ENV !== 'production') {
console.log(arguments); // eslint-disable-line no-console
console.log(...args); // eslint-disable-line no-console
}
}
5 changes: 2 additions & 3 deletions src/ensureChildrenIsValid.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';

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

/**
* Raise an error if more that one child was provided to "children"
Expand Down
7 changes: 3 additions & 4 deletions src/ensureRefIsUsedByChild.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import isDOMElement from './isDOMElement';

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

/**
* Raise an error if "children" is not a DOM Element and there is no ref provided to Waypoint
Expand Down
16 changes: 9 additions & 7 deletions src/getCurrentPosition.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { INVISIBLE, INSIDE, BELOW, ABOVE } from './constants';
import {
INVISIBLE, INSIDE, BELOW, ABOVE,
} from './constants';

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

// top is within the viewport
if (bounds.viewportTop <= bounds.waypointTop &&
bounds.waypointTop <= bounds.viewportBottom) {
if (bounds.viewportTop <= bounds.waypointTop
&& bounds.waypointTop <= bounds.viewportBottom) {
return INSIDE;
}

// bottom is within the viewport
if (bounds.viewportTop <= bounds.waypointBottom &&
bounds.waypointBottom <= bounds.viewportBottom) {
if (bounds.viewportTop <= bounds.waypointBottom
&& bounds.waypointBottom <= bounds.viewportBottom) {
return INSIDE;
}

// top is above the viewport and bottom is below the viewport
if (bounds.waypointTop <= bounds.viewportTop &&
bounds.viewportBottom <= bounds.waypointBottom) {
if (bounds.waypointTop <= bounds.viewportTop
&& bounds.viewportBottom <= bounds.waypointBottom) {
return INSIDE;
}

Expand Down
2 changes: 2 additions & 0 deletions src/parseOffsetAsPercentage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ export default function parseOffsetAsPercentage(str) {
if (str.slice(-1) === '%') {
return parseFloat(str.slice(0, -1)) / 100;
}

return undefined;
}
4 changes: 3 additions & 1 deletion src/parseOffsetAsPixels.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
export default function parseOffsetAsPixels(str) {
if (!isNaN(parseFloat(str)) && isFinite(str)) {
return parseFloat(str);
} else if (str.slice(-2) === 'px') {
} if (str.slice(-2) === 'px') {
return parseFloat(str.slice(0, -2));
}

return undefined;
}
Loading

0 comments on commit d609087

Please sign in to comment.