@rotki/eslint-plugin 1.2.0 → 1.3.1
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 +98 -1
- package/dist/index.d.mts +215 -15
- package/dist/index.d.ts +215 -15
- package/dist/index.mjs +1282 -87
- package/package.json +23 -23
package/README.md
CHANGED
|
@@ -24,11 +24,108 @@ npm install --save-dev @rotki/eslint-plugin
|
|
|
24
24
|
yarn add -D @rotki/eslint-plugin
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
Use the recommended configuration in your ESLint flat config:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import rotkiPlugin from '@rotki/eslint-plugin';
|
|
33
|
+
|
|
34
|
+
export default [
|
|
35
|
+
rotkiPlugin.configs['recommended-flat'],
|
|
36
|
+
];
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or configure individual rules:
|
|
40
|
+
|
|
41
|
+
<!-- eslint-disable perfectionist/sort-imports -->
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import * as jsoncParser from 'jsonc-eslint-parser';
|
|
45
|
+
import rotkiPlugin from '@rotki/eslint-plugin';
|
|
46
|
+
|
|
47
|
+
export default [
|
|
48
|
+
{
|
|
49
|
+
plugins: { '@rotki': rotkiPlugin },
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
files: ['**/src/locales/*.json'],
|
|
53
|
+
languageOptions: { parser: jsoncParser },
|
|
54
|
+
rules: {
|
|
55
|
+
'@rotki/no-unused-i18n-keys': ['error', {
|
|
56
|
+
src: 'src',
|
|
57
|
+
extensions: ['.ts', '.vue'],
|
|
58
|
+
ignoreKeys: ['backend_mappings.*'],
|
|
59
|
+
}],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
<!-- eslint-enable perfectionist/sort-imports -->
|
|
66
|
+
|
|
67
|
+
## Rules
|
|
68
|
+
|
|
69
|
+
| Rule | Description | Fixable |
|
|
70
|
+
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- | ----------- |
|
|
71
|
+
| [consistent-ref-type-annotation](https://rotki.github.io/eslint-plugin/rules/consistent-ref-type-annotation) | Ensures consistent type annotation position for ref, computed assignments | :black_nib: |
|
|
72
|
+
| [max-dependencies](https://rotki.github.io/eslint-plugin/rules/max-dependencies) | Enforce a maximum number of dependencies per file | |
|
|
73
|
+
| [no-deprecated-classes](https://rotki.github.io/eslint-plugin/rules/no-deprecated-classes) | Disallow deprecated vuetify css classes | :black_nib: |
|
|
74
|
+
| [no-deprecated-components](https://rotki.github.io/eslint-plugin/rules/no-deprecated-components) | Disallow deprecated components | :black_nib: |
|
|
75
|
+
| [no-deprecated-props](https://rotki.github.io/eslint-plugin/rules/no-deprecated-props) | Replace deprecated props with their replacements | :black_nib: |
|
|
76
|
+
| [no-dot-ts-imports](https://rotki.github.io/eslint-plugin/rules/no-dot-ts-imports) | Disallow .ts extension in import statements | :black_nib: |
|
|
77
|
+
| [no-legacy-library-import](https://rotki.github.io/eslint-plugin/rules/no-legacy-library-import) | Disallow imports from @rotki/ui-library-compat | :black_nib: |
|
|
78
|
+
| [no-unused-i18n-keys](https://rotki.github.io/eslint-plugin/rules/no-unused-i18n-keys) | Disallow unused i18n keys in locale files | :black_nib: |
|
|
79
|
+
|
|
27
80
|
## Documentation
|
|
28
81
|
|
|
29
|
-
For detailed
|
|
82
|
+
For detailed rule options and configuration,
|
|
30
83
|
please visit our [documentation](https://rotki.github.io/eslint-plugin).
|
|
31
84
|
|
|
85
|
+
<details>
|
|
86
|
+
<summary><h2>Testing Rules with Rotki</h2></summary>
|
|
87
|
+
|
|
88
|
+
To test rules against the real rotki codebase and benchmark performance:
|
|
89
|
+
|
|
90
|
+
### Setup
|
|
91
|
+
|
|
92
|
+
1. Build the plugin:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pnpm run build
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
2. Install it in the rotki frontend via `file:` protocol:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
cd ../rotki/rotki/frontend
|
|
102
|
+
# Update package.json: "@rotki/eslint-plugin": "file:../../eslint-plugin"
|
|
103
|
+
pnpm install --no-frozen-lockfile
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Benchmarking
|
|
107
|
+
|
|
108
|
+
Create minimal ESLint configs that isolate individual rules, then time them against all locale files:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Intlify rule
|
|
112
|
+
time npx eslint -c bench-intlify.config.js 'app/src/locales/*.json'
|
|
113
|
+
|
|
114
|
+
# Rotki rule
|
|
115
|
+
time npx eslint -c bench-rotki.config.js 'app/src/locales/*.json'
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Benchmark Results (rotki frontend, 7 locale files, ~1.1MB total)
|
|
119
|
+
|
|
120
|
+
| Rule | Average Time |
|
|
121
|
+
| ---------------------------------- | ------------ |
|
|
122
|
+
| `@intlify/vue-i18n/no-unused-keys` | ~71s |
|
|
123
|
+
| `@rotki/no-unused-i18n-keys` | ~5s |
|
|
124
|
+
|
|
125
|
+
The rotki rule is ~14x faster due to file-level caching, early bail-out on files without i18n calls, and avoiding the `vue-i18n` settings/localeDir resolution overhead.
|
|
126
|
+
|
|
127
|
+
</details>
|
|
128
|
+
|
|
32
129
|
## Contributing
|
|
33
130
|
|
|
34
131
|
Contributions are welcome!
|
package/dist/index.d.mts
CHANGED
|
@@ -4,32 +4,61 @@ interface PluginRuleModule<TOptions extends readonly unknown[] = []> extends Rul
|
|
|
4
4
|
defaultOptions: TOptions;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
type Options$
|
|
7
|
+
type Options$6 = [
|
|
8
|
+
{
|
|
9
|
+
extensions: string[];
|
|
10
|
+
ignoreKeys: string[];
|
|
11
|
+
src: string;
|
|
12
|
+
}
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
type Options$5 = [{
|
|
8
16
|
legacy: boolean;
|
|
9
17
|
}];
|
|
10
18
|
|
|
11
|
-
interface Options$
|
|
19
|
+
interface Options$4 {
|
|
12
20
|
max: number;
|
|
13
21
|
ignoreTypeImports: boolean;
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
type Options = [{
|
|
24
|
+
type Options$3 = [{
|
|
17
25
|
allowInference: boolean;
|
|
18
26
|
}];
|
|
19
27
|
|
|
28
|
+
type Options$2 = [{
|
|
29
|
+
autofix?: boolean;
|
|
30
|
+
}];
|
|
31
|
+
|
|
32
|
+
type Options$1 = [{
|
|
33
|
+
autofix?: boolean;
|
|
34
|
+
}];
|
|
35
|
+
|
|
36
|
+
type Options = [{
|
|
37
|
+
autofix?: boolean;
|
|
38
|
+
}];
|
|
39
|
+
|
|
20
40
|
declare const plugin: {
|
|
21
41
|
meta: {
|
|
22
42
|
name: string;
|
|
23
43
|
version: string;
|
|
24
44
|
};
|
|
25
45
|
rules: {
|
|
26
|
-
'
|
|
27
|
-
'
|
|
46
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
47
|
+
'composable-naming-convention': PluginRuleModule<[]>;
|
|
48
|
+
'composable-no-default-export': PluginRuleModule<[]>;
|
|
49
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
50
|
+
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
51
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
52
|
+
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
53
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
54
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
28
55
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
29
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
56
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
30
57
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
31
58
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
32
59
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
60
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
61
|
+
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
33
62
|
};
|
|
34
63
|
};
|
|
35
64
|
|
|
@@ -39,13 +68,22 @@ declare const _default: {
|
|
|
39
68
|
version: string;
|
|
40
69
|
};
|
|
41
70
|
rules: {
|
|
42
|
-
'
|
|
43
|
-
'
|
|
71
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
72
|
+
'composable-naming-convention': PluginRuleModule<[]>;
|
|
73
|
+
'composable-no-default-export': PluginRuleModule<[]>;
|
|
74
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
75
|
+
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
76
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
77
|
+
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
78
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
79
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
44
80
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
45
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
81
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
46
82
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
47
83
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
48
84
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
85
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
86
|
+
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
49
87
|
};
|
|
50
88
|
} & {
|
|
51
89
|
configs: {
|
|
@@ -57,13 +95,22 @@ declare const _default: {
|
|
|
57
95
|
version: string;
|
|
58
96
|
};
|
|
59
97
|
rules: {
|
|
60
|
-
'
|
|
61
|
-
'
|
|
98
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
99
|
+
'composable-naming-convention': PluginRuleModule<[]>;
|
|
100
|
+
'composable-no-default-export': PluginRuleModule<[]>;
|
|
101
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
102
|
+
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
103
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
104
|
+
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
105
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
106
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
62
107
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
63
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
108
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
64
109
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
65
110
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
66
111
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
112
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
113
|
+
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
67
114
|
};
|
|
68
115
|
};
|
|
69
116
|
};
|
|
@@ -84,13 +131,166 @@ declare const _default: {
|
|
|
84
131
|
version: string;
|
|
85
132
|
};
|
|
86
133
|
rules: {
|
|
87
|
-
'
|
|
88
|
-
'
|
|
134
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
135
|
+
'composable-naming-convention': PluginRuleModule<[]>;
|
|
136
|
+
'composable-no-default-export': PluginRuleModule<[]>;
|
|
137
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
138
|
+
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
139
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
140
|
+
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
141
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
142
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
143
|
+
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
144
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
145
|
+
'no-deprecated-props': PluginRuleModule<[]>;
|
|
146
|
+
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
147
|
+
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
148
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
149
|
+
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
rules: {
|
|
154
|
+
[k: string]: number;
|
|
155
|
+
};
|
|
156
|
+
} | {
|
|
157
|
+
plugins: string[];
|
|
158
|
+
rules: {
|
|
159
|
+
[k: string]: number;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
strict: {
|
|
163
|
+
plugins: {
|
|
164
|
+
[x: string]: {
|
|
165
|
+
meta: {
|
|
166
|
+
name: string;
|
|
167
|
+
version: string;
|
|
168
|
+
};
|
|
169
|
+
rules: {
|
|
170
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
171
|
+
'composable-naming-convention': PluginRuleModule<[]>;
|
|
172
|
+
'composable-no-default-export': PluginRuleModule<[]>;
|
|
173
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
174
|
+
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
175
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
176
|
+
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
177
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
178
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
179
|
+
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
180
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
181
|
+
'no-deprecated-props': PluginRuleModule<[]>;
|
|
182
|
+
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
183
|
+
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
184
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
185
|
+
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
rules: {
|
|
190
|
+
[k: string]: number;
|
|
191
|
+
};
|
|
192
|
+
} | {
|
|
193
|
+
plugins: string[];
|
|
194
|
+
rules: {
|
|
195
|
+
[k: string]: number;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
'strict-flat': {
|
|
199
|
+
plugins: {
|
|
200
|
+
[x: string]: {
|
|
201
|
+
meta: {
|
|
202
|
+
name: string;
|
|
203
|
+
version: string;
|
|
204
|
+
};
|
|
205
|
+
rules: {
|
|
206
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
207
|
+
'composable-naming-convention': PluginRuleModule<[]>;
|
|
208
|
+
'composable-no-default-export': PluginRuleModule<[]>;
|
|
209
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
210
|
+
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
211
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
212
|
+
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
213
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
214
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
215
|
+
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
216
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
217
|
+
'no-deprecated-props': PluginRuleModule<[]>;
|
|
218
|
+
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
219
|
+
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
220
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
221
|
+
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
rules: {
|
|
226
|
+
[k: string]: number;
|
|
227
|
+
};
|
|
228
|
+
} | {
|
|
229
|
+
plugins: string[];
|
|
230
|
+
rules: {
|
|
231
|
+
[k: string]: number;
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
stylistic: {
|
|
235
|
+
plugins: {
|
|
236
|
+
[x: string]: {
|
|
237
|
+
meta: {
|
|
238
|
+
name: string;
|
|
239
|
+
version: string;
|
|
240
|
+
};
|
|
241
|
+
rules: {
|
|
242
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
243
|
+
'composable-naming-convention': PluginRuleModule<[]>;
|
|
244
|
+
'composable-no-default-export': PluginRuleModule<[]>;
|
|
245
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
246
|
+
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
247
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
248
|
+
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
249
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
250
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
251
|
+
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
252
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
253
|
+
'no-deprecated-props': PluginRuleModule<[]>;
|
|
254
|
+
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
255
|
+
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
256
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
257
|
+
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
rules: {
|
|
262
|
+
[k: string]: number;
|
|
263
|
+
};
|
|
264
|
+
} | {
|
|
265
|
+
plugins: string[];
|
|
266
|
+
rules: {
|
|
267
|
+
[k: string]: number;
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
'stylistic-flat': {
|
|
271
|
+
plugins: {
|
|
272
|
+
[x: string]: {
|
|
273
|
+
meta: {
|
|
274
|
+
name: string;
|
|
275
|
+
version: string;
|
|
276
|
+
};
|
|
277
|
+
rules: {
|
|
278
|
+
'composable-input-flexibility': PluginRuleModule<Options>;
|
|
279
|
+
'composable-naming-convention': PluginRuleModule<[]>;
|
|
280
|
+
'composable-no-default-export': PluginRuleModule<[]>;
|
|
281
|
+
'composable-prefer-shallowref': PluginRuleModule<Options$1>;
|
|
282
|
+
'composable-require-cleanup': PluginRuleModule<[]>;
|
|
283
|
+
'composable-return-readonly': PluginRuleModule<Options$2>;
|
|
284
|
+
'composable-ssr-safety': PluginRuleModule<[]>;
|
|
285
|
+
'consistent-ref-type-annotation': PluginRuleModule<Options$3>;
|
|
286
|
+
'max-dependencies': PluginRuleModule<[Options$4]>;
|
|
89
287
|
'no-deprecated-classes': PluginRuleModule<[]>;
|
|
90
|
-
'no-deprecated-components': PluginRuleModule<Options$
|
|
288
|
+
'no-deprecated-components': PluginRuleModule<Options$5>;
|
|
91
289
|
'no-deprecated-props': PluginRuleModule<[]>;
|
|
92
290
|
'no-dot-ts-imports': PluginRuleModule<[]>;
|
|
93
291
|
'no-legacy-library-import': PluginRuleModule<[]>;
|
|
292
|
+
'no-unused-i18n-keys': PluginRuleModule<Options$6>;
|
|
293
|
+
'require-jsdoc-on-composable-options': PluginRuleModule<[]>;
|
|
94
294
|
};
|
|
95
295
|
};
|
|
96
296
|
};
|