Skip to content

Commit

Permalink
Eslint naming convention
Browse files Browse the repository at this point in the history
- PR #550 suggested a lint check for type naming conventions
  • Loading branch information
irahopkinson committed Oct 20, 2023
1 parent 1ffa861 commit e0d2b43
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ module.exports = {
{ exceptAfterSingleLine: true, exceptAfterOverload: true },
],
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variableLike',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
},
{
selector: 'enumMember',
format: ['PascalCase'],
},
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
],
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': [
'error',
Expand Down
4 changes: 2 additions & 2 deletions lib/papi-dts/papi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ declare module 'shared/utils/papi-util' {
* papiUtil is a collection of functions, objects, and types that are used as helpers in other services.
* Extensions should not use or rely on anything in papiUtil unless some other service requires it.
*/
export type moduleSummaryComments = {};
export type ModuleSummaryComments = {};
}
declare module 'shared/models/papi-event.model' {
import { Unsubscriber, UnsubscriberAsync } from 'shared/utils/papi-util';
Expand Down Expand Up @@ -1663,7 +1663,7 @@ declare module 'shared/services/command.service' {
* You can register a command that other services and extensions can send you.
* You can send commands to other services and extensions that have registered commands.
*/
export type moduleSummaryComments = {};
export type ModuleSummaryComments = {};
}
declare module 'shared/data/web-view.model' {
import { ReactNode } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion src/shared/services/command.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,4 @@ export const registerCommand: <CommandName extends CommandNames>(
* You can register a command that other services and extensions can send you.
* You can send commands to other services and extensions that have registered commands.
*/
export type moduleSummaryComments = {};
export type ModuleSummaryComments = {};
6 changes: 3 additions & 3 deletions src/shared/services/logger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const WARN_TAG = '<WARN>';
/**
* Represents details that can be parsed from a single line of an Error object
*/
type parsedErrorLine =
type ParsedErrorLine =
| {
functionName: string;
fileName: string;
Expand All @@ -22,7 +22,7 @@ type parsedErrorLine =
* @returns Object containing the function name, file name, line number, and column number from the
* line of the Error object string. If the line couldn't be parsed, then undefined.
*/
function parseErrorLine(errorLine: string): parsedErrorLine {
function parseErrorLine(errorLine: string): ParsedErrorLine {
// A few example lines to parse:
// " at functionName (filename.js:15:27)"
// "at /home/username/paranext-core/src/shared/services/logger.service.ts:119:22"
Expand Down Expand Up @@ -65,7 +65,7 @@ function parseErrorLine(errorLine: string): parsedErrorLine {
function identifyCaller(): string | undefined {
const { stack } = new Error();
if (!stack) return undefined;
let details: parsedErrorLine;
let details: ParsedErrorLine;
const lines = stack.split('\n');
// Start at 3 to skip the "Error" line, this function's stack frame, and this function's caller
for (let lineNumber = 3; lineNumber < lines.length; lineNumber += 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/utils/papi-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ export function getModuleSimilarApiMessage(moduleName: string) {
* papiUtil is a collection of functions, objects, and types that are used as helpers in other services.
* Extensions should not use or rely on anything in papiUtil unless some other service requires it.
*/
export type moduleSummaryComments = {};
export type ModuleSummaryComments = {};

0 comments on commit e0d2b43

Please sign in to comment.