Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 9db7e71

Browse files
committed
Use json-schema-to-typescript for third schema
1 parent c3fd7f9 commit 9db7e71

File tree

2 files changed

+46
-37
lines changed

2 files changed

+46
-37
lines changed

scripts/generate-files.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,31 @@ async function main(): Promise<void> {
7070
const mainSchema: JSONSchema4 | undefined = Array.isArray(schema) ? schema[0] : schema;
7171
const sideSchema: JSONSchema4 | undefined =
7272
schema && Array.isArray(schema) && schema.length > 1 ? schema[1] : undefined;
73-
// TODO: vue/max-len has also a third schema
73+
const thirdSchema: JSONSchema4 | undefined =
74+
schema && Array.isArray(schema) && schema.length > 2 ? schema[2] : undefined;
7475
if (mainSchema) {
7576
if (sideSchema) {
77+
if (thirdSchema) {
78+
const ruleSetting: string = await compile(thirdSchema, `${ruleNamePascalCase}Setting`, {
79+
bannerComment: '',
80+
style: {
81+
bracketSpacing: true,
82+
printWidth: 120,
83+
semi: true,
84+
singleQuote: true,
85+
tabWidth: 2,
86+
trailingComma: 'none',
87+
useTabs: false
88+
},
89+
unknownAny: false
90+
});
91+
ruleContent += `
92+
93+
/**
94+
* Setting.
95+
*/
96+
${ruleSetting}`;
97+
}
7698
const ruleConfig: string = await compile(sideSchema, `${ruleNamePascalCase}Config`, {
7799
bannerComment: '',
78100
style: {
@@ -119,7 +141,7 @@ ${ruleOption}
119141
* Options.
120142
*/
121143
export type ${ruleNamePascalCase}Options = [${ruleNamePascalCase}Option?${
122-
sideSchema ? `, ${ruleNamePascalCase}Config?` : ''
144+
sideSchema ? `, ${ruleNamePascalCase}Config?${thirdSchema ? `, ${ruleNamePascalCase}Setting?` : ''}` : ''
123145
}];`;
124146
}
125147

src/rules/vue/max-len.d.ts

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,38 @@
11
import type { RuleConfig } from '../rule-config';
22

3+
/**
4+
* Setting.
5+
*/
6+
export interface MaxLenSetting {
7+
code?: number;
8+
template?: number;
9+
comments?: number;
10+
tabWidth?: number;
11+
ignorePattern?: string;
12+
ignoreComments?: boolean;
13+
ignoreTrailingComments?: boolean;
14+
ignoreUrls?: boolean;
15+
ignoreStrings?: boolean;
16+
ignoreTemplateLiterals?: boolean;
17+
ignoreRegExpLiterals?: boolean;
18+
ignoreHTMLAttributeValues?: boolean;
19+
ignoreHTMLTextContents?: boolean;
20+
}
21+
322
/**
423
* Config.
524
*/
6-
export type MaxLenConfig =
7-
| {
8-
code?: number;
9-
template?: number;
10-
comments?: number;
11-
tabWidth?: number;
12-
ignorePattern?: string;
13-
ignoreComments?: boolean;
14-
ignoreTrailingComments?: boolean;
15-
ignoreUrls?: boolean;
16-
ignoreStrings?: boolean;
17-
ignoreTemplateLiterals?: boolean;
18-
ignoreRegExpLiterals?: boolean;
19-
ignoreHTMLAttributeValues?: boolean;
20-
ignoreHTMLTextContents?: boolean;
21-
}
22-
| number;
25+
export type MaxLenConfig = MaxLenSetting | number;
2326

2427
/**
2528
* Option.
2629
*/
27-
export type MaxLenOption =
28-
| {
29-
code?: number;
30-
template?: number;
31-
comments?: number;
32-
tabWidth?: number;
33-
ignorePattern?: string;
34-
ignoreComments?: boolean;
35-
ignoreTrailingComments?: boolean;
36-
ignoreUrls?: boolean;
37-
ignoreStrings?: boolean;
38-
ignoreTemplateLiterals?: boolean;
39-
ignoreRegExpLiterals?: boolean;
40-
ignoreHTMLAttributeValues?: boolean;
41-
ignoreHTMLTextContents?: boolean;
42-
}
43-
| number;
30+
export type MaxLenOption = MaxLenSetting | number;
4431

4532
/**
4633
* Options.
4734
*/
48-
export type MaxLenOptions = [MaxLenOption?, MaxLenConfig?];
35+
export type MaxLenOptions = [MaxLenOption?, MaxLenConfig?, MaxLenSetting?];
4936

5037
/**
5138
* Enforce a maximum line length

0 commit comments

Comments
 (0)