Skip to content

Commit c84bf9e

Browse files
committed
Switch from auto fixable to suggestions
1 parent 1ce3d7a commit c84bf9e

22 files changed

+146
-308
lines changed

.changeset/curvy-phones-tap.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+
Switch from auto fixable to suggestions

docs/rules/no-config-function-in-source.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ Prohibit the use of config functions outside the Panda config.
88

99
📋 This rule is enabled in `plugin:@pandacss/recommended`.
1010

11-
🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
12-
1311
## Rule details
1412

1513
❌ Examples of **incorrect** code for a file named `App.tsx`:
@@ -47,23 +45,6 @@ export default defineConfig({
4745
});
4846
```
4947

50-
🔧 Examples of code **fixed** by this rule for a file named `App.tsx`:
51-
```js
52-
import { defineKeyframes } from '@pandacss/dev'; /**/ import { } from '@pandacss/dev';
53-
import { css } from './panda/css'; /**/ import { css } from './panda/css';
54-
/**/
55-
const keyframes = defineKeyframes({ /**/
56-
fadeIn: { /**/
57-
'0%': { opacity: '0' }, /**/ const styles = css({
58-
'100%': { opacity: '1' }, /**/ animation: 'fadeIn 1s ease-in-out',
59-
}, /**/ });
60-
}); /**/
61-
/**/
62-
const styles = css({ /**/
63-
animation: 'fadeIn 1s ease-in-out', /**/
64-
}); /**/
65-
```
66-
6748
## Resources
6849

6950
* [Rule source](/plugin/src/rules/no-config-function-in-source.ts)

docs/rules/no-debug.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ Disallow the inclusion of the debug attribute when shipping code to the producti
88

99
📋 This rule is enabled in `plugin:@pandacss/recommended`.
1010

11-
🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
12-
1311
## Rule details
1412

1513
❌ Examples of **incorrect** code:
@@ -34,17 +32,6 @@ import { css } from './panda/css';
3432
const styles = css.raw({ color: 'gray.50' })
3533
```
3634

37-
🔧 Examples of code **fixed** by this rule:
38-
```js
39-
import { css } from './panda/css'; /**/ import { css } from './panda/css';
40-
/**/
41-
const styles = css({ bg: 'gray.900', debug: true }); /**/ const styles = css({ bg: 'gray.900', });
42-
43-
import { css } from './panda/css'; /**/ import { css } from './panda/css';
44-
/**/
45-
const styles = css.raw({ color: 'gray.50', debug: true }) /**/ const styles = css.raw({ color: 'gray.50', })
46-
```
47-
4835
## Resources
4936

5037
* [Rule source](/plugin/src/rules/no-debug.ts)

docs/rules/no-dynamic-styling.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
# no-dynamic-styling
44

5-
Ensure user doesn't use dynamic styling at any point. Prefer to use static styles, leverage css variables or recipes for known dynamic styles.
5+
Ensure user doesn't use dynamic styling at any point.
6+
Prefer to use static styles, leverage css variables or recipes for known dynamic styles.
67

78
📋 This rule is enabled in `plugin:@pandacss/all`.
89

docs/rules/no-escape-hatch.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Prohibit the use of escape hatch syntax in the code.
66

77
📋 This rule is enabled in `plugin:@pandacss/all`.
88

9-
🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
10-
119
## Rule details
1210

1311
❌ Examples of **incorrect** code:
@@ -48,25 +46,6 @@ function App(){
4846
}
4947
```
5048

51-
🔧 Examples of code **fixed** by this rule:
52-
```js
53-
import { css } from './panda/css'; /**/ import { css } from './panda/css';
54-
/**/
55-
const styles = css({ marginLeft: '[4px]' }); /**/ const styles = css({ marginLeft: '4px' });
56-
57-
import { css } from './panda/css'; /**/ import { css } from './panda/css';
58-
/**/
59-
function App(){ /**/ function App(){
60-
return <div className={css({ background: '[#111]' })} />; /**/ return <div className={css({ background: '#111' })} />;
61-
}; /**/ };
62-
63-
import { Circle } from './panda/jsx'; /**/ import { Circle } from './panda/jsx';
64-
/**/
65-
function App(){ /**/ function App(){
66-
return <Circle _hover={{ position: '[absolute]' }} />; /**/ return <Circle _hover={{ position: 'absolute' }} />;
67-
} /**/ }
68-
```
69-
7049
## Resources
7150

7251
* [Rule source](/plugin/src/rules/no-escape-hatch.ts)

docs/rules/no-property-renaming.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
# no-property-renaming
44

5-
Ensure user does not rename a property for a pattern or style prop. It doesn't get tracked.
5+
Ensure user does not rename a property for a pattern or style prop.
6+
It doesn't get tracked.
67

78
📋 This rule is enabled in `plugin:@pandacss/all`.
89

@@ -22,27 +23,6 @@ import { css } from './panda/css';
2223

2324
function Text(props){
2425
return <p className={css({ textStyle: props.variant })} />;
25-
};
26-
27-
import { Circle } from './panda/jsx';
28-
29-
function CustomCircle(props){
30-
const { circleSize = '3' } = props
31-
return (
32-
<Circle
33-
size={circleSize}
34-
/>
35-
)
36-
};
37-
38-
import { Circle } from './panda/jsx';
39-
40-
function CustomCircle(props){
41-
return (
42-
<Circle
43-
size={props.circleSize}
44-
/>
45-
)
4626
}
4727
```
4828

docs/rules/no-shorthand-prop.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Discourage the use of shorthand properties and promote the preference for longha
66

77
📋 This rule is enabled in `plugin:@pandacss/all`.
88

9-
🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
10-
119
## Rule details
1210

1311
❌ Examples of **incorrect** code:
@@ -48,25 +46,6 @@ function App(){
4846
}
4947
```
5048

51-
🔧 Examples of code **fixed** by this rule:
52-
```js
53-
import { css } from './panda/css'; /**/ import { css } from './panda/css';
54-
/**/
55-
const styles = css({ ml: '4' }); /**/ const styles = css({ marginLeft: '4' });
56-
57-
import { css } from './panda/css'; /**/ import { css } from './panda/css';
58-
/**/
59-
function App(){ /**/ function App(){
60-
return <div className={css({ bg: 'red.100' })} />; /**/ return <div className={css({ background: 'red.100' })} />;
61-
}; /**/ };
62-
63-
import { Circle } from './panda/jsx'; /**/ import { Circle } from './panda/jsx';
64-
/**/
65-
function App(){ /**/ function App(){
66-
return <Circle _hover={{ pos: 'absolute' }} />; /**/ return <Circle _hover={{ position: 'absolute' }} />;
67-
} /**/ }
68-
```
69-
7049
## Resources
7150

7251
* [Rule source](/plugin/src/rules/no-shorthand-prop.ts)

docs/rules/no-unsafe-token-fn-usage.md

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Prevent users from using the token function in situations where they could simpl
66

77
📋 This rule is enabled in `plugin:@pandacss/all`.
88

9-
🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
10-
119
## Rule details
1210

1311
❌ Examples of **incorrect** code:
@@ -18,17 +16,17 @@ import { css } from './panda/css';
1816
const styles = css({ bg: token('colors.red.300') });
1917

2018
import { token } from './panda/tokens';
21-
import { css } from './panda/css';
19+
import { css } from './panda/css';
2220

23-
function App(){
24-
return <div className={css({ bg: 'token(colors.red.300)' })} />;
25-
};
21+
function App(){
22+
return <div className={css({ bg: 'token(colors.red.300)' })} />;
23+
};
2624

2725
import { Circle } from './panda/jsx';
2826

29-
function App(){
30-
return <Circle margin='{sizes.4}' />;
31-
}
27+
function App(){
28+
return <Circle margin='{sizes.4}' />;
29+
}
3230
```
3331

3432
✔️ Examples of **correct** code:
@@ -51,27 +49,6 @@ function App(){
5149
}
5250
```
5351

54-
🔧 Examples of code **fixed** by this rule:
55-
```js
56-
import { token } from './panda/tokens'; /**/ import { token } from './panda/tokens';
57-
import { css } from './panda/css'; /**/ import { css } from './panda/css';
58-
/**/
59-
const styles = css({ bg: token('colors.red.300') }); /**/ const styles = css({ bg: 'red.300' });
60-
61-
import { token } from './panda/tokens'; /**/ import { token } from './panda/tokens';
62-
import { css } from './panda/css'; /**/ import { css } from './panda/css';
63-
/**/
64-
function App(){ /**/ function App(){
65-
return <div className={css({ bg: 'token(colors.red.300)' })} />; /**/ return <div className={css({ bg: 'red.300' })} />;
66-
}; /**/ };
67-
68-
import { Circle } from './panda/jsx'; /**/ import { Circle } from './panda/jsx';
69-
/**/
70-
function App(){ /**/ function App(){
71-
return <Circle margin='{sizes.4}' />; /**/ return <Circle margin='4' />;
72-
} /**/ }
73-
```
74-
7552
## Resources
7653

7754
* [Rule source](/plugin/src/rules/no-unsafe-token-fn-usage.ts)

plugin/src/rules/no-config-function-in-source.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ const rule: Rule = createRule({
1111
description: 'Prohibit the use of config functions outside the Panda config.',
1212
},
1313
messages: {
14-
configFunction: 'Remove `{{name}}` usage. Config functions should only be used in panda config',
14+
configFunction: 'Unnecessary`{{name}}` call. \nConfig functions should only be used in panda config.',
15+
delete: 'Delete `{{name}}` call.',
1516
},
1617
type: 'suggestion',
17-
fixable: 'code',
18+
hasSuggestions: true,
1819
schema: [],
1920
},
2021
defaultOptions: [],
@@ -31,16 +32,24 @@ const rule: Rule = createRule({
3132
data: {
3233
name: node.callee.name,
3334
},
34-
fix(fixer) {
35-
const declaration = getAncestor(isVariableDeclaration, node)
36-
const importSpec = getImportSpecifiers(context).find(
37-
(s) => isIdentifier(node.callee) && s.specifier.local.name === node.callee.name,
38-
)
39-
return [
40-
fixer.remove(declaration ?? node),
41-
importSpec?.specifier ? fixer.remove(importSpec?.specifier) : ({} as any),
42-
]
43-
},
35+
suggest: [
36+
{
37+
messageId: 'delete',
38+
data: {
39+
name: node.callee.name,
40+
},
41+
fix(fixer) {
42+
const declaration = getAncestor(isVariableDeclaration, node)
43+
const importSpec = getImportSpecifiers(context).find(
44+
(s) => isIdentifier(node.callee) && s.specifier.local.name === node.callee.name,
45+
)
46+
return [
47+
fixer.remove(declaration ?? node),
48+
importSpec?.specifier ? fixer.remove(importSpec?.specifier) : ({} as any),
49+
]
50+
},
51+
},
52+
],
4453
})
4554
},
4655
}

plugin/src/rules/no-debug.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ const rule: Rule = createRule({
1111
description: 'Disallow the inclusion of the debug attribute when shipping code to the production environment.',
1212
},
1313
messages: {
14-
debug: 'Remove the debug utility.',
14+
debug: 'Unnecessary debug utility.',
15+
prop: 'Remove the debug prop.',
16+
property: 'Remove the debug property.',
1517
},
1618
type: 'suggestion',
17-
fixable: 'code',
19+
hasSuggestions: true,
1820
schema: [],
1921
},
2022
defaultOptions: [],
@@ -27,7 +29,12 @@ const rule: Rule = createRule({
2729
context.report({
2830
node,
2931
messageId: 'debug',
30-
fix: (fixer) => fixer.remove(node),
32+
suggest: [
33+
{
34+
messageId: 'prop',
35+
fix: (fixer) => fixer.remove(node),
36+
},
37+
],
3138
})
3239
},
3340

@@ -38,7 +45,12 @@ const rule: Rule = createRule({
3845
context.report({
3946
node: node.key,
4047
messageId: 'debug',
41-
fix: (fixer) => fixer.removeRange([node.range[0], node.range[1] + 1]),
48+
suggest: [
49+
{
50+
messageId: 'property',
51+
fix: (fixer) => fixer.removeRange([node.range[0], node.range[1] + 1]),
52+
},
53+
],
4254
})
4355
},
4456
}

0 commit comments

Comments
 (0)