Skip to content

Commit 9d3b454

Browse files
committed
Update readme
1 parent b1b2459 commit 9d3b454

File tree

4 files changed

+183
-1
lines changed

4 files changed

+183
-1
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- This file is built by build-readme.js. Do not edit it directly; edit README.md.template instead. -->
12
<br>
23
<div align="center">
34

@@ -79,6 +80,22 @@ Or enable all rules in extends:
7980
8081
## Rules
8182

83+
Rules with options are indicated with ⚙️. Rules which are fixable are indicated with 🔧.
84+
85+
Where rules are included in the configs `recommended`, or `all` it is indicated below.
86+
87+
* [`@pandacss/file-not-included`](docs/rules/file-not-included.md) `all`, `recommended`
88+
* [`@pandacss/no-config-function-in-source`](docs/rules/no-config-function-in-source.md) 🔧 `all`, `recommended`
89+
* [`@pandacss/no-debug`](docs/rules/no-debug.md) 🔧 `all`, `recommended`
90+
* [`@pandacss/no-dynamic-styling`](docs/rules/no-dynamic-styling.md) `all`, `recommended`
91+
* [`@pandacss/no-escape-hatch`](docs/rules/no-escape-hatch.md) 🔧 `all`
92+
* [`@pandacss/no-hardcoded-color`](docs/rules/no-hardcoded-color.md) `all`
93+
* [`@pandacss/no-invalid-token-paths`](docs/rules/no-invalid-token-paths.md) `all`, `recommended`
94+
* [`@pandacss/no-property-renaming`](docs/rules/no-property-renaming.md) `all`, `recommended`
95+
* [`@pandacss/no-shorthand-prop`](docs/rules/no-shorthand-prop.md) 🔧 `all`
96+
* [`@pandacss/no-unsafe-token-fn-usage`](docs/rules/no-unsafe-token-fn-usage.md) 🔧 `all`
97+
* [`@pandacss/prefer-atomic-properties`](docs/rules/prefer-atomic-properties.md) `all`
98+
8299
## Settings
83100

84101
### `configPath`

README.md.template

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<br>
2+
<div align="center">
3+
4+
<p align="center">
5+
<a href="https://panda-css.com">
6+
<picture>
7+
<img alt="Panda CSS" src="https://github.com/chakra-ui/panda/raw/main/.github/assets/banner.png" width="100%">
8+
</picture>
9+
</a>
10+
</p>
11+
<p align="center">ESLint plugin for Panda CSS</p>
12+
13+
<p align="center">
14+
<a aria-label="Github Actions" href="https://github.com/chakra-ui/eslint-plugin-panda/actions/workflows/quality.yml">
15+
<picture>
16+
<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">
17+
<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">
18+
<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">
19+
</picture>
20+
</a>
21+
</p>
22+
23+
</div>
24+
25+
## Documentation
26+
27+
Visit the Panda CSS [eslint docs](https://panda-css.com/docs/references/eslint) to view the full documentation for this
28+
plugin.
29+
30+
## Getting Started
31+
32+
### Installation
33+
34+
```bash
35+
pnpm add -D @pandacss/eslint-plugin
36+
```
37+
38+
### Usage
39+
40+
Add `@pandacss/eslint-plugin` to the plugins section of your `.eslintrc` configuration file. You can omit the
41+
`/eslint-plugin` suffx:
42+
43+
```json
44+
{
45+
"plugins": ["@pandacss"]
46+
}
47+
```
48+
49+
Then configure the rules you want to use under the rules section.
50+
51+
```json
52+
{
53+
"rules": {
54+
"@pandacss/no-debug": "error"
55+
}
56+
}
57+
```
58+
59+
You can also enable the `recommended` rules in extends:
60+
61+
```diff
62+
{
63+
- "plugins": ["@pandacss"]
64+
+ "extends": ["plugin:@pandacss/recommended"]
65+
}
66+
```
67+
68+
Or enable all rules in extends:
69+
70+
```diff
71+
{
72+
- "plugins": ["@pandacss"]
73+
+ "extends": ["plugin:@pandacss/all"]
74+
}
75+
```
76+
77+
> [!WARNING]
78+
> This is not recommended. You should only enable the rules you need.
79+
80+
## Rules
81+
82+
Rules with options are indicated with ⚙️. Rules which are fixable are indicated with 🔧.
83+
84+
Where rules are included in the configs `recommended`, or `all` it is indicated below.
85+
86+
<!-- rules -->
87+
88+
## Settings
89+
90+
### `configPath`
91+
92+
You can tell `eslint` to use a custom panda config file by setting the `configPath` option in your `.eslintrc.js` file.
93+
94+
By default we find the nearest panda config to the linted file.
95+
96+
```js filename=".eslintrc.(c)js"
97+
const path = require('path')
98+
99+
module.exports = {
100+
plugins: ['@pandacss'],
101+
settings: {
102+
'@pandacss/configPath': path.join('PATH-TO/panda.config.js'),
103+
},
104+
}
105+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "pnpm -r --parallel dev",
88
"build": "pnpm -r --parallel build",
99
"test": "vitest run",
10-
"docs": "rm -rf docs/rules && DOCGEN=1 vitest run",
10+
"docs": "rm -rf docs/rules && DOCGEN=1 vitest run && node tools/build-readme.js",
1111
"lint": "eslint . --ext .ts",
1212
"lint:eslint-docs": "npm run update:eslint-docs -- --check",
1313
"update:eslint-docs": "eslint-doc-generator plugin && pnpm run prettier-fix",

tools/build-readme.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
'use strict'
2+
3+
const fs = require('fs')
4+
const template = fs.readFileSync('README.md.template', { encoding: 'UTF8' })
5+
const rulesWithConfig = require('eslint-docgen').rulesWithConfig
6+
const pluginName = '@pandacss'
7+
const docPath = 'docs/rules/{name}.md'
8+
9+
function getRules(deprecated) {
10+
return Array.from(rulesWithConfig.keys())
11+
.map((rule) => {
12+
const fullRule = pluginName + '/' + rule
13+
const ruleData = rulesWithConfig.get(rule)
14+
const docs = ruleData.meta.docs
15+
if (!!docs.deprecated === deprecated) {
16+
return (
17+
'* [`' +
18+
fullRule +
19+
'`](' +
20+
docPath.replace('{name}', rule) +
21+
')' +
22+
(ruleData.meta.schema.length ? ' ⚙️' : '') +
23+
(ruleData.meta.fixable ? ' 🔧' : '') +
24+
(docs.replacedBy
25+
? ' (use [`' +
26+
pluginName +
27+
'/' +
28+
docs.replacedBy +
29+
'`](' +
30+
docPath.replace('{name}', docs.replacedBy) +
31+
'))'
32+
: '') +
33+
(ruleData.configMap.size
34+
? ' ' +
35+
Array.from(ruleData.configMap.keys())
36+
.map((name) => {
37+
const options = ruleData.configMap.get(name)
38+
return '`' + name + (options && Object.keys(options[0]).length ? '†' : '') + '`'
39+
})
40+
.join(', ')
41+
: '')
42+
)
43+
}
44+
return null
45+
})
46+
.filter((rule) => rule)
47+
.join('\n')
48+
}
49+
50+
fs.writeFile(
51+
'README.md',
52+
'<!-- This file is built by build-readme.js. Do not edit it directly; edit README.md.template instead. -->\n' +
53+
template.replace('<!-- rules -->', getRules(false)).replace('<!-- deprecated -->', getRules(true)),
54+
(err) => {
55+
if (err) {
56+
throw err
57+
}
58+
},
59+
)
60+

0 commit comments

Comments
 (0)