@component-hook/eslint-plugin 1.5.0 → 1.6.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,6 +1,6 @@
1
1
  # @component-hook/eslint-plugin
2
2
 
3
- A opinionated ESLint config preset for `JavaScript`, `TypeScript`, `Vue3`, `React` and `Prettier`.
3
+ A opinionated ESLint config preset for `JavaScript`, `TypeScript`, `Vue3`, `React`, `Prettier` and `oxfmt`.
4
4
 
5
5
  <p>
6
6
  <a href="https://npm-stat.com/charts.html?package=@component-hook/eslint-plugin">
@@ -14,14 +14,15 @@ A opinionated ESLint config preset for `JavaScript`, `TypeScript`, `Vue3`, `Reac
14
14
  ## Features
15
15
 
16
16
  - Support `TypeScript`, `Vue3` and `React` out-of-box.
17
- - Format with `Prettier`.
17
+ - Format with `Prettier` or [`oxfmt`](https://oxc.rs/docs/guide/usage/formatter).
18
18
  - Ignores common files like `dist`, `node_modules`, `coverage`, and files in `.gitignore`.
19
19
  - Various built-in configurations can be referenced according to respective needs.
20
20
  - Reasonable defaults, best practices, and just a few lines of configuration.
21
+ - Prefer [oxlint](https://oxc.rs/docs/guide/usage/linter)? [`@component-hook/oxlint-config`](https://github.com/tzuyi0817/component-hook/tree/master/packages/oxlint-config) is generated from this preset.
21
22
 
22
23
  ## Documentation
23
24
 
24
- For detailed documentation and usage examples, please visit: [Official Docs](https://tzuyi0817.github.io/component-hook/#/eslint/plugin).
25
+ For detailed documentation and usage examples, please visit: [Official Docs](https://tzuyi0817.github.io/component-hook/#/lint/eslint-plugin).
25
26
 
26
27
  ## Installation
27
28
 
@@ -36,7 +37,11 @@ $ yarn add @component-hook/eslint-plugin --dev
36
37
  $ pnpm install @component-hook/eslint-plugin --save-dev
37
38
  ```
38
39
 
39
- Require ESLint >= 9.0.0
40
+ > **Compatibility Note:**
41
+ >
42
+ > Require ESLint >= 9.0.0
43
+ >
44
+ > This package is ESM only because several bundled plugins are ESM only. Write your config as `eslint.config.js` in a `"type": "module"` project or as `eslint.config.mjs`. On Node.js 20.19+ / 22.12+ `require()` still works through `require(esm)`, and the plugin is exposed on the `default` property.
40
45
 
41
46
  ## Basic Usage
42
47
 
@@ -84,6 +89,29 @@ import { vuePreset } from '@component-hook/eslint-plugin';
84
89
  export default vuePreset;
85
90
  ```
86
91
 
92
+ ## Formatting with oxfmt
93
+
94
+ Use `configs.oxfmt` instead of `configs.prettier` to format with [oxfmt](https://oxc.rs/docs/guide/usage/formatter). It discovers `.oxfmtrc.json` (or other oxfmt config files) the same way as the oxfmt CLI, and turns off the stylistic rules that conflict with the formatter.
95
+
96
+ oxfmt also sorts top-level `package.json` keys by default (`sortPackageJson`), so the preset no longer orders them itself; it still sorts nested fields oxfmt leaves alone, such as `exports` conditions and dependency maps. If you stay on `configs.prettier` and still want `package.json` sorted, add [`prettier-plugin-packagejson`](https://github.com/matzkoh/prettier-plugin-packagejson), which uses the same `sort-package-json` order as oxfmt.
97
+
98
+ `oxfmt` >= 0.71.0 is a peer dependency. Most package managers install it automatically; otherwise add it yourself:
99
+
100
+ ```bash
101
+ $ pnpm add -D oxfmt
102
+ ```
103
+
104
+ ```js
105
+ import componentHookPlugin from '@component-hook/eslint-plugin';
106
+
107
+ export default [
108
+ ...componentHookPlugin.configs.basic,
109
+ ...componentHookPlugin.configs.vue,
110
+ componentHookPlugin.configs.oxfmt,
111
+ // your custom config
112
+ ];
113
+ ```
114
+
87
115
  ## Configs
88
116
 
89
117
  | Name | Type | Reference |
@@ -93,6 +121,7 @@ export default vuePreset;
93
121
  | react | `Linter.Config[]` | `eslint-plugin-react/recommended`, `eslint-plugin-react-hooks/recommended`, `eslint-plugin-jsx-a11y/recommended` |
94
122
  | markdown | `Linter.Config[]` | `@eslint/markdown` |
95
123
  | prettier | `Linter.Config` | `eslint-plugin-prettier/recommended` |
124
+ | oxfmt | `Linter.Config` | `eslint-plugin-oxfmt`, `eslint-config-prettier` |
96
125
  | sonarjs | `Linter.Config[]` | `eslint-plugin-sonarjs/recommended` |
97
126
  | security | `Linter.Config` | `eslint-plugin-security/recommended` |
98
127
  | playwright | `Linter.Config` | `eslint-plugin-playwright/flat/recommended` |
@@ -116,6 +145,7 @@ export default vuePreset;
116
145
  - [eslint-plugin-perfectionist](https://github.com/azat-io/eslint-plugin-perfectionist)
117
146
  - [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml)
118
147
  - [eslint-plugin-prettier/recommended](https://github.com/prettier/eslint-plugin-prettier/blob/master/recommended.js)
148
+ - [eslint-plugin-oxfmt](https://github.com/ntnyq/eslint-plugin-oxfmt)
119
149
  - [eslint-plugin-react/recommended](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/configs/recommended.js)
120
150
  - [eslint-plugin-react-hooks/recommended](https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/index.js)
121
151
  - [eslint-plugin-jsx-a11y/recommended](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/index.js)