@fun-foundry/prettier-config 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,24 +1,44 @@
1
- # @fun-foundry/eslint-config
1
+ # @fun-foundry/prettier-config
2
2
 
3
3
  Opinionated Prettier configuration maintained by fun-foundry.
4
4
 
5
+ This package provides a shared Prettier configuration for JavaScript / TypeScript projects.
6
+
5
7
  ## Installation
6
8
 
9
+ Install both Prettier and this configuration package.
10
+
11
+ ```sh
12
+ npm install --save-dev prettier @fun-foundry/prettier-config
13
+ ```
14
+
15
+ or
16
+
7
17
  ```sh
8
- npm install --save-dev @fun-foundry/prettier-config
18
+ yarn add -D prettier @fun-foundry/prettier-config
19
+ ```
20
+
21
+ or
22
+
23
+ ```sh
24
+ pnpm add -D prettier @fun-foundry/prettier-config
9
25
  ```
10
26
 
11
27
  ## Usage
12
28
 
13
- In your `package.json`:
29
+ Create a Prettier configuration file and import this package.
14
30
 
15
- ```json
16
- {
17
- "prettier": "@fun-foundry/prettier-config"
18
- }
31
+ Example: `prettier.config.mjs`
32
+
33
+ ```js
34
+ import config from '@fun-foundry/prettier-config'
35
+
36
+ export default config
19
37
  ```
20
38
 
21
- Or in `prettier.config.js` (or `.mjs`):
39
+ If your project already uses ESM ("type": "module" in package.json), you can also use prettier.config.js.
40
+
41
+ Example: `prettier.config.js`
22
42
 
23
43
  ```js
24
44
  import config from '@fun-foundry/prettier-config'
@@ -26,6 +46,29 @@ import config from '@fun-foundry/prettier-config'
26
46
  export default config
27
47
  ```
28
48
 
49
+ ## Customization
50
+
51
+ You can extend this config and override individual options in your project.
52
+
53
+ Example: `prettier.config.js`
54
+
55
+ ```js
56
+ import config from '@fun-foundry/prettier-config'
57
+
58
+ export default {
59
+ ...config,
60
+ printWidth: 100,
61
+ semi: true
62
+ }
63
+ ```
64
+
65
+ This is useful when you want to keep the base style from this package while adapting a few rules for a specific project.
66
+
67
+ ## Requirements
68
+
69
+ - Node.js >= 18.18.0
70
+ - Prettier >= 3 < 4
71
+
29
72
  ## License
30
73
 
31
74
  [MIT](LICENSE)
@@ -0,0 +1,14 @@
1
+ declare const prettierConfig: {
2
+ arrowParens: "avoid";
3
+ bracketSameLine: false;
4
+ bracketSpacing: true;
5
+ jsxSingleQuote: true;
6
+ printWidth: number;
7
+ semi: false;
8
+ singleQuote: true;
9
+ tabWidth: number;
10
+ trailingComma: "none";
11
+ useTabs: false;
12
+ };
13
+ export default prettierConfig;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,cAAc;;;;;;;;;;;CAWF,CAAA;AAElB,eAAe,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAG;IACrB,WAAW,EAAE,OAAO;IACpB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,IAAI;IACpB,UAAU,EAAE,GAAG;IACf,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,MAAM;IACrB,OAAO,EAAE,KAAK;CACE,CAAA;AAElB,eAAe,cAAc,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../test/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import prettier from 'prettier';
4
+ import config from '../src/index.js';
5
+ test('exports expected prettier config', () => {
6
+ assert.deepEqual(config, {
7
+ arrowParens: 'avoid',
8
+ bracketSameLine: false,
9
+ bracketSpacing: true,
10
+ jsxSingleQuote: true,
11
+ printWidth: 120,
12
+ semi: false,
13
+ singleQuote: true,
14
+ tabWidth: 2,
15
+ trailingComma: 'none',
16
+ useTabs: false
17
+ });
18
+ });
19
+ test('can format code with exported config', async () => {
20
+ const formatted = await prettier.format("const hello = ( name ) => { return 'world' }\n", {
21
+ ...config,
22
+ parser: 'babel'
23
+ });
24
+ assert.equal(formatted, `const hello = name => {
25
+ return 'world'
26
+ }
27
+ `);
28
+ });
29
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../test/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,MAAM,MAAM,oBAAoB,CAAA;AACvC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,MAAM,MAAM,iBAAiB,CAAA;AAEpC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAC5C,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE;QACvB,WAAW,EAAE,OAAO;QACpB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,IAAI;QACjB,QAAQ,EAAE,CAAC;QACX,aAAa,EAAE,MAAM;QACrB,OAAO,EAAE,KAAK;KACf,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;IACtD,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,MAAM,CACrC,gDAAgD,EAChD;QACE,GAAG,MAAM;QACT,MAAM,EAAE,OAAO;KAChB,CACF,CAAA;IAED,MAAM,CAAC,KAAK,CACV,SAAS,EACb;;;CAGC,CAAC,CAAA;AACF,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,16 +1,26 @@
1
1
  {
2
2
  "name": "@fun-foundry/prettier-config",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
- "main": "dist/index.js",
5
+ "main": "dist/src/index.js",
6
6
  "exports": {
7
- ".": "./dist/index.js"
7
+ ".": {
8
+ "types": "./dist/src/index.d.ts",
9
+ "default": "./dist/src/index.js"
10
+ }
8
11
  },
9
- "types": "dist/index.d.ts",
12
+ "types": "dist/src/index.d.ts",
13
+ "files": [
14
+ "dist",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
10
18
  "description": "Opinionated Prettier configuration maintained by fun-foundry.",
11
19
  "license": "MIT",
12
20
  "scripts": {
13
- "build": "tsc"
21
+ "build": "tsc",
22
+ "test": "npm run build && npm run test:run",
23
+ "test:run": "node --test dist/test/*.test.js"
14
24
  },
15
25
  "engines": {
16
26
  "node": ">=18.18.0"
@@ -24,9 +34,11 @@
24
34
  },
25
35
  "homepage": "https://github.com/fun-foundry/prettier-config#readme",
26
36
  "peerDependencies": {
27
- "prettier": "^3.6.0"
37
+ "prettier": ">=3 <4"
28
38
  },
29
39
  "devDependencies": {
40
+ "@types/node": "^25.5.0",
41
+ "prettier": "^3.8.1",
30
42
  "typescript": "^5.9.0"
31
43
  }
32
44
  }
package/dist/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { Config } from 'prettier';
2
- declare const prettierConfig: Config;
3
- export default prettierConfig;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC,QAAA,MAAM,cAAc,EAAE,MAWrB,CAAA;AAED,eAAe,cAAc,CAAA"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAW;IAC7B,WAAW,EAAE,OAAO;IACpB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,IAAI;IACpB,UAAU,EAAE,GAAG;IACf,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,MAAM;IACrB,OAAO,EAAE,KAAK;CACf,CAAA;AAED,eAAe,cAAc,CAAA"}
package/src/index.ts DELETED
@@ -1,16 +0,0 @@
1
- import type { Config } from 'prettier'
2
-
3
- const prettierConfig: Config = {
4
- arrowParens: 'avoid',
5
- bracketSameLine: false,
6
- bracketSpacing: true,
7
- jsxSingleQuote: true,
8
- printWidth: 120,
9
- semi: false,
10
- singleQuote: true,
11
- tabWidth: 2,
12
- trailingComma: 'none',
13
- useTabs: false
14
- }
15
-
16
- export default prettierConfig
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ES2022",
5
- "moduleResolution": "Bundler",
6
- "outDir": "dist",
7
- "rootDir": "src",
8
- "declaration": true,
9
- "declarationMap": true,
10
- "sourceMap": true,
11
- "strict": true,
12
- "skipLibCheck": true,
13
- "esModuleInterop": true,
14
- "forceConsistentCasingInFileNames": true
15
- },
16
- "include": ["src/**/*.ts"],
17
- "exclude": ["dist", "node_modules"]
18
- }
File without changes