Skip to content

Commit

Permalink
eslint-plugin-panda (#2739)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchristina authored Dec 29, 2024
1 parent b6e0e55 commit 19f3efc
Show file tree
Hide file tree
Showing 10 changed files with 590 additions and 22 deletions.
10 changes: 10 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import panda from '@pandacss/eslint-plugin'
import stylisticTs from '@stylistic/eslint-plugin'
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import typescriptParser from '@typescript-eslint/parser'
Expand Down Expand Up @@ -28,6 +29,7 @@ const commonPlugins = {
'@typescript-eslint': typescriptEslint,
import: importPlugin,
'react-hooks': reactHooks,
'@pandacss': panda,
}

const commonRules = {
Expand Down Expand Up @@ -191,6 +193,14 @@ export default [
// react-refresh

'react-refresh/only-export-components': 'error',
// pandacss

...panda.configs.recommended.rules,
'@pandacss/no-config-function-in-source': 'off',
'@pandacss/prefer-longhand-properties': 'error',
'@pandacss/no-dynamic-styling': 'off',
'@pandacss/no-hardcoded-color': 'error',
'@pandacss/no-property-renaming': 'error',
},
},

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@capacitor/cli": "^6.2.0",
"@pandacss/dev": "^0.47.0",
"@pandacss/eslint-plugin": "^0.2.3",
"@sinonjs/fake-timers": "^13.0.4",
"@stylistic/eslint-plugin": "^2.11.0",
"@testing-library/dom": "^10.4.0",
Expand Down
4 changes: 4 additions & 0 deletions src/colors.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const colors = {
pinkAgainstFg: 'rgba(233, 12, 89, 1)',
brightBlue: 'rgba(70, 223, 240, 1)', // #46dff0
exportTextareaColor: 'rgba(170, 170, 170, 1)', // #aaa, also used in anchorButton
inherit: 'inherit',
currentColor: 'currentColor',
},
light: {
// Background colors in capacitor app needs to be in hexadecimal codes
Expand Down Expand Up @@ -128,6 +130,8 @@ const colors = {
pinkAgainstFg: 'rgba(227, 179, 196, 1)',
brightBlue: 'rgba(70, 223, 240, 1)', // #46dff0
exportTextareaColor: 'rgba(85, 85, 85, 1)',
inherit: 'inherit',
currentColor: 'currentColor',
},
} as const

Expand Down
6 changes: 2 additions & 4 deletions src/components/Bullet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,7 @@ const Bullet = ({
const isHolding = state.draggedSimplePath && head(state.draggedSimplePath) === head(simplePath)
return isHolding || isDragging || isMulticursor
})
const bulletIsDivider = useSelector(state =>
isDivider(getThoughtById(state, thoughtId)?.value) ? 'none' : undefined,
)
const bulletIsDivider = useSelector(state => isDivider(getThoughtById(state, thoughtId)?.value))

/** Returns true if the thought is pending. */
const pending = useSelector(state => {
Expand Down Expand Up @@ -593,7 +591,7 @@ const Bullet = ({
marginLeft: '-3px',
},
},
display: bulletIsDivider,
display: bulletIsDivider ? 'none' : undefined,
position: 'absolute',
verticalAlign: 'top',
cursor: 'pointer',
Expand Down
4 changes: 2 additions & 2 deletions src/components/LayoutTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ const TreeNode = ({
const marginRight = isTableCol1 ? xCol2 - (width || 0) - x - (bulletWidth || 0) : 0

// Speed up the tree-node's transition (normally layoutNodeAnimationDuration) by 50% on New (Sub)Thought only.
const layoutTransition = isLastActionNewThought
const transition = isLastActionNewThought
? `left {durations.layoutNodeAnimationFast} ease-out,top {durations.layoutNodeAnimationFast} ease-out`
: `left {durations.layoutNodeAnimation} ease-out,top {durations.layoutNodeAnimation} ease-out`

Expand All @@ -470,7 +470,7 @@ const TreeNode = ({
// It should not be based on editable values such as Path, value, rank, etc, otherwise moving the thought would make it appear to be a completely new thought to React.
className={css({
position: 'absolute',
transition: layoutTransition,
transition,
})}
style={{
// Cannot use transform because it creates a new stacking context, which causes later siblings' DropChild to be covered by previous siblings'.
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const Toolbar: FC<ToolbarProps> = ({ customize, onSelect, selected }) => {
textAlign: 'right',
maxWidth: '100%',
userSelect: 'none',
WebkitTapHighlightColor: '{colors.bgTransparent}',
WebkitTapHighlightColor: 'bgTransparent',
whiteSpace: 'nowrap',
...(!customize && {
zIndex: 'toolbarContainer',
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const ModalAuth = () => {
</button>
)}

{error && <span className={css({ color: 'crimson' })}>{error}</span>}
{error && <span className={css({ color: 'error' })}>{error}</span>}
</div>
</ModalComponent>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const ModalSignup = () => {
{/* Show validation or submit error. */}
{(validationError || submitError) && (
<div className={css({ display: 'flex', minHeight: '100px', flexDirection: 'column' })}>
<span className={css({ color: 'crimson', paddingBottom: '30px', fontSize: '18px' })}>
<span className={css({ color: 'error', paddingBottom: '30px', fontSize: '18px' })}>
{validationError || submitError}
</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/util/getHideCaretAnimationName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const hideCaretAnimationNames = [

const hideCaret = cva({
base: {
animationDuration: '{durations.layoutSlowShift}',
animationDuration: 'layoutSlowShift',
},
variants: {
animation: hideCaretAnimationNames.reduce(
Expand Down
Loading

0 comments on commit 19f3efc

Please sign in to comment.