You've already forked joplin
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:
@ -159,6 +159,7 @@ module.exports = {
|
|||||||
// make everything public which is not great. New code however should specify member accessibility.
|
// make everything public which is not great. New code however should specify member accessibility.
|
||||||
'@typescript-eslint/explicit-member-accessibility': ['warn'],
|
'@typescript-eslint/explicit-member-accessibility': ['warn'],
|
||||||
'@typescript-eslint/type-annotation-spacing': ['error', { 'before': false, 'after': true }],
|
'@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', {
|
'@typescript-eslint/comma-dangle': ['error', {
|
||||||
'arrays': 'always-multiline',
|
'arrays': 'always-multiline',
|
||||||
'objects': 'always-multiline',
|
'objects': 'always-multiline',
|
||||||
|
@ -20,7 +20,7 @@ const { space } = require('styled-system');
|
|||||||
|
|
||||||
const logger = Logger.create('PluginState');
|
const logger = Logger.create('PluginState');
|
||||||
|
|
||||||
const maxWidth: number = 320;
|
const maxWidth = 320;
|
||||||
|
|
||||||
const Root = styled.div`
|
const Root = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -102,7 +102,7 @@ interface LastOnChangeEventInfo {
|
|||||||
let loadedCssFiles_: string[] = [];
|
let loadedCssFiles_: string[] = [];
|
||||||
let loadedJsFiles_: string[] = [];
|
let loadedJsFiles_: string[] = [];
|
||||||
let dispatchDidUpdateIID_: any = null;
|
let dispatchDidUpdateIID_: any = null;
|
||||||
let changeId_: number = 1;
|
let changeId_ = 1;
|
||||||
|
|
||||||
const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||||
const [editor, setEditor] = useState(null);
|
const [editor, setEditor] = useState(null);
|
||||||
|
@ -178,7 +178,7 @@ export default class ReportService {
|
|||||||
|
|
||||||
for (let i = 0; i < disabledItems.length; i++) {
|
for (let i = 0; i < disabledItems.length; i++) {
|
||||||
const row = disabledItems[i];
|
const row = disabledItems[i];
|
||||||
let msg: string = '';
|
let msg = '';
|
||||||
if (row.location === BaseItem.SYNC_ITEM_LOCATION_LOCAL) {
|
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);
|
msg = _('%s (%s) could not be uploaded: %s', row.item.title, row.item.id, row.syncInfo.sync_disabled_reason);
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,7 +15,7 @@ interface AdvancedExpression {
|
|||||||
|
|
||||||
function parseAdvancedExpression(advancedExpression: string): AdvancedExpression {
|
function parseAdvancedExpression(advancedExpression: string): AdvancedExpression {
|
||||||
let subExpressionIndex = -1;
|
let subExpressionIndex = -1;
|
||||||
let subExpressions: string = '';
|
let subExpressions = '';
|
||||||
let currentSubExpressionKey = '';
|
let currentSubExpressionKey = '';
|
||||||
const subContext: any = {};
|
const subContext: any = {};
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ export default class MenuUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public commandsToMenuItems(commandNames: string[], onClick: Function, locale: string): MenuItems {
|
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];
|
if (this.menuItemCache_[key]) return this.menuItemCache_[key];
|
||||||
|
|
||||||
const output: MenuItems = {};
|
const output: MenuItems = {};
|
||||||
|
@ -61,7 +61,7 @@ export default async function populateDatabase(db: any, options: Options = null)
|
|||||||
const createdTagIds: string[] = [];
|
const createdTagIds: string[] = [];
|
||||||
const createdFolderDepths: Record<string, number> = {};
|
const createdFolderDepths: Record<string, number> = {};
|
||||||
const folderDepthToId: Record<number, string[]> = {};
|
const folderDepthToId: Record<number, string[]> = {};
|
||||||
let rootFolderCount: number = 0;
|
let rootFolderCount = 0;
|
||||||
|
|
||||||
for (let i = 0; i < options.folderCount; i++) {
|
for (let i = 0; i < options.folderCount; i++) {
|
||||||
const folder: any = {
|
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;
|
if (options.rootFolderCount && rootFolderCount >= options.rootFolderCount) isRoot = false;
|
||||||
|
|
||||||
let depth: number = 0;
|
let depth = 0;
|
||||||
|
|
||||||
if (!isRoot) {
|
if (!isRoot) {
|
||||||
let possibleFolderIds: string[] = [];
|
let possibleFolderIds: string[] = [];
|
||||||
|
@ -110,7 +110,7 @@ export default class InteropService_Importer_Md extends InteropService_Importer_
|
|||||||
if (stat && !isDir) {
|
if (stat && !isDir) {
|
||||||
const supportedFileExtension = this.metadata().fileExtensions;
|
const supportedFileExtension = this.metadata().fileExtensions;
|
||||||
const resolvedPath = shim.fsDriver().resolve(pathWithExtension);
|
const resolvedPath = shim.fsDriver().resolve(pathWithExtension);
|
||||||
let id: string = '';
|
let id = '';
|
||||||
// If the link looks like a note, then import it
|
// If the link looks like a note, then import it
|
||||||
if (supportedFileExtension.indexOf(fileExtension(trimmedLink).toLowerCase()) >= 0) {
|
if (supportedFileExtension.indexOf(fileExtension(trimmedLink).toLowerCase()) >= 0) {
|
||||||
// If the note hasn't been imported yet, do so now
|
// If the note hasn't been imported yet, do so now
|
||||||
|
@ -188,7 +188,7 @@ describe('ShareService', function() {
|
|||||||
const recipientPpk = await generateKeyPair(encryptionService(), '222222');
|
const recipientPpk = await generateKeyPair(encryptionService(), '222222');
|
||||||
expect(ppk.id).not.toBe(recipientPpk.id);
|
expect(ppk.id).not.toBe(recipientPpk.id);
|
||||||
|
|
||||||
let uploadedEmail: string = '';
|
let uploadedEmail = '';
|
||||||
let uploadedMasterKey: MasterKeyEntity = null;
|
let uploadedMasterKey: MasterKeyEntity = null;
|
||||||
|
|
||||||
const service = testShareFolderService({
|
const service = testShareFolderService({
|
||||||
|
@ -141,7 +141,7 @@ async function testMigrationE2EE(migrationVersion: number, maxSyncVersion: numbe
|
|||||||
await expectNotThrow(async () => await checkTestData(testData));
|
await expectNotThrow(async () => await checkTestData(testData));
|
||||||
}
|
}
|
||||||
|
|
||||||
let previousSyncTargetName: string = '';
|
let previousSyncTargetName = '';
|
||||||
|
|
||||||
describe('MigrationHandler', function() {
|
describe('MigrationHandler', function() {
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ async function commandVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const scriptName: string = 'plugin-repo-cli';
|
const scriptName = 'plugin-repo-cli';
|
||||||
|
|
||||||
const commands: Record<string, Function> = {
|
const commands: Record<string, Function> = {
|
||||||
build: commandBuild,
|
build: commandBuild,
|
||||||
@ -279,8 +279,8 @@ async function main() {
|
|||||||
updateRelease: commandUpdateRelease,
|
updateRelease: commandUpdateRelease,
|
||||||
};
|
};
|
||||||
|
|
||||||
let selectedCommand: string = '';
|
let selectedCommand = '';
|
||||||
let selectedCommandArgs: string = '';
|
let selectedCommandArgs = '';
|
||||||
|
|
||||||
function setSelectedCommand(name: string, args: any) {
|
function setSelectedCommand(name: string, args: any) {
|
||||||
selectedCommand = name;
|
selectedCommand = name;
|
||||||
|
@ -291,7 +291,7 @@ export default {
|
|||||||
// set KaTeX as the renderer for markdown-it-simplemath
|
// set KaTeX as the renderer for markdown-it-simplemath
|
||||||
const katexInline = function(latex: string) {
|
const katexInline = function(latex: string) {
|
||||||
katexOptions.displayMode = false;
|
katexOptions.displayMode = false;
|
||||||
let outputHtml: string = '';
|
let outputHtml = '';
|
||||||
try {
|
try {
|
||||||
outputHtml = renderToStringWithCache(latex, katexOptions);
|
outputHtml = renderToStringWithCache(latex, katexOptions);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -306,7 +306,7 @@ export default {
|
|||||||
|
|
||||||
const katexBlock = function(latex: string) {
|
const katexBlock = function(latex: string) {
|
||||||
katexOptions.displayMode = true;
|
katexOptions.displayMode = true;
|
||||||
let outputHtml: string = '';
|
let outputHtml = '';
|
||||||
try {
|
try {
|
||||||
outputHtml = renderToStringWithCache(latex, katexOptions);
|
outputHtml = renderToStringWithCache(latex, katexOptions);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -11,7 +11,7 @@ interface PackageJson {
|
|||||||
|
|
||||||
const packageJson: PackageJson = require(`${__dirname}/packageInfo.js`);
|
const packageJson: PackageJson = require(`${__dirname}/packageInfo.js`);
|
||||||
|
|
||||||
let runningInDocker_: boolean = false;
|
let runningInDocker_ = false;
|
||||||
|
|
||||||
export function runningInDocker(): boolean {
|
export function runningInDocker(): boolean {
|
||||||
return runningInDocker_;
|
return runningInDocker_;
|
||||||
|
@ -22,7 +22,7 @@ export default async function(config: StorageDriverConfig | number, db: DbConnec
|
|||||||
...options,
|
...options,
|
||||||
};
|
};
|
||||||
|
|
||||||
let storageId: number = 0;
|
let storageId = 0;
|
||||||
|
|
||||||
if (typeof config === 'number') {
|
if (typeof config === 'number') {
|
||||||
storageId = config;
|
storageId = config;
|
||||||
|
@ -24,7 +24,7 @@ interface ResetPasswordFields {
|
|||||||
|
|
||||||
const subRoutes: Record<string, RouteHandler> = {
|
const subRoutes: Record<string, RouteHandler> = {
|
||||||
forgot: async (_path: SubPath, ctx: AppContext) => {
|
forgot: async (_path: SubPath, ctx: AppContext) => {
|
||||||
let confirmationMessage: string = '';
|
let confirmationMessage = '';
|
||||||
|
|
||||||
if (ctx.method === 'POST') {
|
if (ctx.method === 'POST') {
|
||||||
const fields = await bodyFields<ForgotPasswordFields>(ctx.req);
|
const fields = await bodyFields<ForgotPasswordFields>(ctx.req);
|
||||||
@ -46,7 +46,7 @@ const subRoutes: Record<string, RouteHandler> = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
reset: async (_path: SubPath, ctx: AppContext) => {
|
reset: async (_path: SubPath, ctx: AppContext) => {
|
||||||
let successMessage: string = '';
|
let successMessage = '';
|
||||||
let error: Error = null;
|
let error: Error = null;
|
||||||
const token = ctx.query.token as string;
|
const token = ctx.query.token as string;
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ export default class UserDeletionService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let error: any = null;
|
let error: any = null;
|
||||||
let success: boolean = true;
|
let success = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.models.userDeletion().start(deletion.id);
|
await this.models.userDeletion().start(deletion.id);
|
||||||
|
@ -2,7 +2,7 @@ import sqlts from '@rmp135/sql-ts';
|
|||||||
|
|
||||||
require('source-map-support').install();
|
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';
|
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}`);
|
if (!fs.existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
|
||||||
let content: string = fs.readFileSync(filePath, 'utf-8');
|
let content: string = fs.readFileSync(filePath, 'utf-8');
|
||||||
// [^]* matches any character including new lines
|
// [^]* 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}`);
|
if (!content.match(regex)) throw new Error(`Could not find markers: ${markerOpen}`);
|
||||||
content = content.replace(regex, `${markerOpen}\n${contentToInsert}\n${markerClose}`);
|
content = content.replace(regex, `${markerOpen}\n${contentToInsert}\n${markerClose}`);
|
||||||
fs.writeFileSync(filePath, content);
|
fs.writeFileSync(filePath, content);
|
||||||
|
@ -18,7 +18,7 @@ const readProp = (line: string): string[] => {
|
|||||||
export const stripOffFrontMatter = (md: string): MarkdownAndFrontMatter => {
|
export const stripOffFrontMatter = (md: string): MarkdownAndFrontMatter => {
|
||||||
if (md.indexOf('---') !== 0) return { doc: md };
|
if (md.indexOf('---') !== 0) return { doc: md };
|
||||||
|
|
||||||
let state: string = 'start';
|
let state = 'start';
|
||||||
const lines = md.split('\n');
|
const lines = md.split('\n');
|
||||||
const docLines: string[] = [];
|
const docLines: string[] = [];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user