Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eslint-plugin-ramda #335

Merged
merged 12 commits into from
Feb 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ engines:
- javascript
eslint:
enabled: true
channel: "eslint-4"
checks:
import/extensions:
enabled: false
Expand Down
10 changes: 8 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
}
},
"extends": [
"airbnb-base"
"airbnb-base",
"plugin:ramda/recommended"
],
"plugins": ["eslint-plugin-ramda"],
"rules": {
"strict": [2, "global"],
"semi": ["error", "always", { "omitLastInOneLineBlock": true}],
Expand All @@ -24,6 +26,10 @@
}],
"no-underscore-dangle": 0,
"object-curly-newline": 0,
"import/newline-after-import": ["error", { "count": 2 }]
"import/newline-after-import": ["error", { "count": 2 }],
"ramda/always-simplification": ["error"],
"ramda/compose-simplification": ["error"],
"ramda/eq-by-simplification": ["error"],
"ramda/prefer-complement": ["error"]
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"eslint-config-airbnb-base": "12.1.0",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-mocha": "=4.11.0",
"eslint-plugin-ramda": "=2.4.0",
"fantasy-land": "3.5.0",
"glob": "=7.1.2",
"istanbul": "=0.4.5",
Expand Down
5 changes: 1 addition & 4 deletions src/internal/polyfills/Number.MAX_SAFE_INTEGER.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { or } from 'ramda';


const MAX_SAFE_INTEGER = or(Number.MAX_SAFE_INTEGER, (2 ** 53) - 1);
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || (2 ** 53) - 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would use parenthesis to explicitly state the associations of operands

const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || ((2 ** 53) - 1)


export default MAX_SAFE_INTEGER;
5 changes: 1 addition & 4 deletions src/internal/polyfills/Number.MIN_SAFE_INTEGER.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { or } from 'ramda';


const MIN_SAFE_INTEGER = or(Number.MIN_SAFE_INTEGER, -(2 ** 53) - 1);
const MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -(2 ** 53) - 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would use parenthesis to explicitly state the associations of operands

const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || (-(2 ** 53) - 1)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I'm so used to prettier purging my files of extra parens that I it doesn't bother me. Sooner or later we'll start using it for this project and they'll be gone anyway.

Not saying I disagree with you (I'v actually been complaining about its handling of parens for ages - see my comment towards the end), but using prettier is such a huge win in terms of time that it's worth the small bumps.

So doesn't bother me but happy to change if you would like.


export default MIN_SAFE_INTEGER;
3 changes: 1 addition & 2 deletions src/isArray.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _isArray from 'ramda/src/internal/_isArray';
import { or } from 'ramda';


/**
Expand All @@ -19,6 +18,6 @@ import { or } from 'ramda';
* RA.isArray(null); //=> false
* RA.isArray({}); //=> false
*/
const isArray = or(Array.isArray, _isArray);
const isArray = Array.isArray || _isArray;

export default isArray;
4 changes: 1 addition & 3 deletions src/isFinite.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { or } from 'ramda';

import polyfill from './internal/polyfills/Number.isFinite';

/**
Expand Down Expand Up @@ -27,6 +25,6 @@ import polyfill from './internal/polyfills/Number.isFinite';
* RA.isFinite(null); // => false
* // would've been true with global isFinite(null)
*/
const _isFinite = or(Number.isFinite, polyfill);
const _isFinite = Number.isFinite || polyfill;

export default _isFinite;
4 changes: 1 addition & 3 deletions src/isGeneratorFunction.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { or } from 'ramda';

import isNotNull from './isNotNull';


Expand Down Expand Up @@ -33,7 +31,7 @@ const isGeneratorFunction = (val) => {
const toStringCheck = Object.prototype.toString.call(val) === '[object GeneratorFunction]';
const legacyConstructorCheck = isNotNull(GeneratorFunction) && val instanceof GeneratorFunction;

return or(toStringCheck, legacyConstructorCheck);
return toStringCheck || legacyConstructorCheck;
};

export default isGeneratorFunction;
4 changes: 1 addition & 3 deletions src/isInteger.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { or } from 'ramda';

import polyfill from './internal/polyfills/Number.isInteger';

/**
Expand Down Expand Up @@ -30,6 +28,6 @@ import polyfill from './internal/polyfills/Number.isInteger';
* RA.isInteger(false); //=> false
* RA.isInteger([1]); //=> false
*/
const isInteger = or(Number.isInteger, polyfill);
const isInteger = Number.isInteger || polyfill;

export default isInteger;
4 changes: 1 addition & 3 deletions src/isNaN.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { or } from 'ramda';

import polyfill from './internal/polyfills/Number.isNaN';

/**
Expand Down Expand Up @@ -35,6 +33,6 @@ import polyfill from './internal/polyfills/Number.isNaN';
* RA.isNaN(''); // => false
* RA.isNaN(' '); // => false
*/
const _isNaN = or(Number.isNaN, polyfill);
const _isNaN = Number.isNaN || polyfill;

export default _isNaN;
4 changes: 2 additions & 2 deletions test/liftFN.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as R from 'ramda';
import chai from 'chai';
import { Maybe } from 'monet';
import { add, reduce } from 'ramda';

import * as RA from '../src/index';
import eq from './shared/eq';
import Identity from '../src/fantasy-land/Identity';


const addN = (...args) => reduce(add, 0, args);
const addN = (...args) => R.sum(args);
const add3 = (a, b, c) => a + b + c;

describe('liftFN', function () {
Expand Down
4 changes: 2 additions & 2 deletions test/neither.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as R from 'ramda';
import { Just, Nothing } from 'monet';
import sinon from 'sinon';

Expand Down Expand Up @@ -40,10 +41,9 @@ describe('neither', function () {

context('when the result of first function is true', function () {
specify('should not evaluate the second expression', function () {
const f = () => true;
const z = sinon.spy();

RA.neither(f, z)();
RA.neither(R.T, z)();
eq(z.notCalled, true);
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/notBoth.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as R from 'ramda';
import { Just, Nothing } from 'monet';
import sinon from 'sinon';

Expand Down Expand Up @@ -40,10 +41,9 @@ describe('notBoth', function () {

context('when the first function returns false', function () {
specify('should not evaluate the second function', function () {
const f = () => false;
const z = sinon.spy();

RA.notBoth(f, z)();
RA.notBoth(R.F, z)();
eq(z.notCalled, true);
});
});
Expand Down