Skip to content

Commit 3aaba9f

Browse files
committed
update plugin
1 parent f5c63db commit 3aaba9f

File tree

14 files changed

+615
-327
lines changed

14 files changed

+615
-327
lines changed

.changeset/light-insects-know.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pandacss/eslint-plugin": patch
3+
---
4+
5+
- Rename `no-shorthand-prop` rule to `prefer-longhand-properties`

README.md

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

fixture/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
"deps": "pnpm up '@pandacss/*' --latest"
1111
},
1212
"devDependencies": {
13-
"@pandacss/config": "^0.29.0",
14-
"@pandacss/core": "^0.29.0",
15-
"@pandacss/generator": "^0.29.0",
16-
"@pandacss/node": "^0.29.0",
17-
"@pandacss/preset-base": "^0.29.0",
18-
"@pandacss/preset-panda": "^0.29.0",
19-
"@pandacss/shared": "^0.29.0",
20-
"@pandacss/token-dictionary": "^0.29.0",
21-
"@pandacss/types": "^0.29.0",
13+
"@pandacss/config": "^0.30.1",
14+
"@pandacss/core": "^0.30.1",
15+
"@pandacss/generator": "^0.30.1",
16+
"@pandacss/node": "^0.30.1",
17+
"@pandacss/preset-base": "^0.30.1",
18+
"@pandacss/preset-panda": "^0.30.1",
19+
"@pandacss/shared": "^0.30.1",
20+
"@pandacss/token-dictionary": "^0.30.1",
21+
"@pandacss/types": "^0.30.1",
2222
"postcss": "^8.4.33"
2323
}
2424
}

plugin/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
"dist"
3434
],
3535
"dependencies": {
36-
"@pandacss/config": "^0.29.1",
37-
"@pandacss/generator": "^0.29.1",
38-
"@pandacss/node": "^0.29.1",
39-
"@pandacss/shared": "^0.29.1",
36+
"@pandacss/config": "^0.30.1",
37+
"@pandacss/generator": "^0.30.1",
38+
"@pandacss/node": "^0.30.1",
39+
"@pandacss/shared": "^0.30.1",
4040
"@typescript-eslint/utils": "^6.19.1",
4141
"hookable": "^5.5.3",
4242
"synckit": "^0.9.0"

plugin/src/rules/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import noEscapeHatch, { RULE_NAME as NoEscapeHatch } from './no-escape-hatch'
66
import noHardCodedColor, { RULE_NAME as NoHardCodedColor } from './no-hardcoded-color'
77
import noInvalidTokenPaths, { RULE_NAME as NoInvalidTokenPaths } from './no-invalid-token-paths'
88
import noPropertyRenaming, { RULE_NAME as NoPropertyRenaming } from './no-property-renaming'
9-
import noShorthandProp, { RULE_NAME as NoShorthandProp } from './no-shorthand-prop'
9+
import preferLonghandProperties, { RULE_NAME as PreferLonghandProperties } from './prefer-longhand-properties'
1010
import noUnsafeTokenUsage, { RULE_NAME as NoUnsafeTokenUsage } from './no-unsafe-token-fn-usage'
1111
import preferAtomicProperties, { RULE_NAME as PreferAtomicProperties } from './prefer-atomic-properties'
1212

@@ -19,7 +19,7 @@ export const rules = {
1919
[NoHardCodedColor]: noHardCodedColor,
2020
[NoInvalidTokenPaths]: noInvalidTokenPaths,
2121
[NoPropertyRenaming]: noPropertyRenaming,
22-
[NoShorthandProp]: noShorthandProp,
22+
[PreferLonghandProperties]: preferLonghandProperties,
2323
[NoUnsafeTokenUsage]: noUnsafeTokenUsage,
2424
[PreferAtomicProperties]: preferAtomicProperties,
2525
} as any

plugin/src/rules/prefer-atomic-properties.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { isPandaAttribute, isPandaProp, isValidProperty, resolveShorthand } from '../utils/helpers'
22
import { type Rule, createRule } from '../utils'
3-
import { shorthandProperties } from '../utils/shorthand-properties'
3+
import { compositeProperties } from '../utils/composite-properties'
44
import { isIdentifier, isJSXIdentifier } from '../utils/nodes'
55

66
export const RULE_NAME = 'prefer-atomic-properties'
@@ -20,16 +20,16 @@ const rule: Rule = createRule({
2020
defaultOptions: [],
2121
create(context) {
2222
const resolveCompositeProperty = (name: string) => {
23-
if (Object.hasOwn(shorthandProperties, name)) return name
23+
if (Object.hasOwn(compositeProperties, name)) return name
2424

2525
const longhand = resolveShorthand(name, context)
26-
if (isValidProperty(longhand, context) && Object.hasOwn(shorthandProperties, longhand)) return longhand
26+
if (isValidProperty(longhand, context) && Object.hasOwn(compositeProperties, longhand)) return longhand
2727
}
2828

2929
const sendReport = (node: any, name: string) => {
3030
const cpd = resolveCompositeProperty(name)!
3131

32-
const atomics = shorthandProperties[cpd].map((name) => `\`${name}\``).join(',\n')
32+
const atomics = compositeProperties[cpd].map((name) => `\`${name}\``).join(',\n')
3333

3434
return context.report({
3535
node,

plugin/src/utils/shorthand-properties.ts renamed to plugin/src/utils/composite-properties.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const shorthandProperties: Record<string, string[]> = {
1+
export const compositeProperties: Record<string, string[]> = {
22
animation: [
33
'animationName',
44
'animationDuration',

plugin/src/utils/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export const extractTokens = (value: string) => {
245245
export const getInvalidTokens = (value: string, context: RuleContext<any, any>) => {
246246
const tokens = extractTokens(value)
247247
if (!tokens.length) return []
248-
return syncAction('filterInvalidTokenz', getSyncOpts(context), tokens)
248+
return syncAction('filterInvalidTokens', getSyncOpts(context), tokens)
249249
}
250250

251251
export const getExtendWarnings = (context: RuleContext<any, any>) => {

plugin/src/utils/worker.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ async function getExtendWarnings(): Promise<string[]> {
5858
return Array.from(warnings)
5959
}
6060

61-
async function filterInvalidTokenz(ctx: PandaContext, paths: string[]): Promise<string[]> {
62-
return paths.filter((path) => !ctx.utility.tokens.get(path))
61+
async function filterInvalidTokens(ctx: PandaContext, paths: string[]): Promise<string[]> {
62+
return paths.filter((path) => !ctx.utility.tokens.view.get(path))
6363
}
6464

6565
async function isColorToken(ctx: PandaContext, value: string): Promise<boolean> {
66-
return !!ctx.utility.tokens.values.get('colors')?.get(value)
66+
return !!ctx.utility.tokens.view.categoryMap.get('colors')?.get(value)
6767
}
6868

6969
async function isColorAttribute(ctx: PandaContext, _attr: string): Promise<boolean> {
@@ -139,7 +139,7 @@ type Opts = {
139139
}
140140

141141
export function runAsync(action: 'getExtendWarnings', opts: Opts): Promise<string[]>
142-
export function runAsync(action: 'filterInvalidTokenz', opts: Opts, paths: string[]): Promise<string[]>
142+
export function runAsync(action: 'filterInvalidTokens', opts: Opts, paths: string[]): Promise<string[]>
143143
export function runAsync(action: 'isColorToken', opts: Opts, value: string): Promise<boolean>
144144
export function runAsync(action: 'isColorAttribute', opts: Opts, attr: string): Promise<boolean>
145145
export function runAsync(action: 'isConfigFile', opts: Opts, fileName: string): Promise<string>
@@ -178,16 +178,16 @@ export async function runAsync(action: string, opts: Opts, ...args: any): Promis
178178
case 'isColorToken':
179179
// @ts-expect-error cast
180180
return isColorToken(ctx, ...args)
181-
case 'filterInvalidTokenz':
181+
case 'filterInvalidTokens':
182182
// @ts-expect-error cast
183-
return filterInvalidTokenz(ctx, ...args)
183+
return filterInvalidTokens(ctx, ...args)
184184
case 'getExtendWarnings':
185185
return getExtendWarnings()
186186
}
187187
}
188188

189189
export function run(action: 'getExtendWarnings', opts: Opts): string[]
190-
export function run(action: 'filterInvalidTokenz', opts: Opts, paths: string[]): string[]
190+
export function run(action: 'filterInvalidTokens', opts: Opts, paths: string[]): string[]
191191
export function run(action: 'isColorToken', opts: Opts, value: string): boolean
192192
export function run(action: 'isColorAttribute', opts: Opts, attr: string): boolean
193193
export function run(action: 'isConfigFile', opts: Opts): boolean

0 commit comments

Comments
 (0)