eslint-plugin-ramda
eslint-plugin-ramda copied to clipboard
Support for Ramda imported with alias
Currently, we support linting code imported with:
import { ifElse, cond } from 'ramda'
and:
import R from 'ramda'
but things like:
import { ifElse as if_else }, Ramda from 'ramda'
won't be caught by the linter.
We need to think about a way to checking how Ramda was imported to figure out what to lint and avoid false positives or false negatives.
I’ve worked on this a while ago but haven’t had time to finish it, see 013b2a5bd20e60d7d81484be365ed00b10193ed4 (branch infer-ramda-method-reference).
In addition to import it also supports static require of 'ramda', global.R, window.R and R.* is only supported when it is not shadowed and thus would implicitly resolve to a global reference of R. We might also want to support this.R in cases where this resolve to the global object.
Currently, we support linting code imported with:
import { ifElse, cond } from 'ramda'and:import R from 'ramda'
Currently we don’t even check imports, so e.g. the following code would cause false-positive problems reported by eslint-plugin-ramda:
import R from 'ramda';
function foo() {
const R = { filter: 'foo' };
R.filter(R.complement(R.T));
}
Would this enhancement cover the following case too?
import * as _ from 'ramda'
Can we globally(per project) set somewhere in the configuration file that the namespace is not R but _ ?
I think this should be covered.
Currently, there is no way to change the R, but I'll be working this weekend on, at least, a custom option to set the name of the Ramda object.