@rotki/eslint-plugin 0.0.3 → 0.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.
package/dist/rules.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare const _default: {
2
- 'no-deprecated-classes': import("./types").RuleModule;
3
- };
4
- export = _default;
package/dist/rules.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- const no_deprecated_classes_1 = __importDefault(require("./rules/no-deprecated-classes"));
6
- module.exports = {
7
- 'no-deprecated-classes': no_deprecated_classes_1.default,
8
- };
@@ -1,212 +0,0 @@
1
- import type { AST as JSONAST } from 'jsonc-eslint-parser';
2
- import type { AST as YAMLAST } from 'yaml-eslint-parser';
3
- import type { AST as VAST } from 'vue-eslint-parser';
4
- import type { RuleListener, VueParserServices } from './vue-parser-services';
5
- import type { TokenStore } from './types';
6
- export interface Position {
7
- line: number;
8
- column: number;
9
- }
10
- export type Range = [number, number];
11
- export interface SourceLocation {
12
- start: Position;
13
- end: Position;
14
- }
15
- export interface MaybeNode {
16
- type: string;
17
- range: Range;
18
- loc: SourceLocation;
19
- }
20
- export interface MaybeToken extends MaybeNode {
21
- value: string;
22
- }
23
- export interface RuleContext {
24
- id: string;
25
- options: any[];
26
- settings: object;
27
- parserPath: string;
28
- parserServices: {
29
- isYAML?: true;
30
- isJSON?: true;
31
- } & VueParserServices;
32
- getFilename(): string;
33
- getSourceCode(): SourceCode;
34
- getScope(): Scope;
35
- report(descriptor: ReportDescriptor): void;
36
- getCwd?: () => string;
37
- }
38
- interface ReportDescriptorOptionsBase {
39
- data?: {
40
- [key: string]: string;
41
- };
42
- fix?: null | ((fixer: RuleFixer) => null | Fix | IterableIterator<Fix> | Fix[]);
43
- }
44
- type SuggestionDescriptorMessage = {
45
- desc: string;
46
- } | {
47
- messageId: string;
48
- };
49
- export type SuggestionReportDescriptor = SuggestionDescriptorMessage & ReportDescriptorOptionsBase;
50
- interface ReportDescriptorOptions extends ReportDescriptorOptionsBase {
51
- suggest?: SuggestionReportDescriptor[] | null;
52
- }
53
- type ReportDescriptor = ReportDescriptorMessage & ReportDescriptorLocation & ReportDescriptorOptions;
54
- type ReportDescriptorMessage = {
55
- message: string;
56
- } | {
57
- messageId: string;
58
- };
59
- type ReportDescriptorLocation = {
60
- node: MaybeNode;
61
- } | {
62
- loc: SourceLocation | {
63
- line: number;
64
- column: number;
65
- };
66
- };
67
- export interface RuleFixer {
68
- insertTextAfter(nodeOrToken: MaybeNode, text: string): Fix;
69
- insertTextAfterRange(range: Range, text: string): Fix;
70
- insertTextBefore(nodeOrToken: MaybeNode, text: string): Fix;
71
- insertTextBeforeRange(range: Range, text: string): Fix;
72
- remove(nodeOrToken: MaybeNode): Fix;
73
- removeRange(range: Range): Fix;
74
- replaceText(nodeOrToken: MaybeNode, text: string): Fix;
75
- replaceTextRange(range: Range, text: string): Fix;
76
- }
77
- export interface Fix {
78
- range: Range;
79
- text: string;
80
- }
81
- export type FilterPredicate = (tokenOrComment: MaybeToken) => boolean;
82
- export type CursorWithSkipOptions = number | FilterPredicate | {
83
- includeComments?: boolean;
84
- filter?: FilterPredicate;
85
- skip?: number;
86
- };
87
- export type CursorWithCountOptions = number | FilterPredicate | {
88
- includeComments?: boolean;
89
- filter?: FilterPredicate;
90
- count?: number;
91
- };
92
- export interface SourceCode extends TokenStore {
93
- text: string;
94
- ast: VAST.ESLintProgram | JSONAST.JSONProgram | YAMLAST.YAMLProgram;
95
- lines: string[];
96
- hasBOM: boolean;
97
- scopeManager: ScopeManager;
98
- visitorKeys: VisitorKeys;
99
- parserServices: {
100
- isYAML?: true;
101
- isJSON?: true;
102
- } & VueParserServices;
103
- getText(node?: MaybeNode, beforeCount?: number, afterCount?: number): string;
104
- getLines(): string[];
105
- getAllComments(): MaybeToken[];
106
- getComments(node: MaybeNode): {
107
- leading: MaybeToken[];
108
- trailing: MaybeToken[];
109
- };
110
- getJSDocComment(node: MaybeNode): MaybeToken | null;
111
- getNodeByRangeIndex(index: number): MaybeNode;
112
- isSpaceBetweenTokens(first: MaybeToken, second: MaybeToken): boolean;
113
- getLocFromIndex(index: number): Position;
114
- getIndexFromLoc(location: Position): number;
115
- }
116
- export interface ScopeManager {
117
- scopes: Scope[];
118
- globalScope: Scope | null;
119
- acquire(node: VAST.ESLintNode | VAST.ESLintProgram, inner?: boolean): Scope | null;
120
- getDeclaredVariables(node: VAST.ESLintNode): Variable[];
121
- }
122
- export interface Scope {
123
- type: 'block' | 'catch' | 'class' | 'for' | 'function' | 'function-expression-name' | 'global' | 'module' | 'switch' | 'with' | 'TDZ';
124
- isStrict: boolean;
125
- upper: Scope | null;
126
- childScopes: Scope[];
127
- variableScope: Scope;
128
- block: VAST.ESLintNode;
129
- variables: Variable[];
130
- set: Map<string, Variable>;
131
- references: Reference[];
132
- through: Reference[];
133
- functionExpressionScope: boolean;
134
- }
135
- export interface Variable {
136
- name: string;
137
- identifiers: VAST.ESLintIdentifier[];
138
- references: Reference[];
139
- defs: Definition[];
140
- }
141
- export interface Reference {
142
- identifier: VAST.ESLintIdentifier;
143
- from: Scope;
144
- resolved: Variable | null;
145
- writeExpr: VAST.ESLintNode | null;
146
- init: boolean;
147
- isWrite(): boolean;
148
- isRead(): boolean;
149
- isWriteOnly(): boolean;
150
- isReadOnly(): boolean;
151
- isReadWrite(): boolean;
152
- }
153
- export type DefinitionType = {
154
- type: 'CatchClause';
155
- node: VAST.ESLintCatchClause;
156
- parent: null;
157
- } | {
158
- type: 'ClassName';
159
- node: VAST.ESLintClassDeclaration | VAST.ESLintClassExpression;
160
- parent: null;
161
- } | {
162
- type: 'FunctionName';
163
- node: VAST.ESLintFunctionDeclaration | VAST.ESLintFunctionExpression;
164
- parent: null;
165
- } | {
166
- type: 'ImplicitGlobalVariable';
167
- node: VAST.ESLintProgram;
168
- parent: null;
169
- } | {
170
- type: 'ImportBinding';
171
- node: VAST.ESLintImportSpecifier | VAST.ESLintImportDefaultSpecifier | VAST.ESLintImportNamespaceSpecifier;
172
- parent: VAST.ESLintImportDeclaration;
173
- } | {
174
- type: 'Parameter';
175
- node: VAST.ESLintFunctionDeclaration | VAST.ESLintFunctionExpression | VAST.ESLintArrowFunctionExpression;
176
- parent: null;
177
- } | {
178
- type: 'TDZ';
179
- node: any;
180
- parent: null;
181
- } | {
182
- type: 'Variable';
183
- node: VAST.ESLintVariableDeclarator;
184
- parent: VAST.ESLintVariableDeclaration;
185
- };
186
- export type Definition = DefinitionType & {
187
- name: VAST.ESLintIdentifier;
188
- };
189
- export interface VisitorKeys {
190
- [type: string]: string[];
191
- }
192
- export type RuleModule = {
193
- create(context: RuleContext): RuleListener;
194
- meta: RuleMetaData;
195
- };
196
- export interface RuleMetaData {
197
- docs: {
198
- description: string;
199
- category: 'Recommended' | 'Best Practices' | 'Stylistic Issues';
200
- recommended?: boolean;
201
- replacedBy?: string[];
202
- url: string;
203
- };
204
- messages?: {
205
- [messageId: string]: string;
206
- };
207
- fixable: 'code' | 'whitespace' | null;
208
- hasSuggestions?: true;
209
- deprecated?: boolean;
210
- type: 'problem' | 'suggestion' | 'layout';
211
- }
212
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- export * from './types';
2
- export * from './eslint';
3
- export * from './vue-parser-services';
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./eslint"), exports);
19
- __exportStar(require("./vue-parser-services"), exports);
@@ -1,38 +0,0 @@
1
- import type { CursorWithCountOptions, CursorWithSkipOptions, MaybeNode, MaybeToken } from './eslint';
2
- export interface TokenStore {
3
- getTokenByRangeStart(offset: number, options?: {
4
- includeComments: boolean;
5
- }): MaybeToken | null;
6
- getFirstToken(node: MaybeNode): MaybeToken;
7
- getFirstToken(node: MaybeNode, options: number): MaybeToken;
8
- getFirstToken(node: MaybeNode, options: CursorWithSkipOptions): MaybeToken | null;
9
- getLastToken(node: MaybeNode): MaybeToken;
10
- getLastToken(node: MaybeNode, options: number): MaybeToken;
11
- getLastToken(node: MaybeNode, options: CursorWithSkipOptions): MaybeToken | null;
12
- getTokenBefore(node: MaybeNode): MaybeToken;
13
- getTokenBefore(node: MaybeNode, options: number): MaybeToken;
14
- getTokenBefore(node: MaybeNode, options: {
15
- includeComments: boolean;
16
- }): MaybeToken;
17
- getTokenBefore(node: MaybeNode, options: CursorWithSkipOptions): MaybeToken | null;
18
- getTokenAfter(node: MaybeNode): MaybeToken;
19
- getTokenAfter(node: MaybeNode, options: number): MaybeToken;
20
- getTokenAfter(node: MaybeNode, options: {
21
- includeComments: boolean;
22
- }): MaybeToken;
23
- getTokenAfter(node: MaybeNode, options: CursorWithSkipOptions): MaybeToken | null;
24
- getFirstTokenBetween(left: MaybeNode, right: MaybeNode, options?: CursorWithSkipOptions): MaybeToken | null;
25
- getLastTokenBetween(left: MaybeNode, right: MaybeNode, options?: CursorWithSkipOptions): MaybeToken | null;
26
- getFirstTokens(node: MaybeNode, options?: CursorWithCountOptions): MaybeToken[];
27
- getLastTokens(node: MaybeNode, options?: CursorWithCountOptions): MaybeToken[];
28
- getTokensBefore(node: MaybeNode, options?: CursorWithCountOptions): MaybeToken[];
29
- getTokensAfter(node: MaybeNode, options?: CursorWithCountOptions): MaybeToken[];
30
- getFirstTokensBetween(left: MaybeNode, right: MaybeNode, options?: CursorWithCountOptions): MaybeToken[];
31
- getLastTokensBetween(left: MaybeNode, right: MaybeNode, options?: CursorWithCountOptions): MaybeToken[];
32
- getTokens(node: MaybeNode, beforeCount?: CursorWithCountOptions, afterCount?: number): MaybeToken[];
33
- getTokensBetween(left: MaybeNode, right: MaybeNode, padding?: CursorWithCountOptions): MaybeToken[];
34
- commentsExistBetween(left: MaybeNode, right: MaybeNode): boolean;
35
- getCommentsBefore(nodeOrToken: MaybeNode): MaybeToken[];
36
- getCommentsAfter(nodeOrToken: MaybeNode): MaybeToken[];
37
- getCommentsInside(node: MaybeNode): MaybeToken[];
38
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,32 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- import type { RuleContext } from './eslint';
3
- import type { AST as VAST } from 'vue-eslint-parser';
4
- import type { TokenStore } from './types';
5
- import type { VElement } from 'vue-eslint-parser/ast';
6
- export interface TemplateListener {
7
- [key: string]: ((node: never) => void) | undefined;
8
- }
9
- export interface RuleListener {
10
- onCodePathStart?(codePath: Rule.CodePath, node: never): void;
11
- onCodePathEnd?(codePath: Rule.CodePath, node: never): void;
12
- onCodePathSegmentStart?(segment: Rule.CodePathSegment, node: never): void;
13
- onCodePathSegmentEnd?(segment: Rule.CodePathSegment, node: never): void;
14
- onCodePathSegmentLoop?(fromSegment: Rule.CodePathSegment, toSegment: Rule.CodePathSegment, node: never): void;
15
- [key: string]: ((node: never) => void) | ((codePath: Rule.CodePath, node: never) => void) | ((segment: Rule.CodePathSegment, node: never) => void) | ((fromSegment: Rule.CodePathSegment, toSegment: Rule.CodePathSegment, node: never) => void) | undefined;
16
- }
17
- export interface VueParserServices {
18
- getTemplateBodyTokenStore: () => TokenStore;
19
- defineTemplateBodyVisitor?: (templateBodyVisitor: TemplateListener, scriptVisitor?: RuleListener) => RuleListener;
20
- defineCustomBlocksVisitor?: (context: RuleContext, parser: {
21
- parseForESLint: (code: string, options: any) => any;
22
- }, rule: {
23
- target: string | string[] | ((lang: string | null, customBlock: VAST.VElement) => boolean);
24
- create: CustomBlockVisitorFactory;
25
- }, scriptVisitor?: RuleListener) => RuleListener;
26
- getDocumentFragment?: () => VAST.VDocumentFragment | null;
27
- }
28
- export type CustomBlockVisitorFactory = (context: RuleContext & {
29
- parserServices: RuleContext['parserServices'] & {
30
- customBlock: VElement;
31
- };
32
- }) => RuleListener | null;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- import { type RuleContext, type RuleListener, type TemplateListener } from '../types';
2
- export declare function defineTemplateBodyVisitor(context: RuleContext, templateBodyVisitor: TemplateListener, scriptVisitor?: RuleListener): RuleListener;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineTemplateBodyVisitor = void 0;
4
- const node_path_1 = require("node:path");
5
- const UNEXPECTED_ERROR_LOCATION = { line: 1, column: 0 };
6
- function defineTemplateBodyVisitor(context, templateBodyVisitor, scriptVisitor) {
7
- const sourceCode = context.getSourceCode();
8
- if (sourceCode.parserServices.defineTemplateBodyVisitor == null) {
9
- const filename = context.getFilename();
10
- if ((0, node_path_1.extname)(filename) === '.vue') {
11
- context.report({
12
- loc: UNEXPECTED_ERROR_LOCATION,
13
- 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',
14
- });
15
- }
16
- return {};
17
- }
18
- return sourceCode.parserServices.defineTemplateBodyVisitor(templateBodyVisitor, scriptVisitor);
19
- }
20
- exports.defineTemplateBodyVisitor = defineTemplateBodyVisitor;
@@ -1,2 +0,0 @@
1
- import type { RuleModule } from '../types';
2
- export declare function createRule(module: RuleModule): RuleModule;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRule = void 0;
4
- function createRule(module) {
5
- return module;
6
- }
7
- exports.createRule = createRule;
package/dist/utils.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import * as index from './utils/index';
2
- import * as rule from './utils/rule';
3
- declare const _default: {
4
- index: typeof index;
5
- rule: typeof rule;
6
- };
7
- export = _default;
package/dist/utils.js DELETED
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- const index = __importStar(require("./utils/index"));
26
- const rule = __importStar(require("./utils/rule"));
27
- module.exports = {
28
- index,
29
- rule,
30
- };