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

Unable to specify a specific import from a specific module #253

Closed
43081j opened this issue Mar 14, 2019 · 1 comment
Closed

Unable to specify a specific import from a specific module #253

43081j opened this issue Mar 14, 2019 · 1 comment

Comments

@43081j
Copy link
Contributor

43081j commented Mar 14, 2019

So you provide two options:

  • moduleName
  • importName

Used like so:

// moduleName = module
import {x, y} from 'module';
x`test`; // parsed
y`test`; // parsed
// moduleName = module
// importName = y
import {x, y} from 'module';
x`test`; // parsed
y`test`; // parsed
y(whatever)`test`; // parsed
y.whatever`test`; // parsed

Surely this isn't how importName should work. I would expect only tagged templates which use the specified import name to be parsed, rather than ALL imported names and the extra styled-specific stuff.

Like this:

// moduleName = module
// importName = y
import {x, y} from 'module';
x`test`; // NOT parsed
y`test`; // parsed

With this ability we could use the same component on other tagged template css libraries. Something like LitElement. But we can't yet because we over-parse:

css`this is css`; // parsed
html`this is html`; // parsed <- WRONG, it shouldn't be
@chinesedfan
Copy link
Member

Agree with your feature request. But importName is there. We have use another option name or try to enhance it. Like single string means the old usage, and an array is used to provide names whitelist.

43081j added a commit to crispthinking/stylelint-processor-styled-components that referenced this issue Mar 25, 2019
Fixes styled-components#253.

Enables stricter parsing, in that only expressions using the specified
`importName` from the `moduleName` will be parsed.
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

2 participants