Skip to content

Commit

Permalink
Tools: Add eslint rule "@typescript-eslint/no-inferrable-types"
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Feb 5, 2023
1 parent e629a4d commit 0019bb8
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 23 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ module.exports = {
// make everything public which is not great. New code however should specify member accessibility.
'@typescript-eslint/explicit-member-accessibility': ['warn'],
'@typescript-eslint/type-annotation-spacing': ['error', { 'before': false, 'after': true }],
'@typescript-eslint/no-inferrable-types': ['error', { 'ignoreParameters': true, 'ignoreProperties': true }],
'@typescript-eslint/comma-dangle': ['error', {
'arrays': 'always-multiline',
'objects': 'always-multiline',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const { space } = require('styled-system');

const logger = Logger.create('PluginState');

const maxWidth: number = 320;
const maxWidth = 320;

const Root = styled.div`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ interface LastOnChangeEventInfo {
let loadedCssFiles_: string[] = [];
let loadedJsFiles_: string[] = [];
let dispatchDidUpdateIID_: any = null;
let changeId_: number = 1;
let changeId_ = 1;

const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
const [editor, setEditor] = useState(null);
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/services/ReportService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default class ReportService {

for (let i = 0; i < disabledItems.length; i++) {
const row = disabledItems[i];
let msg: string = '';
let msg = '';
if (row.location === BaseItem.SYNC_ITEM_LOCATION_LOCAL) {
msg = _('%s (%s) could not be uploaded: %s', row.item.title, row.item.id, row.syncInfo.sync_disabled_reason);
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/services/WhenClause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface AdvancedExpression {

function parseAdvancedExpression(advancedExpression: string): AdvancedExpression {
let subExpressionIndex = -1;
let subExpressions: string = '';
let subExpressions = '';
let currentSubExpressionKey = '';
const subContext: any = {};

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/services/commands/MenuUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default class MenuUtils {
}

public commandsToMenuItems(commandNames: string[], onClick: Function, locale: string): MenuItems {
const key: string = `${this.keymapService.lastSaveTime}_${commandNames.join('_')}_${locale}`;
const key = `${this.keymapService.lastSaveTime}_${commandNames.join('_')}_${locale}`;
if (this.menuItemCache_[key]) return this.menuItemCache_[key];

const output: MenuItems = {};
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/services/debug/populateDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default async function populateDatabase(db: any, options: Options = null)
const createdTagIds: string[] = [];
const createdFolderDepths: Record<string, number> = {};
const folderDepthToId: Record<number, string[]> = {};
let rootFolderCount: number = 0;
let rootFolderCount = 0;

for (let i = 0; i < options.folderCount; i++) {
const folder: any = {
Expand All @@ -72,7 +72,7 @@ export default async function populateDatabase(db: any, options: Options = null)

if (options.rootFolderCount && rootFolderCount >= options.rootFolderCount) isRoot = false;

let depth: number = 0;
let depth = 0;

if (!isRoot) {
let possibleFolderIds: string[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default class InteropService_Importer_Md extends InteropService_Importer_
if (stat && !isDir) {
const supportedFileExtension = this.metadata().fileExtensions;
const resolvedPath = shim.fsDriver().resolve(pathWithExtension);
let id: string = '';
let id = '';
// If the link looks like a note, then import it
if (supportedFileExtension.indexOf(fileExtension(trimmedLink).toLowerCase()) >= 0) {
// If the note hasn't been imported yet, do so now
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/services/share/ShareService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe('ShareService', function() {
const recipientPpk = await generateKeyPair(encryptionService(), '222222');
expect(ppk.id).not.toBe(recipientPpk.id);

let uploadedEmail: string = '';
let uploadedEmail = '';
let uploadedMasterKey: MasterKeyEntity = null;

const service = testShareFolderService({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async function testMigrationE2EE(migrationVersion: number, maxSyncVersion: numbe
await expectNotThrow(async () => await checkTestData(testData));
}

let previousSyncTargetName: string = '';
let previousSyncTargetName = '';

describe('MigrationHandler', function() {

Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-repo-cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,16 @@ async function commandVersion() {
}

async function main() {
const scriptName: string = 'plugin-repo-cli';
const scriptName = 'plugin-repo-cli';

const commands: Record<string, Function> = {
build: commandBuild,
version: commandVersion,
updateRelease: commandUpdateRelease,
};

let selectedCommand: string = '';
let selectedCommandArgs: string = '';
let selectedCommand = '';
let selectedCommandArgs = '';

function setSelectedCommand(name: string, args: any) {
selectedCommand = name;
Expand Down
4 changes: 2 additions & 2 deletions packages/renderer/MdToHtml/rules/katex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export default {
// set KaTeX as the renderer for markdown-it-simplemath
const katexInline = function(latex: string) {
katexOptions.displayMode = false;
let outputHtml: string = '';
let outputHtml = '';
try {
outputHtml = renderToStringWithCache(latex, katexOptions);
} catch (error) {
Expand All @@ -306,7 +306,7 @@ export default {

const katexBlock = function(latex: string) {
katexOptions.displayMode = true;
let outputHtml: string = '';
let outputHtml = '';
try {
outputHtml = renderToStringWithCache(latex, katexOptions);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface PackageJson {

const packageJson: PackageJson = require(`${__dirname}/packageInfo.js`);

let runningInDocker_: boolean = false;
let runningInDocker_ = false;

export function runningInDocker(): boolean {
return runningInDocker_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default async function(config: StorageDriverConfig | number, db: DbConnec
...options,
};

let storageId: number = 0;
let storageId = 0;

if (typeof config === 'number') {
storageId = config;
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/routes/index/password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface ResetPasswordFields {

const subRoutes: Record<string, RouteHandler> = {
forgot: async (_path: SubPath, ctx: AppContext) => {
let confirmationMessage: string = '';
let confirmationMessage = '';

if (ctx.method === 'POST') {
const fields = await bodyFields<ForgotPasswordFields>(ctx.req);
Expand All @@ -46,7 +46,7 @@ const subRoutes: Record<string, RouteHandler> = {
},

reset: async (_path: SubPath, ctx: AppContext) => {
let successMessage: string = '';
let successMessage = '';
let error: Error = null;
const token = ctx.query.token as string;

Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/services/UserDeletionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default class UserDeletionService extends BaseService {
}

let error: any = null;
let success: boolean = true;
let success = true;

try {
await this.models.userDeletion().start(deletion.id);
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/tools/generateTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sqlts from '@rmp135/sql-ts';

require('source-map-support').install();

const dbFilePath: string = `${__dirname}/../../src/services/database/types.ts`;
const dbFilePath = `${__dirname}/../../src/services/database/types.ts`;

const fileReplaceWithinMarker = '// AUTO-GENERATED-TYPES';

Expand Down Expand Up @@ -74,7 +74,7 @@ function insertContentIntoFile(filePath: string, markerOpen: string, markerClose
if (!fs.existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
let content: string = fs.readFileSync(filePath, 'utf-8');
// [^]* matches any character including new lines
const regex: RegExp = new RegExp(`${markerOpen}[^]*?${markerClose}`);
const regex = new RegExp(`${markerOpen}[^]*?${markerClose}`);
if (!content.match(regex)) throw new Error(`Could not find markers: ${markerOpen}`);
content = content.replace(regex, `${markerOpen}\n${contentToInsert}\n${markerClose}`);
fs.writeFileSync(filePath, content);
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/website/utils/frontMatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const readProp = (line: string): string[] => {
export const stripOffFrontMatter = (md: string): MarkdownAndFrontMatter => {
if (md.indexOf('---') !== 0) return { doc: md };

let state: string = 'start';
let state = 'start';
const lines = md.split('\n');
const docLines: string[] = [];

Expand Down

0 comments on commit 0019bb8

Please sign in to comment.