@component-hook/eslint-plugin 1.0.4 → 1.1.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.
Files changed (4) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +128 -127
  3. package/dist/index.js +37 -6
  4. package/package.json +3 -2
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Tzuyi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Tzuyi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,127 +1,128 @@
1
- # @component-hook/eslint-plugin
2
-
3
- A opinionated ESLint config preset for `JavaScript`, `TypeScript`, `Vue3`, `React` and `Prettier`.
4
-
5
- <p>
6
- <a href="https://npm-stat.com/charts.html?package=@component-hook/eslint-plugin">
7
- <img src="https://img.shields.io/npm/dm/@component-hook/eslint-plugin.svg" alt="npm"/>
8
- </a>
9
- <a href="https://www.npmjs.com/package/@component-hook/eslint-plugin">
10
- <img src="https://img.shields.io/npm/v/@component-hook/eslint-plugin.svg" alt="npm"/>
11
- </a>
12
- </p>
13
-
14
- ## Features
15
-
16
- - Support `TypeScript`, `Vue3` and `React` out-of-box.
17
- - Format with `Prettier`.
18
- - Ignores common files like `dist`, `node_modules`, `coverage`, and files in `.gitignore`.
19
- - Various built-in configurations can be referenced according to respective needs.
20
- - Reasonable defaults, best practices, and just a few lines of configuration.
21
-
22
- ## Documentation
23
-
24
- For detailed documentation and usage examples, please visit: [Official Docs](https://tzuyi0817.github.io/component-hook/#/eslint/plugin).
25
-
26
- ## Installation
27
-
28
- ```bash
29
- # Using npm
30
- $ npm install @component-hook/eslint-plugin --save-dev
31
-
32
- # Using yarn
33
- $ yarn add @component-hook/eslint-plugin --dev
34
-
35
- # Using pnpm
36
- $ pnpm install @component-hook/eslint-plugin --save-dev
37
- ```
38
-
39
- Require ESLint >= 9.0.0
40
-
41
- ## Basic Usage
42
-
43
- ```js
44
- import componentHookPlugin from '@component-hook/eslint-plugin';
45
-
46
- export default [
47
- ...componentHookPlugin.configs.basic,
48
- ...componentHookPlugin.configs.vue,
49
- componentHookPlugin.configs.prettier,
50
- ...componentHookPlugin.configs.sonarjs,
51
- componentHookPlugin.configs.security,
52
- ...componentHookPlugin.configs.markdown,
53
- {
54
- files: ['**/__tests__/unit/**/*.test.[jt]s?(x)'],
55
- ...componentHookPlugin.configs['testing-library/vue'],
56
- },
57
- {
58
- files: ['**/__tests__/e2e/**/*.spec.[jt]s?(x)'],
59
- ...componentHookPlugin.configs.playwright,
60
- },
61
- // your custom config
62
- ];
63
- ```
64
-
65
- See [basic](./index.ts) and [ignores](./configs/ignores.ts) for more details.
66
-
67
- ## React Presets Usage
68
-
69
- Includes `basic`, `react`, `markdown`, `prettier`, `sonarjs`, `security` configs.
70
-
71
- ```js
72
- import { reactPreset } from '@component-hook/eslint-plugin';
73
-
74
- export default reactPreset;
75
- ```
76
-
77
- ## Vue Presets Usage
78
-
79
- Includes `basic`, `vue`, `markdown`, `prettier`, `sonarjs`, `security` configs.
80
-
81
- ```js
82
- import { vuePreset } from '@component-hook/eslint-plugin';
83
-
84
- export default vuePreset;
85
- ```
86
-
87
- ## Configs
88
-
89
- | Name | Type | Reference |
90
- | ----------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
91
- | basic | `Linter.Config[]` | `eslint-recommended`, `typescript-eslint`, `eslint-plugin-eslint-comments`, `eslint-plugin-import`, `eslint-plugin-unicorn`, `eslint-plugin-regexp`, `eslint-plugin-de-morgan` |
92
- | vue | `Linter.Config[]` | `eslint-plugin-vue`, `typescript-eslint` |
93
- | react | `Linter.Config[]` | `eslint-plugin-react/recommended`, `eslint-plugin-react-hooks/recommended`, `eslint-plugin-jsx-a11y/recommended` |
94
- | markdown | `Linter.Config[]` | `eslint-plugin-markdown/recommended` |
95
- | prettier | `Linter.Config` | `eslint-plugin-prettier/recommended` |
96
- | sonarjs | `Linter.Config[]` | `eslint-plugin-sonarjs/recommended` |
97
- | security | `Linter.Config` | `eslint-plugin-security/recommended` |
98
- | playwright | `Linter.Config` | `eslint-plugin-playwright/flat/recommended` |
99
- | testing-library/dom | `Linter.Config` | `eslint-plugin-testing-library/dom` |
100
- | testing-library/vue | `Linter.Config` | `eslint-plugin-testing-library/vue` |
101
- | testing-library/react | `Linter.Config` | `eslint-plugin-testing-library/react` |
102
- | testing-library/angular | `Linter.Config` | `eslint-plugin-testing-library/angular` |
103
- | testing-library/marko | `Linter.Config` | `eslint-plugin-testing-library/marko` |
104
-
105
- ## Reference eslint plugin
106
-
107
- - [eslint-recommended](https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js)
108
- - [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint)
109
- - [eslint-plugin-eslint-comments](https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/lib/configs/recommended.js)
110
- - [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import)
111
- - [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)
112
- - [eslint-plugin-regexp/flat/recommended](https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/flat/recommended.ts)
113
- - [eslint-plugin-de-morgan](https://github.com/azat-io/eslint-plugin-de-morgan/blob/main/index.ts)
114
- - [eslint-plugin-prettier/recommended](https://github.com/prettier/eslint-plugin-prettier/blob/master/recommended.js)
115
- - [eslint-plugin-react/recommended](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/configs/recommended.js)
116
- - [eslint-plugin-react-hooks/recommended](https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/index.js)
117
- - [eslint-plugin-jsx-a11y/recommended](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/index.js)
118
- - [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue)
119
- - [eslint-plugin-markdown/recommended](https://github.com/eslint/markdown/blob/main/src/index.js)
120
- - [eslint-plugin-sonarjs/recommended](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/src/index.ts)
121
- - [eslint-plugin-security/recommended](https://github.com/eslint-community/eslint-plugin-security/blob/main/index.js)
122
- - [eslint-plugin-testing-library/dom](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/lib/configs/dom.ts)
123
- - [eslint-plugin-testing-library/vue](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/lib/configs/vue.ts)
124
- - [eslint-plugin-testing-library/react](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/lib/configs/react.ts)
125
- - [eslint-plugin-testing-library/angular](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/lib/configs/angular.ts)
126
- - [eslint-plugin-testing-library/marko](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/lib/configs/marko.ts)
127
- - [eslint-plugin-playwright/flat/recommended](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/src/index.ts)
1
+ # @component-hook/eslint-plugin
2
+
3
+ A opinionated ESLint config preset for `JavaScript`, `TypeScript`, `Vue3`, `React` and `Prettier`.
4
+
5
+ <p>
6
+ <a href="https://npm-stat.com/charts.html?package=@component-hook/eslint-plugin">
7
+ <img src="https://img.shields.io/npm/dm/@component-hook/eslint-plugin.svg" alt="npm"/>
8
+ </a>
9
+ <a href="https://www.npmjs.com/package/@component-hook/eslint-plugin">
10
+ <img src="https://img.shields.io/npm/v/@component-hook/eslint-plugin.svg" alt="npm"/>
11
+ </a>
12
+ </p>
13
+
14
+ ## Features
15
+
16
+ - Support `TypeScript`, `Vue3` and `React` out-of-box.
17
+ - Format with `Prettier`.
18
+ - Ignores common files like `dist`, `node_modules`, `coverage`, and files in `.gitignore`.
19
+ - Various built-in configurations can be referenced according to respective needs.
20
+ - Reasonable defaults, best practices, and just a few lines of configuration.
21
+
22
+ ## Documentation
23
+
24
+ For detailed documentation and usage examples, please visit: [Official Docs](https://tzuyi0817.github.io/component-hook/#/eslint/plugin).
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ # Using npm
30
+ $ npm install @component-hook/eslint-plugin --save-dev
31
+
32
+ # Using yarn
33
+ $ yarn add @component-hook/eslint-plugin --dev
34
+
35
+ # Using pnpm
36
+ $ pnpm install @component-hook/eslint-plugin --save-dev
37
+ ```
38
+
39
+ Require ESLint >= 9.0.0
40
+
41
+ ## Basic Usage
42
+
43
+ ```js
44
+ import componentHookPlugin from '@component-hook/eslint-plugin';
45
+
46
+ export default [
47
+ ...componentHookPlugin.configs.basic,
48
+ ...componentHookPlugin.configs.vue,
49
+ componentHookPlugin.configs.prettier,
50
+ ...componentHookPlugin.configs.sonarjs,
51
+ componentHookPlugin.configs.security,
52
+ ...componentHookPlugin.configs.markdown,
53
+ {
54
+ files: ['**/__tests__/unit/**/*.test.[jt]s?(x)'],
55
+ ...componentHookPlugin.configs['testing-library/vue'],
56
+ },
57
+ {
58
+ files: ['**/__tests__/e2e/**/*.spec.[jt]s?(x)'],
59
+ ...componentHookPlugin.configs.playwright,
60
+ },
61
+ // your custom config
62
+ ];
63
+ ```
64
+
65
+ See [basic](./index.ts) and [ignores](./configs/ignores.ts) for more details.
66
+
67
+ ## React Presets Usage
68
+
69
+ Includes `basic`, `react`, `markdown`, `prettier`, `sonarjs`, `security` configs.
70
+
71
+ ```js
72
+ import { reactPreset } from '@component-hook/eslint-plugin';
73
+
74
+ export default reactPreset;
75
+ ```
76
+
77
+ ## Vue Presets Usage
78
+
79
+ Includes `basic`, `vue`, `markdown`, `prettier`, `sonarjs`, `security` configs.
80
+
81
+ ```js
82
+ import { vuePreset } from '@component-hook/eslint-plugin';
83
+
84
+ export default vuePreset;
85
+ ```
86
+
87
+ ## Configs
88
+
89
+ | Name | Type | Reference |
90
+ | ----------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
91
+ | basic | `Linter.Config[]` | `eslint-recommended`, `typescript-eslint`, `eslint-plugin-eslint-comments`, `eslint-plugin-import`, `eslint-plugin-unicorn`, `eslint-plugin-regexp`, `eslint-plugin-de-morgan`, `eslint-plugin-perfectionist` |
92
+ | vue | `Linter.Config[]` | `eslint-plugin-vue`, `typescript-eslint` |
93
+ | react | `Linter.Config[]` | `eslint-plugin-react/recommended`, `eslint-plugin-react-hooks/recommended`, `eslint-plugin-jsx-a11y/recommended` |
94
+ | markdown | `Linter.Config[]` | `eslint-plugin-markdown/recommended` |
95
+ | prettier | `Linter.Config` | `eslint-plugin-prettier/recommended` |
96
+ | sonarjs | `Linter.Config[]` | `eslint-plugin-sonarjs/recommended` |
97
+ | security | `Linter.Config` | `eslint-plugin-security/recommended` |
98
+ | playwright | `Linter.Config` | `eslint-plugin-playwright/flat/recommended` |
99
+ | testing-library/dom | `Linter.Config` | `eslint-plugin-testing-library/dom` |
100
+ | testing-library/vue | `Linter.Config` | `eslint-plugin-testing-library/vue` |
101
+ | testing-library/react | `Linter.Config` | `eslint-plugin-testing-library/react` |
102
+ | testing-library/angular | `Linter.Config` | `eslint-plugin-testing-library/angular` |
103
+ | testing-library/marko | `Linter.Config` | `eslint-plugin-testing-library/marko` |
104
+
105
+ ## Reference eslint plugin
106
+
107
+ - [eslint-recommended](https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js)
108
+ - [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint)
109
+ - [eslint-plugin-eslint-comments](https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/lib/configs/recommended.js)
110
+ - [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import)
111
+ - [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)
112
+ - [eslint-plugin-regexp/flat/recommended](https://github.com/ota-meshi/eslint-plugin-regexp/blob/master/lib/configs/flat/recommended.ts)
113
+ - [eslint-plugin-de-morgan](https://github.com/azat-io/eslint-plugin-de-morgan/blob/main/index.ts)
114
+ - [eslint-plugin-perfectionist](https://github.com/azat-io/eslint-plugin-perfectionist)
115
+ - [eslint-plugin-prettier/recommended](https://github.com/prettier/eslint-plugin-prettier/blob/master/recommended.js)
116
+ - [eslint-plugin-react/recommended](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/configs/recommended.js)
117
+ - [eslint-plugin-react-hooks/recommended](https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/index.js)
118
+ - [eslint-plugin-jsx-a11y/recommended](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/index.js)
119
+ - [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue)
120
+ - [eslint-plugin-markdown/recommended](https://github.com/eslint/markdown/blob/main/src/index.js)
121
+ - [eslint-plugin-sonarjs/recommended](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/src/index.ts)
122
+ - [eslint-plugin-security/recommended](https://github.com/eslint-community/eslint-plugin-security/blob/main/index.js)
123
+ - [eslint-plugin-testing-library/dom](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/lib/configs/dom.ts)
124
+ - [eslint-plugin-testing-library/vue](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/lib/configs/vue.ts)
125
+ - [eslint-plugin-testing-library/react](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/lib/configs/react.ts)
126
+ - [eslint-plugin-testing-library/angular](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/lib/configs/angular.ts)
127
+ - [eslint-plugin-testing-library/marko](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/lib/configs/marko.ts)
128
+ - [eslint-plugin-playwright/flat/recommended](https://github.com/playwright-community/eslint-plugin-playwright/blob/main/src/index.ts)
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ import { default as default18 } from "eslint-plugin-markdown";
20
20
  import { default as default19 } from "@eslint-community/eslint-plugin-eslint-comments/configs";
21
21
  import { default as default20 } from "eslint-plugin-unicorn";
22
22
  import { default as default21 } from "eslint-plugin-de-morgan";
23
+ import { default as default22 } from "eslint-plugin-perfectionist";
23
24
 
24
25
  // configs/javascript.ts
25
26
  var isProduction = process.env.NODE_ENV === "production";
@@ -88,12 +89,6 @@ var importConfigs = [
88
89
  plugins,
89
90
  languageOptions,
90
91
  rules: {
91
- "import/order": [
92
- "error",
93
- {
94
- groups: ["builtin", "external", "internal", "parent", "sibling", "index"]
95
- }
96
- ],
97
92
  "import/first": "error",
98
93
  "import/no-default-export": "error",
99
94
  "import/no-duplicates": "error",
@@ -240,6 +235,41 @@ var deMorganConfig = {
240
235
  name: "component-hook/de-morgan"
241
236
  };
242
237
 
238
+ // configs/perfectionist.ts
239
+ var perfectionistConfig = {
240
+ name: "component-hook/perfectionist/import",
241
+ plugins: {
242
+ perfectionist: default22
243
+ },
244
+ rules: {
245
+ "perfectionist/sort-imports": [
246
+ "error",
247
+ {
248
+ groups: [
249
+ "builtin",
250
+ "external",
251
+ "internal",
252
+ "internal-type",
253
+ "parent",
254
+ "parent-type",
255
+ "sibling",
256
+ "sibling-type",
257
+ "index",
258
+ "index-type",
259
+ "object",
260
+ "type",
261
+ "side-effect",
262
+ "side-effect-style"
263
+ ],
264
+ internalPattern: ["^[~@#]/.*"],
265
+ newlinesBetween: "ignore"
266
+ }
267
+ ],
268
+ "perfectionist/sort-named-exports": ["warn", { groupKind: "values-first" }],
269
+ "perfectionist/sort-named-imports": ["warn", { groupKind: "values-first" }]
270
+ }
271
+ };
272
+
243
273
  // configs/prettier.ts
244
274
  var rules3 = { ...default11.rules };
245
275
  delete rules3["vue/html-self-closing"];
@@ -526,6 +556,7 @@ var basicConfigs = [
526
556
  unicornConfig,
527
557
  regexpConfig,
528
558
  deMorganConfig,
559
+ perfectionistConfig,
529
560
  {
530
561
  name: "component-hook/globals",
531
562
  languageOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@component-hook/eslint-plugin",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "ESLint config for component hook",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,6 +41,7 @@
41
41
  "eslint-plugin-import": "^2.31.0",
42
42
  "eslint-plugin-jsx-a11y": "^6.10.2",
43
43
  "eslint-plugin-markdown": "^5.1.0",
44
+ "eslint-plugin-perfectionist": "^4.11.0",
44
45
  "eslint-plugin-playwright": "^2.2.0",
45
46
  "eslint-plugin-prettier": "^5.2.3",
46
47
  "eslint-plugin-react": "^7.37.4",
@@ -49,7 +50,7 @@
49
50
  "eslint-plugin-security": "^3.0.1",
50
51
  "eslint-plugin-sonarjs": "^3.0.2",
51
52
  "eslint-plugin-testing-library": "^7.1.1",
52
- "eslint-plugin-unicorn": "^57.0.0",
53
+ "eslint-plugin-unicorn": "^58.0.0",
53
54
  "eslint-plugin-vue": "^10.0.0",
54
55
  "globals": "^16.0.0",
55
56
  "typescript-eslint": "^8.26.1",