@configg/bases 0.1.7 → 0.1.9
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 +4 -1
- package/package.json +24 -2
- package/packages/oxc/src/lint.ts +1 -0
- package/packages/prettier/src/index.ts +79 -0
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ The presets ship as TypeScript and JSON source. There is no build step, so use t
|
|
|
14
14
|
| Package | Version | What it configures |
|
|
15
15
|
| ------------------------------------------ | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
16
16
|
| [`@configg/oxc`](./packages/oxc) | [](https://www.npmjs.com/package/@configg/oxc) | `oxfmt` (`/fmt`) and `oxlint` (`/lint`) presets |
|
|
17
|
+
| [`@configg/prettier`](./packages/prettier) | [](https://www.npmjs.com/package/@configg/prettier) | Prettier presets and `combine()` |
|
|
17
18
|
| [`@configg/tsconfig`](./packages/tsconfig) | [](https://www.npmjs.com/package/@configg/tsconfig) | Strictest `tsconfig` presets for Bun and Vite |
|
|
18
19
|
| `@configg/bases` (this repo's root) | [](https://www.npmjs.com/package/@configg/bases) | All of the above under one name, straight from `packages/*` |
|
|
19
20
|
|
|
@@ -23,11 +24,12 @@ Install only what you use, or install `@configg/bases` and import everything fro
|
|
|
23
24
|
| ---------------------------- | ------------------------------------- |
|
|
24
25
|
| `oxfmt` | `@configg/oxc/fmt` |
|
|
25
26
|
| `oxlint` | `@configg/oxc/lint` |
|
|
27
|
+
| `prettier` | `@configg/prettier` |
|
|
26
28
|
| `tsconfig/{bun,client,vite}` | `@configg/tsconfig/{bun,client,vite}` |
|
|
27
29
|
|
|
28
30
|
## Usage
|
|
29
31
|
|
|
30
|
-
Tools are `peerDependencies`: you install `oxfmt`, `oxlint` and `typescript` yourself and pin the versions you want. The packages only supply the presets.
|
|
32
|
+
Tools are `peerDependencies`: you install `oxfmt`, `oxlint`, `prettier` and `typescript` yourself and pin the versions you want, plus the Prettier plugins of the presets you compose. The packages only supply the presets.
|
|
31
33
|
|
|
32
34
|
```sh
|
|
33
35
|
bun add -d @configg/bases oxfmt oxlint oxlint-tsgolint typescript
|
|
@@ -60,6 +62,7 @@ Installing a single package works the same way, for example `@configg/oxc/fmt` a
|
|
|
60
62
|
|
|
61
63
|
- `oxfmt` exports `configs`: `client` (Tailwind class sorting, import grouping), `scripts` (shared base for tooling and config files) and `server` (shared base).
|
|
62
64
|
- `oxlint` exports `configs`: `client` (browser env, React, and a `**/*.spec.{ts,tsx}` override with Vitest and Testing Library rules) and `scripts` (Node env).
|
|
65
|
+
- `prettier` exports `config` (the same options as oxfmt), one preset per plugin (`sortImports`, `astro`, `svelte`, `tailwind`) and `combine()` to merge them: `combine(config, sortImports, tailwind({ tailwindStylesheet: './src/main.css' }))`. See [its README](./packages/prettier/README.md).
|
|
63
66
|
- `tsconfig/bun` (`strictest` + Bun), `tsconfig/vite` (`strictest` + Vite/React) and `tsconfig/client` (`vite` with ambient `types` cleared, so a package only picks up the `@types/*` it asks for).
|
|
64
67
|
|
|
65
68
|
The Oxlint presets don't enable anti-slop. `antiSlop` from the oxlint entry is an opt-in set with the plugin and all 18 rules as errors; `unicorn/prefer-reflect-apply` is off. See [UPSTREAM.md](./packages/oxc/src/anti-slop/UPSTREAM.md) for its source and update policy.
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configg/bases",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "All @configg presets in one package: oxc and tsconfig",
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"description": "All @configg presets in one package: oxc, prettier and tsconfig",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"config",
|
|
7
7
|
"oxc",
|
|
8
8
|
"oxfmt",
|
|
9
9
|
"oxlint",
|
|
10
|
+
"prettier",
|
|
10
11
|
"tsconfig"
|
|
11
12
|
],
|
|
12
13
|
"homepage": "https://github.com/crutchcrew/configg#readme",
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
"exports": {
|
|
30
31
|
"./oxfmt": "./packages/oxc/src/fmt.ts",
|
|
31
32
|
"./oxlint": "./packages/oxc/src/lint.ts",
|
|
33
|
+
"./prettier": "./packages/prettier/src/index.ts",
|
|
32
34
|
"./tsconfig/bun": "./packages/tsconfig/src/bun.json",
|
|
33
35
|
"./tsconfig/client": "./packages/tsconfig/src/client.json",
|
|
34
36
|
"./tsconfig/vite": "./packages/tsconfig/src/vite.json",
|
|
@@ -66,10 +68,15 @@
|
|
|
66
68
|
"typescript": "7"
|
|
67
69
|
},
|
|
68
70
|
"peerDependencies": {
|
|
71
|
+
"@ianvs/prettier-plugin-sort-imports": "^4",
|
|
69
72
|
"eslint-plugin-testing-library": "^7.16",
|
|
70
73
|
"oxfmt": ">=0.65.0",
|
|
71
74
|
"oxlint": "^1.12.0",
|
|
72
75
|
"oxlint-tsgolint": "^7",
|
|
76
|
+
"prettier": "^3.5.0",
|
|
77
|
+
"prettier-plugin-astro": ">=0.14",
|
|
78
|
+
"prettier-plugin-svelte": "^3",
|
|
79
|
+
"prettier-plugin-tailwindcss": ">=0.6",
|
|
73
80
|
"typescript": "^7"
|
|
74
81
|
},
|
|
75
82
|
"peerDependenciesMeta": {
|
|
@@ -84,6 +91,21 @@
|
|
|
84
91
|
},
|
|
85
92
|
"oxlint-tsgolint": {
|
|
86
93
|
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"prettier": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"@ianvs/prettier-plugin-sort-imports": {
|
|
99
|
+
"optional": true
|
|
100
|
+
},
|
|
101
|
+
"prettier-plugin-astro": {
|
|
102
|
+
"optional": true
|
|
103
|
+
},
|
|
104
|
+
"prettier-plugin-svelte": {
|
|
105
|
+
"optional": true
|
|
106
|
+
},
|
|
107
|
+
"prettier-plugin-tailwindcss": {
|
|
108
|
+
"optional": true
|
|
87
109
|
}
|
|
88
110
|
},
|
|
89
111
|
"packageManager": "bun@1.4.2"
|
package/packages/oxc/src/lint.ts
CHANGED
|
@@ -7,6 +7,7 @@ const sharedRules = {
|
|
|
7
7
|
'eslint/max-classes-per-file': ['warn', { max: 2 }],
|
|
8
8
|
'eslint/max-lines-per-function': ['warn', { max: 100, skipBlankLines: true, skipComments: true }],
|
|
9
9
|
'eslint/max-statements': ['warn', { max: 30 }],
|
|
10
|
+
'eslint/no-continue': 'off',
|
|
10
11
|
'import/prefer-default-export': 'off',
|
|
11
12
|
'oxc/no-async-await': 'off',
|
|
12
13
|
'typescript/restrict-template-expressions': [
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Config } from 'prettier'
|
|
2
|
+
|
|
3
|
+
/** A config for `combine()`. Call it with overrides to get a preset with them merged in. */
|
|
4
|
+
export interface Preset {
|
|
5
|
+
(overrides: Config): Preset
|
|
6
|
+
readonly config: Config
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function isList<T>(value: T | readonly T[]): value is readonly T[] {
|
|
10
|
+
return Array.isArray(value)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Arrays concatenate, so `plugins` and `overrides` accumulate; any other value is replaced. */
|
|
14
|
+
function merge(target: Config, source: Config): Config {
|
|
15
|
+
const merged: Config = { ...target }
|
|
16
|
+
|
|
17
|
+
for (const [key, value] of Object.entries(source)) {
|
|
18
|
+
const current = merged[key]
|
|
19
|
+
|
|
20
|
+
merged[key] = value
|
|
21
|
+
|
|
22
|
+
if (isList(current) && isList(value)) {
|
|
23
|
+
merged[key] = [...current, ...value]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return merged
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function preset(config: Config): Preset {
|
|
31
|
+
return Object.assign((overrides: Config) => preset(merge(config, overrides)), { config })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Merges presets in order. Pass `tailwind` last: it wraps the parsers of the plugins before it. */
|
|
35
|
+
export function combine(...presets: Preset[]): Config {
|
|
36
|
+
return presets.reduce<Config>((merged, { config }) => merge(merged, config), {})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const config = preset({
|
|
40
|
+
arrowParens: 'always',
|
|
41
|
+
bracketSameLine: false,
|
|
42
|
+
bracketSpacing: true,
|
|
43
|
+
embeddedLanguageFormatting: 'auto',
|
|
44
|
+
endOfLine: 'lf',
|
|
45
|
+
experimentalOperatorPosition: 'end',
|
|
46
|
+
htmlWhitespaceSensitivity: 'css',
|
|
47
|
+
jsxSingleQuote: false,
|
|
48
|
+
objectWrap: 'preserve',
|
|
49
|
+
printWidth: 100,
|
|
50
|
+
proseWrap: 'preserve',
|
|
51
|
+
quoteProps: 'as-needed',
|
|
52
|
+
semi: false,
|
|
53
|
+
singleAttributePerLine: false,
|
|
54
|
+
singleQuote: true,
|
|
55
|
+
tabWidth: 2,
|
|
56
|
+
trailingComma: 'all',
|
|
57
|
+
useTabs: true,
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
export const sortImports = preset({
|
|
61
|
+
plugins: ['@ianvs/prettier-plugin-sort-imports'],
|
|
62
|
+
importOrder: ['<BUILTIN_MODULES>', '<THIRD_PARTY_MODULES>', '', '^#/(.*)$', '', '^[.]'],
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
export const astro = preset({
|
|
66
|
+
plugins: ['prettier-plugin-astro'],
|
|
67
|
+
overrides: [{ files: '*.astro', options: { parser: 'astro' } }],
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
export const svelte = preset({
|
|
71
|
+
plugins: ['prettier-plugin-svelte'],
|
|
72
|
+
overrides: [{ files: '*.svelte', options: { parser: 'svelte' } }],
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
export const tailwind = preset({
|
|
76
|
+
plugins: ['prettier-plugin-tailwindcss'],
|
|
77
|
+
tailwindAttributes: ['class', 'className'],
|
|
78
|
+
tailwindFunctions: ['cn', 'cx', 'clsx', 'cva', 'cvx', 'createVariants'],
|
|
79
|
+
})
|