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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added '@emotion/react' ESLint config #2960

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sweet-forks-whisper.md
@@ -0,0 +1,5 @@
---
'@emotion/eslint-plugin': minor
---

Added '@emotion/react' ESLint config
22 changes: 17 additions & 5 deletions packages/eslint-plugin/README.md
Expand Up @@ -28,10 +28,20 @@ Add `@emotion` to the plugins section of your `.eslintrc` configuration file. Yo
}
```

Then configure the rules you want to use under the rules section.
You can enable the rules we recommend for `react` by listing the `@emotion/react` preset under `extends`:

```json
{
"extends": ["@emotion/react"],
"plugins": ["@emotion"]
}
```

Alternately, you configure specifically rules you want to use under the `rules` section.

```json
{
"plugins": ["@emotion"],
"rules": {
"@emotion/jsx-import": "error"
}
Expand Down Expand Up @@ -71,8 +81,10 @@ The Emotion 10 codemods are contained in this package. To use them, enable the r

## Supported Rules

- [jsx-import](https://github.com/emotion-js/emotion/blob/main/packages/eslint-plugin/docs/rules/jsx-import.md)
- [styled-import](https://github.com/emotion-js/emotion/blob/main/packages/eslint-plugin/docs/rules/styled-import.md)
- [import-from-emotion](https://github.com/emotion-js/emotion/blob/main/packages/eslint-plugin/docs/rules/import-from-emotion.md)
- [no-vanilla](https://github.com/emotion-js/emotion/blob/main/packages/eslint-plugin/docs/rules/no-vanilla.md)
Rules enabled by default in the `react` config are marked with 鈿涳笍.

- 鈿涳笍 [import-from-emotion](https://github.com/emotion-js/emotion/blob/main/packages/eslint-plugin/docs/rules/import-from-emotion.md)
- 鈿涳笍 [jsx-import](https://github.com/emotion-js/emotion/blob/main/packages/eslint-plugin/docs/rules/jsx-import.md)
- 鈿涳笍 [no-vanilla](https://github.com/emotion-js/emotion/blob/main/packages/eslint-plugin/docs/rules/no-vanilla.md)
- 鈿涳笍 [styled-import](https://github.com/emotion-js/emotion/blob/main/packages/eslint-plugin/docs/rules/styled-import.md)
- [syntax-preference](https://github.com/emotion-js/emotion/blob/main/packages/eslint-plugin/docs/rules/syntax-preference.md)
15 changes: 12 additions & 3 deletions packages/eslint-plugin/src/index.js
Expand Up @@ -7,11 +7,20 @@ import styledImport from './rules/styled-import'
import jsxImport from './rules/jsx-import'
import pkgRenaming from './rules/pkg-renaming'

export let configs = {
react: {
'import-from-emotion': 'error',
'jsx-import': 'error',
'no-vanilla': 'error',
'styled-import': 'error'
}
}

export let rules = {
'import-from-emotion': importFromEmotion,
'jsx-import': jsxImport,
'no-vanilla': noVanilla,
'syntax-preference': syntaxPreference,
'pkg-renaming': pkgRenaming,
'styled-import': styledImport,
'jsx-import': jsxImport,
'pkg-renaming': pkgRenaming
'syntax-preference': syntaxPreference
}