@effect/dprint 0.0.0 → 0.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +114 -28
  3. package/package.json +39 -7
  4. package/plugin.wasm +0 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Effectful Technologies Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,131 @@
1
1
  # @effect/dprint
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ A [dprint](https://dprint.dev) Wasm plugin that stacks method chains and groups imports before `dprint-plugin-typescript` formats the file.
4
4
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
5
+ - **Stacks method chains.** When two or more method calls follow the start of a chain, each one goes on its own line, so a pipeline or a view reads top to bottom.
6
+ - **Groups imports.** Imports are split into blank-line-separated groups: packages, `#` subpath aliases, parent imports, then sibling imports.
6
7
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
+ ```ts
9
+ import { Array } from "effect"
8
10
 
9
- ## Purpose
11
+ import { Race } from "#domain"
10
12
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@effect/dprint`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
13
+ import { titlebar } from "../titlebar.ts"
15
14
 
16
- ## What is OIDC Trusted Publishing?
15
+ import { TellRoom } from "./commands.ts"
17
16
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
17
+ const view = h.div
18
+ .class("room")
19
+ .children(titlebar, TellRoom)
20
+ ```
19
21
 
20
- ## Setup Instructions
22
+ The formatting passes run in sandboxed Wasm and do not require Node.js.
21
23
 
22
- To properly configure OIDC trusted publishing for this package:
24
+ ## Requirements
23
25
 
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
26
+ dprint 0.58.0 or newer, and a plugin that formats the files, such as `dprint-plugin-typescript`. This plugin runs alongside that one instead of claiming the files itself. Older versions of dprint don't support that and would let it take TypeScript files away from the TypeScript plugin.
28
27
 
29
- ## DO NOT USE THIS PACKAGE
28
+ ## Setup
30
29
 
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
30
+ List the plugin **before** `dprint-plugin-typescript`. Plugins run in the order of the `plugins` array, so the TypeScript plugin then indents the stacked chains and sorts the imports inside each group.
36
31
 
37
- ## More Information
32
+ Pin a version from npm:
38
33
 
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
34
+ ```json
35
+ {
36
+ "plugins": [
37
+ "npm:@effect/dprint@0.1.0",
38
+ "npm:@dprint/typescript@0.102.0"
39
+ ]
40
+ }
41
+ ```
42
42
 
43
- ---
43
+ `dprint config update` bumps the pinned version.
44
44
 
45
- **Maintained for OIDC setup purposes only**
45
+ Or install both plugins as dev dependencies:
46
+
47
+ ```sh
48
+ npm install --save-dev @effect/dprint @dprint/typescript
49
+ ```
50
+
51
+ Then leave the versions out, so dprint loads both from `node_modules`:
52
+
53
+ ```json
54
+ {
55
+ "plugins": [
56
+ "npm:@effect/dprint",
57
+ "npm:@dprint/typescript"
58
+ ]
59
+ }
60
+ ```
61
+
62
+ Or load it from the GitHub release:
63
+
64
+ ```json
65
+ {
66
+ "plugins": [
67
+ "https://github.com/Effect-TS/effect/releases/download/@effect/dprint@0.1.0/plugin.wasm",
68
+ "https://plugins.dprint.dev/typescript-0.102.0.wasm"
69
+ ]
70
+ }
71
+ ```
72
+
73
+ ## Configuration
74
+
75
+ Configure the plugin under the `effect` key.
76
+
77
+ | Key | Type | Default | Meaning |
78
+ | -------------- | ---------------- | ------- | ---------------------------------------------------------------------- |
79
+ | `stackChains` | boolean | `true` | Stack method chains. |
80
+ | `importGroups` | boolean or array | `true` | Group imports. `true` uses the default groups, an array sets your own. |
81
+
82
+ The plugin formats `.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs` and `.cjs` files. Use dprint's `associations` to choose which files it formats, and `overrides` to turn a pass off for some of them. For example, to stack chains everywhere except in tests:
83
+
84
+ ```json
85
+ {
86
+ "effect": {
87
+ "overrides": { "files": ["**/*.test.{ts,tsx}"], "stackChains": false }
88
+ }
89
+ }
90
+ ```
91
+
92
+ To run the plugin only on one folder, exclude everything and then include that folder, since the last matching pattern wins:
93
+
94
+ ```json
95
+ {
96
+ "effect": {
97
+ "associations": ["!**/*", "src/ui/**/*.{ts,tsx}"]
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### Import groups
103
+
104
+ `importGroups` is an ordered list of groups, and each group is a pattern or an array of patterns. The default is:
105
+
106
+ ```json
107
+ {
108
+ "effect": {
109
+ "importGroups": ["*", "#*", ["..", "../*"], [".", "./*"]]
110
+ }
111
+ }
112
+ ```
113
+
114
+ - `*` matches any characters, including `/`. Every other character matches itself.
115
+ - An import goes to the group of the matching pattern with the most characters other than `*`. For example, `"#domain"` matches `#*` more specifically than `*`.
116
+ - When matching patterns have the same number of literal characters, the earlier group wins.
117
+ - The list must contain a bare `*`, so every import has a group.
118
+
119
+ To put Effect packages in a group of their own after other packages:
120
+
121
+ ```json
122
+ {
123
+ "effect": {
124
+ "importGroups": ["*", ["effect", "effect/*", "@effect/*"], "#*", ["..", "../*"], [".", "./*"]]
125
+ }
126
+ }
127
+ ```
128
+
129
+ The plugin moves imports between groups but keeps their order inside a group. Sorting is left to `dprint-plugin-typescript`, which sorts each blank-line-separated group on its own.
130
+
131
+ Only imports that bind something are grouped. A side-effect import such as `import "./styles.css"`, or any other statement, ends a run of imports, and no import moves past it. Comments above an import move with it, and so does a comment at the end of its line. Comments above the first import, such as a license header, stay at the top. When a line comment sits directly above the first import, that import stays first too, because comments like `// @ts-expect-error` apply to the line below them.
package/package.json CHANGED
@@ -1,10 +1,42 @@
1
1
  {
2
2
  "name": "@effect/dprint",
3
- "version": "0.0.0",
4
- "description": "OIDC trusted publishing setup package for @effect/dprint",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "description": "A dprint plugin that stacks fluent method chains and groups imports for Effect code",
6
+ "homepage": "https://effect.website",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/Effect-TS/effect.git",
10
+ "directory": "packages/tools/dprint"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/Effect-TS/effect/issues"
14
+ },
15
+ "tags": [
16
+ "dprint",
17
+ "dprint-plugin",
18
+ "formatting",
19
+ "effect"
20
+ ],
5
21
  "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
22
+ "dprint",
23
+ "dprint-plugin",
24
+ "formatting",
25
+ "effect"
26
+ ],
27
+ "files": [
28
+ "plugin.wasm"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "provenance": true
33
+ },
34
+ "devDependencies": {
35
+ "dprint": "^0.65.0"
36
+ },
37
+ "scripts": {
38
+ "build": "cargo build --release --locked --target wasm32-unknown-unknown --target-dir target && node -e \"require('node:fs').copyFileSync('target/wasm32-unknown-unknown/release/effect_dprint.wasm', 'plugin.wasm')\"",
39
+ "test": "cargo test --locked",
40
+ "test-cli": "node test/cli.mjs"
41
+ }
42
+ }
package/plugin.wasm ADDED
Binary file