Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@emotion/eslint-plugin

emotion-js641.4kMIT11.12.0TypeScript support: included

ESLint rules for emotion

eslint, eslintplugin, eslint-plugin, emotion

readme

@emotion/eslint-plugin

ESLint rules for emotion

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install @emotion/eslint-plugin:

$ npm install @emotion/eslint-plugin --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install @emotion/eslint-plugin globally.

Usage

Add @emotion to the plugins section of your .eslintrc configuration file. You can omit /eslint-plugin:

{
  "plugins": ["@emotion"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "@emotion/jsx-import": "error"
  }
}

Emotion 11 codemod

The Emotion 11 codemods are contained in this package. To use them, enable the rule shown below.

{
  "rules": {
    "@emotion/pkg-renaming": "error"
  }
}

Emotion 10 codemods

The Emotion 10 codemods are contained in this package. To use them, enable the rules shown below. Keeping these rules after migrating is also useful to have jsx from @emotion/react automatically imported when the css prop is used and other such things. You may also want to not enable certain rules while you are migrating or forever, such the no-vanilla rule.

{
  "rules": {
    "@emotion/jsx-import": "error",
    "@emotion/no-vanilla": "error",
    "@emotion/import-from-emotion": "error",
    "@emotion/styled-import": "error"
  }
}

Note:

These rules assume you are using React, if you are not using React, you should keep using the emotion package.

Supported Rules

changelog

@emotion/eslint-plugin

11.12.0

Minor Changes

  • #2568 304f7e3 Thanks @G-Rath! - Source code has been migrated to TypeScript. From now on type declarations will be emitted based on that, instead of being hand-written.

Patch Changes

  • #2568 304f7e3 Thanks @G-Rath! - An empty css prop (<div css />) will now raise an error in the @emotion/syntax-preference rule instead of crashing on this case.

  • #2568 304f7e3 Thanks @G-Rath! - Fixed a crash on empty css prop (<div css />) in the @emotion/jsx-import rule.

11.11.0

Patch Changes

11.10.0

Minor Changes

  • #2819 bbad8c79 Thanks @nicksrandall! - exports field has been added to the package.json manifest. It limits what files can be imported from a package but we've tried our best to allow importing all the files that were considered to be a part of the public API.

11.7.0

Minor Changes

  • #2562 f046ae40 Thanks @G-Rath! - ESLint 8 has been added to the peer dependency range (ESLint 6 and ESLint 7 are still being supported).

11.5.0

Patch Changes

11.2.0

Patch Changes

  • bfaa1b51 #2246 Thanks @G-Rath! - Improved syntax-preference rule to support css function and check style types for arguments of css & styled calls.

11.0.0

Major Changes

  • b8476e08 #1675 Thanks @emmatown! - Rename eslint-plugin-emotion to @emotion/eslint-plugin. Please replace "plugins": ["emotion"] with "plugins": ["@emotion"] and emotion/ with @emotion/ in your rules config in your ESLint config.

Minor Changes

11.0.0-rc.0

Major Changes

Minor Changes

  • 58e8c110 #2034 Thanks @Andarist! - ESLint 7 has been added to the peer dependency range (ESLint 6 keeps being supported).

11.0.0-next.10

Major Changes

  • b8476e08 #1675 Thanks @emmatown! - Rename eslint-plugin-emotion to @emotion/eslint-plugin. Please replace "plugins": ["emotion"] with "plugins": ["@emotion"] and emotion/ with @emotion/ in your rules config in your ESLint config.

Minor Changes

10.0.27

Patch Changes

10.0.14

Patch Changes