styled-components / stylelint-processor-styled-components

Lint your styled components with stylelint!

Home Page:https://styled-components.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to specify a specific import from a specific module

43081j opened this issue · comments

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

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.