1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Tools: Add eslint rule "@typescript-eslint/no-inferrable-types"

This commit is contained in:
Laurent Cozic
2023-02-05 11:32:28 +00:00
parent e629a4d325
commit 0019bb8d6b
18 changed files with 24 additions and 23 deletions

View File

@ -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',

View File

@ -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;

View File

@ -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);

View File

@ -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 {

View File

@ -15,7 +15,7 @@ interface AdvancedExpression {
function parseAdvancedExpression(advancedExpression: string): AdvancedExpression {
let subExpressionIndex = -1;
let subExpressions: string = '';
let subExpressions = '';
let currentSubExpressionKey = '';
const subContext: any = {};

View File

@ -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 = {};

View File

@ -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 = {
@ -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[] = [];

View File

@ -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

View File

@ -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({

View File

@ -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() {

View File

@ -271,7 +271,7 @@ async function commandVersion() {
}
async function main() {
const scriptName: string = 'plugin-repo-cli';
const scriptName = 'plugin-repo-cli';
const commands: Record<string, Function> = {
build: commandBuild,
@ -279,8 +279,8 @@ async function main() {
updateRelease: commandUpdateRelease,
};
let selectedCommand: string = '';
let selectedCommandArgs: string = '';
let selectedCommand = '';
let selectedCommandArgs = '';
function setSelectedCommand(name: string, args: any) {
selectedCommand = name;

View File

@ -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) {
@ -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) {

View File

@ -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_;

View File

@ -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;

View File

@ -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);
@ -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;

View File

@ -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);

View File

@ -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';
@ -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);

View File

@ -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[] = [];