Skip to content

Commit 89af935

Browse files
committed
Initial bit of prettier, with recommended .prettierrc
Note: I only ran prettier on `src/core`. The reason for this is that this prettier config will mangle some code. It is not the fault of a single prettier plugin, or the prettier version. Instead, it is when 3 plugins are used together that this issue happens. It is kind of difficult to describe - you can see the error on the bash language defintion `npx prettier src/languages/prism-bash.ts --write` Additionally, I did not want to work super hard on forming eslint to the prettier config until we committed to this approach. I would love feedback.
1 parent 3c0e4a7 commit 89af935

File tree

11 files changed

+554
-354
lines changed

11 files changed

+554
-354
lines changed

.eslintrc.js

Lines changed: 160 additions & 173 deletions
Large diffs are not rendered by default.

.prettierrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"plugins": [
3+
"prettier-plugin-brace-style",
4+
"prettier-plugin-space-before-function-paren",
5+
"prettier-plugin-merge"
6+
],
7+
"braceStyle": "stroustrup",
8+
"arrowParens": "avoid",
9+
"bracketSpacing": true,
10+
"endOfLine": "auto",
11+
"semi": true,
12+
"singleQuote": false,
13+
"tabWidth": 4,
14+
"useTabs": true,
15+
"trailingComma": "all",
16+
"printWidth": 100
17+
}

package-lock.json

Lines changed: 154 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@babel/core": "^7.18.13",
4141
"@babel/preset-env": "^7.18.10",
4242
"@babel/register": "^7.18.9",
43+
"@prettier/sync": "^0.5.2",
4344
"@rollup/plugin-terser": "^0.4.3",
4445
"@rollup/plugin-typescript": "^11.1.1",
4546
"@types/benchmark": "^2.1.2",
@@ -48,7 +49,7 @@
4849
"@types/jsdom": "^20.0.0",
4950
"@types/mocha": "^9.1.1",
5051
"@types/node": "^20.2.5",
51-
"@types/prettier": "^2.7.0",
52+
"@types/prettier": "^2.7.3",
5253
"@types/yargs": "^17.0.11",
5354
"@typescript-eslint/eslint-plugin": "^5.59.8",
5455
"@typescript-eslint/parser": "^5.59.8",
@@ -70,7 +71,10 @@
7071
"mocha": "^9.2.2",
7172
"mocha-chai-jest-snapshot": "^1.1.4",
7273
"npm-run-all": "^4.1.5",
73-
"prettier": "^2.7.1",
74+
"prettier": "^3.5.3",
75+
"prettier-plugin-brace-style": "^0.7.2",
76+
"prettier-plugin-merge": "^0.7.2",
77+
"prettier-plugin-space-before-function-paren": "^0.0.5",
7478
"refa": "^0.9.1",
7579
"regexp-ast-analysis": "^0.2.4",
7680
"regexpp": "^3.2.0",

src/core/hook-state.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ export type StateKey<T> = (string | symbol) & { __keyType?: T };
66
export class HookState {
77
private _data = new Map<string | symbol, {}>();
88

9-
has(key: StateKey<{}>): boolean {
9+
has (key: StateKey<{}>): boolean {
1010
return this._data.has(key);
1111
}
1212

13-
get<T extends {}>(key: StateKey<T>, defaultValue: T) {
13+
get <T extends {}>(key: StateKey<T>, defaultValue: T) {
1414
let current = this._data.get(key);
1515
if (current === undefined) {
1616
current = defaultValue;
@@ -19,7 +19,7 @@ export class HookState {
1919
return current as T;
2020
}
2121

22-
set<T extends {}>(key: StateKey<T>, value: T): void {
22+
set <T extends {}>(key: StateKey<T>, value: T): void {
2323
this._data.set(key, value);
2424
}
2525
}

0 commit comments

Comments
 (0)