Skip to content

ESLint - no-unused-expressions warning for template tags #2647

Description

@ffxsam

I'm using styled-components' injectGlobal template tag function, like so:

injectGlobal` .ant-btn-clicked:after { border: 0 solid ${mainTheme.primaryColor.toString()} !important; } .ant-switch-checked { background-color: ${mainTheme.primaryColor.toString()} !important; border-color: ${mainTheme.primaryColor.toString()} !important; }`;

And I got warnings about injectGlobal being an unused expression. So I've modified my .eslintrc to be the following:

{
"extends": "react-app",
"rules": {
"no-unused-expressions": ["error", {"allowTaggedTemplates": true}]
}
}

This seems to stop ESLint warnings in Nuclide, but I'm still getting them in the browser console and shell:

./src/themes.js
Line 20: Expected an assignment or function call and instead saw an expression no-unused-expressions

Am I configuring something wrong?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions