Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Make import name configurable #109

Closed
mxstbr opened this issue Aug 28, 2017 · 1 comment
Closed

Make import name configurable #109

mxstbr opened this issue Aug 28, 2017 · 1 comment
Assignees
Milestone

Comments

@mxstbr
Copy link
Member

mxstbr commented Aug 28, 2017

Right now this processor is hard-coded to only work with styled-components due to checking the import name here:

const isStyledImport = node =>
node.type === 'ImportDeclaration' && node.source.value === 'styled-components'

We should add an option (importName? library? package?) to allow users to say that the name of the imported package is different so it can be used with styled-jss, emotion, etc.

It'd be a shame if all those libraries had to build their own processor, when really they only have to change that one string and it'd work. I don't think we should promise any particular level of support, since all those libraries have slightly diverging APIs, but having basic support would be prettttttty great. (and also awesome to get out with v1.0)

@mxstbr mxstbr added this to the v1.0 milestone Aug 28, 2017
@mxstbr
Copy link
Member Author

mxstbr commented Aug 28, 2017

Ohh I just now realised that this'll already work as we only check for styled.x calls! This code lints:

import styled from 'emotion';

const Div = styled.div`
  color: blue;
`

It only fails if you use a differing import name, that's what that check is for!

import emotion from 'emotion';

const Div = emotion.div`
  color: blue;
`

mxstbr added a commit that referenced this issue Aug 28, 2017
@mxstbr mxstbr self-assigned this Aug 28, 2017
mxstbr added a commit that referenced this issue Aug 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant