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

The parser breaks when using html template tag #4800

Closed
abdonrd opened this issue May 22, 2020 · 3 comments
Closed

The parser breaks when using html template tag #4800

abdonrd opened this issue May 22, 2020 · 3 comments

Comments

@abdonrd
Copy link
Member

abdonrd commented May 22, 2020

Clearly describe the bug

The parser breaks when using html template tag

Which rule, if any, is the bug related to?

None.

What code is needed to reproduce the bug?

export class X extends Y {
  static styles = css`
    :host {
      display: block;
      display: block;
    }
  `;

  render() {
    return html`<div>Hi!</div>`;
  }
}

What stylelint configuration is needed to reproduce the bug?

{
  "rules": {
    "declaration-block-no-duplicate-properties": [
      true,
      {
        "ignore": [
          "consecutive-duplicates-with-different-values"
        ]
      }
    ]
  }
}

Which version of stylelint are you using?

v13.5.0.

It works well with the v13.3.3. Stop working at v13.4.0.

How are you running stylelint: CLI, PostCSS plugin, Node.js API?

CLI with stylelint "**/*.ts"

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

Template literals.

What did you expect to happen?

No parser error

What actually happened (e.g. what warnings or errors did you get)?

The parser breaks when using html template tag:

> stylelint "client/src/pages/**/*.ts"

TypeError: result.apply is not a function
    at /Users/abdonrd/pwa-lit-template/node_modules/@stylelint/postcss-css-in-js/extract.js:274:20
    at Array.some (<anonymous>)
    at isStylePath (/Users/abdonrd/pwa-lit-template/node_modules/@stylelint/postcss-css-in-js/extract.js:260:33)
    at TaggedTemplateExpression (/Users/abdonrd/pwa-lit-template/node_modules/@stylelint/postcss-css-in-js/extract.js:359:8)
    at NodePath._call (/Users/abdonrd/pwa-lit-template/node_modules/@babel/traverse/lib/path/context.js:55:20)
    at NodePath.call (/Users/abdonrd/pwa-lit-template/node_modules/@babel/traverse/lib/path/context.js:42:17)
    at NodePath.visit (/Users/abdonrd/pwa-lit-template/node_modules/@babel/traverse/lib/path/context.js:90:31)
    at TraversalContext.visitQueue (/Users/abdonrd/pwa-lit-template/node_modules/@babel/traverse/lib/context.js:112:16)
    at TraversalContext.visitSingle (/Users/abdonrd/pwa-lit-template/node_modules/@babel/traverse/lib/context.js:84:19)
    at TraversalContext.visit (/Users/abdonrd/pwa-lit-template/node_modules/@babel/traverse/lib/context.js:140:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pwa-lit-template@0.1.0 lint:stylelint: `stylelint "client/src/pages/**/*.ts"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the pwa-lit-template@0.1.0 lint:stylelint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/abdonrd/.npm/_logs/2020-05-22T11_59_28_821Z-debug.log
@abdonrd
Copy link
Member Author

abdonrd commented May 22, 2020

After check the diff from 13.3.3...13.4.0:

The error seems related to this:

13.3.3...13.4.0#diff-86e39c31ff3c9300102b40c22b3d8c4a

Because before this release, the html syntax was 'postcss-html', then the result was false here:

https://github.com/stylelint/postcss-css-in-js/blob/7a28eabd8851114b3394b89c8d510bd1da2e1690/extract.js#L256-L274

And now enter here and breaks:

https://github.com/stylelint/postcss-css-in-js/blob/7a28eabd8851114b3394b89c8d510bd1da2e1690/extract.js#L265

@abdonrd
Copy link
Member Author

abdonrd commented May 22, 2020

Here you a demo.

Note: The demo is working but probably because the playground is not using the last Stylelint version?

@abdonrd abdonrd mentioned this issue May 28, 2020
23 tasks
@jeddy3
Copy link
Member

jeddy3 commented Jun 3, 2020

@abdonrd Thank you for digging into this. @m-allanson continued to investigate, so we have a better understanding of what's going on now.

There's a workaround fix pending release, so I'll close this issue for now.

The demo is working but probably because the playground is not using the last Stylelint version?

The demo is updated as part of the release process, and so should be using the latest version of stylelint.

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

No branches or pull requests

2 participants