File tree Expand file tree Collapse file tree 14 files changed +153
-79
lines changed
Expand file tree Collapse file tree 14 files changed +153
-79
lines changed Original file line number Diff line number Diff line change 3535 "eslint-plugin-unicorn" : " ^56.0.1" ,
3636 "eslint-plugin-vitest" : " ^0.5.4" ,
3737 "prettier" : " ^3.4.1" ,
38- "prettier-plugin-svelte" : " ^3.3.2" ,
39- "prettier-plugin-tailwindcss" : " ^0.6.9" ,
4038 "semver" : " ^7.6.3" ,
4139 "svelte" : " ^5.4.0" ,
4240 "tailwindcss" : " 3.4.15" ,
Original file line number Diff line number Diff line change 1+ # Viam's Prettier Config for Svelte
2+
3+ This module contains [ Viam] [ ] 's shared [ Prettier] [ ] configurations for Prettier v3 in [ Svelte] [ ] projects.
4+
5+ [ viam ] : https://www.viam.com/
6+ [ prettier ] : https://prettier.io/
7+ [ svelte ] : https://svelte.dev/
8+
9+ ## Usage
10+
11+ Use the [ Svelte config] ( ./prettier-config-svelte.js ) for Svelte projects.
12+
13+ ``` shell
14+ pnpm add --save-dev prettier @viamrobotics/prettier-config-svelte
15+ ```
16+
17+ ``` js
18+ // prettier.config.js
19+ export default ' @viamrobotics/prettier-config-svelte' ;
20+ ```
21+
22+ If the project is inside a monorepo, you'll need to specify the path to your Tailwind config.
23+
24+ ``` js
25+ // prettier.config.js
26+ import path from ' node:path' ;
27+
28+ import baseConfig from ' @viamrobotics/prettier-config-svelte' ;
29+
30+ /** @satisfies {import('prettier').Config} */
31+ const config = {
32+ ... baseConfig,
33+ tailwindConfig: path .join (import .meta.dirname, ' tailwind.config.ts' ),
34+ };
35+
36+ export default config ;
37+ ` ` `
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " @viamrobotics/prettier-config-svelte" ,
3+ "publishConfig" : {
4+ "access" : " public" ,
5+ "provenance" : true
6+ },
7+ "version" : " 1.0.0" ,
8+ "description" : " Viam's shared Prettier configuration for Svelte projects." ,
9+ "type" : " module" ,
10+ "files" : [
11+ " **/*" ,
12+ " !tsconfig.json"
13+ ],
14+ "types" : " ./dist/prettier-config-svelte.d.ts" ,
15+ "exports" : {
16+ "." : {
17+ "types" : " ./dist/prettier-config-svelte.d.ts" ,
18+ "default" : " ./prettier-config-svelte.js"
19+ }
20+ },
21+ "repository" : {
22+ "type" : " git" ,
23+ "url" : " git+https://github.com/viamrobotics/js-config.git" ,
24+ "directory" : " packages/prettier-config-svelte"
25+ },
26+ "keywords" : [
27+ " prettier" ,
28+ " prettierconfig" ,
29+ " svelte"
30+ ],
31+ "license" : " Apache-2.0" ,
32+ "peerDependencies" : {
33+ "prettier" : " >=3 <4" ,
34+ "svelte" : " *" ,
35+ "tailwindcss" : " *"
36+ },
37+ "dependencies" : {
38+ "@viamrobotics/prettier-config" : " workspace:*" ,
39+ "prettier-plugin-svelte" : " ^3.3.2" ,
40+ "prettier-plugin-tailwindcss" : " ^0.6.9"
41+ }
42+ }
Original file line number Diff line number Diff line change 1+ import url from 'node:url' ;
2+
3+ import baseConfig from '@viamrobotics/prettier-config' ;
4+
5+ const sveltePlugin = url . fileURLToPath (
6+ import . meta. resolve ( 'prettier-plugin-svelte' )
7+ ) ;
8+ const tailwindPlugin = url . fileURLToPath (
9+ import . meta. resolve ( 'prettier-plugin-tailwindcss' )
10+ ) ;
11+
12+ /** @satisfies {import('prettier').Config } */
13+ const config = {
14+ ...baseConfig ,
15+ plugins : [ sveltePlugin , tailwindPlugin ] ,
16+ svelteIndentScriptAndStyle : false ,
17+ tailwindAttributes : [ 'cx' ] ,
18+ tailwindFunctions : [ 'classnames' , 'cx' ] ,
19+ // TODO(mc, 2024-12-01): https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/332
20+ tailwindPreserveWhitespace : true ,
21+ } ;
22+
23+ export default config ;
Original file line number Diff line number Diff line change 1+ {
2+ "extends" : " @viamrobotics/typescript-config/base.json" ,
3+ "compilerOptions" : {
4+ "types" : [" node" ],
5+ "composite" : true ,
6+ "declaration" : true ,
7+ "emitDeclarationOnly" : true ,
8+ "outDir" : " dist"
9+ },
10+ "references" : [{ "path" : " ../prettier-config" }],
11+ "include" : [" *.js" ]
12+ }
Original file line number Diff line number Diff line change 1- # Shared Prettier Config for Viam
1+ # Viam's Prettier Config
22
3- This module contains [ Viam] [ ] 's shared [ Prettier] [ ] configurations for Prettier v3.
3+ This module contains [ Viam] [ ] 's shared [ Prettier] [ ] configuration for Prettier v3.
44
55[ viam ] : https://www.viam.com/
66[ prettier ] : https://prettier.io/
77
8- ## Base config
8+ ## Usage
99
10- Use the [ base config] ( ./base .js ) for vanilla JavaScript / TypeScript projects.
10+ Use the [ base config] ( ./prettier-config .js ) for vanilla JavaScript / TypeScript projects.
1111
1212``` shell
1313pnpm add --save-dev prettier @viamrobotics/prettier-config
1414```
1515
1616``` js
17- // .prettierrc.cjs
18- module . exports = ' @viamrobotics/prettier-config' ;
17+ // prettier.config.js
18+ export default ' @viamrobotics/prettier-config' ;
1919```
2020
2121You can also extend the configuration:
2222
2323``` js
24- // .prettierrc.cjs
25- const baseConfig = require ( ' @viamrobotics/prettier-config' ) ;
24+ // prettier.config.js
25+ import baseConfig from ' @viamrobotics/prettier-config' ;
2626
2727export default {
2828 ... baseConfig,
@@ -32,17 +32,4 @@ export default {
3232
3333## Svelte config
3434
35- Use the [ Svelte config] ( ./svelte.js ) for Svelte projects.
36-
37- ``` shell
38- pnpm add --save-dev \
39- @viamrobotics/prettier-config \
40- prettier \
41- prettier-plugin-svelte \
42- prettier-plugin-tailwindcss
43- ```
44-
45- ``` js
46- // .prettierrc.cjs
47- module .exports = ' @viamrobotics/prettier-config/svelte' ;
48- ```
35+ See [ @viamrobotics/prettier-config-svelte ] ( ../prettier-config-svelte/ )
Original file line number Diff line number Diff line change 44 "access" : " public" ,
55 "provenance" : true
66 },
7- "version" : " 0.3.6 " ,
8- "description" : " Common Prettier configuration for Viam projects ." ,
9- "type" : " commonjs " ,
7+ "version" : " 1.0.0 " ,
8+ "description" : " Viam's shared Prettier configuration." ,
9+ "type" : " module " ,
1010 "files" : [
1111 " **/*" ,
1212 " !tsconfig.json"
1313 ],
14- "types" : " dist/base.d.cts" ,
15- "typesVersions" : {
16- "*" : {
17- "svelte" : [
18- " dist/svelte.d.cts"
19- ]
20- }
21- },
14+ "types" : " ./dist/prettier-config.d.ts" ,
2215 "exports" : {
2316 "." : {
24- "types" : " ./dist/base.d.cts" ,
25- "default" : " ./base.cjs"
26- },
27- "./svelte" : {
28- "types" : " ./dist/svelte.d.cts" ,
29- "default" : " ./svelte.cjs"
17+ "types" : " ./dist/prettier-config.d.ts" ,
18+ "default" : " ./prettier-config.js"
3019 }
3120 },
3221 "repository" : {
4029 ],
4130 "license" : " Apache-2.0" ,
4231 "peerDependencies" : {
43- "prettier" : " >=3 <4" ,
44- "prettier-plugin-svelte" : " >=3 <4" ,
45- "prettier-plugin-tailwindcss" : " >=0.4.0 <0.7"
46- },
47- "peerDependenciesMeta" : {
48- "prettier-plugin-svelte" : {
49- "optional" : true
50- },
51- "prettier-plugin-tailwindcss" : {
52- "optional" : true
53- }
32+ "prettier" : " >=3 <4"
5433 }
5534}
Original file line number Diff line number Diff line change 1- 'use strict' ;
2-
31/** @satisfies {import('prettier').Config } */
42const config = {
53 // overrides
@@ -24,4 +22,4 @@ const config = {
2422 embeddedLanguageFormatting : 'auto' ,
2523} ;
2624
27- module . exports = config ;
25+ export default config ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 77 "emitDeclarationOnly" : true ,
88 "outDir" : " dist"
99 },
10- "include" : [" *.cjs " ]
10+ "include" : [" *.js " ]
1111}
You can’t perform that action at this time.
0 commit comments