@rotki/eslint-plugin 0.6.1 → 1.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/dist/index.cjs DELETED
@@ -1,813 +0,0 @@
1
- 'use strict';
2
-
3
- const createDebug = require('debug');
4
- const node_path = require('node:path');
5
- const compat = require('eslint-compat-utils');
6
- const scule = require('scule');
7
- const utils = require('@typescript-eslint/utils');
8
-
9
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
10
-
11
- function _interopNamespaceCompat(e) {
12
- if (e && typeof e === 'object' && 'default' in e) return e;
13
- const n = Object.create(null);
14
- if (e) {
15
- for (const k in e) {
16
- n[k] = e[k];
17
- }
18
- }
19
- n.default = e;
20
- return n;
21
- }
22
-
23
- const createDebug__default = /*#__PURE__*/_interopDefaultCompat(createDebug);
24
- const compat__namespace = /*#__PURE__*/_interopNamespaceCompat(compat);
25
-
26
- const name = "@rotki/eslint-plugin";
27
- const version = "0.6.1";
28
- const packageManager = "pnpm@9.15.0";
29
- const type = "module";
30
- const license = "AGPL-3.0";
31
- const bugs = {
32
- url: "https://github.com/rotki/eslint-plugin/issues"
33
- };
34
- const repository = {
35
- type: "git",
36
- url: "https://github.com/rotki/eslint-plugin.git"
37
- };
38
- const author = "Rotki Solutions GmbH <info@rotki.com>";
39
- const files = [
40
- "dist"
41
- ];
42
- const main = "./dist/index.mjs";
43
- const module$1 = "./dist/index.mjs";
44
- const types = "./dist/index.d.ts";
45
- const exports$1 = {
46
- ".": {
47
- types: "./dist/index.d.ts",
48
- require: "./dist/index.cjs",
49
- "import": "./dist/index.mjs"
50
- }
51
- };
52
- const sideEffects = false;
53
- const scripts = {
54
- clean: "rimraf .nyc_output coverage dist docs/.vitepress/dist",
55
- coverage: "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
56
- generate: "node --experimental-specifier-resolution=node --loader ts-node/esm scripts/update-rule-docs.ts",
57
- "generate:index": "node --experimental-specifier-resolution=node --loader ts-node/esm scripts/update-docs-index.ts",
58
- lint: "eslint .",
59
- "lint:fix": "eslint . --fix",
60
- build: "unbuild",
61
- dev: "unbuild --stub",
62
- prepublishOnly: "pnpm run build",
63
- test: "vitest",
64
- "test:coverage": "vitest run --coverage",
65
- "new": "node --experimental-specifier-resolution=node --loader ts-node/esm ./scripts/new-rule.ts",
66
- docs: "vitepress dev docs",
67
- "docs:build": "pnpm run generate && pnpm run generate:index && vitepress build docs",
68
- prepare: "husky",
69
- typecheck: "tsc --noEmit",
70
- release: "bumpp -r --no-push"
71
- };
72
- const peerDependencies = {
73
- eslint: "^9.0.0"
74
- };
75
- const dependencies = {
76
- "@typescript-eslint/utils": "8.18.0",
77
- debug: "4.4.0",
78
- "eslint-compat-utils": "0.6.4",
79
- "jsonc-eslint-parser": "2.4.0",
80
- scule: "1.3.0",
81
- "vue-eslint-parser": "9.4.3",
82
- "yaml-eslint-parser": "1.2.3"
83
- };
84
- const devDependencies = {
85
- "@commitlint/cli": "19.6.0",
86
- "@commitlint/config-conventional": "19.6.0",
87
- "@rotki/eslint-config": "3.6.0",
88
- "@types/debug": "4.1.12",
89
- "@types/node": "20",
90
- "@typescript-eslint/eslint-plugin": "8.18.0",
91
- "@typescript-eslint/parser": "8.18.0",
92
- "@typescript-eslint/rule-tester": "8.18.0",
93
- "@vitest/coverage-v8": "2.1.8",
94
- bumpp: "9.9.0",
95
- debug: "4.4.0",
96
- eslint: "9.16.0",
97
- husky: "9.1.7",
98
- "lint-staged": "15.2.11",
99
- rimraf: "6.0.1",
100
- "ts-node": "10.9.2",
101
- typescript: "5.7.2",
102
- unbuild: "2.0.0",
103
- vitepress: "1.5.0",
104
- vitest: "2.1.8"
105
- };
106
- const engines = {
107
- node: ">=20",
108
- pnpm: ">=9 <10"
109
- };
110
- const pkg = {
111
- name: name,
112
- version: version,
113
- packageManager: packageManager,
114
- type: type,
115
- license: license,
116
- bugs: bugs,
117
- repository: repository,
118
- author: author,
119
- files: files,
120
- main: main,
121
- module: module$1,
122
- types: types,
123
- exports: exports$1,
124
- sideEffects: sideEffects,
125
- scripts: scripts,
126
- peerDependencies: peerDependencies,
127
- dependencies: dependencies,
128
- devDependencies: devDependencies,
129
- engines: engines,
130
- "lint-staged": {
131
- "*.{js,cjs,ts,vue,yml,json,md}": "eslint"
132
- }
133
- };
134
-
135
- function getFilename(context) {
136
- return compat__namespace.getFilename(context);
137
- }
138
- function getSourceCode(context) {
139
- return compat__namespace.getSourceCode(context);
140
- }
141
-
142
- const blobUrl = "https://rotki.github.io/eslint-plugin/rules/";
143
- function RuleCreator(urlCreator) {
144
- return function createNamedRule({
145
- meta,
146
- name,
147
- ...rule
148
- }) {
149
- return createRule({
150
- meta: {
151
- ...meta,
152
- docs: {
153
- ...meta.docs,
154
- url: urlCreator(name)
155
- }
156
- },
157
- ...rule
158
- });
159
- };
160
- }
161
- function createRule({
162
- create,
163
- defaultOptions,
164
- meta
165
- }) {
166
- return {
167
- create: (context) => {
168
- const optionsWithDefault = context.options.map((options, index) => ({
169
- ...defaultOptions[index] || {},
170
- ...options || {}
171
- }));
172
- return create(context, optionsWithDefault);
173
- },
174
- defaultOptions,
175
- meta
176
- };
177
- }
178
- const createEslintRule = RuleCreator(
179
- (ruleName) => `${blobUrl}${ruleName}`
180
- );
181
-
182
- function defineTemplateBodyVisitor(context, templateBodyVisitor, scriptVisitor, options) {
183
- const sourceCode = getSourceCode(context);
184
- const parserServices = sourceCode.parserServices;
185
- if (!parserServices)
186
- throw new Error("missing parserServices");
187
- if (!("defineTemplateBodyVisitor" in parserServices) || parserServices.defineTemplateBodyVisitor == null) {
188
- const filename = getFilename(context);
189
- if (node_path.extname(filename) === ".vue") {
190
- context.report({
191
- loc: { column: 0, line: 1 },
192
- message: "Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error"
193
- });
194
- }
195
- return {};
196
- }
197
- return parserServices.defineTemplateBodyVisitor(
198
- templateBodyVisitor,
199
- scriptVisitor,
200
- options
201
- );
202
- }
203
-
204
- function getStringLiteralValue(node, stringOnly = false) {
205
- if (node.type === "Literal") {
206
- if (node.value == null) {
207
- if (!stringOnly && node.bigint != null)
208
- return node.bigint;
209
- return null;
210
- }
211
- if (typeof node.value === "string")
212
- return node.value;
213
- if (!stringOnly)
214
- return String(node.value);
215
- return null;
216
- }
217
- if (node.type === "TemplateLiteral" && node.expressions.length === 0 && node.quasis.length === 1) {
218
- return node.quasis[0].value.cooked;
219
- }
220
- return null;
221
- }
222
- function getStaticPropertyName(node) {
223
- if (node.type === "Property" || node.type === "MethodDefinition") {
224
- if (!node.computed) {
225
- const key2 = node.key;
226
- if (key2.type === "Identifier")
227
- return key2.name;
228
- }
229
- const key = node.key;
230
- return getStringLiteralValue(key);
231
- } else if (node.type === "MemberExpression") {
232
- if (!node.computed) {
233
- const property2 = node.property;
234
- if (property2.type === "Identifier")
235
- return property2.name;
236
- return null;
237
- }
238
- const property = node.property;
239
- return getStringLiteralValue(property);
240
- }
241
- return null;
242
- }
243
-
244
- function createRecommended(plugin, name, flat) {
245
- const rules = Object.fromEntries(Object.entries(plugin.rules).filter(([_key, rule]) => rule.meta.recommended === "recommended" && !rule.meta.deprecated).map(([key]) => [`${name}/${key}`, 2]));
246
- if (flat) {
247
- return {
248
- plugins: {
249
- [name]: plugin
250
- },
251
- rules
252
- };
253
- } else {
254
- return {
255
- plugins: [name],
256
- rules
257
- };
258
- }
259
- }
260
-
261
- const RULE_NAME$5 = "no-deprecated-classes";
262
- const debug$3 = createDebug__default("@rotki/eslint-plugin:no-deprecated-classes");
263
- const replacements$2 = [
264
- ["d-block", "block"],
265
- ["d-flex", "flex"],
266
- ["flex-column", "flex-col"],
267
- ["flex-grow-1", "grow"],
268
- ["flex-grow-0", "grow-0"],
269
- ["flex-shrink-1", "shrink"],
270
- ["flex-shrink-0", "shrink-0"],
271
- [
272
- /^align-(start|end|center|baseline|stretch)$/,
273
- ([align]) => `items-${align}`
274
- ],
275
- [/^justify-space-(between|around)$/, ([justify]) => `justify-${justify}`],
276
- [
277
- /^align-self-(start|end|center|baseline|auto|strech)$/,
278
- ([align]) => `self-${align}`
279
- ],
280
- [
281
- /^font-weight-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)$/,
282
- ([weight]) => `font-${weight}`
283
- ],
284
- [/^text-(capitalize|uppercase|lowercase)$/, ([casing]) => casing],
285
- ["text--secondary", "text-rui-text-secondary"],
286
- ["white--text", "text-white"],
287
- ["primary--text", "text-rui-primary"],
288
- [
289
- /^([mp])([abelr-txy]?)-n(\d)$/,
290
- ([type, position, size]) => `-${type}${position === "a" ? "" : position}-${size}`
291
- ],
292
- [
293
- /^([mp])a-(\d)$/,
294
- ([type, size]) => `${type}-${size}`
295
- ]
296
- ];
297
- function isString(replacement) {
298
- return typeof replacement[0] === "string";
299
- }
300
- function isRegex(replacement) {
301
- return replacement[0] instanceof RegExp;
302
- }
303
- function findReplacement(className) {
304
- for (const replacement of replacements$2) {
305
- if (isString(replacement) && replacement[0] === className)
306
- return replacement[1];
307
- if (isRegex(replacement)) {
308
- const matches = (replacement[0].exec(className) || []).slice(1);
309
- const replace = replacement[1];
310
- if (matches.length > 0 && typeof replace === "function")
311
- return replace(matches);
312
- }
313
- }
314
- return void 0;
315
- }
316
- function getRange(node) {
317
- if (node.type === "VAttribute" && node.value && node.value.range)
318
- return node.value.range;
319
- return node.range;
320
- }
321
- function reportReplacement(className, replacement, node, context, position = 1) {
322
- debug$3(`found replacement ${replacement} for ${className}`);
323
- const source = getSourceCode(context);
324
- const initialRange = getRange(node);
325
- const range = [
326
- initialRange[0] + position,
327
- initialRange[0] + position + className.length
328
- ];
329
- const loc = {
330
- end: source.getLocFromIndex(range[1]),
331
- start: source.getLocFromIndex(range[0])
332
- };
333
- context.report({
334
- data: {
335
- className,
336
- replacement
337
- },
338
- fix(fixer) {
339
- return fixer.replaceTextRange(range, replacement);
340
- },
341
- loc,
342
- messageId: "replacedWith"
343
- });
344
- }
345
- function* extractClassNames(node, textOnly = false) {
346
- if (node.type === "Literal") {
347
- const classNames = `${node.value}`;
348
- yield* classNames.split(/\s+/).map((className) => ({ className, position: classNames.indexOf(className) + 1, reportNode: node }));
349
- return;
350
- }
351
- if (node.type === "TemplateLiteral") {
352
- for (const templateElement of node.quasis) {
353
- const classNames = templateElement.value.cooked;
354
- if (classNames === null)
355
- continue;
356
- yield* classNames.split(/\s+/).map((className) => ({ className, position: classNames.indexOf(className) + 1, reportNode: templateElement }));
357
- }
358
- for (const expr of node.expressions)
359
- yield* extractClassNames(expr, true);
360
- return;
361
- }
362
- if (node.type === "BinaryExpression") {
363
- if (node.operator !== "+")
364
- return;
365
- yield* extractClassNames(node.left, true);
366
- yield* extractClassNames(node.right, true);
367
- return;
368
- }
369
- if (textOnly)
370
- return;
371
- if (node.type === "ObjectExpression") {
372
- for (const prop of node.properties) {
373
- if (prop.type !== "Property")
374
- continue;
375
- const classNames = getStaticPropertyName(prop);
376
- if (!classNames)
377
- continue;
378
- yield* classNames.split(/\s+/).map((className) => ({ className, position: classNames.indexOf(className) + 1, reportNode: prop.key }));
379
- }
380
- return;
381
- }
382
- if (node.type === "ArrayExpression") {
383
- for (const element of node.elements) {
384
- if (element == null)
385
- continue;
386
- if (element.type === "SpreadElement")
387
- continue;
388
- yield* extractClassNames(element);
389
- }
390
- }
391
- if (node.type === "ConditionalExpression") {
392
- yield* extractClassNames(node.consequent);
393
- yield* extractClassNames(node.alternate);
394
- }
395
- }
396
- const noDeprecatedClasses = createEslintRule({
397
- create(context) {
398
- return defineTemplateBodyVisitor(context, {
399
- 'VAttribute[directive=false][key.name="class"]': function(node) {
400
- if (!node.value || !node.value.value)
401
- return;
402
- for (const className of node.value.value.split(/\s+/).filter((s) => !!s)) {
403
- const replacement = findReplacement(className);
404
- const position = node.value.value.indexOf(className) + 1;
405
- if (!replacement)
406
- continue;
407
- reportReplacement(className, replacement, node, context, position);
408
- }
409
- },
410
- "VAttribute[directive=true][key.name.name='bind'][key.argument.name='class'] > VExpressionContainer.value": function(node) {
411
- if (!node.expression)
412
- return;
413
- for (const { className, position, reportNode } of extractClassNames(node.expression)) {
414
- const replacement = findReplacement(className);
415
- if (!replacement)
416
- continue;
417
- reportReplacement(className, replacement, reportNode, context, position);
418
- }
419
- }
420
- });
421
- },
422
- defaultOptions: [],
423
- meta: {
424
- docs: {
425
- description: "disallow the usage of vuetify css classes since they are replaced with tailwindcss",
426
- recommendation: "recommended"
427
- },
428
- fixable: "code",
429
- messages: {
430
- replacedWith: `'{{ className }}' has been replaced with '{{ replacement }}'`
431
- },
432
- schema: [],
433
- type: "problem"
434
- },
435
- name: RULE_NAME$5
436
- });
437
-
438
- const debug$2 = createDebug__default("@rotki/eslint-plugin:no-deprecated-components");
439
- const RULE_NAME$4 = "no-deprecated-components";
440
- const vuetify = {
441
- VApp: true,
442
- VAppBar: true,
443
- VAppBarNavIcon: true,
444
- VAutocomplete: true,
445
- VAvatar: true,
446
- VBottomSheet: true,
447
- VColorPicker: true,
448
- VCombobox: true,
449
- VDataFooter: true,
450
- VDataTable: true,
451
- VDialog: true,
452
- VDialogTransition: true,
453
- VExpansionPanel: true,
454
- VExpansionPanelContent: true,
455
- VExpansionPanelHeader: true,
456
- VExpansionPanels: true,
457
- VMain: true,
458
- VMenu: true,
459
- VNavigationDrawer: true,
460
- VPagination: true,
461
- VSelect: true,
462
- VSlider: true,
463
- VSnackbar: true,
464
- VSwitch: true,
465
- VTextField: true
466
- };
467
- const replacements$1 = {
468
- DataTable: true,
469
- Fragment: false,
470
- ...vuetify
471
- };
472
- const skipInLegacy = [
473
- "Fragment"
474
- ];
475
- function hasReplacement$1(tag) {
476
- return Object.prototype.hasOwnProperty.call(replacements$1, tag);
477
- }
478
- const noDeprecatedComponents = createEslintRule({
479
- create(context, optionsWithDefault) {
480
- const options = optionsWithDefault[0] || {};
481
- const legacy = options.legacy;
482
- return defineTemplateBodyVisitor(context, {
483
- VElement(element) {
484
- const tag = scule.pascalCase(element.rawName);
485
- const sourceCode = getSourceCode(context);
486
- if (sourceCode?.parserServices && !("getTemplateBodyTokenStore" in sourceCode.parserServices))
487
- throw new Error("cannot find getTemplateBodyTokenStore in parserServices");
488
- if (!hasReplacement$1(tag))
489
- return;
490
- const replacement = replacements$1[tag];
491
- if (replacement || legacy && skipInLegacy.includes(tag)) {
492
- debug$2(`${tag} has been deprecated`);
493
- context.report({
494
- data: {
495
- name: tag
496
- },
497
- messageId: "deprecated",
498
- node: element
499
- });
500
- } else {
501
- debug$2(`${tag} has will be removed`);
502
- context.report({
503
- data: {
504
- name: tag
505
- },
506
- fix(fixer) {
507
- return [
508
- fixer.remove(element.startTag),
509
- ...element.endTag ? [fixer.remove(element.endTag)] : []
510
- ];
511
- },
512
- messageId: "removed",
513
- node: element
514
- });
515
- }
516
- }
517
- });
518
- },
519
- defaultOptions: [{ legacy: false }],
520
- meta: {
521
- docs: {
522
- description: "Removes deprecated classes that do not exist anymore",
523
- recommendation: "recommended"
524
- },
525
- fixable: "code",
526
- messages: {
527
- deprecated: `'{{ name }}' has been deprecated`,
528
- removed: `'{{ name }}' has been removed`,
529
- replacedWith: `'{{ a }}' has been replaced with '{{ b }}'`
530
- },
531
- schema: [
532
- {
533
- additionalProperties: false,
534
- properties: {
535
- legacy: {
536
- type: "boolean"
537
- }
538
- },
539
- type: "object"
540
- }
541
- ],
542
- type: "problem"
543
- },
544
- name: RULE_NAME$4
545
- });
546
-
547
- const debug$1 = createDebug__default("@rotki/eslint-plugin:no-deprecated-props");
548
- const RULE_NAME$3 = "no-deprecated-props";
549
- const replacements = {
550
- RuiRadio: {
551
- internalValue: "value"
552
- }
553
- };
554
- function hasReplacement(tag) {
555
- return Object.prototype.hasOwnProperty.call(replacements, tag);
556
- }
557
- function getPropName(node) {
558
- if (node.directive) {
559
- if (node.key.argument?.type !== "VIdentifier")
560
- return void 0;
561
- return scule.kebabCase(node.key.argument.rawName);
562
- }
563
- return scule.kebabCase(node.key.rawName);
564
- }
565
- const noDeprecatedProps = createEslintRule({
566
- create(context) {
567
- return defineTemplateBodyVisitor(context, {
568
- VAttribute(node) {
569
- if (node.directive && (node.value?.type === "VExpressionContainer" && (node.key.name.name !== "bind" || !node.key.argument)))
570
- return;
571
- const tag = scule.pascalCase(node.parent.parent.rawName);
572
- if (!hasReplacement(tag))
573
- return;
574
- debug$1(`${tag} has replacement properties`);
575
- const propName = getPropName(node);
576
- const propNameNode = node.directive ? node.key.argument : node.key;
577
- if (!propName || !propNameNode) {
578
- debug$1("could not get prop name and/or node");
579
- return;
580
- }
581
- Object.entries(replacements[tag]).forEach(([prop, replacement]) => {
582
- if (scule.kebabCase(prop) === propName) {
583
- debug$1(`preparing a replacement for ${tag}:${propName} -> ${replacement}`);
584
- context.report({
585
- data: {
586
- prop,
587
- replacement
588
- },
589
- fix(fixer) {
590
- return fixer.replaceText(propNameNode, replacement);
591
- },
592
- messageId: "replacedWith",
593
- node: propNameNode
594
- });
595
- }
596
- });
597
- }
598
- });
599
- },
600
- defaultOptions: [],
601
- meta: {
602
- docs: {
603
- description: "Replaces deprecated props with their replacements",
604
- recommendation: "recommended"
605
- },
606
- fixable: "code",
607
- messages: {
608
- replacedWith: `'{{ prop }}' has been replaced with '{{ replacement }}'`
609
- },
610
- schema: [],
611
- type: "problem"
612
- },
613
- name: RULE_NAME$3
614
- });
615
-
616
- const RULE_NAME$2 = "no-legacy-library-import";
617
- const legacyLibrary = "@rotki/ui-library-compat";
618
- const newLibrary = "@rotki/ui-library";
619
- const noLegacyLibraryImport = createEslintRule({
620
- create(context) {
621
- return {
622
- ImportDeclaration(node) {
623
- if (!node.source.value.startsWith(legacyLibrary))
624
- return;
625
- const replacement = node.source.value.replace(legacyLibrary, newLibrary);
626
- context.report({
627
- fix(fixer) {
628
- return fixer.replaceText(node.source, `'${replacement}'`);
629
- },
630
- messageId: "replacedWith",
631
- node: node.source
632
- });
633
- }
634
- };
635
- },
636
- defaultOptions: [],
637
- meta: {
638
- docs: {
639
- description: `Reports and replaces imports of ${legacyLibrary} with ${newLibrary}`,
640
- recommendation: "recommended"
641
- },
642
- fixable: "code",
643
- messages: {
644
- replacedWith: `${legacyLibrary} has been replaced by ${newLibrary}`
645
- },
646
- schema: [],
647
- type: "problem"
648
- },
649
- name: RULE_NAME$2
650
- });
651
-
652
- const debug = createDebug__default("@rotki/eslint-plugin:consistent-ref-type-annotation");
653
- const RULE_NAME$1 = "consistent-ref-type-annotation";
654
- const FIXABLE_METHODS = ["ref", "computed"];
655
- function checkAssignmentDeclaration(context, node, declaration, options) {
656
- const source = getSourceCode(context);
657
- const { allowInference } = options;
658
- let declarationTypeArguments;
659
- const init = declaration.init;
660
- if (!(init && init.type === utils.TSESTree.AST_NODE_TYPES.CallExpression))
661
- return;
662
- const callee = init.callee;
663
- if (!(callee && callee.type === utils.TSESTree.AST_NODE_TYPES.Identifier))
664
- return;
665
- if (!Array.prototype.includes.call(FIXABLE_METHODS, callee.name))
666
- return;
667
- const name = callee.name;
668
- debug(`found ${name}, checking type arguments`);
669
- const initializationTypeArguments = init.typeArguments;
670
- const typeAnnotation = declaration.id.typeAnnotation;
671
- if (typeAnnotation) {
672
- const typeNode = typeAnnotation.typeAnnotation;
673
- if (typeNode && typeNode.type === utils.TSESTree.AST_NODE_TYPES.TSTypeReference)
674
- declarationTypeArguments = typeNode.typeArguments;
675
- }
676
- if (initializationTypeArguments && !declarationTypeArguments)
677
- return;
678
- debug(`generating report for ${name}`);
679
- if (!initializationTypeArguments && !declarationTypeArguments) {
680
- if (allowInference) {
681
- debug("type inference is allowed");
682
- } else {
683
- context.report({
684
- data: {
685
- name
686
- },
687
- messageId: "missingType",
688
- node
689
- });
690
- }
691
- return;
692
- }
693
- context.report({
694
- data: {
695
- name
696
- },
697
- fix(fixer) {
698
- const fixes = [];
699
- if (!initializationTypeArguments && callee)
700
- fixes.push(fixer.insertTextAfter(callee, source.getText(declarationTypeArguments)));
701
- if (typeAnnotation)
702
- fixes.push(fixer.remove(typeAnnotation));
703
- return fixes;
704
- },
705
- messageId: "inconsistent",
706
- node
707
- });
708
- }
709
- const consistentRefTypeAnnotation = createEslintRule({
710
- create(context, optionsWithDefault) {
711
- const options = optionsWithDefault[0] || {};
712
- const allowInference = options.allowInference;
713
- return {
714
- VariableDeclaration: (node) => {
715
- const declarations = node.declarations;
716
- for (const declaration of declarations) {
717
- if (declaration.type !== utils.TSESTree.AST_NODE_TYPES.VariableDeclarator)
718
- continue;
719
- checkAssignmentDeclaration(context, node, declaration, { allowInference });
720
- }
721
- }
722
- };
723
- },
724
- defaultOptions: [{ allowInference: false }],
725
- meta: {
726
- docs: {
727
- description: "Ensures consistent type annotation position for ref, computed assignments",
728
- recommendation: "recommended"
729
- },
730
- fixable: "code",
731
- messages: {
732
- inconsistent: `Generic type annotation for the {{ name }} call was not on the right side`,
733
- missingType: `variable assignment for {{ name }} is missing the type annotation`
734
- },
735
- schema: [
736
- {
737
- additionalProperties: false,
738
- properties: {
739
- allowInference: {
740
- type: "boolean"
741
- }
742
- },
743
- type: "object"
744
- }
745
- ],
746
- type: "problem"
747
- },
748
- name: RULE_NAME$1
749
- });
750
-
751
- const RULE_NAME = "no-dot-ts-imports";
752
- const noDotTsImport = createEslintRule({
753
- create(context) {
754
- return {
755
- ImportDeclaration(node) {
756
- const importDeclaration = node.source.value;
757
- if (!importDeclaration.endsWith(".ts"))
758
- return;
759
- const lastIndexOfExtension = importDeclaration.lastIndexOf(".ts");
760
- const replacement = importDeclaration.substring(0, lastIndexOfExtension);
761
- context.report({
762
- data: {
763
- import: importDeclaration
764
- },
765
- fix(fixer) {
766
- return fixer.replaceText(node.source, `'${replacement}'`);
767
- },
768
- messageId: "invalidTSExtension",
769
- node: node.source
770
- });
771
- }
772
- };
773
- },
774
- defaultOptions: [],
775
- meta: {
776
- docs: {
777
- description: "Checks and replaces .ts extension in import statements.",
778
- recommendation: "recommended"
779
- },
780
- fixable: "code",
781
- messages: {
782
- invalidTSExtension: `'{{ import }}' has a .ts extension, please remove it'`
783
- },
784
- schema: [],
785
- type: "problem"
786
- },
787
- name: RULE_NAME
788
- });
789
-
790
- const plugin = {
791
- meta: {
792
- name: "@rotki/eslint-plugin",
793
- version: pkg.version
794
- },
795
- rules: {
796
- "consistent-ref-type-annotation": consistentRefTypeAnnotation,
797
- "no-deprecated-classes": noDeprecatedClasses,
798
- "no-deprecated-components": noDeprecatedComponents,
799
- "no-deprecated-props": noDeprecatedProps,
800
- "no-dot-ts-imports": noDotTsImport,
801
- "no-legacy-library-import": noLegacyLibraryImport
802
- }
803
- };
804
- const plugin$1 = plugin;
805
-
806
- const configs = {
807
- "recommended": createRecommended(plugin$1, "@rotki", false),
808
- "recommended-flat": createRecommended(plugin$1, "@rotki", true)
809
- };
810
-
811
- const index = Object.assign(plugin$1, { configs });
812
-
813
- module.exports = index;