eslint-plugin-svg 0.0.2 → 0.0.4

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 CHANGED
@@ -3,7 +3,6 @@
3
3
  [![CI](https://github.com/ntnyq/eslint-plugin-svg/workflows/CI/badge.svg)](https://github.com/ntnyq/eslint-plugin-svg/actions)
4
4
  [![NPM VERSION](https://img.shields.io/npm/v/eslint-plugin-svg.svg)](https://www.npmjs.com/package/eslint-plugin-svg)
5
5
  [![NPM DOWNLOADS](https://img.shields.io/npm/dy/eslint-plugin-svg.svg)](https://www.npmjs.com/package/eslint-plugin-svg)
6
- [![CODECOV](https://codecov.io/github/ntnyq/eslint-plugin-svg/branch/main/graph/badge.svg)](https://codecov.io/github/ntnyq/eslint-plugin-svg)
7
6
  [![LICENSE](https://img.shields.io/github/license/ntnyq/eslint-plugin-svg.svg)](https://github.com/ntnyq/eslint-plugin-svg/blob/main/LICENSE)
8
7
 
9
8
  > Rules for consistent, readable and valid SVG files.
@@ -13,15 +12,15 @@
13
12
 
14
13
  ## Install
15
14
 
16
- ```bash
15
+ ```shell
17
16
  npm install eslint-plugin-svg -D
18
17
  ```
19
18
 
20
- ```bash
19
+ ```shell
21
20
  yarn add eslint-plugin-svg -D
22
21
  ```
23
22
 
24
- ```bash
23
+ ```shell
25
24
  pnpm add eslint-plugin-svg -D
26
25
  ```
27
26
 
@@ -30,15 +29,13 @@ pnpm add eslint-plugin-svg -D
30
29
  Config in ESLint config files:
31
30
 
32
31
  ```ts
33
- import pluginSvg from 'eslint-plugin-svg'
32
+ import { defineConfig } from 'eslint/config'
33
+ import pluginSVG from 'eslint-plugin-svg'
34
34
 
35
- /**
36
- * @type {import('eslint').Linter.Config[]}
37
- */
38
- export default [
35
+ export default defineConfig([
39
36
  // Other configs...
40
- ...pluginSvg.configs.recommended,
41
- ]
37
+ ...pluginSVG.configs.recommended,
38
+ ])
42
39
  ```
43
40
 
44
41
  :apple: For advanced usaged, please check [Advanced Usage](https://eslint-plugin-svg.ntnyq.com/guide/#advanced-usage)
@@ -50,15 +47,16 @@ export default [
50
47
  🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
51
48
  💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).
52
49
 
53
- | Name | Description | 💼 | 🔧 | 💡 |
54
- | :--------------------------------------------------------------------------------- | :------------------------------- | :-: | :-: | :-: |
55
- | [no-empty-title](https://eslint-plugin-svg.ntnyq.com/rules/no-empty-title) | Disallow empty title element | ✅ | | |
56
- | [no-empty-desc](https://eslint-plugin-svg.ntnyq.com/rules/no-empty-desc) | Disallow empty desc element | ✅ | | |
57
- | [no-empty-text](https://eslint-plugin-svg.ntnyq.com/rules/no-empty-text) | Disallow empty text element | ✅ | | |
58
- | [no-empty-container](https://eslint-plugin-svg.ntnyq.com/rules/no-empty-container) | Disallow empty container element | ✅ | | |
59
- | [no-deprecated](https://eslint-plugin-svg.ntnyq.com/rules/no-deprecated) | Disallow deprecated elements | ✅ | | |
60
- | [no-elements](https://eslint-plugin-svg.ntnyq.com/rules/no-elements) | Disallow elements by name | | | |
61
- | [no-doctype](https://eslint-plugin-svg.ntnyq.com/rules/no-doctype) | Disallow doctype | ✅ | 🔧 | |
50
+ | Name | Description | 💼 | 🔧 | 💡 |
51
+ | :--------------------------------------------------------------------------------- | :--------------------------------------- | :-: | :-: | :-: |
52
+ | [no-empty-title](https://eslint-plugin-svg.ntnyq.com/rules/no-empty-title) | Disallow empty title element | ✅ | | |
53
+ | [no-empty-desc](https://eslint-plugin-svg.ntnyq.com/rules/no-empty-desc) | Disallow empty desc element | ✅ | | |
54
+ | [no-empty-text](https://eslint-plugin-svg.ntnyq.com/rules/no-empty-text) | Disallow empty text element | ✅ | | |
55
+ | [no-empty-container](https://eslint-plugin-svg.ntnyq.com/rules/no-empty-container) | Disallow empty container element | ✅ | | |
56
+ | [no-deprecated](https://eslint-plugin-svg.ntnyq.com/rules/no-deprecated) | Disallow deprecated elements | ✅ | | |
57
+ | [no-elements](https://eslint-plugin-svg.ntnyq.com/rules/no-elements) | Disallow elements by name | | | |
58
+ | [no-doctype](https://eslint-plugin-svg.ntnyq.com/rules/no-doctype) | Disallow doctype | ✅ | 🔧 | |
59
+ | [no-invalid-role](https://eslint-plugin-svg.ntnyq.com/rules/no-invalid-role) | Disallow invalid value of role attribute | ✅ | | |
62
60
 
63
61
  ## License
64
62
 
package/dist/index.d.ts CHANGED
@@ -1,339 +1,241 @@
1
- import * as eslint from 'eslint';
2
- import { Rule, Linter } from 'eslint';
3
- import { JSONSchema4 } from 'json-schema';
4
- import { AST } from 'svg-eslint-parser';
1
+ import { AST } from "svg-eslint-parser";
2
+ import { Linter, Rule } from "eslint";
3
+ import { JSONSchema4 } from "json-schema";
5
4
 
5
+ //#region src/types/sourceCode.d.ts
6
6
  interface SourceCode {
7
- ast: AST.Program
8
- hasBOM: boolean
9
- lines: string[]
10
- text: string
11
- getAllComments(): AST.CommentNode[]
12
- getIndexFromLoc(loc: AST.Position): number
13
-
14
- getLines(): string[]
15
-
16
- getLocFromIndex(index: number): AST.Position
17
-
18
- getNodeByRangeIndex(index: number): AST.AnyNode | null
19
-
20
- getText(node?: SVGNodeOrToken, beforeCount?: number, afterCount?: number): string
21
-
22
- isSpaceBetweenTokens(first: SVGToken, second: SVGToken): boolean
23
-
7
+ ast: AST.Program;
8
+ hasBOM: boolean;
9
+ lines: string[];
10
+ text: string;
11
+ commentsExistBetween(left: SVGNodeOrToken, right: SVGNodeOrToken): boolean;
12
+ getAllComments(): AST.CommentNode[];
13
+ getCommentsAfter(nodeOrToken: SVGNodeOrToken): AST.CommentNode[];
14
+ getCommentsBefore(nodeOrToken: SVGNodeOrToken): AST.CommentNode[];
15
+ getCommentsInside(node: AST.AnyNode): AST.CommentNode[];
16
+ getFirstToken(node: AST.AnyNode): AST.AnyToken;
17
+ getIndexFromLoc(loc: AST.Position): number;
18
+ getLastToken(node: AST.AnyNode): AST.AnyToken;
19
+ getLastTokens(node: AST.AnyNode, options?: CursorWithCountOptions): SVGToken[];
20
+ getLines(): string[];
21
+ getLocFromIndex(index: number): AST.Position;
22
+ getNodeByRangeIndex(index: number): AST.AnyNode | null;
23
+ getTokenAfter(node: SVGNodeOrToken): AST.AnyToken | null;
24
+ getTokenBefore(node: SVGNodeOrToken): AST.AnyToken | null;
25
+ isSpaceBetweenTokens(first: SVGToken, second: SVGToken): boolean;
24
26
  visitorKeys: {
25
- [nodeType: string]: string[]
26
- }
27
-
27
+ [nodeType: string]: string[];
28
+ };
28
29
  parserServices?: {
29
- isSVG?: true
30
- parseError?: any
31
- }
32
-
30
+ isSVG?: true;
31
+ parseError?: any;
32
+ };
33
33
  getComments(node: SVGNodeOrToken): {
34
- leading: AST.Comment[]
35
- trailing: AST.Comment[]
36
- }
37
-
38
- // Inherited methods from TokenStore
39
- // ---------------------------------
40
-
41
- commentsExistBetween(left: SVGNodeOrToken, right: SVGNodeOrToken): boolean
42
-
43
- getCommentsAfter(nodeOrToken: SVGNodeOrToken): AST.Comment[]
44
- getCommentsBefore(nodeOrToken: SVGNodeOrToken): AST.Comment[]
45
-
46
- getCommentsInside(node: AST.AnyNode): AST.Comment[]
47
-
48
- getFirstToken(node: AST.AnyNode): AST.Token
49
- getFirstToken(node: AST.AnyNode, options?: CursorWithSkipOptions): SVGToken | null
50
-
51
- getFirstTokens(node: AST.AnyNode, options?: CursorWithCountOptions): SVGToken[]
52
-
53
- getLastToken(node: AST.AnyNode): AST.Token
54
- getLastToken(node: AST.AnyNode, options?: CursorWithSkipOptions): SVGToken | null
55
-
56
- getLastTokens(node: AST.AnyNode, options?: CursorWithCountOptions): SVGToken[]
57
-
58
- getTokenAfter(node: SVGNodeOrToken): AST.Token | null
59
- getTokenAfter(node: SVGNodeOrToken, options?: CursorWithSkipOptions): SVGToken | null
60
-
61
- getTokenBefore(node: SVGNodeOrToken): AST.Token | null
62
-
63
- getTokenBefore(node: SVGNodeOrToken, options?: CursorWithSkipOptions): SVGToken | null
64
-
65
- getTokenByRangeStart(offset: number, options?: { includeComments?: boolean }): SVGToken | null
66
-
67
- getTokens(node: AST.AnyNode, beforeCount?: number, afterCount?: number): SVGToken[]
68
-
69
- getTokens(node: AST.AnyNode, options: CursorWithCountOptions | FilterPredicate): SVGToken[]
70
-
71
- getTokensAfter(node: SVGNodeOrToken, options?: CursorWithCountOptions): SVGToken[]
72
-
73
- getTokensBefore(node: SVGNodeOrToken, options?: CursorWithCountOptions): SVGToken[]
74
- getFirstTokenBetween(
75
- left: SVGNodeOrToken,
76
- right: SVGNodeOrToken,
77
- options?: CursorWithSkipOptions,
78
- ): SVGToken | null
79
-
80
- getFirstTokensBetween(
81
- left: SVGNodeOrToken,
82
- right: SVGNodeOrToken,
83
- options?: CursorWithCountOptions,
84
- ): SVGToken[]
85
-
86
- getLastTokenBetween(
87
- left: SVGNodeOrToken,
88
- right: SVGNodeOrToken,
89
- options?: CursorWithSkipOptions,
90
- ): SVGToken | null
91
-
92
- getLastTokensBetween(
93
- left: SVGNodeOrToken,
94
- right: SVGNodeOrToken,
95
- options?: CursorWithCountOptions,
96
- ): SVGToken[]
97
-
98
- getTokensBetween(
99
- left: SVGNodeOrToken,
100
- right: SVGNodeOrToken,
101
- padding?: number | CursorWithCountOptions | FilterPredicate,
102
- ): SVGToken[]
34
+ leading: AST.CommentNode[];
35
+ trailing: AST.CommentNode[];
36
+ };
37
+ getFirstToken(node: AST.AnyNode, options?: CursorWithSkipOptions): SVGToken | null;
38
+ getFirstTokenBetween(left: SVGNodeOrToken, right: SVGNodeOrToken, options?: CursorWithSkipOptions): SVGToken | null;
39
+ getFirstTokens(node: AST.AnyNode, options?: CursorWithCountOptions): SVGToken[];
40
+ getFirstTokensBetween(left: SVGNodeOrToken, right: SVGNodeOrToken, options?: CursorWithCountOptions): SVGToken[];
41
+ getLastToken(node: AST.AnyNode, options?: CursorWithSkipOptions): SVGToken | null;
42
+ getLastTokenBetween(left: SVGNodeOrToken, right: SVGNodeOrToken, options?: CursorWithSkipOptions): SVGToken | null;
43
+ getLastTokensBetween(left: SVGNodeOrToken, right: SVGNodeOrToken, options?: CursorWithCountOptions): SVGToken[];
44
+ getText(node?: SVGNodeOrToken, beforeCount?: number, afterCount?: number): string;
45
+ getTokenAfter(node: SVGNodeOrToken, options?: CursorWithSkipOptions): SVGToken | null;
46
+ getTokenBefore(node: SVGNodeOrToken, options?: CursorWithSkipOptions): SVGToken | null;
47
+ getTokenByRangeStart(offset: number, options?: {
48
+ includeComments?: boolean;
49
+ }): SVGToken | null;
50
+ getTokens(node: AST.AnyNode, beforeCount?: number, afterCount?: number): SVGToken[];
51
+ getTokens(node: AST.AnyNode, options: CursorWithCountOptions | FilterPredicate): SVGToken[];
52
+ getTokensAfter(node: SVGNodeOrToken, options?: CursorWithCountOptions): SVGToken[];
53
+ getTokensBefore(node: SVGNodeOrToken, options?: CursorWithCountOptions): SVGToken[];
54
+ getTokensBetween(left: SVGNodeOrToken, right: SVGNodeOrToken, padding?: number | CursorWithCountOptions | FilterPredicate): SVGToken[];
103
55
  }
104
- type CursorWithCountOptions =
105
- | number
106
- | FilterPredicate
107
- | {
108
- count?: number
109
- filter?: FilterPredicate
110
- includeComments?: boolean
111
- }
112
-
113
- type CursorWithSkipOptions =
114
- | number
115
- | FilterPredicate
116
- | {
117
- filter?: FilterPredicate
118
- includeComments?: boolean
119
- skip?: number
120
- }
121
-
122
- type FilterPredicate = (tokenOrComment: SVGToken) => boolean
123
-
124
- type SVGNodeOrToken = AST.AnyNode | AST.AnyToken
125
- type SVGToken = AST.AnyToken | AST.CommentNode
126
-
127
- type ReportDescriptor<TMessageIds extends string> =
128
- ReportDescriptorWithSuggestion<TMessageIds> &
129
- (ReportDescriptorLocOnly | ReportDescriptorNodeOptionalLoc)
130
-
56
+ type CursorWithCountOptions = number | FilterPredicate | {
57
+ count?: number;
58
+ filter?: FilterPredicate;
59
+ includeComments?: boolean;
60
+ };
61
+ type CursorWithSkipOptions = number | FilterPredicate | {
62
+ filter?: FilterPredicate;
63
+ includeComments?: boolean;
64
+ skip?: number;
65
+ };
66
+ type FilterPredicate = (tokenOrComment: SVGToken) => boolean;
67
+ type SVGNodeOrToken = AST.AnyNode | AST.AnyToken;
68
+ type SVGToken = AST.AnyToken | AST.CommentNode;
69
+ //#endregion
70
+ //#region src/types/eslint.d.ts
71
+ /**
72
+ * Rule fixer
73
+ */
74
+ type Fix = {
75
+ range: AST.Range;
76
+ text: string;
77
+ };
78
+ type ReportDescriptor<TMessageIds extends string> = ReportDescriptorWithSuggestion<TMessageIds> & (ReportDescriptorLocOnly | ReportDescriptorNodeOptionalLoc);
79
+ type ReportDescriptorBase<TMessageIds extends string> = {
80
+ readonly messageId: TMessageIds;
81
+ readonly data?: ReportDescriptorMessageData;
82
+ readonly fix?: ReportFixer;
83
+ };
131
84
  type ReportDescriptorLocOnly = {
132
- loc: Readonly<AST.Position> | Readonly<AST.SourceLocation>
133
- }
134
-
135
- type ReportDescriptorMessageData = Readonly<Record<string, unknown>>
136
-
85
+ loc: Readonly<AST.Position> | Readonly<AST.SourceLocation>;
86
+ };
87
+ type ReportDescriptorMessageData = Readonly<Record<string, unknown>>;
137
88
  type ReportDescriptorNodeOptionalLoc = {
138
- readonly node: AST.AnyNode
139
- readonly loc?: Readonly<AST.Position> | Readonly<AST.SourceLocation>
140
- }
141
- interface ReportDescriptorWithSuggestion<TMessageIds extends string>
142
- extends ReportDescriptorBase<TMessageIds> {
143
- readonly suggest?: readonly Rule.SuggestionReportDescriptor[]
89
+ readonly node: AST.AnyNode;
90
+ readonly loc?: Readonly<AST.Position> | Readonly<AST.SourceLocation>;
91
+ };
92
+ interface ReportDescriptorWithSuggestion<TMessageIds extends string> extends ReportDescriptorBase<TMessageIds> {
93
+ readonly suggest?: readonly Rule.SuggestionReportDescriptor[];
144
94
  }
95
+ type ReportFixer = (fixer: RuleFixer) => Fix | Fix[] | IterableIterator<Fix> | null;
145
96
  interface RuleContext<TMessageIds extends string, TOptions extends readonly unknown[] = []> {
146
- id: string
147
- options: TOptions
148
- parserPath: string
149
- settings: { svg?: SVGSettings; [name: string]: any }
150
- getAncestors(): AST.AnyNode[]
151
- getFilename(): string
152
- getSourceCode(): SourceCode
153
- report(descriptor: ReportDescriptor<TMessageIds>): void
97
+ id: string;
98
+ options: TOptions;
99
+ parserPath: string;
100
+ settings: {
101
+ svg?: SVGSettings;
102
+ [name: string]: any;
103
+ };
104
+ getFilename(): string;
105
+ getSourceCode(): SourceCode;
106
+ report(descriptor: ReportDescriptor<TMessageIds>): void;
154
107
  parserServices?: {
155
- isSVG?: true
156
- parseError?: any
157
- }
108
+ isSVG?: true;
109
+ parseError?: any;
110
+ };
158
111
  }
112
+ type RuleFixer = {
113
+ insertTextAfter(nodeOrToken: AST.AnyNode | AST.AnyToken, text: string): Fix;
114
+ insertTextAfterRange(range: AST.Range, text: string): Fix;
115
+ insertTextBefore(nodeOrToken: AST.AnyNode | AST.AnyToken, text: string): Fix;
116
+ insertTextBeforeRange(range: AST.Range, text: string): Fix;
117
+ remove(nodeOrToken: AST.AnyNode | AST.AnyToken): Fix;
118
+ removeRange(range: AST.Range): Fix;
119
+ replaceText(nodeOrToken: AST.AnyNode | AST.AnyToken, text: string): Fix;
120
+ replaceTextRange(range: AST.Range, text: string): Fix;
121
+ };
159
122
  interface RuleListener {
160
- // document
161
- Document?: (node: AST.DocumentNode) => void
162
- 'Document:exit'?: (node: AST.DocumentNode) => void
163
-
164
- // program
165
- Program?: (node: AST.Program) => void
166
- 'Program:exit'?: (node: AST.Program) => void
167
-
168
- // text
169
- Text?: (node: AST.TextNode) => void
170
- 'Text:exit'?: (node: AST.TextNode) => void
171
-
172
- // comment
173
- Comment?: (node: AST.CommentNode) => void
174
- 'Comment:exit'?: (node: AST.CommentNode) => void
175
-
176
- // doctype
177
- Doctype?: (node: AST.DoctypeNode) => void
178
- 'Doctype:exit'?: (node: AST.DoctypeNode) => void
179
- DoctypeAttribute?: (node: AST.DoctypeAttributeNode) => void
180
- 'DoctypeAttribute:exit'?: (node: AST.DoctypeAttributeNode) => void
181
-
182
- // tag
183
- Tag?: (node: AST.TagNode) => void
184
- 'Tag:exit'?: (node: AST.TagNode) => void
185
-
186
- // attribute
187
- Attribute?: (node: AST.AttributeNode) => void
188
- 'Attribute:exit'?: (node: AST.AttributeNode) => void
189
- [key: string]: ((node: never) => void) | undefined
123
+ Attribute?: (node: AST.AttributeNode) => void;
124
+ 'Attribute:exit'?: (node: AST.AttributeNode) => void;
125
+ Comment?: (node: AST.CommentNode) => void;
126
+ 'Comment:exit'?: (node: AST.CommentNode) => void;
127
+ Doctype?: (node: AST.DoctypeNode) => void;
128
+ 'Doctype:exit'?: (node: AST.DoctypeNode) => void;
129
+ DoctypeAttribute?: (node: AST.DoctypeAttributeNode) => void;
130
+ 'DoctypeAttribute:exit'?: (node: AST.DoctypeAttributeNode) => void;
131
+ Document?: (node: AST.DocumentNode) => void;
132
+ 'Document:exit'?: (node: AST.DocumentNode) => void;
133
+ Program?: (node: AST.Program) => void;
134
+ 'Program:exit'?: (node: AST.Program) => void;
135
+ Tag?: (node: AST.TagNode) => void;
136
+ 'Tag:exit'?: (node: AST.TagNode) => void;
137
+ Text?: (node: AST.TextNode) => void;
138
+ 'Text:exit'?: (node: AST.TextNode) => void;
139
+ [key: string]: ((node: never) => void) | undefined;
190
140
  }
191
-
192
- interface RuleModule<
193
- TMessageIds extends string,
194
- TOptions extends readonly unknown[] = [],
195
- TDocs = unknown,
196
- > {
197
- defaultOptions: TOptions
198
- meta?: RuleMetaData<TMessageIds, TDocs, TOptions>
199
- create(context: RuleContext<TMessageIds, TOptions>): RuleListener
141
+ interface RuleMetaData<TMessageIds extends string, TDocs = unknown, TOptions extends readonly unknown[] = []> {
142
+ messages: Record<TMessageIds, string>;
143
+ schema: JSONSchema4 | readonly JSONSchema4[];
144
+ type: 'layout' | 'problem' | 'suggestion';
145
+ defaultOptions?: TOptions;
146
+ deprecated?: boolean;
147
+ docs?: RuleMetaDataDocs & TDocs;
148
+ fixable?: 'code' | 'whitespace';
149
+ hasSuggestions?: boolean;
150
+ replacedBy?: readonly string[];
200
151
  }
201
-
202
- type SVGSettings = { indent?: number }
203
- interface RuleMetaData<
204
- TMessageIds extends string,
205
- TDocs = unknown,
206
- TOptions extends readonly unknown[] = [],
207
- > {
208
- messages: Record<TMessageIds, string>
209
- schema: JSONSchema4 | readonly JSONSchema4[]
210
- type: 'layout' | 'problem' | 'suggestion'
211
- defaultOptions?: TOptions
212
- deprecated?: boolean
213
- docs?: RuleMetaDataDocs & TDocs
214
- fixable?: 'code' | 'whitespace'
215
- hasSuggestions?: boolean
216
- replacedBy?: readonly string[]
217
- }
218
-
219
152
  interface RuleMetaDataDocs {
220
- description: string
221
- category?: string
222
- recommended?: boolean
223
- url?: string
153
+ description: string;
154
+ category?: string;
155
+ recommended?: boolean;
156
+ url?: string;
224
157
  }
225
-
226
- /**
227
- * rule fixer
228
- */
229
- type Fix = {
230
- range: AST.Range
231
- text: string
158
+ interface RuleModule<TMessageIds extends string, TOptions extends readonly unknown[] = [], TDocs = unknown> {
159
+ defaultOptions: TOptions;
160
+ meta?: RuleMetaData<TMessageIds, TDocs, TOptions>;
161
+ create(context: RuleContext<TMessageIds, TOptions>): RuleListener;
232
162
  }
233
- type ReportDescriptorBase<TMessageIds extends string> = {
234
- readonly messageId: TMessageIds
235
- readonly data?: ReportDescriptorMessageData
236
- readonly fix?: ReportFixer
237
- }
238
- type ReportFixer = (fixer: RuleFixer) => Fix | Fix[] | IterableIterator<Fix> | null
239
- type RuleFixer = {
240
- insertTextAfter(nodeOrToken: AST.AnyNode | AST.Token, text: string): Fix
241
-
242
- insertTextAfterRange(range: AST.Range, text: string): Fix
243
-
244
- insertTextBefore(nodeOrToken: AST.AnyNode | AST.Token, text: string): Fix
245
-
246
- insertTextBeforeRange(range: AST.Range, text: string): Fix
247
-
248
- remove(nodeOrToken: AST.AnyNode | AST.Token): Fix
249
-
250
- removeRange(range: AST.Range): Fix
251
-
252
- replaceText(nodeOrToken: AST.AnyNode | AST.Token, text: string): Fix
253
-
254
- replaceTextRange(range: AST.Range, text: string): Fix
255
- }
256
-
257
- type Options$2 = [
258
- {
259
- elements?: string[];
260
- ignores?: string[];
261
- ignoreComments?: boolean;
262
- ignoreWhitespace?: boolean;
263
- }
264
- ];
265
-
266
- type Options$1 = [
267
- {
268
- elements?: string[];
269
- }
270
- ];
271
-
272
- type Options = [
273
- {
274
- allowElements?: string[];
275
- }
276
- ];
277
-
278
- declare const rules: {
279
- 'no-deprecated': RuleModule<"deprecatedElement", Options, unknown>;
280
- 'no-doctype': RuleModule<"invalid", [], unknown>;
281
- 'no-elements': RuleModule<"invalid", Options$1, unknown>;
282
- 'no-empty-container': RuleModule<"invalid", Options$2, unknown>;
283
- 'no-empty-desc': RuleModule<"invalid", [], unknown>;
284
- 'no-empty-text': RuleModule<"invalid", [], unknown>;
285
- 'no-empty-title': RuleModule<"invalid", [], unknown>;
286
- };
287
-
288
- type RuleDefinitions = typeof rules;
289
- type RuleOptions = {
290
- [K in keyof RuleDefinitions]: RuleDefinitions[K]['defaultOptions'];
163
+ type SVGSettings = {
164
+ indent?: number;
291
165
  };
292
- type Rules = {
293
- [K in keyof RuleOptions]: Linter.RuleEntry<RuleOptions[K]>;
294
- };
295
- type RulesWithPluginName<Name extends string = 'svg'> = {
296
- [K in keyof RuleOptions as `${Name}/${K}`]: Linter.RuleEntry<RuleOptions[K]>;
166
+ //#endregion
167
+ //#region src/rules/no-deprecated.d.ts
168
+ type Options$3 = [{
169
+ allowElements?: string[];
170
+ }];
171
+ //#endregion
172
+ //#region src/rules/no-elements.d.ts
173
+ type Options$2 = [{
174
+ elements?: string[];
175
+ }];
176
+ //#endregion
177
+ //#region src/rules/no-empty-container.d.ts
178
+ type Options$1 = [{
179
+ elements?: string[];
180
+ ignores?: string[];
181
+ ignoreComments?: boolean;
182
+ ignoreWhitespace?: boolean;
183
+ }];
184
+ //#endregion
185
+ //#region src/rules/no-invalid-role.d.ts
186
+ type Options = [{
187
+ roles?: string[];
188
+ }];
189
+ //#endregion
190
+ //#region src/rules/index.d.ts
191
+ declare const rules: {
192
+ 'no-deprecated': RuleModule<"deprecatedElement", Options$3, unknown>;
193
+ 'no-doctype': RuleModule<"invalid", [], unknown>;
194
+ 'no-elements': RuleModule<"invalid", Options$2, unknown>;
195
+ 'no-empty-container': RuleModule<"invalid", Options$1, unknown>;
196
+ 'no-empty-desc': RuleModule<"invalid", [], unknown>;
197
+ 'no-empty-text': RuleModule<"invalid", [], unknown>;
198
+ 'no-empty-title': RuleModule<"invalid", [], unknown>;
199
+ 'no-invalid-role': RuleModule<"invalid", Options, unknown>;
297
200
  };
298
-
299
- declare const meta: {
201
+ //#endregion
202
+ //#region src/types/plugin.d.ts
203
+ interface PluginSVG {
204
+ rules: typeof rules;
205
+ configs: {
206
+ recommended: Linter.Config<Linter.RulesRecord>[];
207
+ };
208
+ meta: {
300
209
  name: string;
301
210
  version: string;
211
+ };
212
+ }
213
+ //#endregion
214
+ //#region src/dts.d.ts
215
+ type RuleDefinitions = typeof rules;
216
+ type RuleOptions = { [K in keyof RuleDefinitions]: RuleDefinitions[K]['defaultOptions'] };
217
+ type Rules = { [K in keyof RuleOptions]: Linter.RuleEntry<RuleOptions[K]> };
218
+ //#endregion
219
+ //#region src/meta.d.ts
220
+ declare const meta: {
221
+ name: string;
222
+ version: string;
302
223
  };
303
-
304
- type CreateConfigOptions = Omit<Linter.Config, 'rules'> & {
305
- rules?: Partial<RulesWithPluginName>;
306
- };
307
- /**
308
- * Create a ESLint config.
309
- *
310
- * @param options - ESLint Linter.Config with type support.
311
- * @returns ESLint config.
312
- */
313
- declare function createConfig(options?: CreateConfigOptions): Linter.Config<Linter.RulesRecord>;
224
+ //#endregion
225
+ //#region src/configs/index.d.ts
314
226
  /**
315
227
  * recommended config preset
316
228
  */
317
229
  declare const recommended: Linter.Config<Linter.RulesRecord>[];
318
- declare const configs: {
319
- recommended: Linter.Config<Linter.RulesRecord>[];
320
- };
321
-
230
+ declare const configs: PluginSVG['configs'];
231
+ //#endregion
232
+ //#region src/index.d.ts
322
233
  /**
323
234
  * eslint-plugin-svg
324
235
  * Rules for consistent, readable and valid SVG files.
325
236
  *
326
237
  * @see {@link https://github.com/ntnyq/eslint-plugin-svg}
327
238
  */
328
- declare const plugin: {
329
- meta: {
330
- name: string;
331
- version: string;
332
- };
333
- rules: Record<string, Rule.RuleModule>;
334
- configs: {
335
- recommended: eslint.Linter.Config<eslint.Linter.RulesRecord>[];
336
- };
337
- };
338
-
339
- export { type CreateConfigOptions, type RuleOptions, type Rules, type RulesWithPluginName, configs, createConfig, plugin as default, meta, plugin, recommended, rules };
239
+ declare const plugin: PluginSVG;
240
+ //#endregion
241
+ export { RuleOptions, Rules, configs, plugin as default, plugin, meta, recommended, rules };