Skip to content

Commit

Permalink
Bugfix/upgrade linter (#627)
Browse files Browse the repository at this point in the history
* Make lint work again

* Support mocha in eslint

* Use isFinite explicitly

* Define getComponentPaths before used

* Fix misspelt proptypes

* Remove nordnet eslint config

* Disable linting any prop types

* Remove nordnet eslint config from yarn lockfile

* Remove explicit use of isFinite
  • Loading branch information
gish authored and bstream committed Oct 16, 2017
1 parent a3016f0 commit efb2505
Show file tree
Hide file tree
Showing 13 changed files with 690 additions and 376 deletions.
33 changes: 24 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
{
"extends": "eslint-config-nordnet",
"rules": {
"comma-dangle": 0,
"no-param-reassign": [2, { "props": false }],
"react/forbid-prop-types": 0,
"react/no-unused-prop-types": [ 2, { "skipShapeProps": true }],
"react/require-default-props": 0
},
"extends": [
"airbnb",
"prettier",
"prettier/react"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2016,
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true
"impliedStrict": true,
"jsx": true
}
},
"plugins": [
"react"
],
"env": {
"node": true,
"browser": true,
"es6": true,
"mocha": true
},
"rules": {
"import/no-extraneous-dependencies": 0,
"react/forbid-prop-types": [2, { "forbid": ["any", "array"] }],
"react/require-default-props": 0
}
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"autoprefixer": "^7.1.0",
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-eslint": "^8.0.1",
"babel-loader": "^7.0.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-polyfill": "^6.23.0",
Expand All @@ -85,11 +86,11 @@
"dirty-chai": "^1.2.2",
"enzyme": "^2.8.0",
"eslint": "^4.1.0",
"eslint-config-airbnb": "^15.0.0",
"eslint-config-nordnet": "^1.1.1",
"eslint-plugin-import": "^2.2.0",
"eslint-config-airbnb": "^16.0.0",
"eslint-config-prettier": "^2.6.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.0",
"eslint-plugin-react": "^7.0.0",
"eslint-plugin-react": "^7.4.0",
"extract-text-webpack-plugin": "^2.1.0",
"git-directory-deploy": "^1.5.1",
"husky": "^0.14.0",
Expand Down
6 changes: 3 additions & 3 deletions src/components/addon/addon.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { PropTypes } from 'react';
import classNames from 'classnames';

/**
Expand All @@ -23,6 +23,6 @@ Addon.defaultProps = {
};

Addon.propTypes = {
className: React.PropTypes.string,
children: React.PropTypes.node.isRequired,
className: PropTypes.string,
children: PropTypes.node.isRequired,
};
16 changes: 8 additions & 8 deletions src/components/currency/currency.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { PropTypes } from 'react';
import Number from '../number/number';
import variables from '../../variables';

Expand Down Expand Up @@ -45,17 +45,17 @@ Currency.defaultProps = {
};

Currency.propTypes = {
value: React.PropTypes.any.isRequired,
value: PropTypes.any.isRequired, // eslint-disable-line
/**
Syntactic sugar for `suffix` (either one can be used)
*/
currency: React.PropTypes.string,
currency: PropTypes.string,
/**
Default is a space (`' '`)
*/
suffixSeparator: React.PropTypes.string,
suffixSize: React.PropTypes.oneOf(['normal', 'small']),
decimals: React.PropTypes.number,
maxDecimals: React.PropTypes.number,
minDecimals: React.PropTypes.number,
suffixSeparator: PropTypes.string,
suffixSize: PropTypes.oneOf(['normal', 'small']),
decimals: PropTypes.number,
maxDecimals: PropTypes.number,
minDecimals: PropTypes.number,
};
26 changes: 13 additions & 13 deletions src/components/date-time-iso/date-time-iso.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { PropTypes } from 'react';
import isoDate from './iso-date';

/**
Expand Down Expand Up @@ -38,20 +38,20 @@ DateTimeIso.defaultProps = {
};

DateTimeIso.propTypes = {
value: React.PropTypes.oneOfType([
React.PropTypes.number,
React.PropTypes.instanceOf(Date),
value: PropTypes.oneOfType([
PropTypes.number,
PropTypes.instanceOf(Date),
]).isRequired,
hour: React.PropTypes.oneOfType([
React.PropTypes.bool,
React.PropTypes.string,
hour: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.string,
]),
minute: React.PropTypes.oneOfType([
React.PropTypes.bool,
React.PropTypes.string,
minute: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.string,
]),
second: React.PropTypes.oneOfType([
React.PropTypes.bool,
React.PropTypes.string,
second: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.string,
]),
};
14 changes: 7 additions & 7 deletions src/components/date-time/date-time.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { PropTypes } from 'react';
import { FormattedDate, FormattedTime, FormattedRelative } from 'react-intl';
import DateTimeIso from '../date-time-iso/date-time-iso';
import formats from './date-time-formats';
Expand Down Expand Up @@ -40,19 +40,19 @@ DateTime.defaultProps = {
};

DateTime.propTypes = {
format: React.PropTypes.oneOf(['numeric', 'human']),
format: PropTypes.oneOf(['numeric', 'human']),
/**
Only applicable for dates, indicates that the date should follow [ISO 8601](https://sv.wikipedia.org/wiki/ISO_8601)
*/
iso: React.PropTypes.bool,
iso: PropTypes.bool,
/**
A timestamp.
*/
value: React.PropTypes.oneOfType([
React.PropTypes.number,
React.PropTypes.instanceOf(Date),
value: PropTypes.oneOfType([
PropTypes.number,
PropTypes.instanceOf(Date),
]).isRequired,
type: React.PropTypes.oneOf(['date', 'time', 'relative']),
type: PropTypes.oneOf(['date', 'time', 'relative']),
};

export default DateTime;
16 changes: 8 additions & 8 deletions src/components/development/development.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { PropTypes } from 'react';
import classNames from 'classnames';
import NumberComponent from '../number/number';
import CurrencyComponent from '../currency/currency';
Expand Down Expand Up @@ -70,13 +70,13 @@ export default function Development({
}

Development.propTypes = {
className: React.PropTypes.string,
value: React.PropTypes.any.isRequired,
decimals: React.PropTypes.number,
type: React.PropTypes.oneOf(['number', 'currency', 'percentage']),
direction: React.PropTypes.oneOf(['positive', 'negative', 'neutral']),
maxDecimals: React.PropTypes.number,
minDecimals: React.PropTypes.number,
className: PropTypes.string,
value: PropTypes.any.isRequired, // eslint-disable-line
decimals: PropTypes.number,
type: PropTypes.oneOf(['number', 'currency', 'percentage']),
direction: PropTypes.oneOf(['positive', 'negative', 'neutral']),
maxDecimals: PropTypes.number,
minDecimals: PropTypes.number,
};

Development.defaultProps = {
Expand Down
46 changes: 23 additions & 23 deletions src/components/number/number.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { PropTypes } from 'react';
import { injectIntl, intlShape } from 'react-intl';
import classNames from 'classnames';
import Addon from '../addon/addon';
Expand Down Expand Up @@ -75,29 +75,29 @@ function Number({
}

Number.propTypes = {
className: React.PropTypes.string,
style: React.PropTypes.object,
value: React.PropTypes.any.isRequired,
valueClass: React.PropTypes.string,
valueDecimals: React.PropTypes.number,
valueMaxDecimals: React.PropTypes.number,
valueMinDecimals: React.PropTypes.number,
valueStyle: React.PropTypes.object,
prefix: React.PropTypes.node,
prefixClass: React.PropTypes.string,
prefixSeparator: React.PropTypes.string,
prefixStyle: React.PropTypes.object,
suffix: React.PropTypes.node,
suffixClass: React.PropTypes.string,
suffixSeparator: React.PropTypes.string,
suffixStyle: React.PropTypes.object,
ticks: React.PropTypes.arrayOf(React.PropTypes.shape({
decimals: React.PropTypes.number,
to_price: React.PropTypes.number,
from_price: React.PropTypes.number,
tick: React.PropTypes.number,
className: PropTypes.string,
style: PropTypes.object,
value: PropTypes.any.isRequired, // eslint-disable-line
valueClass: PropTypes.string,
valueDecimals: PropTypes.number,
valueMaxDecimals: PropTypes.number,
valueMinDecimals: PropTypes.number,
valueStyle: PropTypes.object,
prefix: PropTypes.node,
prefixClass: PropTypes.string,
prefixSeparator: PropTypes.string,
prefixStyle: PropTypes.object,
suffix: PropTypes.node,
suffixClass: PropTypes.string,
suffixSeparator: PropTypes.string,
suffixStyle: PropTypes.object,
ticks: PropTypes.arrayOf(PropTypes.shape({
decimals: PropTypes.number,
to_price: PropTypes.number,
from_price: PropTypes.number,
tick: PropTypes.number,
})),
intl: intlShape.isRequired,
intl: intlShape.isRequired, // eslint-disable-line react/no-typos
};

Number.defaultProps = {
Expand Down
12 changes: 6 additions & 6 deletions src/components/percent/percent.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { PropTypes } from 'react';
import Number from '../number/number';

/**
Expand Down Expand Up @@ -33,12 +33,12 @@ Percent.defaultProps = {
};

Percent.propTypes = {
value: React.PropTypes.any.isRequired,
decimals: React.PropTypes.number,
value: PropTypes.any.isRequired, // eslint-disable-line
decimals: PropTypes.number,
/**
Default is an empty string (`''`)
*/
suffixSeparator: React.PropTypes.string,
maxDecimals: React.PropTypes.number,
minDecimals: React.PropTypes.number,
suffixSeparator: PropTypes.string,
maxDecimals: PropTypes.number,
minDecimals: PropTypes.number,
};
10 changes: 5 additions & 5 deletions src/components/value/value.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { PropTypes } from 'react';
import Number from '../number/number';

/**
Expand Down Expand Up @@ -29,8 +29,8 @@ Value.defaultProps = {
};

Value.propTypes = {
value: React.PropTypes.any.isRequired,
decimals: React.PropTypes.number,
maxDecimals: React.PropTypes.number,
minDecimals: React.PropTypes.number,
value: PropTypes.any.isRequired, // eslint-disable-line
decimals: PropTypes.number,
maxDecimals: PropTypes.number,
minDecimals: PropTypes.number,
};
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function numberIsFinite(value) {
return typeof value === 'number' && isFinite(value);
return typeof value === 'number' && isFinite(value); // eslint-disable-line
}

export function getTickDecimals(value, ticks) {
Expand Down
8 changes: 4 additions & 4 deletions styleguide/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = require('../webpack.config.babel');

function getComponentPaths(components) {
return components.map(componentPath => `${path.resolve(__dirname)}/${componentPath}`);
}

const numberComponentPaths = getComponentPaths([
'../src/components/value/value.jsx',
'../src/components/currency/currency.jsx',
Expand All @@ -17,10 +21,6 @@ const otherComponentPaths = getComponentPaths([
'../src/components/icon-row/icon-row.jsx',
]);

function getComponentPaths(components) {
return components.map(componentPath => `${path.resolve(__dirname)}/${componentPath}`);
}

function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
Expand Down
Loading

0 comments on commit efb2505

Please sign in to comment.