Skip to content

Commit

Permalink
Refine prettier setup and format project
Browse files Browse the repository at this point in the history
  • Loading branch information
techniq committed May 16, 2024
1 parent 7e96131 commit f6af3fd
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 48 deletions.
11 changes: 10 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"singleQuote": true,
"printWidth": 100,
"trailingComma": "es5"
"trailingComma": "es5",
"plugins": ["prettier-plugin-svelte"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
]
}
16 changes: 16 additions & 0 deletions packages/layerchart/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.DS_Store
node_modules
/build
/dist
/.svelte-kit
/package
.env
.env.*
!.env.example
static/data/
**/examples/_data/

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
16 changes: 4 additions & 12 deletions packages/layerchart/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,15 @@

```svelte
<Chart tooltip={{ snapToDataX: true, snapToDataY: true }}>
<Tooltip>
...
</Tooltip>
<Tooltip>...</Tooltip>
</Chart>
```

After:

```svelte
<Chart tooltip>
<Tooltip x="data" y="data">
...
</Tooltip>
<Tooltip x="data" y="data">...</Tooltip>
</Chart>
```

Expand All @@ -264,19 +260,15 @@

```svelte
<Chart tooltip>
<Tooltip left={0} top={0}>
...
</Tooltip>
<Tooltip left={0} top={0}>...</Tooltip>
</Chart>
```

After:

```svelte
<Chart tooltip>
<Tooltip x={0} left={0}>
...
</Tooltip>
<Tooltip x={0} left={0}>...</Tooltip>
</Chart>
```

Expand Down
4 changes: 2 additions & 2 deletions packages/layerchart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"prepublishOnly": "svelte-package",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. .",
"lint": "prettier --check .",
"format": "prettier --write .",
"prepare": "svelte-kit sync"
},
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions packages/layerchart/src/lib/components/Sankey.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
sankeyCenter,
sankeyRight,
sankeyJustify,
type SankeyNode
type SankeyNode,
} from 'd3-sankey';
const dispatch = createEventDispatcher();
Expand Down Expand Up @@ -40,12 +40,12 @@
nodeAlign === 'left'
? sankeyLeft
: nodeAlign === 'center'
? sankeyCenter
: nodeAlign === 'right'
? sankeyRight
: nodeAlign === 'justify'
? sankeyJustify
: nodeAlign
? sankeyCenter
: nodeAlign === 'right'
? sankeyRight
: nodeAlign === 'justify'
? sankeyJustify
: nodeAlign
)
.nodeWidth(nodeWidth)
.nodePadding(nodePadding)
Expand Down
20 changes: 10 additions & 10 deletions packages/layerchart/src/lib/docs/PathDataMenuField.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,51 @@
{
label: 'sin',
group: 'math',
value: (x: number) => amplitude * Math.sin(x * frequency) + phase
value: (x: number) => amplitude * Math.sin(x * frequency) + phase,
},
{
label: 'cos',
group: 'math',
value: (x: number) => amplitude * Math.cos(x * frequency) + phase
value: (x: number) => amplitude * Math.cos(x * frequency) + phase,
},
{
label: 'tan',
group: 'math',
value: (x: number) => amplitude * Math.tan(x * frequency) + phase
value: (x: number) => amplitude * Math.tan(x * frequency) + phase,
},
{
label: 'sqrt',
group: 'math',
value: (x: number) => amplitude * Math.sqrt(x * frequency) + phase
value: (x: number) => amplitude * Math.sqrt(x * frequency) + phase,
},
{
label: 'ceil',
group: 'math',
value: (x: number) => amplitude * Math.ceil(x * frequency) + phase
value: (x: number) => amplitude * Math.ceil(x * frequency) + phase,
},
{
label: 'floor',
group: 'math',
value: (x: number) => amplitude * Math.floor(x * frequency) + phase
value: (x: number) => amplitude * Math.floor(x * frequency) + phase,
},
{
label: 'round',
group: 'math',
value: (x: number) => amplitude * Math.round(x * frequency) + phase
value: (x: number) => amplitude * Math.round(x * frequency) + phase,
},
{ label: 'random', group: 'math', value: (x: number) => amplitude * Math.random() + phase },
{
label: 'pow',
group: 'math',
value: (x: number) => amplitude * Math.pow(x, frequency) + phase
}
value: (x: number) => amplitude * Math.pow(x, frequency) + phase,
},
];
const easingOptions = Object.entries(easings).map(([key, value]) => {
return {
label: key,
value,
group: 'easing'
group: 'easing',
};
});
Expand Down
22 changes: 12 additions & 10 deletions packages/layerchart/src/lib/stores/motionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,21 @@ export function resolveOptions(prop: string, options: PropMotionOptions) {
typeof options.spring === 'boolean' || options.spring == null
? options.spring
: prop in options.spring
? options.spring[prop]
: Object.keys(options.spring).some((key) =>
['precision', 'damping', 'stiffness'].includes(key)
)
? options.tweened
: false,
? options.spring[prop]
: Object.keys(options.spring).some((key) =>
['precision', 'damping', 'stiffness'].includes(key)
)
? options.tweened
: false,
tweened:
typeof options.tweened === 'boolean' || options.tweened == null
? options.tweened
: prop in options.tweened
? options.tweened[prop]
: Object.keys(options.tweened).some((key) => ['delay', 'duration', 'easing'].includes(key))
? options.tweened
: false,
? options.tweened[prop]
: Object.keys(options.tweened).some((key) =>
['delay', 'duration', 'easing'].includes(key)
)
? options.tweened
: false,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@
value={settings.snapToDataX && settings.snapToDataY
? 'both'
: settings.snapToDataX
? 'x-only'
: settings.snapToDataY
? 'y-only'
: 'off'}
? 'x-only'
: settings.snapToDataY
? 'y-only'
: 'off'}
on:change={(e) => {
switch (e.detail.value) {
case 'off':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
frequencyData = [...frequency].map((value, i) => ({ key: i, value }));
timeData = [...time].map((value, i) => ({ key: i, value }));
if(active) {
if (active) {
requestAnimationFrame(step);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ export async function load() {
return {
meta: {
pageSource,
related: ['components/Spline', 'components/Tooltip', 'components/Highlight', 'examples/Sparkbar'],
related: [
'components/Spline',
'components/Tooltip',
'components/Highlight',
'examples/Sparkbar',
],
},
};
}

0 comments on commit f6af3fd

Please sign in to comment.