-
Notifications
You must be signed in to change notification settings - Fork 5
/
README.md.template
151 lines (117 loc) · 3.97 KB
/
README.md.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<br>
<div align="center">
<p align="center">
<a href="https://panda-css.com">
<picture>
<img alt="Panda CSS" src="https://github.com/chakra-ui/eslint-plugin-panda/raw/main/.github/banner.png" width="100%">
</picture>
</a>
</p>
<p align="center">ESLint plugin for Panda CSS</p>
<p align="center">
<a aria-label="Github Actions" href="https://github.com/chakra-ui/eslint-plugin-panda/actions/workflows/quality.yml">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/github/actions/workflow/status/chakra-ui/eslint-plugin-panda/quality.yml?branch=main&label=%20&message=twitter&color=212022&logo=githubactions&style=for-the-badge">
<source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/github/actions/workflow/status/chakra-ui/eslint-plugin-panda/quality.yml?branch=main&label=%20&message=twitter&color=f6f7f8&logo=githubactions&style=for-the-badge&logoColor=%23000">
<img alt="Github release actions" src="https://img.shields.io/github/actions/workflow/status/chakra-ui/eslint-plugin-panda/quality.yml?branch=main&label=%20&message=twitter&color=f6f7f8&logo=githubactions&style=for-the-badge&logoColor=%23000">
</picture>
</a>
</p>
</div>
## Getting Started
### Installation
```bash
pnpm add -D @pandacss/eslint-plugin
```
### Usage
Add `@pandacss/eslint-plugin` to the plugins section of your `.eslintrc` configuration file. You can omit the
`/eslint-plugin` suffx:
```json
{
"plugins": ["@pandacss"]
}
```
Then configure the rules you want to use under the rules section.
```json
{
"rules": {
"@pandacss/no-debug": "error"
}
}
```
You can also enable the `recommended` rules in extends:
```diff
{
- "plugins": ["@pandacss"]
+ "extends": ["plugin:@pandacss/recommended"]
}
```
Or enable all rules in extends:
```diff
{
- "plugins": ["@pandacss"]
+ "extends": ["plugin:@pandacss/all"]
}
```
> [!WARNING]
> This is not recommended. You should only enable the rules you need.
### Flat Config
If you use [the flat config format](https://eslint.org/docs/latest/use/configure/configuration-files), you can import
the plugin and rules from `@pandacss/eslint-plugin` and put it into your config.
```js filename="eslint.config.mjs"
import typescriptParser from '@typescript-eslint/parser'
import panda from '@pandacss/eslint-plugin'
export default [
{
files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
ignores: ['**/*.d.ts', 'styled-system'],
plugins: {
'@pandacss': panda,
},
languageOptions: {
parser: typescriptParser,
},
rules: {
// Configure rules here
"@pandacss/no-debug": "error",
// You can also use the recommended rules
...panda.configs.recommended.rules,
// Or all rules
...panda.configs.all.rules,
},
},
]
```
You can see an example using `typescript-eslint` at [sandbox/v9/eslint.config.mjs](./sandbox/v9/eslint.config.mjs).
## Rules
Rules with ⚙️ have options. Click on the rule to see the options.
Where rules are included in the configs `recommended`, or `all` it is indicated below.
<!-- rules -->
## Settings
### `configPath`
You can tell `eslint` to use a custom panda config file by setting the `configPath` option in your `.eslintrc.js` file.
By default we find the nearest panda config to the linted file.
```js filename=".eslintrc.(c)js"
const path = require('path')
module.exports = {
plugins: ['@pandacss'],
settings: {
'@pandacss/configPath': path.join('PATH-TO/panda.config.js'),
},
}
```
#### Flat Config
```js filename="eslint.config.mjs"
import panda from '@pandacss/eslint-plugin'
import path from 'node:path'
export default [
{
plugins: {
'@pandacss': panda,
},
settings: {
'@pandacss/configPath': path.join('PATH-TO/panda.config.js'),
},
},
]
```