Skip to content

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

Closed
@ffxsam

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?

Activity

gaearon

gaearon commented on Jun 27, 2017

@gaearon
Contributor

Overriding our ESLint settings is not really supported. It technically "works" for IDEs so we documented it, but we still want everyone to have the same base configuration. This helps make sure it works correctly for everyone, that bugfixes are coordinated, and that everyone has mostly good experience out of the box.

In this particular case it seems like we should change our config. Our stance is that we try to create a config that's good for most users rather than allow users to make individual tweaks, thus keeping the base config less ideal.

If you send a PR for fixing this in our config I'm happy to take that in.

denkristoffer

denkristoffer commented on Aug 10, 2017

@denkristoffer
Contributor

This issue can be closed now 👍

Timer

Timer commented on Aug 10, 2017

@Timer
Contributor

Thanks!

Timer

Timer commented on Aug 10, 2017

@Timer
Contributor

This feature has been released as of v1.0.11. :)

locked and limited conversation to collaborators on Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @denkristoffer@Timer@gaearon@ffxsam

        Issue actions

          ESLint - no-unused-expressions warning for template tags · Issue #2647 · facebook/create-react-app