Skip to content

Commit 1ec9d8e

Browse files
Merge pull request #20 from ds300/prettier-setup
Set up prettier
2 parents 138e90f + 4cf87ce commit 1ec9d8e

32 files changed

+483
-509
lines changed

.github/workflows/ci.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@ concurrency:
1212

1313
jobs:
1414
test:
15-
name: "Test ${{ matrix.testenv.name }}"
15+
name: 'Test ${{ matrix.testenv.name }}'
1616
runs-on: ubuntu-latest
1717
timeout-minutes: 5
18-
strategy:
18+
strategy:
1919
matrix:
20-
testenv:
21-
- { name: "Node", args: '' }
22-
- { name: "Chrome", args: '--browser.name=chrome --browser.headless' }
23-
- { name: "Firefox", args: '--browser.name=firefox --browser.headless' }
20+
testenv:
21+
- {name: 'Node', args: ''}
22+
- {name: 'Chrome', args: '--browser.name=chrome --browser.headless'}
23+
- {name: 'Firefox', args: '--browser.name=firefox --browser.headless'}
2424

2525
steps:
2626
- uses: actions/checkout@v4
2727
- uses: wyvox/action-setup-pnpm@v3
2828
- run: pnpm install --no-lockfile
29+
- run: pnpm lint
2930
- run: pnpm build
3031
- run: pnpm vitest ${{ matrix.testenv.args }}

.github/workflows/plan-release.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ concurrency:
1414

1515
jobs:
1616
check-plan:
17-
name: "Check Release Plan"
17+
name: 'Check Release Plan'
1818
runs-on: ubuntu-latest
1919
outputs:
2020
command: ${{ steps.check-release.outputs.command }}
@@ -52,14 +52,14 @@ jobs:
5252
ref: 'main'
5353
- uses: wyvox/action-setup-pnpm@v3
5454
- run: pnpm install --frozen-lockfile
55-
56-
- name: "Generate Explanation and Prep Changelogs"
55+
56+
- name: 'Generate Explanation and Prep Changelogs'
5757
id: explanation
5858
run: |
5959
set +e
60-
60+
6161
pnpm release-plan prepare 2> >(tee -a release-plan-stderr.txt >&2)
62-
62+
6363
6464
if [ $? -ne 0 ]; then
6565
echo 'text<<EOF' >> $GITHUB_OUTPUT
@@ -77,7 +77,7 @@ jobs:
7777
- uses: peter-evans/create-pull-request@v6
7878
with:
7979
commit-message: "Prepare Release using 'release-plan'"
80-
labels: "internal"
80+
labels: 'internal'
8181
branch: release-preview
8282
title: Prepare Release
8383
body: |

.github/workflows/publish.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ concurrency:
1717

1818
jobs:
1919
check-plan:
20-
name: "Check Release Plan"
20+
name: 'Check Release Plan'
2121
runs-on: ubuntu-latest
2222
outputs:
2323
command: ${{ steps.check-release.outputs.command }}
@@ -34,7 +34,7 @@ jobs:
3434
run: if git diff --name-only HEAD HEAD~1 | grep -w -q ".release-plan.json"; then echo "command=release"; fi >> $GITHUB_OUTPUT
3535

3636
publish:
37-
name: "NPM Publish"
37+
name: 'NPM Publish'
3838
runs-on: ubuntu-latest
3939
needs: check-plan
4040
if: needs.check-plan.outputs.command == 'release'
@@ -51,7 +51,7 @@ jobs:
5151
- run: pnpm install --frozen-lockfile
5252
- name: npm publish
5353
run: pnpm release-plan publish
54-
54+
5555
env:
5656
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
5757
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.prettierrc.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"embeddedLanguageFormatting": "off",
6+
"singleQuote": true,
7+
"semi": true,
8+
"quoteProps": "preserve",
9+
"bracketSpacing": false
10+
}

CHANGELOG.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
signal-polyfill 0.1.1 (patch)
66

77
#### :house: Internal
8-
* `signal-polyfill`
9-
* [#6](https://github.com/proposal-signals/signal-polyfill/pull/6) Fix repo references ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
10-
* [#4](https://github.com/proposal-signals/signal-polyfill/pull/4) Setup release automation ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
11-
* [#1](https://github.com/proposal-signals/signal-polyfill/pull/1) Fix CI ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
8+
9+
- `signal-polyfill`
10+
- [#6](https://github.com/proposal-signals/signal-polyfill/pull/6) Fix repo references ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
11+
- [#4](https://github.com/proposal-signals/signal-polyfill/pull/4) Setup release automation ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
12+
- [#1](https://github.com/proposal-signals/signal-polyfill/pull/1) Fix CI ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
1213

1314
#### Committers: 1
15+
1416
- [@NullVoxPopuli](https://github.com/NullVoxPopuli)

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Signal Polyfill
22

3-
## ⚠️ This polyfill is a preview of an in-progress proposal and could change at any time. Do not use this in production. ⚠️
3+
## ⚠️ This polyfill is a preview of an in-progress proposal and could change at any time. Do not use this in production. ⚠️
44

55
A "signal" is [a proposed first-class JavaScript data type](https://github.com/tc39/proposal-signals) that enables one-way data flow through cells of state or computations derived from other state/computations.
66

@@ -10,16 +10,16 @@ This is a polyfill for the `Signal` API.
1010

1111
### Using signals
1212

13-
* Use `Signal.State(value)` to create a single "cell" of data that can flow through the unidirectional state graph.
14-
* Use `Signal.Computed(callback)` to define a computation based on state or other computations flowing through the graph.
13+
- Use `Signal.State(value)` to create a single "cell" of data that can flow through the unidirectional state graph.
14+
- Use `Signal.Computed(callback)` to define a computation based on state or other computations flowing through the graph.
1515

1616
```js
1717
import { Signal } from "signal-polyfill";
1818
import { effect } from "./effect.js";
1919

2020
const counter = new Signal.State(0);
2121
const isEven = new Signal.Computed(() => (counter.get() & 1) == 0);
22-
const parity = new Signal.Computed(() => isEven.get() ? "even" : "odd");
22+
const parity = new Signal.Computed(() => (isEven.get() ? "even" : "odd"));
2323

2424
effect(() => console.log(parity.get())); // Console logs "even" immediately.
2525
setInterval(() => counter.set(counter.get() + 1), 1000); // Changes the counter every 1000ms.
@@ -44,11 +44,11 @@ Depending on how the effect is implemented, the above code could result in an in
4444

4545
### Creating a simple effect
4646

47-
* You can use `Signal.subtle.Watch(callback)` combined with `Signal.Computed(callback)` to create a simple _effect_ implementation.
48-
* The `Signal.subtle.Watch` `callback` is invoked synchronously when a watched signal becomes dirty.
49-
* To batch effect updates, library authors are expected to implement their own schedulers.
50-
* Use `Signal.subtle.Watch#getPending()` to retrieve an array of dirty signals.
51-
* Calling `Signal.subtle.Watch#watch()` with no arguments will re-watch the list of tracked signals again.
47+
- You can use `Signal.subtle.Watch(callback)` combined with `Signal.Computed(callback)` to create a simple _effect_ implementation.
48+
- The `Signal.subtle.Watch` `callback` is invoked synchronously when a watched signal becomes dirty.
49+
- To batch effect updates, library authors are expected to implement their own schedulers.
50+
- Use `Signal.subtle.Watch#getPending()` to retrieve an array of dirty signals.
51+
- Calling `Signal.subtle.Watch#watch()` with no arguments will re-watch the list of tracked signals again.
5252

5353
```js
5454
import { Signal } from "signal-polyfill";
@@ -64,7 +64,7 @@ const w = new Signal.subtle.Watcher(() => {
6464

6565
function processPending() {
6666
needsEnqueue = true;
67-
67+
6868
for (const s of w.getPending()) {
6969
s.get();
7070
}
@@ -74,15 +74,15 @@ function processPending() {
7474

7575
export function effect(callback) {
7676
let cleanup;
77-
77+
7878
const computed = new Signal.Computed(() => {
7979
typeof cleanup === "function" && cleanup();
8080
cleanup = callback();
8181
});
82-
82+
8383
w.watch(computed);
8484
computed.get();
85-
85+
8686
return () => {
8787
w.unwatch(computed);
8888
typeof cleanup === "function" && cleanup();
@@ -112,7 +112,7 @@ export function signal(target) {
112112
set(value) {
113113
get.call(this).set(value);
114114
},
115-
115+
116116
init(value) {
117117
return new Signal.State(value);
118118
},

RELEASE.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ Releases in this repo are mostly automated using [release-plan](https://github.c
44

55
## Preparation
66

7-
Since the majority of the actual release process is automated, the remaining tasks before releasing are:
7+
Since the majority of the actual release process is automated, the remaining tasks before releasing are:
88

9-
- correctly labeling **all** pull requests that have been merged since the last release
10-
- updating pull request titles so they make sense to our users
9+
- correctly labeling **all** pull requests that have been merged since the last release
10+
- updating pull request titles so they make sense to our users
1111

1212
Some great information on why this is important can be found at [keepachangelog.com](https://keepachangelog.com/en/1.1.0/), but the overall
1313
guiding principle here is that changelogs are for humans, not machines.
1414

1515
When reviewing merged PR's the labels to be used are:
1616

17-
* breaking - Used when the PR is considered a breaking change.
18-
* enhancement - Used when the PR adds a new feature or enhancement.
19-
* bug - Used when the PR fixes a bug included in a previous release.
20-
* documentation - Used when the PR adds or updates documentation.
21-
* internal - Internal changes or things that don't fit in any other category.
17+
- breaking - Used when the PR is considered a breaking change.
18+
- enhancement - Used when the PR adds a new feature or enhancement.
19+
- bug - Used when the PR fixes a bug included in a previous release.
20+
- documentation - Used when the PR adds or updates documentation.
21+
- internal - Internal changes or things that don't fit in any other category.
2222

2323
**Note:** `release-plan` requires that **all** PRs are labeled. If a PR doesn't fit in a category it's fine to label it as `internal`
2424

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
"build": "tsc && vite build",
2121
"dev": "vite",
2222
"prepack": "npm run build",
23+
"lint": "prettier --check .",
24+
"lint:fix": "prettier --write .",
2325
"test": "vitest"
2426
},
2527
"devDependencies": {

src/computed.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@
77
*/
88

99
import {defaultEquals, ValueEqualityFn} from './equality.js';
10-
import {consumerAfterComputation, consumerBeforeComputation, producerAccessed, producerUpdateValueVersion, REACTIVE_NODE, ReactiveNode, SIGNAL} from './graph.js';
11-
10+
import {
11+
consumerAfterComputation,
12+
consumerBeforeComputation,
13+
producerAccessed,
14+
producerUpdateValueVersion,
15+
REACTIVE_NODE,
16+
ReactiveNode,
17+
SIGNAL,
18+
} from './graph.js';
1219

1320
/**
1421
* A computation, which derives a value from a declarative reactive expression.
@@ -36,7 +43,7 @@ export interface ComputedNode<T> extends ReactiveNode {
3643
equal: ValueEqualityFn<T>;
3744
}
3845

39-
export type ComputedGetter<T> = (() => T)&{
46+
export type ComputedGetter<T> = (() => T) & {
4047
[SIGNAL]: ComputedNode<T>;
4148
};
4249

src/equality.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ export type ValueEqualityFn<T> = (a: T, b: T) => boolean;
1616
*/
1717
export function defaultEquals<T>(a: T, b: T) {
1818
return Object.is(a, b);
19-
}
19+
}

src/errors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ export function throwInvalidWriteToSignalError() {
1818

1919
export function setThrowInvalidWriteToSignalError(fn: () => never): void {
2020
throwInvalidWriteToSignalErrorFn = fn;
21-
}
21+
}

0 commit comments

Comments
 (0)