Skip to content

Commit 1c2b776

Browse files
committed
Initial commit
0 parents  commit 1c2b776

23 files changed

+1069
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
coverage
3+
node_modules
4+
package-lock.json
5+
pnpm-lock.yaml
6+
tsconfig.tsbuildinfo

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
access=public
2+
package-lock=false

.oxlintrc.json

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
{
2+
"plugins": [
3+
"eslint",
4+
"import",
5+
"node",
6+
"oxc",
7+
"promise",
8+
"typescript",
9+
"unicorn",
10+
"vitest"
11+
],
12+
"categories": {
13+
"correctness": "error",
14+
"pedantic": "error",
15+
"perf": "error",
16+
"restriction": "error",
17+
"style": "error",
18+
"suspicious": "error"
19+
},
20+
"env": {
21+
"node": true
22+
},
23+
"settings": {
24+
"vitest": {
25+
"typecheck": true
26+
}
27+
},
28+
"rules": {
29+
"eslint/accessor-pairs": ["error", { "enforceForClassMembers": true }],
30+
"eslint/array-callback-return": ["error", { "allowImplicit": true }],
31+
"eslint/arrow-body-style": "off",
32+
"eslint/capitalized-comments": "off",
33+
"eslint/func-names": "off",
34+
"eslint/func-style": [
35+
"error",
36+
"declaration",
37+
{ "allowArrowFunctions": true }
38+
],
39+
"eslint/grouped-accessor-pairs": ["error", "getBeforeSet"],
40+
"eslint/id-length": "off",
41+
"eslint/init-declarations": "off",
42+
"eslint/max-lines": "off",
43+
"eslint/max-lines-per-function": "off",
44+
"eslint/max-params": "off",
45+
"eslint/max-statements": "off",
46+
"eslint/new-cap": "off",
47+
"eslint/no-await-in-loop": "off",
48+
"eslint/no-continue": "off",
49+
"eslint/no-duplicate-imports": "off",
50+
"eslint/no-else-return": ["error", { "allowElseIf": false }],
51+
"eslint/no-empty": ["error", { "allowEmptyCatch": true }],
52+
"eslint/no-magic-numbers": "off",
53+
"eslint/no-param-reassign": ["error", { "props": true }],
54+
"eslint/no-return-assign": ["error", "always"],
55+
"eslint/no-self-assign": ["error", { "props": true }],
56+
"eslint/no-ternary": "off",
57+
"eslint/no-undefined": "off",
58+
"eslint/no-unsafe-negation": [
59+
"error",
60+
{ "enforceForOrderingRelations": true }
61+
],
62+
"eslint/no-unsafe-optional-chaining": [
63+
"error",
64+
{ "disallowArithmeticOperators": true }
65+
],
66+
"eslint/no-unused-expressions": ["error", { "enforceForJSX": true }],
67+
"eslint/no-unused-vars": [
68+
"error",
69+
{
70+
"argsIgnorePattern": "^_",
71+
"caughtErrorsIgnorePattern": "^_",
72+
"destructuredArrayIgnorePattern": "^_",
73+
"varsIgnorePattern": "^_"
74+
}
75+
],
76+
"eslint/no-void": "off",
77+
"eslint/prefer-destructuring": [
78+
"error",
79+
{ "enforceForRenamedProperties": false }
80+
],
81+
"eslint/prefer-promise-reject-errors": "off",
82+
"eslint/prefer-regex-literals": [
83+
"error",
84+
{ "disallowRedundantWrapping": true }
85+
],
86+
"eslint/require-await": "off",
87+
"eslint/sort-imports": "off",
88+
"eslint/sort-keys": "off",
89+
"eslint/valid-typeof": ["error", { "requireStringLiterals": false }],
90+
"import/exports-last": "off",
91+
"import/group-exports": "off",
92+
"import/max-dependencies": "off",
93+
"import/no-default-export": "off",
94+
"import/no-named-export": "off",
95+
"import/no-namespace": "off",
96+
"import/no-unassigned-import": "error",
97+
"oxc/no-async-await": "off",
98+
"oxc/no-optional-chaining": "off",
99+
"oxc/no-rest-spread-properties": "off",
100+
"promise/avoid-new": "off",
101+
"promise/prefer-await-to-callbacks": "off",
102+
"typescript/array-type": [
103+
"error",
104+
{
105+
"default": "array-simple",
106+
"readonly": "generic"
107+
}
108+
],
109+
"typescript/ban-ts-comment": [
110+
"error",
111+
{
112+
"ts-check": true,
113+
"ts-expect-error": false,
114+
"ts-ignore": true,
115+
"ts-nocheck": true
116+
}
117+
],
118+
"typescript/consistent-type-definitions": ["error", "type"],
119+
"typescript/consistent-type-imports": [
120+
"error",
121+
{
122+
"fixStyle": "separate-type-imports",
123+
"prefer": "type-imports"
124+
}
125+
],
126+
"typescript/explicit-function-return-type": "off",
127+
"typescript/no-confusing-void-expression": [
128+
"error",
129+
{ "ignoreArrowShorthand": true }
130+
],
131+
"typescript/no-misused-promises": [
132+
"error",
133+
{ "checksConditionals": true, "checksVoidReturn": false }
134+
],
135+
"typescript/no-namespace": ["error", { "allowDeclarations": true }],
136+
"typescript/no-non-null-assertion": "off",
137+
"typescript/no-restricted-types": [
138+
"error",
139+
{
140+
"types": {
141+
"[]": true,
142+
"null": true,
143+
"object": true
144+
}
145+
}
146+
],
147+
"typescript/no-unsafe-type-assertion": "off",
148+
"typescript/only-throw-error": [
149+
"error",
150+
{ "allowThrowingAny": false, "allowThrowingUnknown": true }
151+
],
152+
"typescript/prefer-nullish-coalescing": [
153+
"error",
154+
{ "ignoreConditionalTests": false }
155+
],
156+
"typescript/prefer-promise-reject-errors": "off",
157+
"typescript/require-array-sort-compare": [
158+
"error",
159+
{ "ignoreStringArrays": true }
160+
],
161+
"typescript/restrict-template-expressions": [
162+
"error",
163+
{ "allowNumber": true }
164+
],
165+
"typescript/strict-boolean-expressions": "off",
166+
"typescript/switch-exhaustiveness-check": [
167+
"error",
168+
{
169+
"allowDefaultCaseForExhaustiveSwitch": false,
170+
"requireDefaultForNonUnion": true
171+
}
172+
],
173+
"typescript/unbound-method": "off",
174+
"unicorn/no-array-callback-reference": "off",
175+
"unicorn/no-null": "off",
176+
"unicorn/no-single-promise-in-promise-methods": "off",
177+
"unicorn/no-useless-undefined": "off",
178+
"unicorn/prefer-bigint-literals": "off"
179+
},
180+
"overrides": [
181+
{
182+
"files": ["*.d.ts"],
183+
"rules": {
184+
"import/no-unassigned-import": "off",
185+
"import/unambiguous": "off",
186+
"typescript/consistent-type-definitions": "off",
187+
"typescript/no-restricted-types": "off"
188+
}
189+
},
190+
{
191+
"files": ["**/*.test.ts"],
192+
"rules": {
193+
"eslint/no-alert": "off",
194+
"promise/prefer-await-to-then": "off",
195+
"typescript/ban-ts-comment": "off",
196+
"typescript/no-confusing-void-expression": "off",
197+
"typescript/no-empty-function": "off",
198+
"typescript/no-extraneous-class": "off",
199+
"typescript/no-unsafe-assignment": "off",
200+
"typescript/no-unsafe-member-access": "off",
201+
"unicorn/consistent-function-scoping": "off",
202+
"vitest/no-conditional-tests": "off",
203+
"vitest/prefer-to-be-falsy": "off",
204+
"vitest/prefer-to-be-truthy": "off"
205+
}
206+
}
207+
]
208+
}

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright © Dom Porada <dom@dom.engineering> (https://dom.engineering)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# @standard-config/prettier
2+
3+
Curated Prettier config for modern TypeScript projects.
4+
5+
- Enables the [`oxc` parser](https://oxc.rs/docs/guide/usage/parser.html) for lightning-fast TypeScript formatting.
6+
- Sorts all JSON files, with curated order patterns for common config files: `package.json`, `tsconfig.json`, `.oxlintrc.json`, and more.
7+
8+
## Install
9+
10+
```sh
11+
npm install --save-dev @standard-config/prettier
12+
```
13+
14+
```sh
15+
pnpm add --save-dev @standard-config/prettier
16+
```
17+
18+
## Usage
19+
20+
Create your `prettier.config.ts`:
21+
22+
```ts
23+
import { defineConfig } from '@standard-config/prettier';
24+
25+
export default defineConfig();
26+
```
27+
28+
Optionally, pass your own [config options](https://prettier.io/docs/options) to overwrite the [package defaults](src/config.ts):
29+
30+
```ts
31+
import { defineConfig } from '@standard-config/prettier';
32+
33+
export default defineConfig({
34+
semi: false,
35+
});
36+
```

package.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "@standard-config/prettier",
3+
"version": "0.0.0",
4+
"description": "Curated Prettier config for modern TypeScript projects",
5+
"license": "MIT",
6+
"author": {
7+
"name": "Dom Porada",
8+
"email": "dom@dom.engineering",
9+
"url": "https://dom.engineering"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/standard-config/prettier.git"
14+
},
15+
"keywords": [
16+
"json-sorting",
17+
"oxc",
18+
"oxc-parser",
19+
"prettier-config",
20+
"standard-config",
21+
"typescript"
22+
],
23+
"files": [
24+
"src/**/*.ts",
25+
"!**/*.test.ts"
26+
],
27+
"type": "module",
28+
"sideEffects": false,
29+
"exports": "./src/index.ts",
30+
"engines": {
31+
"node": ">=24"
32+
},
33+
"dependencies": {
34+
"@prettier/plugin-oxc": "^0.1.3",
35+
"klona": "^2.0.6",
36+
"prettier-plugin-packagejson": "2.5.20",
37+
"prettier-plugin-sort-json": "4.1.1"
38+
},
39+
"peerDependencies": {
40+
"prettier": ">=3.7"
41+
},
42+
"devDependencies": {
43+
"@standard-config/tsconfig": "^1.0.0",
44+
"@vitest/coverage-v8": "~4.0.16",
45+
"oxlint": "~1.38.0",
46+
"oxlint-tsgolint": "~0.10.1",
47+
"prettier": "^3.7.4",
48+
"typescript": "^5.9.3",
49+
"vitest": "~4.0.16"
50+
},
51+
"scripts": {
52+
"format": "prettier --write --ignore-unknown .",
53+
"lint": "oxlint --fix --type-aware --type-check --deny-warnings --report-unused-disable-directives",
54+
"test": "vitest run",
55+
"typecheck": "tsc --noEmit"
56+
}
57+
}

pnpm-workspace.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
onlyBuiltDependencies:
2+
- esbuild

prettier.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { defineConfig } from './src/index.ts';
2+
3+
export default defineConfig();

src/config.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { Config } from 'prettier';
2+
import { expectTypeOf, test } from 'vitest';
3+
import BASE_CONFIG from './config.ts';
4+
5+
test('is a valid Prettier config', () => {
6+
expectTypeOf(BASE_CONFIG).toExtend<Config>();
7+
8+
/* @ts-expect-error */
9+
BASE_CONFIG.quoteProps = 'all';
10+
});

0 commit comments

Comments
 (0)