eslint-plugin-ramda icon indicating copy to clipboard operation
eslint-plugin-ramda copied to clipboard

Support for Ramda imported with alias

Open haskellcamargo opened this issue 7 years ago • 4 comments

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.

haskellcamargo avatar Mar 04 '18 22:03 haskellcamargo

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.

lo1tuma avatar Mar 04 '18 22:03 lo1tuma

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));
}

lo1tuma avatar Mar 04 '18 22:03 lo1tuma

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 _ ?

1024gs avatar Jun 15 '18 15:06 1024gs

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.

haskellcamargo avatar Jun 15 '18 18:06 haskellcamargo