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

`exportDefaultFrom` error from parser after upgrade to 1.4.0

thmsobrmlr opened this issue · comments

I'm currently in the process of updating from version 1.3.2 to 1.4.0. As I can see from the changelog, babel errors are now shown to users. I'm now getting a few of those:

This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:7)

The files where this occurs are very simple e.g.:

export Container from './Container';

How can I configure the parser used by this plugin to allow for the experimental syntax? Am I doing something wrong?

@Thomas88 #229 should provide a way to config babel. You can try it locally and I will publish later.

v1.5.0 has been published.

Awesome, thanks for the quick fix @chinesedfan! I've now added exportDefaultFrom to the default plugins and it works again.

A question from my side: I think it would be better if the plugin could simply use the same configuration as I use for babel i.e. .babelrc / babel prop in package.json. Does this not work? Do you think this is a bad idea?

@Thomas88 Good idea. I created #231 to remind later developers.

I am on latest version of this package, as well as babel, but I am still receiving this error. Any ideas as to why that might be the case?

I've now added exportDefaultFrom to the default plugins and it works again.

@rtymchyk Have you changed your configurations like this? If still met this problem, feel free to open a new issue with detailed environments information.

@chinesedfan Sorry, I misread. I thought the PR was including this as a plugin already. Working fine now, but definitely would be great to utilize the central Babel config instead of this.

For those who stumbled upon this issue from Google and are confused, just add this to your .stylelintrc:

{
  "processors": [
    ["stylelint-processor-styled-components", {
      "parserPlugins": [
        "jsx",
        "objectRestSpread",
        ["decorators", { "decoratorsBeforeExport": true }],
        "classProperties",
        "exportExtensions",
        "asyncGenerators",
        "functionBind",
        "functionSent",
        "dynamicImport",
        "optionalCatchBinding",
        "optionalChaining",
        "exportDefaultFrom"
      ]
    }]
  ],

  ... REST OF YOUR CONFIG

}