eslint-plugin-ramda
Version:
ESLint rules for use with Ramda
36 lines (32 loc) • 859 B
JavaScript
;
const R = require('ramda');
const isCalling = require('../ast-helper').isCalling;
const create = context => ({
CallExpression(node) {
const match = isCalling({
name: 'eqBy',
arguments: R.both(
R.complement(R.isEmpty),
R.propSatisfies(isCalling({
name: 'prop',
arguments: R.propEq('length', 1)
}), 0)
)
});
if (match(node)) {
context.report({
node,
message: '`eqBy(prop(_))` should be simplified to `eqProps(_)`'
});
}
}
});
module.exports = {
create,
meta: {
docs: {
description: 'Detects when `eqBy(prop(_))` can be replaced by `eqProps(_)`',
recommended: 'off'
}
}
};