Skip to content

Commit bfbb583

Browse files
authored
chore: Naming convention linting (#28)
1 parent f0864eb commit bfbb583

File tree

8 files changed

+53
-45
lines changed

8 files changed

+53
-45
lines changed

.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@typescript-eslint/no-unused-vars": 0,
2525
"require-await": "off",
2626
"@typescript-eslint/require-await": "error",
27+
"@typescript-eslint/naming-convention": "error",
2728
"import/order": [
2829
2,
2930
{
@@ -39,7 +40,8 @@
3940
{
4041
"files": ["src/grpc/**/*.ts"],
4142
"rules": {
42-
"unicorn/no-null": 0
43+
"unicorn/no-null": 0,
44+
"@typescript-eslint/naming-convention": 0
4345
}
4446
},
4547
{

src/logger/logger.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import { createLogger as createWinstonLogger, format as winstonFormat, transports } from 'winston';
22

33
export enum LogLevel {
4-
TRACE = 'trace',
5-
DEBUG = 'debug',
6-
INFO = 'info',
7-
WARN = 'warn',
8-
ERROR = 'error',
4+
trace = 'trace',
5+
debug = 'debug',
6+
info = 'info',
7+
warn = 'warn',
8+
error = 'error',
99
}
1010

1111
export enum LogFormat {
12-
JSON = 'json',
13-
TEXT = 'text',
12+
json = 'json',
13+
text = 'text',
1414
}
1515

1616
export const createLogger = (level: LogLevel, format: LogFormat) => {
1717
// Winston doesn't have a TRACE level, so we need to normalize it to DEBUG.
18-
const normalizedLevel = level === LogLevel.TRACE ? LogLevel.DEBUG : level;
18+
const normalizedLevel = level === LogLevel.trace ? LogLevel.debug : level;
1919
const logger = createWinstonLogger({
2020
level: normalizedLevel,
21-
format: format == LogFormat.JSON ? winstonFormat.json() : winstonFormat.simple(),
21+
format: format == LogFormat.json ? winstonFormat.json() : winstonFormat.simple(),
2222
transports: [new transports.Console()],
2323
});
2424

src/plugin/serve.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ export const createServeCommand = (plugin: Plugin) => {
4545
description: 'network to bind to',
4646
default: 'tcp',
4747
},
48+
// eslint-disable-next-line @typescript-eslint/naming-convention
4849
'log-level': {
4950
alias: 'l',
5051
type: 'string',
5152
choices: Object.values(LogLevel),
5253
description: 'log level',
5354
default: 'info',
5455
},
56+
// eslint-disable-next-line @typescript-eslint/naming-convention
5557
'log-format': {
5658
alias: 'f',
5759
type: 'string',
@@ -64,16 +66,19 @@ export const createServeCommand = (plugin: Plugin) => {
6466
description: 'enable sentry reporting. Pass `--no-sentry` to disable.',
6567
default: true,
6668
},
69+
// eslint-disable-next-line @typescript-eslint/naming-convention
6770
'otel-endpoint': {
6871
type: 'string',
6972
description: 'OpenTelemetry collector endpoint',
7073
default: '',
7174
},
75+
// eslint-disable-next-line @typescript-eslint/naming-convention
7276
'otel-endpoint-insecure': {
7377
type: 'boolean',
7478
description: 'use Open Telemetry HTTP endpoint (for development only)',
7579
default: false,
7680
},
81+
// eslint-disable-next-line @typescript-eslint/naming-convention
7782
'telemetry-level': {
7883
type: 'string',
7984
description: 'CQ Telemetry level',

src/scalar/bool.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ import { Bool } from './bool.js';
77
[null, undefined].forEach((v) => {
88
test(`should set values to false when ${v} is passed`, (t) => {
99
const b = new Bool(v);
10-
t.is(b.Valid, false);
11-
t.true(DataType.isBool(b.DataType));
10+
t.is(b.valid, false);
11+
t.true(DataType.isBool(b.dataType));
1212
});
1313
});
1414

1515
[1, true, 'true', 'Y', 'y', 'TRUE', 'on', new Bool(true)].forEach((v, index) => {
1616
test(`should support truthy value '${v}' (${index})`, (t) => {
1717
const b = new Bool(v);
18-
t.is(b.Valid, true);
19-
t.is(b.Value, true);
20-
t.true(DataType.isBool(b.DataType));
18+
t.is(b.valid, true);
19+
t.is(b.value, true);
20+
t.true(DataType.isBool(b.dataType));
2121
t.is(b.toString(), 'true');
2222
});
2323
});
2424

2525
[0, false, 'false', 'N', 'n', 'FALSE', 'off'].forEach((v, index) => {
2626
test(`should support falsy value '${v}' (${index})`, (t) => {
2727
const b = new Bool(v);
28-
t.is(b.Valid, true);
29-
t.is(b.Value, false);
30-
t.true(DataType.isBool(b.DataType));
28+
t.is(b.valid, true);
29+
t.is(b.value, false);
30+
t.true(DataType.isBool(b.dataType));
3131
t.is(b.toString(), 'false');
3232
});
3333
});

src/scalar/bool.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ export class Bool {
88
private _value = false;
99

1010
public constructor(v: unknown) {
11-
this.Valid = v;
11+
this.valid = v;
1212
return this;
1313
}
1414

15-
public get DataType() {
15+
public get dataType() {
1616
return new ArrowBool();
1717
}
1818

19-
public get Valid(): boolean {
19+
public get valid(): boolean {
2020
return this._valid;
2121
}
2222

23-
public get Value(): boolean {
23+
public get value(): boolean {
2424
return this._value;
2525
}
2626

27-
public set Valid(value: unknown) {
27+
public set valid(value: unknown) {
2828
if (isInvalid(value)) {
2929
this._valid = false;
3030
return;
3131
}
3232

3333
if (value instanceof Bool) {
34-
this._valid = value.Valid;
35-
this._value = value.Value;
34+
this._valid = value.valid;
35+
this._value = value.value;
3636
return;
3737
}
3838

src/schema/column.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ export class Column {
66
name: string;
77
type: DataType;
88
description: string;
9-
primary_key: boolean;
10-
not_null: boolean;
11-
incremental_key: boolean;
9+
primaryKey: boolean;
10+
notNull: boolean;
11+
incrementalKey: boolean;
1212
unique: boolean;
1313

1414
constructor(
1515
name: string,
1616
type: DataType,
1717
description: string = '',
18-
primary_key: boolean = false,
19-
not_null: boolean = false,
20-
incremental_key: boolean = false,
18+
primaryKey: boolean = false,
19+
notNull: boolean = false,
20+
incrementalKey: boolean = false,
2121
unique: boolean = false,
2222
) {
2323
this.name = name;
2424
this.type = type;
2525
this.description = description;
26-
this.primary_key = primary_key;
27-
this.not_null = not_null;
28-
this.incremental_key = incremental_key;
26+
this.primaryKey = primaryKey;
27+
this.notNull = notNull;
28+
this.incrementalKey = incrementalKey;
2929
this.unique = unique;
3030
}
3131

3232
toString(): string {
33-
return `Column(name=${this.name}, type=${this.type}, description=${this.description}, primary_key=${this.primary_key}, not_null=${this.not_null}, incremental_key=${this.incremental_key}, unique=${this.unique})`;
33+
return `Column(name=${this.name}, type=${this.type}, description=${this.description}, primary_key=${this.primaryKey}, not_null=${this.notNull}, incremental_key=${this.incrementalKey}, unique=${this.unique})`;
3434
}
3535

3636
// JavaScript (and TypeScript) uses a single method for both string representation and debugging output
@@ -44,9 +44,9 @@ export class Column {
4444
this.name === value.name &&
4545
this.type === value.type &&
4646
this.description === value.description &&
47-
this.primary_key === value.primary_key &&
48-
this.not_null === value.not_null &&
49-
this.incremental_key === value.incremental_key &&
47+
this.primaryKey === value.primaryKey &&
48+
this.notNull === value.notNull &&
49+
this.incrementalKey === value.incrementalKey &&
5050
this.unique === value.unique
5151
);
5252
}
@@ -55,19 +55,19 @@ export class Column {
5555

5656
toArrowField(): Field {
5757
const metadataMap = new Map<string, string>();
58-
metadataMap.set(arrow.METADATA_PRIMARY_KEY, this.primary_key ? arrow.METADATA_TRUE : arrow.METADATA_FALSE);
58+
metadataMap.set(arrow.METADATA_PRIMARY_KEY, this.primaryKey ? arrow.METADATA_TRUE : arrow.METADATA_FALSE);
5959
metadataMap.set(arrow.METADATA_UNIQUE, this.unique ? arrow.METADATA_TRUE : arrow.METADATA_FALSE);
60-
metadataMap.set(arrow.METADATA_INCREMENTAL, this.incremental_key ? arrow.METADATA_TRUE : arrow.METADATA_FALSE);
60+
metadataMap.set(arrow.METADATA_INCREMENTAL, this.incrementalKey ? arrow.METADATA_TRUE : arrow.METADATA_FALSE);
6161

62-
return new Field(this.name, this.type, /*nullable=*/ !this.not_null, metadataMap);
62+
return new Field(this.name, this.type, /*nullable=*/ !this.notNull, metadataMap);
6363
}
6464

6565
static fromArrowField(field: Field): Column {
6666
const metadata = field.metadata;
67-
const primary_key = metadata.get(arrow.METADATA_PRIMARY_KEY) === arrow.METADATA_TRUE;
67+
const primaryKey = metadata.get(arrow.METADATA_PRIMARY_KEY) === arrow.METADATA_TRUE;
6868
const unique = metadata.get(arrow.METADATA_UNIQUE) === arrow.METADATA_TRUE;
69-
const incremental_key = metadata.get(arrow.METADATA_INCREMENTAL) === arrow.METADATA_TRUE;
69+
const incrementalKey = metadata.get(arrow.METADATA_INCREMENTAL) === arrow.METADATA_TRUE;
7070

71-
return new Column(field.name, field.type, '', primary_key, !field.nullable, unique, incremental_key);
71+
return new Column(field.name, field.type, '', primaryKey, !field.nullable, unique, incrementalKey);
7272
}
7373
}

src/transformers/openapi.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const OAPI_SPEC = {
1919
produces: ['application/json'],
2020
paths: {},
2121
definitions: {
22+
// eslint-disable-next-line @typescript-eslint/naming-convention
2223
TestDefinition: {
2324
type: 'object',
2425
properties: {

src/transformers/openapi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function oapiDefinitionToColumns(definition: OAPIDefinition, overrideColu
5959
const overrideColumn = getColumnByName(overrideColumns, key);
6060
if (overrideColumn) {
6161
column.type = overrideColumn.type;
62-
column.primary_key = overrideColumn.primary_key;
62+
column.primaryKey = overrideColumn.primaryKey;
6363
column.unique = overrideColumn.unique;
6464
}
6565
columns.push(column);

0 commit comments

Comments
 (0)