@dartess/eslint-plugin 0.2.0 → 0.3.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/CHANGELOG.md +8 -0
- package/README.md +35 -17
- package/dist/configs/post-format.d.ts +3 -0
- package/dist/configs/post-format.js +9 -0
- package/dist/configs/react.js +1 -7
- package/dist/configs/recommended.js +0 -1
- package/package.json +2 -1
- package/dist/configs/vendor-rules/react-hooks.d.ts +0 -10
- package/dist/configs/vendor-rules/react-hooks.js +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
[//]: # (https://keepachangelog.com/en/1.1.0/)
|
|
4
4
|
|
|
5
|
+
## [0.3.0] - 2026-01-12
|
|
6
|
+
|
|
7
|
+
- add `eslint-plugin-react-hooks:recommended` config to `react` config
|
|
8
|
+
|
|
9
|
+
## [0.2.1] - 2026-01-10
|
|
10
|
+
|
|
11
|
+
- add `recommended-post-format` config for using after formatting tools
|
|
12
|
+
|
|
5
13
|
## [0.2.0] - 2026-01-05
|
|
6
14
|
|
|
7
15
|
- improve `import-x/no-extraneous-dependencies` options
|
package/README.md
CHANGED
|
@@ -11,13 +11,12 @@ Also extends
|
|
|
11
11
|
|
|
12
12
|
Also can extends (if it is applicable)
|
|
13
13
|
* `eslint-plugin-react` — `recommended` & `jsx-runtime`
|
|
14
|
+
* `eslint-plugin-react-hooks` — `recommended`
|
|
14
15
|
* `@next/eslint-plugin-next` — `recommended` & `core-web-vitals`
|
|
15
16
|
* `eslint-config-next`
|
|
16
17
|
* `eslint-plugin-mobx` — `recommended`
|
|
17
18
|
* `eslint-plugin-storybook` — `recommended` & `csf-strict`
|
|
18
19
|
|
|
19
|
-
_(We also use `eslint-plugin-unicorn` and `eslint-plugin-decorator-position` but only special rules, without `recommended` config)_
|
|
20
|
-
|
|
21
20
|
All of it pinched with extra configs, setups and extra rules. Just take it and use it!
|
|
22
21
|
|
|
23
22
|
### Notes
|
|
@@ -30,10 +29,18 @@ All of it pinched with extra configs, setups and extra rules. Just take it and u
|
|
|
30
29
|
|
|
31
30
|
## Installation
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
Install [ESLint](https://eslint.org/), required peer deps and the plugin itself:
|
|
34
33
|
|
|
35
34
|
```sh
|
|
36
|
-
npm i -D eslint
|
|
35
|
+
npm i -D eslint \
|
|
36
|
+
eslint-plugin-import-x \
|
|
37
|
+
eslint-import-resolver-typescript \
|
|
38
|
+
eslint-plugin-unicorn \
|
|
39
|
+
eslint-plugin-decorator-position \
|
|
40
|
+
eslint-plugin-de-morgan \
|
|
41
|
+
typescript-eslint \
|
|
42
|
+
@eslint-community/eslint-plugin-eslint-comments \
|
|
43
|
+
@dartess/eslint-plugin
|
|
37
44
|
```
|
|
38
45
|
|
|
39
46
|
Next, also install the packages that suit your needs.
|
|
@@ -51,12 +58,6 @@ npm i -D eslint-plugin-mobx
|
|
|
51
58
|
npm i -D eslint-plugin-storybook
|
|
52
59
|
```
|
|
53
60
|
|
|
54
|
-
Next, install `@dartess/eslint-plugin` itself.
|
|
55
|
-
|
|
56
|
-
```sh
|
|
57
|
-
npm i -D @dartess/eslint-plugin
|
|
58
|
-
```
|
|
59
|
-
|
|
60
61
|
## Usage configs
|
|
61
62
|
|
|
62
63
|
Shared config based on `eslint-config-airbnb`, `eslint-config-airbnb-typescript`, `eslint-plugin-react/recommended`, `eslint-plugin-react/jsx-runtime`.
|
|
@@ -65,6 +66,7 @@ Edit or create `eslint.config.ts` (or `eslint.config.mts`). You probably have to
|
|
|
65
66
|
|
|
66
67
|
```ts
|
|
67
68
|
import dartessEslintPluginRecommended from '@dartess/eslint-plugin/recommended';
|
|
69
|
+
import dartessEslintPluginRecommendedPostFormat from '@dartess/eslint-plugin/recommended-post-format';
|
|
68
70
|
|
|
69
71
|
// if `react` is used
|
|
70
72
|
import dartessEslintPluginReact from '@dartess/eslint-plugin/react';
|
|
@@ -89,6 +91,7 @@ export default [
|
|
|
89
91
|
},
|
|
90
92
|
|
|
91
93
|
...dartessEslintPluginRecommended,
|
|
94
|
+
|
|
92
95
|
// if `react` is used
|
|
93
96
|
...dartessEslintPluginReact,
|
|
94
97
|
// if `next.js` is used
|
|
@@ -97,21 +100,26 @@ export default [
|
|
|
97
100
|
...dartessEslintPluginMobx,
|
|
98
101
|
// if `storybook` is used
|
|
99
102
|
...dartessEslintPluginStorybook,
|
|
103
|
+
|
|
104
|
+
// <-- Put here your formatters congifs -->
|
|
105
|
+
// @see `Fine Tuning` -> `Formatters` section below
|
|
106
|
+
|
|
107
|
+
...dartessEslintPluginRecommendedPostFormat,
|
|
100
108
|
]
|
|
101
109
|
|
|
102
110
|
```
|
|
103
111
|
|
|
104
|
-
##
|
|
112
|
+
## Fine Tuning
|
|
105
113
|
|
|
106
|
-
|
|
107
|
-
[eslint-plugin-react-refresh](https://www.npmjs.com/package/eslint-plugin-react-refresh).
|
|
108
|
-
This plugin requires manual setup for you build tools.
|
|
114
|
+
### Formatting tools
|
|
109
115
|
|
|
110
|
-
If you're
|
|
116
|
+
If you're want to (and you should to) use formatting tools, you need to additionally install and setup something else.
|
|
111
117
|
|
|
112
|
-
|
|
118
|
+
Replace the `<-- Put here your formatters congifs -->` comment with the required code, beacuse we have a special config
|
|
119
|
+
that fine-tunes formatter behavior and should be applied afterward.
|
|
113
120
|
|
|
114
|
-
|
|
121
|
+
In case you for some reason don't want to use any formatting tools, you still have to put
|
|
122
|
+
`...dartessEslintPluginRecommendedPostFormat` in any place of your config.
|
|
115
123
|
|
|
116
124
|
#### dprint
|
|
117
125
|
|
|
@@ -131,6 +139,16 @@ Use `eslint-plugin-oxlint` for disabling unnecessary rules.
|
|
|
131
139
|
* Or use `eslint-plugin-prettier` for running `prettier` as eslint rule.
|
|
132
140
|
* Or use `eslint-plugin-format` with rule `format/prettier` for running `prettier` as eslint rule (you probably will want to add `eslint-config-prettier` for disabling unnecessary rules).
|
|
133
141
|
|
|
142
|
+
### (for React users)
|
|
143
|
+
|
|
144
|
+
If you're using React, you also probably will want to add
|
|
145
|
+
[eslint-plugin-react-refresh](https://www.npmjs.com/package/eslint-plugin-react-refresh).
|
|
146
|
+
This plugin requires manual setup for you build tools.
|
|
147
|
+
|
|
148
|
+
### (for Mobx users)
|
|
149
|
+
|
|
150
|
+
If you're using Mobx with legacy decorators, you have to enable rule `mobx/missing-make-observable` manually.
|
|
151
|
+
|
|
134
152
|
## Supported Rules
|
|
135
153
|
|
|
136
154
|
Each rule has emojis denoting:
|
package/dist/configs/react.js
CHANGED
|
@@ -5,7 +5,6 @@ import reactPlugin from 'eslint-plugin-react';
|
|
|
5
5
|
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
6
6
|
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
|
|
7
7
|
import vendorRulesReact from "./vendor-rules/react.js";
|
|
8
|
-
import vendorRulesReactHooks from "./vendor-rules/react-hooks.js";
|
|
9
8
|
const config = [
|
|
10
9
|
{
|
|
11
10
|
name: '@dartess/react-setup',
|
|
@@ -19,6 +18,7 @@ const config = [
|
|
|
19
18
|
},
|
|
20
19
|
},
|
|
21
20
|
},
|
|
21
|
+
reactHooksPlugin.configs.flat.recommended,
|
|
22
22
|
{
|
|
23
23
|
name: 'react/recommended', // missed name, @see e.g. https://github.com/jsx-eslint/eslint-plugin-react/pull/3882
|
|
24
24
|
...reactPlugin.configs.flat.recommended,
|
|
@@ -71,11 +71,5 @@ const config = [
|
|
|
71
71
|
'react/jsx-no-undef': 'off', // checked by typescript
|
|
72
72
|
},
|
|
73
73
|
},
|
|
74
|
-
{
|
|
75
|
-
name: '@dartess/react-hooks',
|
|
76
|
-
rules: {
|
|
77
|
-
...vendorRulesReactHooks,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
74
|
];
|
|
81
75
|
export default config;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dartess/eslint-plugin",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "A set of rules and configs for various TypeScript projects",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"eslint",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"exports": {
|
|
17
17
|
".": "./dist/index.js",
|
|
18
18
|
"./recommended": "./dist/configs/recommended.js",
|
|
19
|
+
"./recommended-post-format": "./dist/configs/post-format.js",
|
|
19
20
|
"./react": "./dist/configs/react.js",
|
|
20
21
|
"./next": "./dist/configs/next.js",
|
|
21
22
|
"./mobx": "./dist/configs/mobx.js",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare const rules: {
|
|
2
|
-
/**
|
|
3
|
-
* react-hooks
|
|
4
|
-
* copied from
|
|
5
|
-
* https://github.com/airbnb/javascript/blob/c25bce83be4db06e6a221d79686c485cd2ed5d5d/packages/eslint-config-airbnb/rules/react-hooks.js
|
|
6
|
-
* */
|
|
7
|
-
'react-hooks/rules-of-hooks': "error";
|
|
8
|
-
'react-hooks/exhaustive-deps': "error";
|
|
9
|
-
};
|
|
10
|
-
export default rules;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// This file contains code from the `eslint-config-airbnb` project
|
|
2
|
-
// Original author: Jake Teton-Landis (https://twitter.com/@jitl)
|
|
3
|
-
// License: MIT (see LICENSE-eslint-config-airbnb.md file)
|
|
4
|
-
const rules = {
|
|
5
|
-
/**
|
|
6
|
-
* react-hooks
|
|
7
|
-
* copied from
|
|
8
|
-
* https://github.com/airbnb/javascript/blob/c25bce83be4db06e6a221d79686c485cd2ed5d5d/packages/eslint-config-airbnb/rules/react-hooks.js
|
|
9
|
-
* */
|
|
10
|
-
// Enforce Rules of Hooks
|
|
11
|
-
// https://github.com/facebook/react/blob/c11015ff4f610ac2924d1fc6d569a17657a404fd/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
|
|
12
|
-
'react-hooks/rules-of-hooks': 'error',
|
|
13
|
-
// Verify the list of the dependencies for Hooks like useEffect and similar
|
|
14
|
-
// https://github.com/facebook/react/blob/1204c789776cb01fbaf3e9f032e7e2ba85a44137/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
|
|
15
|
-
'react-hooks/exhaustive-deps': 'error',
|
|
16
|
-
};
|
|
17
|
-
export default rules;
|