@michaelhelvey/vite-config 1.0.1 → 2.0.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.
- package/README.md +50 -58
- package/dist/index.d.mts +6026 -24
- package/dist/index.mjs +6957 -109
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -13
- package/dist/rules-CnWlgdks.mjs +0 -6316
- package/dist/rules-CnWlgdks.mjs.map +0 -1
- package/dist/rules-DdF6uL2A.d.mts +0 -5613
- package/dist/rules.d.mts +0 -2
- package/dist/rules.mjs +0 -2
package/README.md
CHANGED
|
@@ -1,83 +1,75 @@
|
|
|
1
1
|
# @michaelhelvey/vite-config
|
|
2
2
|
|
|
3
|
-
Opinionated defaults for [
|
|
3
|
+
Opinionated defaults and configuration helpers for [VitePlus](https://viteplus.dev/).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Getting Started
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
npm install -D @michaelhelvey/vite-config vite-plus
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
In your `vite.config.ts`:
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import { defineConfig } from "vite-plus";
|
|
17
|
-
import defaults from "@michaelhelvey/vite-config";
|
|
7
|
+
Install the package:
|
|
18
8
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// override anything you need
|
|
22
|
-
});
|
|
9
|
+
```shell
|
|
10
|
+
npm install -D @michaelhelvey/vite-config
|
|
23
11
|
```
|
|
24
12
|
|
|
25
|
-
|
|
13
|
+
_Or use the package manager of your choice_.
|
|
26
14
|
|
|
27
|
-
|
|
15
|
+
Then create your config file at `./vite.config.ts`:
|
|
28
16
|
|
|
29
|
-
|
|
17
|
+
```typescript
|
|
18
|
+
import { defineConfig } from "@michaelhelvey/vite-config";
|
|
30
19
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
import defaults from "@michaelhelvey/vite-config";
|
|
20
|
+
export default await defineConfig();
|
|
21
|
+
```
|
|
34
22
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
While this is all you have to do to get (what I consider to be) reasonable defaults for linting,
|
|
24
|
+
formatting, and testing, out of the box, you can also pass in additional options to the
|
|
25
|
+
`defineConfig` function. These options will be deeply merged (using `lodash.merge`) into the base
|
|
26
|
+
configuration, so you don't have to worry about manually spreading defaults:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { defineConfig, FileTypes } from "@michaelhelvey/vite-config";
|
|
30
|
+
|
|
31
|
+
export default await defineConfig({
|
|
32
|
+
lint: {
|
|
33
|
+
overrides: [
|
|
34
|
+
{
|
|
35
|
+
files: FileTypes.JS_SOURCE,
|
|
36
|
+
rules: {
|
|
37
|
+
"no-console": "off",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
],
|
|
40
41
|
},
|
|
41
42
|
});
|
|
42
43
|
```
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
Note that while I encourage defining everything within `overrides` so as to save your own sanity
|
|
46
|
+
regarding what rules are enabled for what file types, you certainly don't have to do that if you
|
|
47
|
+
want the same rules enabled for everything. Use the
|
|
48
|
+
[oxlint config reference](https://oxc.rs/docs/guide/usage/linter/config.html) for more information.
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
## Helpers
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
rulesForCategory,
|
|
51
|
-
pluginsForCategory,
|
|
52
|
-
} from "@michaelhelvey/vite-config";
|
|
52
|
+
There's a few different helpers defined by the package to help you build your own configuration
|
|
53
|
+
files.
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
- **FileTypes**: an enumeration of various patterns defining common groupings of files within modern
|
|
56
|
+
Typescript projects.
|
|
57
|
+
- **RULES**: An exported, strongly-typed list of all oxlint rules. You can iterate over this in
|
|
58
|
+
order to build up dynamic lists of rules in code rather than statically defining them. See
|
|
59
|
+
`./src/index.ts` in this project to see what I mean.
|
|
60
|
+
- **ruleSelector**: A function that returns a dictionary of rules for a given set of `categories`
|
|
61
|
+
and `sources` (where a category is something like "correctness" and a source is something like
|
|
62
|
+
"eslint").
|
|
63
|
+
- Typescript types corresponding to many of the above, such as `Rule`, `RuleSource`, `RuleCategory`
|
|
64
|
+
and `RuleName`.
|
|
56
65
|
|
|
57
|
-
|
|
58
|
-
const plugins = pluginsForCategory("test");
|
|
59
|
-
```
|
|
66
|
+
You are encouraged to read the source of `./src/index.ts` within this repository for more details.
|
|
60
67
|
|
|
61
|
-
|
|
68
|
+
## Development
|
|
62
69
|
|
|
63
|
-
|
|
70
|
+
You can re-generate the rules by scraping the oxlint website by running `bun run build:generate`.
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
import { RULES } from "@michaelhelvey/vite-config/rules";
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Each entry includes `scope`, `value`, `category`, `type_aware`, `fix`,
|
|
70
|
-
`default`, and `docs_url`.
|
|
71
|
-
|
|
72
|
-
## Updating rules
|
|
73
|
-
|
|
74
|
-
The rule table in `src/rules.ts` is auto-generated from the
|
|
75
|
-
[oxc rules page](https://oxc.rs/docs/guide/usage/linter/rules.html). To refresh
|
|
76
|
-
it:
|
|
77
|
-
|
|
78
|
-
```sh
|
|
79
|
-
npm run build:generate # runs scripts/scrape-rules.ts
|
|
80
|
-
```
|
|
72
|
+
Publishing is only performed locally.
|
|
81
73
|
|
|
82
74
|
## License
|
|
83
75
|
|