Skip to content

Commit 2d93e6f

Browse files
authored
chore: turn on padding-line-between-statements (#1691)
1 parent e296ff2 commit 2d93e6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+127
-13
lines changed

.eslintrc.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ module.exports = defineConfig({
3434
'@typescript-eslint/ban-ts-comment': 'warn',
3535
'@typescript-eslint/consistent-type-imports': 'error',
3636
'@typescript-eslint/explicit-module-boundary-types': 'error',
37+
'@typescript-eslint/naming-convention': [
38+
'error',
39+
{
40+
format: ['PascalCase'],
41+
selector: ['class', 'interface', 'typeAlias', 'enumMember'],
42+
leadingUnderscore: 'forbid',
43+
trailingUnderscore: 'forbid',
44+
},
45+
],
3746
'@typescript-eslint/no-inferrable-types': [
3847
'error',
3948
{ ignoreParameters: true },
@@ -43,23 +52,15 @@ module.exports = defineConfig({
4352
'@typescript-eslint/no-unsafe-call': 'off',
4453
'@typescript-eslint/no-unsafe-member-access': 'off',
4554
'@typescript-eslint/no-unsafe-return': 'warn',
46-
'@typescript-eslint/restrict-template-expressions': [
55+
'@typescript-eslint/padding-line-between-statements': [
4756
'error',
48-
{
49-
allowNumber: true,
50-
allowBoolean: true,
51-
},
57+
{ blankLine: 'always', prev: 'block-like', next: '*' },
5258
],
53-
'@typescript-eslint/unbound-method': 'off',
54-
'@typescript-eslint/naming-convention': [
59+
'@typescript-eslint/restrict-template-expressions': [
5560
'error',
56-
{
57-
format: ['PascalCase'],
58-
selector: ['class', 'interface', 'typeAlias', 'enumMember'],
59-
leadingUnderscore: 'forbid',
60-
trailingUnderscore: 'forbid',
61-
},
61+
{ allowNumber: true, allowBoolean: true },
6262
],
63+
'@typescript-eslint/unbound-method': 'off',
6364
},
6465
overrides: [
6566
{

scripts/apidoc/apiDocsWriter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export function writeApiSearchIndex(project: ProjectReflection): void {
161161
},
162162
];
163163
}
164+
164165
return apiSection;
165166
})
166167
.sort((a, b) => a.text.localeCompare(b.text));

scripts/apidoc/moduleMethods.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export function extractModuleName(module: DeclarationReflection): string {
4646
} else if (name === 'NameModule') {
4747
return 'Person';
4848
}
49+
4950
return name.replace(/Module$/, '');
5051
}
5152

scripts/apidoc/parameterDefaults.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function cleanParameterDefault(value?: string): string | undefined {
5252
if (value == null) {
5353
return undefined;
5454
}
55+
5556
// Strip type casts: "'foobar' as unknown as T" => "'foobar'"
5657
return value.replace(/ as unknown as [A-Za-z<>]+/, '');
5758
}
@@ -124,6 +125,7 @@ function patchSignatureParameterDefaults(
124125
if (signatureParameters.length !== parameterDefaults.length) {
125126
throw new Error('Unexpected parameter length mismatch');
126127
}
128+
127129
signatureParameters.forEach(
128130
(param, index) =>
129131
(param.defaultValue = parameterDefaults[index] || param.defaultValue)

scripts/apidoc/signature.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export function analyzeSignature(
142142
if (signatureTypeParameters.length !== 0) {
143143
signatureTypeParametersString = `<${signatureTypeParameters.join(', ')}>`;
144144
}
145+
145146
const signatureParametersString = signatureParameters.join(', ');
146147

147148
let examples: string;
@@ -150,6 +151,7 @@ export function analyzeSignature(
150151
} else {
151152
examples = `faker.${methodName}${signatureTypeParametersString}(${signatureParametersString}): ${signature.type?.toString()}\n`;
152153
}
154+
153155
faker.seed(0);
154156
if (moduleName) {
155157
try {
@@ -230,6 +232,7 @@ function analyzeParameterOptions(
230232
if (!parameterType) {
231233
return [];
232234
}
235+
233236
if (parameterType.type === 'union') {
234237
return parameterType.types.flatMap((type) =>
235238
analyzeParameterOptions(name, type)
@@ -261,6 +264,7 @@ function typeToText(type_?: Type, short = false): string {
261264
if (!type_) {
262265
return '?';
263266
}
267+
264268
const type = type_ as SomeType;
265269
switch (type.type) {
266270
case 'array':
@@ -283,6 +287,7 @@ function typeToText(type_?: Type, short = false): string {
283287
.map((t) => typeToText(t, short))
284288
.join(', ')}>`;
285289
}
290+
286291
case 'reflection':
287292
return declarationTypeToText(type.declaration, short);
288293
case 'indexedAccess':
@@ -335,6 +340,7 @@ function signatureTypeToText(signature?: SignatureReflection): string {
335340
if (!signature) {
336341
return '(???) => ?';
337342
}
343+
338344
return `(${signature.parameters
339345
?.map((p) => `${p.name}: ${typeToText(p.type)}`)
340346
.join(', ')}) => ${typeToText(signature.type)}`;
@@ -350,18 +356,22 @@ function extractDefaultFromComment(comment?: Comment): string | undefined {
350356
if (!comment) {
351357
return;
352358
}
359+
353360
const summary = comment.summary;
354361
const text = joinTagParts(summary).trim();
355362
if (!text) {
356363
return;
357364
}
365+
358366
const result = /^(.*)[ \n]Defaults to `([^`]+)`\.(.*)$/s.exec(text);
359367
if (!result) {
360368
return;
361369
}
370+
362371
if (result[3].trim()) {
363372
throw new Error(`Found description text after the default value:\n${text}`);
364373
}
374+
365375
summary.splice(summary.length - 2, 2);
366376
const lastSummaryPart = summary[summary.length - 1];
367377
lastSummaryPart.text = lastSummaryPart.text.replace(/[ \n]Defaults to $/, '');

scripts/apidoc/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export function extractSeeAlsos(signature?: SignatureReflection): string[] {
122122
if (link.startsWith('-')) {
123123
link = link.slice(1).trim();
124124
}
125+
125126
return link;
126127
})
127128
.filter((link) => link)

scripts/bundle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const target = ['ES2019', 'node14.17'];
1212
if (existsSync(localeDir)) {
1313
rmSync(localeDir, { recursive: true, force: true });
1414
}
15+
1516
mkdirSync(localeDir);
1617
for (const locale of Object.keys(locales)) {
1718
writeFileSync(

scripts/generateLocales.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ function removeIndexTs(files: string[]): string[] {
8282
if (index !== -1) {
8383
files.splice(index, 1);
8484
}
85+
8586
return files;
8687
}
8788

@@ -152,6 +153,7 @@ function tryLoadLocalesMainIndexFile(pathModules: string): LocaleDefinition {
152153
console.error(`Failed to load ${pathModules} or manually parse it.`, e);
153154
}
154155
}
156+
155157
return localeDef;
156158
}
157159

@@ -177,6 +179,7 @@ function generateLocalesIndexFile(
177179
)}';`
178180
);
179181
}
182+
180183
content.push(
181184
...modules.map((m) => `import ${escapeImport(m)} from './${m}';`)
182185
);

src/faker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export class Faker {
6262
`Locale ${locale} is not supported. You might want to add the requested locale first to \`faker.locales\`.`
6363
);
6464
}
65+
6566
this._locale = locale;
6667
}
6768

@@ -75,6 +76,7 @@ export class Faker {
7576
`Locale ${localeFallback} is not supported. You might want to add the requested locale first to \`faker.locales\`.`
7677
);
7778
}
79+
7880
this._localeFallback = localeFallback;
7981
}
8082

src/internal/mersenne/twister.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export default class MersenneTwister19937 {
129129
sum = this.addition32(sum, this.unsigned32(n2 << i));
130130
}
131131
}
132+
132133
return sum;
133134
}
134135

@@ -194,10 +195,12 @@ export default class MersenneTwister19937 {
194195
this.mt[0] = this.mt[this.N - 1];
195196
i = 1;
196197
}
198+
197199
if (j >= keyLength) {
198200
j = 0;
199201
}
200202
}
203+
201204
for (k = this.N - 1; k; k--) {
202205
// mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941)) - i
203206
this.mt[i] = this.subtraction32(
@@ -218,6 +221,7 @@ export default class MersenneTwister19937 {
218221
i = 1;
219222
}
220223
}
224+
221225
this.mt[0] = 0x80000000; // MSB is 1; assuring non-zero initial array
222226
}
223227

src/modules/animal/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class AnimalModule {
1010
if (name === 'constructor' || typeof this[name] !== 'function') {
1111
continue;
1212
}
13+
1314
this[name] = this[name].bind(this);
1415
}
1516
}

src/modules/color/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ function formatHexColor(
5858
hexColor = hexColor.toLowerCase();
5959
break;
6060
}
61+
6162
if (options?.prefix) {
6263
hexColor = options.prefix + hexColor;
6364
}
65+
6466
return hexColor;
6567
}
6668

@@ -78,6 +80,7 @@ function toBinary(values: number[]): string {
7880
const bytes = new Uint8Array(buffer);
7981
return toBinary(Array.from(bytes)).split(' ').join('');
8082
}
83+
8184
return (value >>> 0).toString(2).padStart(8, '0');
8285
});
8386
return binary.join(' ');
@@ -161,6 +164,7 @@ export class ColorModule {
161164
if (name === 'constructor' || typeof this[name] !== 'function') {
162165
continue;
163166
}
167+
164168
this[name] = this[name].bind(this);
165169
}
166170
}
@@ -320,11 +324,13 @@ export class ColorModule {
320324
color = formatHexColor(color, options);
321325
return color;
322326
}
327+
323328
color = Array.from({ length: 3 }, () => this.faker.number.int(255));
324329
if (includeAlpha) {
325330
color.push(this.faker.number.float());
326331
cssFunction = 'rgba';
327332
}
333+
328334
return toColorFormat(color, format, cssFunction);
329335
}
330336

@@ -460,6 +466,7 @@ export class ColorModule {
460466
for (let i = 0; i < (options?.includeAlpha ? 3 : 2); i++) {
461467
hsl.push(this.faker.number.float());
462468
}
469+
463470
return toColorFormat(
464471
hsl,
465472
options?.format || 'decimal',
@@ -537,6 +544,7 @@ export class ColorModule {
537544
for (let i = 0; i < 2; i++) {
538545
hsl.push(this.faker.number.float());
539546
}
547+
540548
return toColorFormat(hsl, options?.format || 'decimal', 'hwb');
541549
}
542550

@@ -598,6 +606,7 @@ export class ColorModule {
598606
this.faker.number.float({ min: -100, max: 100, precision: 0.0001 })
599607
);
600608
}
609+
601610
return toColorFormat(lab, options?.format || 'decimal', 'lab');
602611
}
603612

@@ -669,6 +678,7 @@ export class ColorModule {
669678
for (let i = 0; i < 2; i++) {
670679
lch.push(this.faker.number.float({ max: 230, precision: 0.1 }));
671680
}
681+
672682
return toColorFormat(lch, options?.format || 'decimal', 'lch');
673683
}
674684

@@ -742,6 +752,7 @@ export class ColorModule {
742752
if (options?.format === 'css' && !options?.space) {
743753
options = { ...options, space: 'sRGB' };
744754
}
755+
745756
const color = Array.from({ length: 3 }, () =>
746757
this.faker.number.float({ precision: 0.0001 })
747758
);

src/modules/commerce/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class CommerceModule {
1010
if (name === 'constructor' || typeof this[name] !== 'function') {
1111
continue;
1212
}
13+
1314
this[name] = this[name].bind(this);
1415
}
1516
}

src/modules/company/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class CompanyModule {
1010
if (name === 'constructor' || typeof this[name] !== 'function') {
1111
continue;
1212
}
13+
1314
this[name] = this[name].bind(this);
1415
}
1516
}

src/modules/database/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class DatabaseModule {
1010
if (name === 'constructor' || typeof this[name] !== 'function') {
1111
continue;
1212
}
13+
1314
this[name] = this[name].bind(this);
1415
}
1516
}

src/modules/datatype/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class DatatypeModule {
1111
if (name === 'constructor' || typeof this[name] !== 'function') {
1212
continue;
1313
}
14+
1415
this[name] = this[name].bind(this);
1516
}
1617
}
@@ -211,14 +212,17 @@ export class DatatypeModule {
211212
probability: options,
212213
};
213214
}
215+
214216
const { probability = 0.5 } = options;
215217
if (probability <= 0) {
216218
return false;
217219
}
220+
218221
if (probability >= 1) {
219222
// This check is required to avoid returning false when float() returns 1
220223
return true;
221224
}
225+
222226
return this.faker.number.float() < probability;
223227
}
224228

src/modules/date/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class DateModule {
2828
if (name === 'constructor' || typeof this[name] !== 'function') {
2929
continue;
3030
}
31+
3132
this[name] = this[name].bind(this);
3233
}
3334
}

src/modules/finance/iban.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,7 @@ const iban: Iban = {
14011401
for (let i = 0; i < digitStr.length; i++) {
14021402
m = (m * 10 + +digitStr[i]) % 97;
14031403
}
1404+
14041405
return m;
14051406
},
14061407
pattern10: ['01', '02', '03', '04', '05', '06', '07', '08', '09'],

0 commit comments

Comments
 (0)