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

Support for Ramda imported with alias #17

Open
haskellcamargo opened this issue Mar 4, 2018 · 4 comments
Open

Support for Ramda imported with alias #17

haskellcamargo opened this issue Mar 4, 2018 · 4 comments

Comments

@haskellcamargo
Copy link
Member

haskellcamargo commented Mar 4, 2018

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 haskellcamargo changed the title Support for R Support for Ramda imported with alias Mar 4, 2018
@lo1tuma
Copy link
Member

lo1tuma commented Mar 4, 2018

I’ve worked on this a while ago but haven’t had time to finish it, see 013b2a5 (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
Copy link
Member

lo1tuma commented Mar 4, 2018

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

@1024gs
Copy link

1024gs commented Jun 15, 2018

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

@haskellcamargo
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants