@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 CHANGED
@@ -1,83 +1,75 @@
1
1
  # @michaelhelvey/vite-config
2
2
 
3
- Opinionated defaults for [Vite+](https://viteplus.dev/).
3
+ Opinionated defaults and configuration helpers for [VitePlus](https://viteplus.dev/).
4
4
 
5
- ## Install
5
+ ## Getting Started
6
6
 
7
- ```sh
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
- export default defineConfig({
20
- ...defaults,
21
- // override anything you need
22
- });
9
+ ```shell
10
+ npm install -D @michaelhelvey/vite-config
23
11
  ```
24
12
 
25
- ## Customization
13
+ _Or use the package manager of your choice_.
26
14
 
27
- ### Extending the default config
15
+ Then create your config file at `./vite.config.ts`:
28
16
 
29
- Spread the defaults and override individual sections:
17
+ ```typescript
18
+ import { defineConfig } from "@michaelhelvey/vite-config";
30
19
 
31
- ```ts
32
- import { defineConfig } from "vite-plus";
33
- import defaults from "@michaelhelvey/vite-config";
20
+ export default await defineConfig();
21
+ ```
34
22
 
35
- export default defineConfig({
36
- ...defaults,
37
- test: {
38
- ...defaults.test,
39
- passWithNoTests: false,
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
- ### Using lint presets directly
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
- You can import the rule and plugin helpers to build your own lint config:
50
+ ## Helpers
47
51
 
48
- ```ts
49
- import {
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
- // Get all rules for a preset as { "scope/rule-name": "error" }
55
- const rules = rulesForCategory("production_react");
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
- // Get the plugin list for a preset
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
- ### Accessing the raw rule data
68
+ ## Development
62
69
 
63
- The full scraped oxlint rule table is available as a separate export:
70
+ You can re-generate the rules by scraping the oxlint website by running `bun run build:generate`.
64
71
 
65
- ```ts
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